Skip to content

Commit

Permalink
Improved: variable name for the check for moquiInCaseOfOms (preorder-…
Browse files Browse the repository at this point in the history
…293)
  • Loading branch information
amansinghbais committed Oct 14, 2024
1 parent c74c421 commit a674706
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 3 additions & 3 deletions src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
export { isMaargLogin, isOmsWithMaarg, showToast }
6 changes: 3 additions & 3 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -251,7 +251,7 @@ export default defineComponent({
domain,
goToOms,
isMaargLogin,
isMaargLoginRequired,
isOmsWithMaarg,
lockClosedOutline,
hardwareChipOutline,
openOutline,
Expand Down
4 changes: 2 additions & 2 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a674706

Please sign in to comment.