@mirai/core 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/Core.provider.js
CHANGED
|
@@ -19,7 +19,8 @@ const CoreProvider = _ref => {
|
|
|
19
19
|
currency,
|
|
20
20
|
id,
|
|
21
21
|
locale,
|
|
22
|
-
type
|
|
22
|
+
type,
|
|
23
|
+
value = {}
|
|
23
24
|
} = _ref;
|
|
24
25
|
const [store, setStore] = (0, _react.useState)();
|
|
25
26
|
(0, _react.useLayoutEffect)(() => {
|
|
@@ -47,7 +48,10 @@ const CoreProvider = _ref => {
|
|
|
47
48
|
return store ? /*#__PURE__*/_react.default.createElement(_dataSources.MetricsProvider, {
|
|
48
49
|
token: process && process.env && process.env.METRICS || "1b987cfadc91e233ab8c0b016bd5ecd8"
|
|
49
50
|
}, /*#__PURE__*/_react.default.createElement(_dataSources.StoreProvider, {
|
|
50
|
-
value:
|
|
51
|
+
value: {
|
|
52
|
+
...store,
|
|
53
|
+
...value
|
|
54
|
+
}
|
|
51
55
|
}, /*#__PURE__*/_react.default.createElement(_Core.Core, null, children))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
|
|
52
56
|
};
|
|
53
57
|
exports.CoreProvider = CoreProvider;
|
|
@@ -56,6 +60,7 @@ CoreProvider.propTypes = {
|
|
|
56
60
|
currency: _propTypes.default.string,
|
|
57
61
|
id: _propTypes.default.string.isRequired,
|
|
58
62
|
locale: _propTypes.default.string,
|
|
59
|
-
type: _propTypes.default.oneOf(['hotel', 'chain'])
|
|
63
|
+
type: _propTypes.default.oneOf(['hotel', 'chain']),
|
|
64
|
+
value: _propTypes.default.shape({})
|
|
60
65
|
};
|
|
61
66
|
//# sourceMappingURL=Core.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Core.provider.js","names":["CoreProvider","children","currency","id","locale","type","store","setStore","useState","useLayoutEffect","urlParams","fetchUrlParams","location","search","substring","cookies","fetchCookies","COOKIE_CART","COOKIE_VALUES","session","fetchSession","instance","config","fetchConfig","consolidateStore","propTypes","PropTypes","node","isRequired","string","oneOf"],"sources":["../src/Core.provider.jsx"],"sourcesContent":["import { MetricsProvider, StoreProvider } from '@mirai/data-sources';\nimport PropTypes from 'prop-types';\nimport React, { useLayoutEffect, useState } from 'react';\n\nimport { Core } from './Core';\nimport { COOKIE_CART, COOKIE_VALUES } from './Core.definition';\nimport { consolidateStore, fetchConfig, fetchCookies, fetchSession, fetchUrlParams } from './helpers';\n\nconst CoreProvider = ({ children, currency, id, locale, type }) => {\n const [store, setStore] = useState();\n\n useLayoutEffect(() => {\n (async () => {\n const urlParams = fetchUrlParams(location.search.substring(1));\n const cookies = fetchCookies([COOKIE_CART, COOKIE_VALUES]);\n const session = fetchSession(urlParams);\n\n const instance = { currency, id, type, locale };\n const config = await fetchConfig(instance);\n\n setStore(consolidateStore({ config, cookies, instance, session, urlParams }));\n })();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return store ? (\n <MetricsProvider token={process.env.METRICS}>\n <StoreProvider value={store}>\n <Core>{children}</Core>\n </StoreProvider>\n </MetricsProvider>\n ) : (\n <></>\n );\n};\n\nCoreProvider.propTypes = {\n children: PropTypes.node.isRequired,\n currency: PropTypes.string,\n id: PropTypes.string.isRequired,\n locale: PropTypes.string,\n type: PropTypes.oneOf(['hotel', 'chain']),\n};\n\nexport { CoreProvider };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAsG;AAAA;AAAA;AAEtG,MAAMA,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"Core.provider.js","names":["CoreProvider","children","currency","id","locale","type","value","store","setStore","useState","useLayoutEffect","urlParams","fetchUrlParams","location","search","substring","cookies","fetchCookies","COOKIE_CART","COOKIE_VALUES","session","fetchSession","instance","config","fetchConfig","consolidateStore","propTypes","PropTypes","node","isRequired","string","oneOf","shape"],"sources":["../src/Core.provider.jsx"],"sourcesContent":["import { MetricsProvider, StoreProvider } from '@mirai/data-sources';\nimport PropTypes from 'prop-types';\nimport React, { useLayoutEffect, useState } from 'react';\n\nimport { Core } from './Core';\nimport { COOKIE_CART, COOKIE_VALUES } from './Core.definition';\nimport { consolidateStore, fetchConfig, fetchCookies, fetchSession, fetchUrlParams } from './helpers';\n\nconst CoreProvider = ({ children, currency, id, locale, type, value = {} }) => {\n const [store, setStore] = useState();\n\n useLayoutEffect(() => {\n (async () => {\n const urlParams = fetchUrlParams(location.search.substring(1));\n const cookies = fetchCookies([COOKIE_CART, COOKIE_VALUES]);\n const session = fetchSession(urlParams);\n\n const instance = { currency, id, type, locale };\n const config = await fetchConfig(instance);\n\n setStore(consolidateStore({ config, cookies, instance, session, urlParams }));\n })();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return store ? (\n <MetricsProvider token={process.env.METRICS}>\n <StoreProvider value={{ ...store, ...value }}>\n <Core>{children}</Core>\n </StoreProvider>\n </MetricsProvider>\n ) : (\n <></>\n );\n};\n\nCoreProvider.propTypes = {\n children: PropTypes.node.isRequired,\n currency: PropTypes.string,\n id: PropTypes.string.isRequired,\n locale: PropTypes.string,\n type: PropTypes.oneOf(['hotel', 'chain']),\n value: PropTypes.shape({}),\n};\n\nexport { CoreProvider };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAAsG;AAAA;AAAA;AAEtG,MAAMA,YAAY,GAAG,QAA0D;EAAA,IAAzD;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,EAAE;IAAEC,MAAM;IAAEC,IAAI;IAAEC,KAAK,GAAG,CAAC;EAAE,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,GAAE;EAEpC,IAAAC,sBAAe,EAAC,MAAM;IACpB,CAAC,YAAY;MACX,MAAMC,SAAS,GAAG,IAAAC,uBAAc,EAACC,QAAQ,CAACC,MAAM,CAACC,SAAS,CAAC,CAAC,CAAC,CAAC;MAC9D,MAAMC,OAAO,GAAG,IAAAC,qBAAY,EAAC,CAACC,kBAAW,EAAEC,oBAAa,CAAC,CAAC;MAC1D,MAAMC,OAAO,GAAG,IAAAC,qBAAY,EAACV,SAAS,CAAC;MAEvC,MAAMW,QAAQ,GAAG;QAAEpB,QAAQ;QAAEC,EAAE;QAAEE,IAAI;QAAED;MAAO,CAAC;MAC/C,MAAMmB,MAAM,GAAG,MAAM,IAAAC,oBAAW,EAACF,QAAQ,CAAC;MAE1Cd,QAAQ,CAAC,IAAAiB,yBAAgB,EAAC;QAAEF,MAAM;QAAEP,OAAO;QAAEM,QAAQ;QAAEF,OAAO;QAAET;MAAU,CAAC,CAAC,CAAC;IAC/E,CAAC,GAAG;IACJ;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOJ,KAAK,gBACV,6BAAC,4BAAe;IAAC,KAAK;EAAsB,gBAC1C,6BAAC,0BAAa;IAAC,KAAK,EAAE;MAAE,GAAGA,KAAK;MAAE,GAAGD;IAAM;EAAE,gBAC3C,6BAAC,UAAI,QAAEL,QAAQ,CAAQ,CACT,CACA,gBAElB,2DACD;AACH,CAAC;AAAC;AAEFD,YAAY,CAAC0B,SAAS,GAAG;EACvBzB,QAAQ,EAAE0B,kBAAS,CAACC,IAAI,CAACC,UAAU;EACnC3B,QAAQ,EAAEyB,kBAAS,CAACG,MAAM;EAC1B3B,EAAE,EAAEwB,kBAAS,CAACG,MAAM,CAACD,UAAU;EAC/BzB,MAAM,EAAEuB,kBAAS,CAACG,MAAM;EACxBzB,IAAI,EAAEsB,kBAAS,CAACI,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;EACzCzB,KAAK,EAAEqB,kBAAS,CAACK,KAAK,CAAC,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -32,7 +32,6 @@ const consolidateStore = function () {
|
|
|
32
32
|
const currency = (forceUri ? urlParams.currency : undefined) || cookies.currency || urlParams.currency || instance.currency || _locale.DEFAULT_CURRENCY;
|
|
33
33
|
|
|
34
34
|
// club // ! TODO Check if we need more
|
|
35
|
-
|
|
36
35
|
let club;
|
|
37
36
|
if (config.club) {
|
|
38
37
|
let {
|
|
@@ -61,6 +60,21 @@ const consolidateStore = function () {
|
|
|
61
60
|
let hotel = {
|
|
62
61
|
id
|
|
63
62
|
};
|
|
63
|
+
|
|
64
|
+
// promo
|
|
65
|
+
let promo;
|
|
66
|
+
if (config.showPromoNav) {
|
|
67
|
+
const {
|
|
68
|
+
accomodation: {
|
|
69
|
+
promo: configPromo = {}
|
|
70
|
+
} = {},
|
|
71
|
+
promoText: placeholder = {}
|
|
72
|
+
} = config;
|
|
73
|
+
promo = {
|
|
74
|
+
...configPromo,
|
|
75
|
+
placeholder
|
|
76
|
+
};
|
|
77
|
+
}
|
|
64
78
|
return {
|
|
65
79
|
config,
|
|
66
80
|
cookies,
|
|
@@ -76,10 +90,15 @@ const consolidateStore = function () {
|
|
|
76
90
|
// entities,
|
|
77
91
|
club,
|
|
78
92
|
hotel,
|
|
93
|
+
promo,
|
|
79
94
|
session,
|
|
80
95
|
// components
|
|
81
96
|
finder: {
|
|
82
97
|
// ! TODO: we should hydrate it
|
|
98
|
+
place: undefined,
|
|
99
|
+
calendar: undefined,
|
|
100
|
+
occupation: undefined,
|
|
101
|
+
promocode: promo?.code
|
|
83
102
|
},
|
|
84
103
|
signup: undefined
|
|
85
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidateStore.js","names":["consolidateStore","config","cookies","instance","el","id","type","session","urlParams","forceUri","navigatorLanguage","countryLanguage","window","navigator","language","split","country","locale","lang","currency","undefined","DEFAULT_CURRENCY","club","authentication","idClub","name","conditionsUrl","conditions","privacyPolicyUrl","privacy","url","hotel","DEFAULT_LOCALE","finder","signup"],"sources":["../../src/helpers/consolidateStore.js"],"sourcesContent":["import { DEFAULT_CURRENCY, DEFAULT_LOCALE } from '@mirai/locale';\n\n/* eslint-disable no-unused-vars */\nexport const consolidateStore = ({\n config = {},\n cookies = {},\n instance: { el, id, type, ...instance } = {},\n session,\n urlParams = {},\n} = {}) => {\n const { forceUri = false } = urlParams;\n\n // language & country\n const [navigatorLanguage, countryLanguage] = window.navigator.language?.split('-') || [];\n let [language = navigatorLanguage, country = countryLanguage] = instance.locale?.split('-') || [];\n if (urlParams.lang && urlParams.lang === navigatorLanguage) language = urlParams.lang;\n\n // currency\n const currency =\n (forceUri ? urlParams.currency : undefined) ||\n cookies.currency ||\n urlParams.currency ||\n instance.currency ||\n DEFAULT_CURRENCY;\n\n // club // ! TODO Check if we need more\n
|
|
1
|
+
{"version":3,"file":"consolidateStore.js","names":["consolidateStore","config","cookies","instance","el","id","type","session","urlParams","forceUri","navigatorLanguage","countryLanguage","window","navigator","language","split","country","locale","lang","currency","undefined","DEFAULT_CURRENCY","club","authentication","idClub","name","conditionsUrl","conditions","privacyPolicyUrl","privacy","url","hotel","promo","showPromoNav","accomodation","configPromo","promoText","placeholder","DEFAULT_LOCALE","finder","place","calendar","occupation","promocode","code","signup"],"sources":["../../src/helpers/consolidateStore.js"],"sourcesContent":["import { DEFAULT_CURRENCY, DEFAULT_LOCALE } from '@mirai/locale';\n\n/* eslint-disable no-unused-vars */\nexport const consolidateStore = ({\n config = {},\n cookies = {},\n instance: { el, id, type, ...instance } = {},\n session,\n urlParams = {},\n} = {}) => {\n const { forceUri = false } = urlParams;\n\n // language & country\n const [navigatorLanguage, countryLanguage] = window.navigator.language?.split('-') || [];\n let [language = navigatorLanguage, country = countryLanguage] = instance.locale?.split('-') || [];\n if (urlParams.lang && urlParams.lang === navigatorLanguage) language = urlParams.lang;\n\n // currency\n const currency =\n (forceUri ? urlParams.currency : undefined) ||\n cookies.currency ||\n urlParams.currency ||\n instance.currency ||\n DEFAULT_CURRENCY;\n\n // club // ! TODO Check if we need more\n let club;\n if (config.club) {\n let {\n club: {\n club: { authentication, idClub: id, name },\n conditionsUrl: conditions,\n privacyPolicyUrl: privacy,\n },\n } = config;\n club = { authentication, id, name, url: { conditions, privacy } };\n }\n\n // hotel // ! TODO how we will hydrate it?\n let hotel = {\n id,\n };\n\n // promo\n let promo;\n if (config.showPromoNav) {\n const { accomodation: { promo: configPromo = {} } = {}, promoText: placeholder = {} } = config;\n promo = { ...configPromo, placeholder };\n }\n\n return {\n config,\n cookies,\n urlParams,\n ...instance,\n id,\n type,\n // region\n currency,\n language,\n country,\n locale: language && country ? `${language}-${country}` : DEFAULT_LOCALE,\n // entities,\n club,\n hotel,\n promo,\n session,\n // components\n finder: {\n // ! TODO: we should hydrate it\n place: undefined,\n calendar: undefined,\n occupation: undefined,\n promocode: promo?.code,\n },\n signup: undefined,\n };\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACO,MAAMA,gBAAgB,GAAG,YAMrB;EAAA,IANsB;IAC/BC,MAAM,GAAG,CAAC,CAAC;IACXC,OAAO,GAAG,CAAC,CAAC;IACZC,QAAQ,EAAE;MAAEC,EAAE;MAAEC,EAAE;MAAEC,IAAI;MAAE,GAAGH;IAAS,CAAC,GAAG,CAAC,CAAC;IAC5CI,OAAO;IACPC,SAAS,GAAG,CAAC;EACf,CAAC,uEAAG,CAAC,CAAC;EACJ,MAAM;IAAEC,QAAQ,GAAG;EAAM,CAAC,GAAGD,SAAS;;EAEtC;EACA,MAAM,CAACE,iBAAiB,EAAEC,eAAe,CAAC,GAAGC,MAAM,CAACC,SAAS,CAACC,QAAQ,EAAEC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;EACxF,IAAI,CAACD,QAAQ,GAAGJ,iBAAiB,EAAEM,OAAO,GAAGL,eAAe,CAAC,GAAGR,QAAQ,CAACc,MAAM,EAAEF,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE;EACjG,IAAIP,SAAS,CAACU,IAAI,IAAIV,SAAS,CAACU,IAAI,KAAKR,iBAAiB,EAAEI,QAAQ,GAAGN,SAAS,CAACU,IAAI;;EAErF;EACA,MAAMC,QAAQ,GACZ,CAACV,QAAQ,GA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