(() => { const { pageHelper, constants, utils, EventManager } = ShopbySkin; if (utils.isSignedIn()) { utils.moveToSafeReferrer({ fallback: constants.PAGE.MAIN }); return; } const signUpMethodHelper = pageHelper.signUpMethodHelper(); signUpMethodHelper.initialize({ helperKey: 'sign-up-method', }); const containerEl = document.querySelector('open-id-sign-in'); const clickEventListener = ({ target }) => { const action = target.closest('[shopby-action]')?.getAttribute('shopby-action'); if (action === 'OPEN_ID_CLICK') { const provider = target.closest('[shopby-provider]')?.getAttribute('shopby-provider'); if (provider === 'app-card') { EventManager.fire('OPEN_LAYER_MODAL', { name: 'app-card-authenticate', modalAddClass: 'app-card-authenticate-modal', isFull: true, data: { nextPath: constants.PAGE.MAIN, previousPath: location.href, provider, redirectUri: `${location.origin}${constants.PAGE.AUTH_CALLBACK}`, }, }); return; } signUpMethodHelper.openIdSignIn({ nextPath: constants.PAGE.MAIN, provider, redirectUri: `${location.origin}${constants.PAGE.AUTH_CALLBACK}`, }); } }; containerEl.addEventListener('click', clickEventListener); EventManager.fire('MYAPP:PROXY_REGISTER', { proxyFnKey: 'openIdUrlProxy', applyProxy: (proxyFn) => { signUpMethodHelper.openIdSignIn = proxyFn(signUpMethodHelper.openIdSignIn); }, }); const searchParams = new URLSearchParams(location.search); const code = searchParams.get('code'); if(code !== undefined && code !== '' && code != null){ utils.setLocalStorage('inviteCode', code); }else{ utils.removeLocalStorage("inviteCode"); } EventManager.on('PAGE_LOAD_COMPLETED', async () => { if (utils.isSignedIn()) { if (!document.referrer || location.href === document.referrer) { //history.back(); location.href = '/'; return; } utils.moveTo({ url: document.referrer, }); } }); })();