@postnord/pn-marketweb-components 1.0.36 → 1.0.37
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/cjs/{MarketWebLoginManager-8b675eb4.js → MarketWebLoginManager-859590e2.js} +8 -0
- package/cjs/loader.cjs.js +1 -1
- package/cjs/pn-language-selector_9.cjs.entry.js +6 -1
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-marketweb-siteheader.cjs.entry.js +22 -7
- package/cjs/pn-profile-selector.cjs.entry.js +21 -13
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.js +23 -0
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.js +49 -8
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js +44 -1
- package/collection/components/navigation/pn-profile-selector/pn-profile-selector.js +26 -18
- package/collection/globals/MarketWebLoginManager.js +8 -0
- package/custom-elements/index.js +248 -213
- package/esm/{MarketWebLoginManager-dd7ac023.js → MarketWebLoginManager-83f2e86a.js} +8 -0
- package/esm/loader.js +1 -1
- package/esm/pn-language-selector_9.entry.js +6 -1
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-marketweb-siteheader.entry.js +22 -7
- package/esm/pn-profile-selector.entry.js +21 -13
- package/esm-es5/MarketWebLoginManager-83f2e86a.js +1 -0
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-language-selector_9.entry.js +1 -1
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
- package/esm-es5/pn-profile-selector.entry.js +1 -1
- package/package.json +1 -1
- package/pn-market-web-components/{p-ffdf87ee.entry.js → p-03fb0285.entry.js} +1 -1
- package/pn-market-web-components/p-1649b94a.entry.js +1 -0
- package/pn-market-web-components/p-25bdf3f8.system.js +1 -1
- package/pn-market-web-components/p-58cdf3a6.system.js +1 -0
- package/pn-market-web-components/p-5f256546.entry.js +1 -0
- package/pn-market-web-components/p-6db8065f.system.entry.js +1 -0
- package/pn-market-web-components/{p-6a32362d.system.entry.js → p-7b4c721f.system.entry.js} +1 -1
- package/pn-market-web-components/p-a983c263.system.entry.js +1 -0
- package/pn-market-web-components/p-c254cfdf.js +1 -0
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.d.ts +2 -0
- package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.d.ts +6 -0
- package/types/components/navigation/pn-profile-selector/pn-profile-selector.d.ts +2 -1
- package/types/components.d.ts +18 -2
- package/types/globals/MarketWebLoginManager.d.ts +1 -0
- package/esm-es5/MarketWebLoginManager-dd7ac023.js +0 -1
- package/pn-market-web-components/p-37efd029.entry.js +0 -1
- package/pn-market-web-components/p-4dcea578.js +0 -1
- package/pn-market-web-components/p-4f1a53f4.entry.js +0 -1
- package/pn-market-web-components/p-51768dc0.system.js +0 -1
- package/pn-market-web-components/p-6d718a66.system.entry.js +0 -1
- package/pn-market-web-components/p-db7419be.system.entry.js +0 -1
|
@@ -75,6 +75,14 @@ class MarketWebLoginManager {
|
|
|
75
75
|
const isLoggedIn = (this.store.get(this.keys.token) && this.store.get(this.keys.user)) ? true : false;
|
|
76
76
|
return isLoggedIn;
|
|
77
77
|
}
|
|
78
|
+
registerToken(token) {
|
|
79
|
+
if (!token || token === this.getToken()) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.clearUserData();
|
|
83
|
+
this.store.set(this.keys.token, token);
|
|
84
|
+
this.fetchUserInfo();
|
|
85
|
+
}
|
|
78
86
|
getLoginUrl(redirectPage = "") {
|
|
79
87
|
const currentPage = window.location.href;
|
|
80
88
|
redirectPage = redirectPage ? redirectPage : currentPage;
|
package/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["pn-marketweb-siteheader.cjs",[[4,"pn-marketweb-siteheader",{"market":[1537],"language":[1537],"environment":[1537],"endpoint":[1],"hideSiteSelector":[1540,"hide-site-selector"],"hideLanguageSelector":[1540,"hide-language-selector"],"hideSearch":[1540,"hide-search"],"hideLogin":[1540,"hide-login"],"sessionForward":[4,"session-forward"],"cache":[4],"spaMode":[4,"spa-mode"],"i18n":[32],"gotData":[32],"fetchingData":[32],"homePageLink":[32],"menuItems":[32],"siteDefinition":[32],"search":[32],"siteSelector":[32],"languageSelector":[32],"languageOptions":[32],"loginDialog":[32],"minimizeSearch":[32]},[[0,"setLanguage","onLanguageSelectorChange"],[0,"loginStateChange","onLoginStateChange"],[9,"resize","handleResize"]]]]],["pn-find-service-and-price.cjs",[[0,"pn-find-service-and-price",{"source":[1],"language":[1025],"market":[1025],"filteredItems":[32],"postagetype":[32],"weight":[32],"weightvalue":[32],"deliveryscope":[32],"sourceData":[32]}]]],["pn-product-pricelist.cjs",[[4,"pn-product-pricelist",{"source":[1],"language":[1025],"market":[1025],"productid":[1],"filteredItems":[32],"sourceData":[32],"gotData":[32],"loading":[32],"postagetype":[32],"weight":[32],"weightvalue":[32]}]]],["pn-marketweb-sitefooter.cjs",[[0,"pn-marketweb-sitefooter",{"market":[1537],"language":[1537],"environment":[1537],"endpoint":[1],"cache":[4],"siteDefinition":[32],"footerContent":[32],"i18n":[32],"gotData":[32],"fetchingData":[32]}]]],["pn-filter-checkbox.cjs",[[1,"pn-filter-checkbox",{"value":[520],"name":[1],"checkboxid":[1],"disabled":[4],"checked":[4],"indeterminate":[1028]},[[0,"change","handlechange"]]]]],["pn-filter-search.cjs",[[1,"pn-filter-search",{"disabled":[4],"placeholder":[1],"inputid":[1],"name":[1],"autocomplete":[1],"value":[1],"label":[1],"loading":[4],"button":[1],"light":[4]},[[0,"input","inputHandler"]]]]],["pn-profile-selector.cjs",[[0,"pn-profile-selector",{"language":[1537],"returnUrl":[1,"return-url"],"
|
|
17
|
+
return index.bootstrapLazy([["pn-marketweb-siteheader.cjs",[[4,"pn-marketweb-siteheader",{"market":[1537],"language":[1537],"environment":[1537],"token":[1],"endpoint":[1],"hideSiteSelector":[1540,"hide-site-selector"],"hideLanguageSelector":[1540,"hide-language-selector"],"hideSearch":[1540,"hide-search"],"hideLogin":[1540,"hide-login"],"sessionForward":[4,"session-forward"],"cache":[4],"spaMode":[4,"spa-mode"],"i18n":[32],"gotData":[32],"fetchingData":[32],"homePageLink":[32],"menuItems":[32],"siteDefinition":[32],"search":[32],"siteSelector":[32],"languageSelector":[32],"languageOptions":[32],"loginDialog":[32],"minimizeSearch":[32],"loggedIn":[32],"loginManager":[32]},[[0,"setLanguage","onLanguageSelectorChange"],[0,"loginStateChange","onLoginStateChange"],[9,"resize","handleResize"]]]]],["pn-find-service-and-price.cjs",[[0,"pn-find-service-and-price",{"source":[1],"language":[1025],"market":[1025],"filteredItems":[32],"postagetype":[32],"weight":[32],"weightvalue":[32],"deliveryscope":[32],"sourceData":[32]}]]],["pn-product-pricelist.cjs",[[4,"pn-product-pricelist",{"source":[1],"language":[1025],"market":[1025],"productid":[1],"filteredItems":[32],"sourceData":[32],"gotData":[32],"loading":[32],"postagetype":[32],"weight":[32],"weightvalue":[32]}]]],["pn-marketweb-sitefooter.cjs",[[0,"pn-marketweb-sitefooter",{"market":[1537],"language":[1537],"environment":[1537],"endpoint":[1],"cache":[4],"siteDefinition":[32],"footerContent":[32],"i18n":[32],"gotData":[32],"fetchingData":[32]}]]],["pn-filter-checkbox.cjs",[[1,"pn-filter-checkbox",{"value":[520],"name":[1],"checkboxid":[1],"disabled":[4],"checked":[4],"indeterminate":[1028]},[[0,"change","handlechange"]]]]],["pn-filter-search.cjs",[[1,"pn-filter-search",{"disabled":[4],"placeholder":[1],"inputid":[1],"name":[1],"autocomplete":[1],"value":[1],"label":[1],"loading":[4],"button":[1],"light":[4]},[[0,"input","inputHandler"]]]]],["pn-profile-selector.cjs",[[0,"pn-profile-selector",{"language":[1537],"returnUrl":[1,"return-url"],"spamode":[4],"loginManager":[32],"loggedIn":[32],"i18n":[32],"isLoading":[32],"numberOfProfiles":[32]}]]],["pn-sidenav.cjs",[[4,"pn-sidenav",{"language":[1],"navLabel":[1,"nav-label"],"i18n":[32]},[[0,"language","setLanguage"],[0,"openSubMenuLevelChange","onOpenSubMenuLevelChange"]]]]],["pn-sidenav-level.cjs",[[4,"pn-sidenav-level",{"level":[32],"levelId":[32],"isOpen":[32],"parentName":[32],"parentHref":[32],"parentLinkId":[32],"alignment":[32]}]]],["pn-sidenav-link.cjs",[[4,"pn-sidenav-link",{"name":[1],"href":[1],"target":[1],"linkid":[1],"icon":[1],"current":[4],"levelId":[32],"open":[32],"hasChildren":[32]}]]],["pn-product-tile_3.cjs",[[4,"pn-product-tile"],[0,"pn-product-tile-info",{"label":[1],"text":[1],"icon":[1]}],[0,"pn-product-tile-price",{"label":[1],"amount":[1],"currency":[1],"url":[1]}]]],["pn-product-pricelist-result.cjs",[[0,"pn-product-pricelist-result",{"item":[1040],"shownitems":[16],"weightText":[32]}]]],["pn-choice-button_2.cjs",[[0,"pn-find-service-and-price-result",{"item":[1040],"shownitems":[16],"weightText":[32]}],[4,"pn-choice-button",{"value":[520],"name":[1],"choiceid":[1],"type":[1],"disabled":[4],"checked":[4],"indeterminate":[1028]},[[0,"change","handlechange"]]]]],["pn-site-footer_2.cjs",[[4,"pn-site-footer",{"url":[1]}],[4,"pn-site-footer-col"]]],["pn-mainnav-link.cjs",[[4,"pn-mainnav-link",{"name":[1],"href":[1],"target":[1],"linkid":[1],"levelId":[32],"open":[32],"hasChildren":[32]}]]],["pn-language-selector_9.cjs",[[4,"pn-mainnav-level",{"level":[32],"levelId":[32],"isOpen":[32],"parentName":[32],"parentHref":[32],"parentLinkId":[32],"listCount":[32],"alignment":[32]}],[4,"pn-language-selector",{"value":[1537],"selectedLanguageName":[32],"options":[32],"i18n":[32]}],[0,"pn-language-selector-option",{"name":[1],"code":[1],"url":[1],"selected":[4],"currentLanguage":[1,"current-language"]}],[4,"pn-mainnav",{"market":[1],"language":[1],"navigationId":[1,"navigation-id"],"openMenu":[1028,"open-menu"],"navLabel":[1,"nav-label"]},[[0,"language","setLanguage"],[0,"market","setMarket"],[0,"menuLanguageChange","onLanguageChange"],[0,"setmenuopenstate","setMenuOpenState"],[0,"openMenuLevelChange","onOpenMenuLevelChange"]]],[4,"pn-mainnav-list",{"heading":[1],"linkCount":[32]}],[0,"pn-marketweb-siteheader-login",{"endpoint":[1],"token":[1],"i18n":[8,"i-1-8n"],"emitEvents":[4,"emit-events"],"loginDialog":[1040],"loginManager":[32],"loggedIn":[32],"toggleButtonText":[32],"username":[32]}],[0,"pn-marketweb-siteheader-search",{"i18n":[8,"i-1-8n"],"showOnlyLink":[1028,"show-only-link"],"hideSearch":[1028,"hide-search"],"search":[1040]}],[4,"pn-site-selector",{"buttontext":[1537],"heading":[1537],"language":[1537],"i18n":[32]}],[0,"pn-site-selector-item",{"url":[1],"heading":[1],"description":[1],"newwindow":[4]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-0404c97e.js');
|
|
6
6
|
const pnMainnavStore = require('./pn-mainnav-store-87a95686.js');
|
|
7
|
-
const MarketWebLoginManager = require('./MarketWebLoginManager-
|
|
7
|
+
const MarketWebLoginManager = require('./MarketWebLoginManager-859590e2.js');
|
|
8
8
|
require('./index-ea886985.js');
|
|
9
9
|
|
|
10
10
|
const translations$1 = {
|
|
@@ -326,6 +326,8 @@ let PnMarketwebSiteheaderLogin = class {
|
|
|
326
326
|
this.loginStateChange = index.createEvent(this, "loginStateChange", 7);
|
|
327
327
|
/** Specifies which endpoint domain we should load from */
|
|
328
328
|
this.endpoint = "";
|
|
329
|
+
/** Access token passed from backend */
|
|
330
|
+
this.token = "";
|
|
329
331
|
this.emitEvents = true;
|
|
330
332
|
// Login dialog
|
|
331
333
|
this.loginDialog = null;
|
|
@@ -337,6 +339,9 @@ let PnMarketwebSiteheaderLogin = class {
|
|
|
337
339
|
componentWillLoad() {
|
|
338
340
|
this.loginManager = new MarketWebLoginManager.MarketWebLoginManager({ endpoint: this.endpoint, eventTarget: this.hostElement });
|
|
339
341
|
this.hostElement["loginmanager"] = this.loginManager;
|
|
342
|
+
if (this.token) {
|
|
343
|
+
this.loginManager.registerToken(this.token);
|
|
344
|
+
}
|
|
340
345
|
this.hostElement.addEventListener(this.loginManager.events.loginstatechange, this.onLoginStateChange.bind(this));
|
|
341
346
|
this.init();
|
|
342
347
|
}
|
|
@@ -55,5 +55,5 @@ const patchCloneNodeFix = (HTMLElementPrototype) => {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
patchBrowser().then(options => {
|
|
58
|
-
return index.bootstrapLazy([["pn-marketweb-siteheader.cjs",[[4,"pn-marketweb-siteheader",{"market":[1537],"language":[1537],"environment":[1537],"endpoint":[1],"hideSiteSelector":[1540,"hide-site-selector"],"hideLanguageSelector":[1540,"hide-language-selector"],"hideSearch":[1540,"hide-search"],"hideLogin":[1540,"hide-login"],"sessionForward":[4,"session-forward"],"cache":[4],"spaMode":[4,"spa-mode"],"i18n":[32],"gotData":[32],"fetchingData":[32],"homePageLink":[32],"menuItems":[32],"siteDefinition":[32],"search":[32],"siteSelector":[32],"languageSelector":[32],"languageOptions":[32],"loginDialog":[32],"minimizeSearch":[32]},[[0,"setLanguage","onLanguageSelectorChange"],[0,"loginStateChange","onLoginStateChange"],[9,"resize","handleResize"]]]]],["pn-find-service-and-price.cjs",[[0,"pn-find-service-and-price",{"source":[1],"language":[1025],"market":[1025],"filteredItems":[32],"postagetype":[32],"weight":[32],"weightvalue":[32],"deliveryscope":[32],"sourceData":[32]}]]],["pn-product-pricelist.cjs",[[4,"pn-product-pricelist",{"source":[1],"language":[1025],"market":[1025],"productid":[1],"filteredItems":[32],"sourceData":[32],"gotData":[32],"loading":[32],"postagetype":[32],"weight":[32],"weightvalue":[32]}]]],["pn-marketweb-sitefooter.cjs",[[0,"pn-marketweb-sitefooter",{"market":[1537],"language":[1537],"environment":[1537],"endpoint":[1],"cache":[4],"siteDefinition":[32],"footerContent":[32],"i18n":[32],"gotData":[32],"fetchingData":[32]}]]],["pn-filter-checkbox.cjs",[[1,"pn-filter-checkbox",{"value":[520],"name":[1],"checkboxid":[1],"disabled":[4],"checked":[4],"indeterminate":[1028]},[[0,"change","handlechange"]]]]],["pn-filter-search.cjs",[[1,"pn-filter-search",{"disabled":[4],"placeholder":[1],"inputid":[1],"name":[1],"autocomplete":[1],"value":[1],"label":[1],"loading":[4],"button":[1],"light":[4]},[[0,"input","inputHandler"]]]]],["pn-profile-selector.cjs",[[0,"pn-profile-selector",{"language":[1537],"returnUrl":[1,"return-url"],"
|
|
58
|
+
return index.bootstrapLazy([["pn-marketweb-siteheader.cjs",[[4,"pn-marketweb-siteheader",{"market":[1537],"language":[1537],"environment":[1537],"token":[1],"endpoint":[1],"hideSiteSelector":[1540,"hide-site-selector"],"hideLanguageSelector":[1540,"hide-language-selector"],"hideSearch":[1540,"hide-search"],"hideLogin":[1540,"hide-login"],"sessionForward":[4,"session-forward"],"cache":[4],"spaMode":[4,"spa-mode"],"i18n":[32],"gotData":[32],"fetchingData":[32],"homePageLink":[32],"menuItems":[32],"siteDefinition":[32],"search":[32],"siteSelector":[32],"languageSelector":[32],"languageOptions":[32],"loginDialog":[32],"minimizeSearch":[32],"loggedIn":[32],"loginManager":[32]},[[0,"setLanguage","onLanguageSelectorChange"],[0,"loginStateChange","onLoginStateChange"],[9,"resize","handleResize"]]]]],["pn-find-service-and-price.cjs",[[0,"pn-find-service-and-price",{"source":[1],"language":[1025],"market":[1025],"filteredItems":[32],"postagetype":[32],"weight":[32],"weightvalue":[32],"deliveryscope":[32],"sourceData":[32]}]]],["pn-product-pricelist.cjs",[[4,"pn-product-pricelist",{"source":[1],"language":[1025],"market":[1025],"productid":[1],"filteredItems":[32],"sourceData":[32],"gotData":[32],"loading":[32],"postagetype":[32],"weight":[32],"weightvalue":[32]}]]],["pn-marketweb-sitefooter.cjs",[[0,"pn-marketweb-sitefooter",{"market":[1537],"language":[1537],"environment":[1537],"endpoint":[1],"cache":[4],"siteDefinition":[32],"footerContent":[32],"i18n":[32],"gotData":[32],"fetchingData":[32]}]]],["pn-filter-checkbox.cjs",[[1,"pn-filter-checkbox",{"value":[520],"name":[1],"checkboxid":[1],"disabled":[4],"checked":[4],"indeterminate":[1028]},[[0,"change","handlechange"]]]]],["pn-filter-search.cjs",[[1,"pn-filter-search",{"disabled":[4],"placeholder":[1],"inputid":[1],"name":[1],"autocomplete":[1],"value":[1],"label":[1],"loading":[4],"button":[1],"light":[4]},[[0,"input","inputHandler"]]]]],["pn-profile-selector.cjs",[[0,"pn-profile-selector",{"language":[1537],"returnUrl":[1,"return-url"],"spamode":[4],"loginManager":[32],"loggedIn":[32],"i18n":[32],"isLoading":[32],"numberOfProfiles":[32]}]]],["pn-sidenav.cjs",[[4,"pn-sidenav",{"language":[1],"navLabel":[1,"nav-label"],"i18n":[32]},[[0,"language","setLanguage"],[0,"openSubMenuLevelChange","onOpenSubMenuLevelChange"]]]]],["pn-sidenav-level.cjs",[[4,"pn-sidenav-level",{"level":[32],"levelId":[32],"isOpen":[32],"parentName":[32],"parentHref":[32],"parentLinkId":[32],"alignment":[32]}]]],["pn-sidenav-link.cjs",[[4,"pn-sidenav-link",{"name":[1],"href":[1],"target":[1],"linkid":[1],"icon":[1],"current":[4],"levelId":[32],"open":[32],"hasChildren":[32]}]]],["pn-product-tile_3.cjs",[[4,"pn-product-tile"],[0,"pn-product-tile-info",{"label":[1],"text":[1],"icon":[1]}],[0,"pn-product-tile-price",{"label":[1],"amount":[1],"currency":[1],"url":[1]}]]],["pn-product-pricelist-result.cjs",[[0,"pn-product-pricelist-result",{"item":[1040],"shownitems":[16],"weightText":[32]}]]],["pn-choice-button_2.cjs",[[0,"pn-find-service-and-price-result",{"item":[1040],"shownitems":[16],"weightText":[32]}],[4,"pn-choice-button",{"value":[520],"name":[1],"choiceid":[1],"type":[1],"disabled":[4],"checked":[4],"indeterminate":[1028]},[[0,"change","handlechange"]]]]],["pn-site-footer_2.cjs",[[4,"pn-site-footer",{"url":[1]}],[4,"pn-site-footer-col"]]],["pn-mainnav-link.cjs",[[4,"pn-mainnav-link",{"name":[1],"href":[1],"target":[1],"linkid":[1],"levelId":[32],"open":[32],"hasChildren":[32]}]]],["pn-language-selector_9.cjs",[[4,"pn-mainnav-level",{"level":[32],"levelId":[32],"isOpen":[32],"parentName":[32],"parentHref":[32],"parentLinkId":[32],"listCount":[32],"alignment":[32]}],[4,"pn-language-selector",{"value":[1537],"selectedLanguageName":[32],"options":[32],"i18n":[32]}],[0,"pn-language-selector-option",{"name":[1],"code":[1],"url":[1],"selected":[4],"currentLanguage":[1,"current-language"]}],[4,"pn-mainnav",{"market":[1],"language":[1],"navigationId":[1,"navigation-id"],"openMenu":[1028,"open-menu"],"navLabel":[1,"nav-label"]},[[0,"language","setLanguage"],[0,"market","setMarket"],[0,"menuLanguageChange","onLanguageChange"],[0,"setmenuopenstate","setMenuOpenState"],[0,"openMenuLevelChange","onOpenMenuLevelChange"]]],[4,"pn-mainnav-list",{"heading":[1],"linkCount":[32]}],[0,"pn-marketweb-siteheader-login",{"endpoint":[1],"token":[1],"i18n":[8,"i-1-8n"],"emitEvents":[4,"emit-events"],"loginDialog":[1040],"loginManager":[32],"loggedIn":[32],"toggleButtonText":[32],"username":[32]}],[0,"pn-marketweb-siteheader-search",{"i18n":[8,"i-1-8n"],"showOnlyLink":[1028,"show-only-link"],"hideSearch":[1028,"hide-search"],"search":[1040]}],[4,"pn-site-selector",{"buttontext":[1537],"heading":[1537],"language":[1537],"i18n":[32]}],[0,"pn-site-selector-item",{"url":[1],"heading":[1],"description":[1],"newwindow":[4]}]]]], options);
|
|
59
59
|
});
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-0404c97e.js');
|
|
6
6
|
const MarketWebContextService = require('./MarketWebContextService-bdc46f40.js');
|
|
7
|
+
const MarketWebLoginManager = require('./MarketWebLoginManager-859590e2.js');
|
|
7
8
|
const FetchHelper = require('./FetchHelper-f80943bf.js');
|
|
8
9
|
|
|
9
10
|
const translations = {
|
|
@@ -70,6 +71,8 @@ let PnMarketwebSiteheader = class {
|
|
|
70
71
|
this.language = null; //sv
|
|
71
72
|
/** Specifies which environment we're fetching data from. (production, preproduction, integration, localhost) */
|
|
72
73
|
this.environment = null; //sv
|
|
74
|
+
/** Access token passed from backend */
|
|
75
|
+
this.token = "";
|
|
73
76
|
/** Specifies which endpoint domain we should load from */
|
|
74
77
|
this.endpoint = null;
|
|
75
78
|
/** Hides the site selector if set to true*/
|
|
@@ -101,10 +104,14 @@ let PnMarketwebSiteheader = class {
|
|
|
101
104
|
// Login dialog
|
|
102
105
|
this.loginDialog = null;
|
|
103
106
|
this.minimizeSearch = false;
|
|
107
|
+
this.loggedIn = false;
|
|
104
108
|
// FetchHelper
|
|
105
109
|
this.fetchHelper = new FetchHelper.FetchHelper("siteheader");
|
|
110
|
+
// Login manager
|
|
111
|
+
this.loginManager = null;
|
|
106
112
|
}
|
|
107
113
|
componentWillLoad() {
|
|
114
|
+
this.loginManager = new MarketWebLoginManager.MarketWebLoginManager({ eventTarget: this.hostElement });
|
|
108
115
|
this.setInitialValues().then(() => {
|
|
109
116
|
this.init();
|
|
110
117
|
});
|
|
@@ -240,12 +247,9 @@ let PnMarketwebSiteheader = class {
|
|
|
240
247
|
return;
|
|
241
248
|
}
|
|
242
249
|
onLoginStateChange(e) {
|
|
243
|
-
var _a, _b;
|
|
244
|
-
if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.loggedIn) && ((_b = e.detail) === null || _b === void 0 ? void 0 : _b.token)
|
|
245
|
-
|
|
246
|
-
fetch('/api/userprofile/sync?token=' + e.detail.token);
|
|
247
|
-
}
|
|
248
|
-
catch (e) { }
|
|
250
|
+
var _a, _b, _c;
|
|
251
|
+
if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.loggedIn) && ((_b = e.detail) === null || _b === void 0 ? void 0 : _b.token)) {
|
|
252
|
+
this.loggedIn = ((_c = e.detail) === null || _c === void 0 ? void 0 : _c.loggedIn) === true;
|
|
249
253
|
}
|
|
250
254
|
}
|
|
251
255
|
promotedItemId(item) {
|
|
@@ -276,11 +280,22 @@ let PnMarketwebSiteheader = class {
|
|
|
276
280
|
this.minimizeSearch = true;
|
|
277
281
|
}
|
|
278
282
|
}
|
|
283
|
+
adjustSiteSelectorUrl(href) {
|
|
284
|
+
if (!this.loggedIn) {
|
|
285
|
+
return href;
|
|
286
|
+
}
|
|
287
|
+
const loginDomains = ['portal.postnord.com'];
|
|
288
|
+
const matchedHref = loginDomains.filter((domain) => { return href.indexOf(domain) !== -1; });
|
|
289
|
+
if (matchedHref.length === 0) {
|
|
290
|
+
return href;
|
|
291
|
+
}
|
|
292
|
+
return this.loginManager.getLoginUrl(href);
|
|
293
|
+
}
|
|
279
294
|
render() {
|
|
280
295
|
var _a, _b, _c, _d, _e, _f;
|
|
281
296
|
return (index.h(index.Host, { language: this.language, market: this.market, environment: this.environment }, index.h("header", null, index.h("div", { class: "siteheader-row" }, index.h("div", { class: "siteheader-topleft" }, index.h("slot", { name: "topleft" }), !this.hideSiteSelector &&
|
|
282
297
|
index.h("pn-site-selector", { language: this.language, buttontext: (_b = (_a = this.siteSelector) === null || _a === void 0 ? void 0 : _a.currentSiteTitle) !== null && _b !== void 0 ? _b : 'postnord' }, (this.gotData && ((_c = this.siteSelector) === null || _c === void 0 ? void 0 : _c.currentSiteTitle)) &&
|
|
283
|
-
index.h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle + ' ', description: this.siteSelector.currentSiteDescription }), (this.gotData && ((_d = this.siteSelector) === null || _d === void 0 ? void 0 : _d.siteSelections)) && this.siteSelector.siteSelections.map((site) => index.h("pn-site-selector-item", { heading: site.linkText + ' ', description: site.linkDescription, url: site.href, newwindow: site.openInNewWindow })))), index.h("div", { class: "siteheader-logocontainer" }, index.h("a", { href: this.homePageLink, title: "Home", class: "siteheader-logolink" }, index.h("svg", { class: "siteheader-logo", xmlns: "http://www.w3.org/2000/svg", width: "12.7rem", height: "2.4rem", viewBox: "0 0 141.73 26.65" }, index.h("path", { d: "M108.84,13.35c0,6.34-5.17,9-10,9S89,19.76,89,13.63c0-6.28,5.08-9,10-9S108.84,7.25,108.84,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.29,3.29,0,0,0,3.42,3.41A3.24,3.24,0,0,0,102.28,13.54Zm-83,0c0,4.83-3.32,8.82-8.49,8.82a6.54,6.54,0,0,1-4.65-1.57v5.86H0V5.16H6.17V6.8a6.43,6.43,0,0,1,5.11-2.18C16.41,4.62,19.31,8.58,19.31,13.54Zm-6.53,0A3.27,3.27,0,0,0,9.4,10,3.28,3.28,0,0,0,6,13.54,3.29,3.29,0,0,0,9.4,16.95,3.24,3.24,0,0,0,12.78,13.54Zm103.69,0.27c0-2.54,1.54-3.32,3.6-3.32a6.56,6.56,0,0,1,2.08.3L122.3,5.1a3.92,3.92,0,0,0-1.45-.18c-3.45,0-4.38,2.18-4.38,2.18V5.16H110.3V21.84h6.17v-8ZM141.73,0V21.84h-6.16V20.21a6.43,6.43,0,0,1-5.11,2.18c-5.14,0-8-4-8-8.91s3.32-8.82,8.49-8.82a6.54,6.54,0,0,1,4.65,1.57v-5Zm-6,13.48a3.28,3.28,0,0,0-3.41-3.41A3.24,3.24,0,0,0,129,13.47,3.4,3.4,0,1,0,135.75,13.47ZM81.35,4.62c-3.6,0-4.9,2.18-4.9,2.18V5.16H70.29V21.84h6.16V13.29c0-2.11.79-3.08,2.69-3.08s2.18,1.57,2.18,3.57v8.07h6.22V11.6C87.55,7,85.34,4.62,81.35,4.62ZM64.07,1.42H57.9V21.84h6.16V10.36H67l2.81-5.2H64.07V1.42ZM50.26,11.21c-2-.3-2.87-0.3-2.87-1.09s0.81-.94,2.42-0.94a16.15,16.15,0,0,1,5.11.91L56,5.41a24.56,24.56,0,0,0-6.13-.75c-5.89,0-9,2.27-9,5.89,0,2.81,1.66,4.47,6.53,5.11,2.06,0.27,2.81.39,2.81,1.15s-0.82,1-2.24,1a16.67,16.67,0,0,1-6-1.3L40.77,21.3a22.14,22.14,0,0,0,6.68,1c6.35,0,9.28-2.24,9.28-5.89C56.72,13.54,55.15,12,50.26,11.21ZM40.19,13.35c0,6.34-5.17,9-10,9s-9.82-2.6-9.82-8.73c0-6.28,5.08-9,10-9S40.19,7.25,40.19,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.28,3.28,0,0,0,3.41,3.41A3.24,3.24,0,0,0,33.63,13.54Z", fill: "#00A0D6", transform: "translate(0 0)" })))), index.h("div", { class: "siteheader-topright" }, index.h("slot", { name: "toprightstart" }), (this.gotData && this.loginDialog && !this.hideLogin) && (index.h("pn-marketweb-siteheader-login", { loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n })), (this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
|
|
298
|
+
index.h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle + ' ', description: this.siteSelector.currentSiteDescription }), (this.gotData && ((_d = this.siteSelector) === null || _d === void 0 ? void 0 : _d.siteSelections)) && this.siteSelector.siteSelections.map((site) => index.h("pn-site-selector-item", { heading: site.linkText + ' ', description: site.linkDescription, url: this.adjustSiteSelectorUrl(site.href), newwindow: site.openInNewWindow })))), index.h("div", { class: "siteheader-logocontainer" }, index.h("a", { href: this.homePageLink, title: "Home", class: "siteheader-logolink" }, index.h("svg", { class: "siteheader-logo", xmlns: "http://www.w3.org/2000/svg", width: "12.7rem", height: "2.4rem", viewBox: "0 0 141.73 26.65" }, index.h("path", { d: "M108.84,13.35c0,6.34-5.17,9-10,9S89,19.76,89,13.63c0-6.28,5.08-9,10-9S108.84,7.25,108.84,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.29,3.29,0,0,0,3.42,3.41A3.24,3.24,0,0,0,102.28,13.54Zm-83,0c0,4.83-3.32,8.82-8.49,8.82a6.54,6.54,0,0,1-4.65-1.57v5.86H0V5.16H6.17V6.8a6.43,6.43,0,0,1,5.11-2.18C16.41,4.62,19.31,8.58,19.31,13.54Zm-6.53,0A3.27,3.27,0,0,0,9.4,10,3.28,3.28,0,0,0,6,13.54,3.29,3.29,0,0,0,9.4,16.95,3.24,3.24,0,0,0,12.78,13.54Zm103.69,0.27c0-2.54,1.54-3.32,3.6-3.32a6.56,6.56,0,0,1,2.08.3L122.3,5.1a3.92,3.92,0,0,0-1.45-.18c-3.45,0-4.38,2.18-4.38,2.18V5.16H110.3V21.84h6.17v-8ZM141.73,0V21.84h-6.16V20.21a6.43,6.43,0,0,1-5.11,2.18c-5.14,0-8-4-8-8.91s3.32-8.82,8.49-8.82a6.54,6.54,0,0,1,4.65,1.57v-5Zm-6,13.48a3.28,3.28,0,0,0-3.41-3.41A3.24,3.24,0,0,0,129,13.47,3.4,3.4,0,1,0,135.75,13.47ZM81.35,4.62c-3.6,0-4.9,2.18-4.9,2.18V5.16H70.29V21.84h6.16V13.29c0-2.11.79-3.08,2.69-3.08s2.18,1.57,2.18,3.57v8.07h6.22V11.6C87.55,7,85.34,4.62,81.35,4.62ZM64.07,1.42H57.9V21.84h6.16V10.36H67l2.81-5.2H64.07V1.42ZM50.26,11.21c-2-.3-2.87-0.3-2.87-1.09s0.81-.94,2.42-0.94a16.15,16.15,0,0,1,5.11.91L56,5.41a24.56,24.56,0,0,0-6.13-.75c-5.89,0-9,2.27-9,5.89,0,2.81,1.66,4.47,6.53,5.11,2.06,0.27,2.81.39,2.81,1.15s-0.82,1-2.24,1a16.67,16.67,0,0,1-6-1.3L40.77,21.3a22.14,22.14,0,0,0,6.68,1c6.35,0,9.28-2.24,9.28-5.89C56.72,13.54,55.15,12,50.26,11.21ZM40.19,13.35c0,6.34-5.17,9-10,9s-9.82-2.6-9.82-8.73c0-6.28,5.08-9,10-9S40.19,7.25,40.19,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.28,3.28,0,0,0,3.41,3.41A3.24,3.24,0,0,0,33.63,13.54Z", fill: "#00A0D6", transform: "translate(0 0)" })))), index.h("div", { class: "siteheader-topright" }, index.h("slot", { name: "toprightstart" }), (this.gotData && this.loginDialog && !this.hideLogin) && (index.h("pn-marketweb-siteheader-login", { token: this.token, loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n })), (this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
|
|
284
299
|
index.h("pn-language-selector", { value: this.language }, this.languageOptions.map(language => index.h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))), index.h("slot", { name: "toprightend" }))), index.h("div", { class: "siteheader-row" }, index.h("div", { class: "siteheader-menu" }, index.h("pn-mainnav", { market: this.market, language: this.language, onMenuOpenChange: (e) => {
|
|
285
300
|
document.body.setAttribute("data-siteheader-menuopen", (e.detail + ''));
|
|
286
301
|
} }, index.h("pn-mainnav-level", null, index.h("pn-mainnav-list", null, this.menuItems.map((item) => {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-0404c97e.js');
|
|
6
6
|
const MarketWebContextService = require('./MarketWebContextService-bdc46f40.js');
|
|
7
|
-
const MarketWebLoginManager = require('./MarketWebLoginManager-
|
|
7
|
+
const MarketWebLoginManager = require('./MarketWebLoginManager-859590e2.js');
|
|
8
8
|
|
|
9
9
|
const translations = {
|
|
10
10
|
'sv': {
|
|
@@ -31,7 +31,8 @@ let PnProfileSelector = class {
|
|
|
31
31
|
index.registerInstance(this, hostRef);
|
|
32
32
|
this.language = null; //sv
|
|
33
33
|
this.returnUrl = "/"; //sv
|
|
34
|
-
|
|
34
|
+
// @Prop() endpoint = "/api/userprofile/sync"; // Endpoint where we send in the current user session
|
|
35
|
+
this.spamode = false; // Endpoint where we send in the current user session
|
|
35
36
|
this.loginManager = null;
|
|
36
37
|
this.loggedIn = false;
|
|
37
38
|
this.i18n = translations["en"];
|
|
@@ -40,9 +41,10 @@ let PnProfileSelector = class {
|
|
|
40
41
|
}
|
|
41
42
|
componentWillLoad() {
|
|
42
43
|
this.loginManager = new MarketWebLoginManager.MarketWebLoginManager({ eventTarget: this.hostElement });
|
|
43
|
-
this.loginManager.init(
|
|
44
|
+
this.loginManager.init(this.spamode);
|
|
44
45
|
this.hostElement["loginmanager"] = this.loginManager;
|
|
45
46
|
this.hostElement.addEventListener(this.loginManager.events.loginstatechange, this.onLoginStateChange.bind(this));
|
|
47
|
+
this.checkLoggedInState();
|
|
46
48
|
this.setInitialValues().then(() => {
|
|
47
49
|
this.init();
|
|
48
50
|
});
|
|
@@ -62,19 +64,25 @@ let PnProfileSelector = class {
|
|
|
62
64
|
init() {
|
|
63
65
|
this.setTranslations();
|
|
64
66
|
}
|
|
67
|
+
checkLoggedInState() {
|
|
68
|
+
if (this.loginManager.getToken() && this.loginManager.getUserInfo()) {
|
|
69
|
+
this.onLoginStateChange({ detail: true });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
65
72
|
async onLoginStateChange(e) {
|
|
66
73
|
if (this.loggedIn !== e.detail) {
|
|
67
74
|
this.loggedIn = e.detail;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
75
|
+
this.isLoading = false;
|
|
76
|
+
this.redirectUser();
|
|
77
|
+
// const token = this.loginManager.getToken();
|
|
78
|
+
// if (this.loggedIn && token) {
|
|
79
|
+
// try {
|
|
80
|
+
// await fetch(this.endpoint + '?token=' + token);
|
|
81
|
+
// if (this.numberOfProfiles === 1) {
|
|
82
|
+
// this.redirectUser();
|
|
83
|
+
// }
|
|
84
|
+
// } catch(e) { }
|
|
85
|
+
// }
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
async onLoggedIn() {
|
|
@@ -4,6 +4,8 @@ export class PnMarketwebSiteheaderLogin {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
/** Specifies which endpoint domain we should load from */
|
|
6
6
|
this.endpoint = "";
|
|
7
|
+
/** Access token passed from backend */
|
|
8
|
+
this.token = "";
|
|
7
9
|
this.emitEvents = true;
|
|
8
10
|
// Login dialog
|
|
9
11
|
this.loginDialog = null;
|
|
@@ -15,6 +17,9 @@ export class PnMarketwebSiteheaderLogin {
|
|
|
15
17
|
componentWillLoad() {
|
|
16
18
|
this.loginManager = new MarketWebLoginManager({ endpoint: this.endpoint, eventTarget: this.hostElement });
|
|
17
19
|
this.hostElement["loginmanager"] = this.loginManager;
|
|
20
|
+
if (this.token) {
|
|
21
|
+
this.loginManager.registerToken(this.token);
|
|
22
|
+
}
|
|
18
23
|
this.hostElement.addEventListener(this.loginManager.events.loginstatechange, this.onLoginStateChange.bind(this));
|
|
19
24
|
this.init();
|
|
20
25
|
}
|
|
@@ -160,6 +165,24 @@ export class PnMarketwebSiteheaderLogin {
|
|
|
160
165
|
"reflect": false,
|
|
161
166
|
"defaultValue": "\"\""
|
|
162
167
|
},
|
|
168
|
+
"token": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"mutable": false,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "string",
|
|
173
|
+
"resolved": "string",
|
|
174
|
+
"references": {}
|
|
175
|
+
},
|
|
176
|
+
"required": false,
|
|
177
|
+
"optional": false,
|
|
178
|
+
"docs": {
|
|
179
|
+
"tags": [],
|
|
180
|
+
"text": "Access token passed from backend"
|
|
181
|
+
},
|
|
182
|
+
"attribute": "token",
|
|
183
|
+
"reflect": false,
|
|
184
|
+
"defaultValue": "\"\""
|
|
185
|
+
},
|
|
163
186
|
"i18n": {
|
|
164
187
|
"type": "any",
|
|
165
188
|
"mutable": false,
|
package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, Prop, h, State, Element, Listen, Watch, Host, Event } from "@stencil/core";
|
|
2
2
|
import { translations } from "./translations";
|
|
3
3
|
import { MarketWebContextService } from "../../../globals/MarketWebContextService";
|
|
4
|
+
import { MarketWebLoginManager } from "../../../globals/MarketWebLoginManager";
|
|
4
5
|
import { FetchHelper } from "../../../globals/FetchHelper";
|
|
5
6
|
export class PnMarketwebSiteheader {
|
|
6
7
|
constructor() {
|
|
@@ -13,6 +14,8 @@ export class PnMarketwebSiteheader {
|
|
|
13
14
|
this.language = null; //sv
|
|
14
15
|
/** Specifies which environment we're fetching data from. (production, preproduction, integration, localhost) */
|
|
15
16
|
this.environment = null; //sv
|
|
17
|
+
/** Access token passed from backend */
|
|
18
|
+
this.token = "";
|
|
16
19
|
/** Specifies which endpoint domain we should load from */
|
|
17
20
|
this.endpoint = null;
|
|
18
21
|
/** Hides the site selector if set to true*/
|
|
@@ -44,10 +47,14 @@ export class PnMarketwebSiteheader {
|
|
|
44
47
|
// Login dialog
|
|
45
48
|
this.loginDialog = null;
|
|
46
49
|
this.minimizeSearch = false;
|
|
50
|
+
this.loggedIn = false;
|
|
47
51
|
// FetchHelper
|
|
48
52
|
this.fetchHelper = new FetchHelper("siteheader");
|
|
53
|
+
// Login manager
|
|
54
|
+
this.loginManager = null;
|
|
49
55
|
}
|
|
50
56
|
componentWillLoad() {
|
|
57
|
+
this.loginManager = new MarketWebLoginManager({ eventTarget: this.hostElement });
|
|
51
58
|
this.setInitialValues().then(() => {
|
|
52
59
|
this.init();
|
|
53
60
|
});
|
|
@@ -183,12 +190,15 @@ export class PnMarketwebSiteheader {
|
|
|
183
190
|
return;
|
|
184
191
|
}
|
|
185
192
|
onLoginStateChange(e) {
|
|
186
|
-
var _a, _b;
|
|
187
|
-
if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.loggedIn) && ((_b = e.detail) === null || _b === void 0 ? void 0 : _b.token)
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
var _a, _b, _c;
|
|
194
|
+
if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.loggedIn) && ((_b = e.detail) === null || _b === void 0 ? void 0 : _b.token)) {
|
|
195
|
+
this.loggedIn = ((_c = e.detail) === null || _c === void 0 ? void 0 : _c.loggedIn) === true;
|
|
196
|
+
if (this.sessionForward) {
|
|
197
|
+
try {
|
|
198
|
+
//fetch('/api/userprofile/sync?token=' + e.detail.token);
|
|
199
|
+
}
|
|
200
|
+
catch (e) { }
|
|
190
201
|
}
|
|
191
|
-
catch (e) { }
|
|
192
202
|
}
|
|
193
203
|
}
|
|
194
204
|
promotedItemId(item) {
|
|
@@ -219,6 +229,17 @@ export class PnMarketwebSiteheader {
|
|
|
219
229
|
this.minimizeSearch = true;
|
|
220
230
|
}
|
|
221
231
|
}
|
|
232
|
+
adjustSiteSelectorUrl(href) {
|
|
233
|
+
if (!this.loggedIn) {
|
|
234
|
+
return href;
|
|
235
|
+
}
|
|
236
|
+
const loginDomains = ['portal.postnord.com'];
|
|
237
|
+
const matchedHref = loginDomains.filter((domain) => { return href.indexOf(domain) !== -1; });
|
|
238
|
+
if (matchedHref.length === 0) {
|
|
239
|
+
return href;
|
|
240
|
+
}
|
|
241
|
+
return this.loginManager.getLoginUrl(href);
|
|
242
|
+
}
|
|
222
243
|
render() {
|
|
223
244
|
var _a, _b, _c, _d, _e, _f;
|
|
224
245
|
return (h(Host, { language: this.language, market: this.market, environment: this.environment },
|
|
@@ -230,14 +251,14 @@ export class PnMarketwebSiteheader {
|
|
|
230
251
|
h("pn-site-selector", { language: this.language, buttontext: (_b = (_a = this.siteSelector) === null || _a === void 0 ? void 0 : _a.currentSiteTitle) !== null && _b !== void 0 ? _b : 'postnord' },
|
|
231
252
|
(this.gotData && ((_c = this.siteSelector) === null || _c === void 0 ? void 0 : _c.currentSiteTitle)) &&
|
|
232
253
|
h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle + ' ', description: this.siteSelector.currentSiteDescription }),
|
|
233
|
-
(this.gotData && ((_d = this.siteSelector) === null || _d === void 0 ? void 0 : _d.siteSelections)) && this.siteSelector.siteSelections.map((site) => h("pn-site-selector-item", { heading: site.linkText + ' ', description: site.linkDescription, url: site.href, newwindow: site.openInNewWindow })))),
|
|
254
|
+
(this.gotData && ((_d = this.siteSelector) === null || _d === void 0 ? void 0 : _d.siteSelections)) && this.siteSelector.siteSelections.map((site) => h("pn-site-selector-item", { heading: site.linkText + ' ', description: site.linkDescription, url: this.adjustSiteSelectorUrl(site.href), newwindow: site.openInNewWindow })))),
|
|
234
255
|
h("div", { class: "siteheader-logocontainer" },
|
|
235
256
|
h("a", { href: this.homePageLink, title: "Home", class: "siteheader-logolink" },
|
|
236
257
|
h("svg", { class: "siteheader-logo", xmlns: "http://www.w3.org/2000/svg", width: "12.7rem", height: "2.4rem", viewBox: "0 0 141.73 26.65" },
|
|
237
258
|
h("path", { d: "M108.84,13.35c0,6.34-5.17,9-10,9S89,19.76,89,13.63c0-6.28,5.08-9,10-9S108.84,7.25,108.84,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.29,3.29,0,0,0,3.42,3.41A3.24,3.24,0,0,0,102.28,13.54Zm-83,0c0,4.83-3.32,8.82-8.49,8.82a6.54,6.54,0,0,1-4.65-1.57v5.86H0V5.16H6.17V6.8a6.43,6.43,0,0,1,5.11-2.18C16.41,4.62,19.31,8.58,19.31,13.54Zm-6.53,0A3.27,3.27,0,0,0,9.4,10,3.28,3.28,0,0,0,6,13.54,3.29,3.29,0,0,0,9.4,16.95,3.24,3.24,0,0,0,12.78,13.54Zm103.69,0.27c0-2.54,1.54-3.32,3.6-3.32a6.56,6.56,0,0,1,2.08.3L122.3,5.1a3.92,3.92,0,0,0-1.45-.18c-3.45,0-4.38,2.18-4.38,2.18V5.16H110.3V21.84h6.17v-8ZM141.73,0V21.84h-6.16V20.21a6.43,6.43,0,0,1-5.11,2.18c-5.14,0-8-4-8-8.91s3.32-8.82,8.49-8.82a6.54,6.54,0,0,1,4.65,1.57v-5Zm-6,13.48a3.28,3.28,0,0,0-3.41-3.41A3.24,3.24,0,0,0,129,13.47,3.4,3.4,0,1,0,135.75,13.47ZM81.35,4.62c-3.6,0-4.9,2.18-4.9,2.18V5.16H70.29V21.84h6.16V13.29c0-2.11.79-3.08,2.69-3.08s2.18,1.57,2.18,3.57v8.07h6.22V11.6C87.55,7,85.34,4.62,81.35,4.62ZM64.07,1.42H57.9V21.84h6.16V10.36H67l2.81-5.2H64.07V1.42ZM50.26,11.21c-2-.3-2.87-0.3-2.87-1.09s0.81-.94,2.42-0.94a16.15,16.15,0,0,1,5.11.91L56,5.41a24.56,24.56,0,0,0-6.13-.75c-5.89,0-9,2.27-9,5.89,0,2.81,1.66,4.47,6.53,5.11,2.06,0.27,2.81.39,2.81,1.15s-0.82,1-2.24,1a16.67,16.67,0,0,1-6-1.3L40.77,21.3a22.14,22.14,0,0,0,6.68,1c6.35,0,9.28-2.24,9.28-5.89C56.72,13.54,55.15,12,50.26,11.21ZM40.19,13.35c0,6.34-5.17,9-10,9s-9.82-2.6-9.82-8.73c0-6.28,5.08-9,10-9S40.19,7.25,40.19,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.28,3.28,0,0,0,3.41,3.41A3.24,3.24,0,0,0,33.63,13.54Z", fill: "#00A0D6", transform: "translate(0 0)" })))),
|
|
238
259
|
h("div", { class: "siteheader-topright" },
|
|
239
260
|
h("slot", { name: "toprightstart" }),
|
|
240
|
-
(this.gotData && this.loginDialog && !this.hideLogin) && (h("pn-marketweb-siteheader-login", { loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n })),
|
|
261
|
+
(this.gotData && this.loginDialog && !this.hideLogin) && (h("pn-marketweb-siteheader-login", { token: this.token, loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n })),
|
|
241
262
|
(this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
|
|
242
263
|
h("pn-language-selector", { value: this.language }, this.languageOptions.map(language => h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))),
|
|
243
264
|
h("slot", { name: "toprightend" }))),
|
|
@@ -334,6 +355,24 @@ export class PnMarketwebSiteheader {
|
|
|
334
355
|
"reflect": true,
|
|
335
356
|
"defaultValue": "null"
|
|
336
357
|
},
|
|
358
|
+
"token": {
|
|
359
|
+
"type": "string",
|
|
360
|
+
"mutable": false,
|
|
361
|
+
"complexType": {
|
|
362
|
+
"original": "string",
|
|
363
|
+
"resolved": "string",
|
|
364
|
+
"references": {}
|
|
365
|
+
},
|
|
366
|
+
"required": false,
|
|
367
|
+
"optional": false,
|
|
368
|
+
"docs": {
|
|
369
|
+
"tags": [],
|
|
370
|
+
"text": "Access token passed from backend"
|
|
371
|
+
},
|
|
372
|
+
"attribute": "token",
|
|
373
|
+
"reflect": false,
|
|
374
|
+
"defaultValue": "\"\""
|
|
375
|
+
},
|
|
337
376
|
"endpoint": {
|
|
338
377
|
"type": "string",
|
|
339
378
|
"mutable": false,
|
|
@@ -491,7 +530,9 @@ export class PnMarketwebSiteheader {
|
|
|
491
530
|
"languageSelector": {},
|
|
492
531
|
"languageOptions": {},
|
|
493
532
|
"loginDialog": {},
|
|
494
|
-
"minimizeSearch": {}
|
|
533
|
+
"minimizeSearch": {},
|
|
534
|
+
"loggedIn": {},
|
|
535
|
+
"loginManager": {}
|
|
495
536
|
}; }
|
|
496
537
|
static get events() { return [{
|
|
497
538
|
"method": "changeLanguage",
|
|
@@ -73,7 +73,7 @@ Primary.args = {
|
|
|
73
73
|
market : "se",
|
|
74
74
|
language: 'sv',
|
|
75
75
|
endpoint: 'https://com-production.postnord.com'
|
|
76
|
-
}
|
|
76
|
+
}
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
const MinimalOptionsTemplate = ({ ...args }) => {
|
|
@@ -106,4 +106,47 @@ SPAModeOptions.args = {
|
|
|
106
106
|
market : "",
|
|
107
107
|
language: '',
|
|
108
108
|
endpoint: ''
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const LocalhostTemplate = ({ ...args }) => {
|
|
112
|
+
return `
|
|
113
|
+
<div style="background:#ddd;min-height:100vh;">
|
|
114
|
+
<pn-marketweb-siteheader
|
|
115
|
+
market="${ args.market }"
|
|
116
|
+
language="${ args.language }"
|
|
117
|
+
endpoint="${ args.endpoint }"
|
|
118
|
+
environment="${ args.environment }"
|
|
119
|
+
>
|
|
120
|
+
</pn-marketweb-siteheader>
|
|
121
|
+
</div>
|
|
122
|
+
`;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const LocalhostOptions = LocalhostTemplate.bind({});
|
|
126
|
+
LocalhostOptions.args = {
|
|
127
|
+
market : "se",
|
|
128
|
+
language: 'sv',
|
|
129
|
+
endpoint: 'http://localhost:51444/',
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const LoggedInTemplate = ({ ...args }) => {
|
|
133
|
+
return `
|
|
134
|
+
<div style="background:#ddd;min-height:100vh;">
|
|
135
|
+
<pn-marketweb-siteheader
|
|
136
|
+
market="${ args.market }"
|
|
137
|
+
language="${ args.language }"
|
|
138
|
+
endpoint="${ args.endpoint }"
|
|
139
|
+
token="${ args.token }"
|
|
140
|
+
>
|
|
141
|
+
</pn-marketweb-siteheader>
|
|
142
|
+
</div>
|
|
143
|
+
`;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const LoggedIn = LoggedInTemplate.bind({});
|
|
147
|
+
LoggedIn.args = {
|
|
148
|
+
market : "se",
|
|
149
|
+
language: 'sv',
|
|
150
|
+
endpoint: 'https://com-integration.postnord.com',
|
|
151
|
+
token: '12c8287a039c57a87cef023dde90605a6d27b4141f74ff7356347e3',
|
|
109
152
|
};
|
|
@@ -6,7 +6,8 @@ export class PnProfileSelector {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
this.language = null; //sv
|
|
8
8
|
this.returnUrl = "/"; //sv
|
|
9
|
-
|
|
9
|
+
// @Prop() endpoint = "/api/userprofile/sync"; // Endpoint where we send in the current user session
|
|
10
|
+
this.spamode = false; // Endpoint where we send in the current user session
|
|
10
11
|
this.loginManager = null;
|
|
11
12
|
this.loggedIn = false;
|
|
12
13
|
this.i18n = translations["en"];
|
|
@@ -15,9 +16,10 @@ export class PnProfileSelector {
|
|
|
15
16
|
}
|
|
16
17
|
componentWillLoad() {
|
|
17
18
|
this.loginManager = new MarketWebLoginManager({ eventTarget: this.hostElement });
|
|
18
|
-
this.loginManager.init(
|
|
19
|
+
this.loginManager.init(this.spamode);
|
|
19
20
|
this.hostElement["loginmanager"] = this.loginManager;
|
|
20
21
|
this.hostElement.addEventListener(this.loginManager.events.loginstatechange, this.onLoginStateChange.bind(this));
|
|
22
|
+
this.checkLoggedInState();
|
|
21
23
|
this.setInitialValues().then(() => {
|
|
22
24
|
this.init();
|
|
23
25
|
});
|
|
@@ -37,19 +39,25 @@ export class PnProfileSelector {
|
|
|
37
39
|
init() {
|
|
38
40
|
this.setTranslations();
|
|
39
41
|
}
|
|
42
|
+
checkLoggedInState() {
|
|
43
|
+
if (this.loginManager.getToken() && this.loginManager.getUserInfo()) {
|
|
44
|
+
this.onLoginStateChange({ detail: true });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
40
47
|
async onLoginStateChange(e) {
|
|
41
48
|
if (this.loggedIn !== e.detail) {
|
|
42
49
|
this.loggedIn = e.detail;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
50
|
+
this.isLoading = false;
|
|
51
|
+
this.redirectUser();
|
|
52
|
+
// const token = this.loginManager.getToken();
|
|
53
|
+
// if (this.loggedIn && token) {
|
|
54
|
+
// try {
|
|
55
|
+
// await fetch(this.endpoint + '?token=' + token);
|
|
56
|
+
// if (this.numberOfProfiles === 1) {
|
|
57
|
+
// this.redirectUser();
|
|
58
|
+
// }
|
|
59
|
+
// } catch(e) { }
|
|
60
|
+
// }
|
|
53
61
|
}
|
|
54
62
|
}
|
|
55
63
|
async onLoggedIn() {
|
|
@@ -114,12 +122,12 @@ export class PnProfileSelector {
|
|
|
114
122
|
"reflect": false,
|
|
115
123
|
"defaultValue": "\"/\""
|
|
116
124
|
},
|
|
117
|
-
"
|
|
118
|
-
"type": "
|
|
125
|
+
"spamode": {
|
|
126
|
+
"type": "boolean",
|
|
119
127
|
"mutable": false,
|
|
120
128
|
"complexType": {
|
|
121
|
-
"original": "
|
|
122
|
-
"resolved": "
|
|
129
|
+
"original": "boolean",
|
|
130
|
+
"resolved": "boolean",
|
|
123
131
|
"references": {}
|
|
124
132
|
},
|
|
125
133
|
"required": false,
|
|
@@ -128,9 +136,9 @@ export class PnProfileSelector {
|
|
|
128
136
|
"tags": [],
|
|
129
137
|
"text": ""
|
|
130
138
|
},
|
|
131
|
-
"attribute": "
|
|
139
|
+
"attribute": "spamode",
|
|
132
140
|
"reflect": false,
|
|
133
|
-
"defaultValue": "
|
|
141
|
+
"defaultValue": "false"
|
|
134
142
|
}
|
|
135
143
|
}; }
|
|
136
144
|
static get states() { return {
|
|
@@ -73,6 +73,14 @@ class MarketWebLoginManager {
|
|
|
73
73
|
const isLoggedIn = (this.store.get(this.keys.token) && this.store.get(this.keys.user)) ? true : false;
|
|
74
74
|
return isLoggedIn;
|
|
75
75
|
}
|
|
76
|
+
registerToken(token) {
|
|
77
|
+
if (!token || token === this.getToken()) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.clearUserData();
|
|
81
|
+
this.store.set(this.keys.token, token);
|
|
82
|
+
this.fetchUserInfo();
|
|
83
|
+
}
|
|
76
84
|
getLoginUrl(redirectPage = "") {
|
|
77
85
|
const currentPage = window.location.href;
|
|
78
86
|
redirectPage = redirectPage ? redirectPage : currentPage;
|