diff --git a/.env.example b/.env.example index fe4f382..fae3aa0 100644 --- a/.env.example +++ b/.env.example @@ -6,4 +6,4 @@ VUE_APP_CURRENCY_FORMATS={"en": {"currency": {"style": "currency","currency": "U VUE_APP_DEFAULT_ALIAS= VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing", "inventorycount"] VUE_APP_USERS_LOGIN_URL="http://users.hotwax.io/login" -VUE_APP_MAARG_LOGIN_REQUIRED=["preorder"] +VUE_APP_OMS_WITH_MAARG=["preorder"] diff --git a/src/util/index.ts b/src/util/index.ts index b151711..13784dc 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -16,10 +16,10 @@ const isMaargLogin = (handle: string, environment = "") => { return maargLoginApps.some((appName: string) => appHandle.includes(appName)) } -const isMaargLoginRequired = (handle: string, environment = "") => { +const isOmsWithMaarg = (handle: string, environment = "") => { const appHandle = environment ? handle + environment : handle - const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_MAARG_LOGIN_REQUIRED ? process.env.VUE_APP_MAARG_LOGIN_REQUIRED : []) + const maargOmsRequiredApps = JSON.parse(process.env.VUE_APP_OMS_WITH_MAARG ? process.env.VUE_APP_OMS_WITH_MAARG : []) return maargOmsRequiredApps.some((appName: string) => appHandle.includes(appName)) } -export { isMaargLogin, isMaargLoginRequired, showToast } \ No newline at end of file +export { isMaargLogin, isOmsWithMaarg, showToast } \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index c603af4..ccd1938 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -95,7 +95,7 @@ import { import { useAuthStore } from '@/store/auth'; import { useRouter } from "vue-router"; import { goToOms } from '@hotwax/dxp-components' -import { isMaargLogin, isMaargLoginRequired } from '@/util'; +import { isMaargLogin, isOmsWithMaarg } from '@/util'; import { translate } from '@/i18n'; import UserActionsPopover from '@/components/UserActionsPopover.vue' import Image from "@/components/Image.vue"; @@ -144,7 +144,7 @@ export default defineComponent({ }, generateAppLink(app: any, appEnvironment = '') { const oms = isMaargLogin(app.handle, appEnvironment) ? this.authStore.getMaargOms : this.authStore.getOMS; - window.location.href = this.scheme + app.handle + appEnvironment + this.domain + (this.authStore.isAuthenticated ? `/login?oms=${oms.startsWith('http') ? isMaargLogin(app.handle, appEnvironment) ? oms : oms.includes('/api') ? oms : `${oms}/api/` : oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getOMS : isMaargLoginRequired(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getMaargOms : ''}` : '') + window.location.href = this.scheme + app.handle + appEnvironment + this.domain + (this.authStore.isAuthenticated ? `/login?oms=${oms.startsWith('http') ? isMaargLogin(app.handle, appEnvironment) ? oms : oms.includes('/api') ? oms : `${oms}/api/` : oms}&token=${this.authStore.token.value}&expirationTime=${this.authStore.token.expiration}${isMaargLogin(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getOMS : isOmsWithMaarg(app.handle, appEnvironment) ? '&omsRedirectionUrl=' + this.authStore.getMaargOms : ''}` : '') }, async openUserActionsPopover(event: any) { const userActionsPopover = await popoverController.create({ @@ -251,7 +251,7 @@ export default defineComponent({ domain, goToOms, isMaargLogin, - isMaargLoginRequired, + isOmsWithMaarg, lockClosedOutline, hardwareChipOutline, openOutline, diff --git a/src/views/Login.vue b/src/views/Login.vue index 871d343..c498423 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -76,7 +76,7 @@ import Logo from '@/components/Logo.vue'; import { arrowForwardOutline, gridOutline } from 'ionicons/icons' import { UserService } from "@/services/UserService"; import { translate } from "@/i18n"; -import { isMaargLogin, isMaargLoginRequired, showToast } from "@/util"; +import { isMaargLogin, isOmsWithMaarg, showToast } from "@/util"; import { hasError } from "@hotwax/oms-api"; export default defineComponent({ @@ -315,7 +315,7 @@ export default defineComponent({ omsRedirectionUrl = this.authStore.oms } - if(isMaargLoginRequired(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) { + if(isOmsWithMaarg(this.authStore.getRedirectUrl) && this.authStore.getMaargOms) { omsRedirectionUrl = this.authStore.getMaargOms }