diff --git a/package-lock.json b/package-lock.json index c9a4b1a6..0681a1c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18354,4 +18354,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 5a592701..75f4f873 100644 --- a/src/App.vue +++ b/src/App.vue @@ -24,6 +24,7 @@ import { mapGetters, useStore } from 'vuex'; import { Settings } from 'luxon' import { initialise, resetConfig } from '@/adapter' import { useRouter } from 'vue-router'; +import { useProductIdentificationStore } from "@hotwax/dxp-components"; export default defineComponent({ name: "App", @@ -43,7 +44,8 @@ export default defineComponent({ ...mapGetters({ userProfile: 'user/getUserProfile', userToken: 'user/getUserToken', - instanceUrl: 'user/getInstanceUrl' + instanceUrl: 'user/getInstanceUrl', + currentEComStore: 'user/getCurrentEComStore' }) }, methods: { @@ -101,6 +103,10 @@ export default defineComponent({ if (this.userProfile && this.userProfile.userTimeZone) { Settings.defaultZone = this.userProfile.userTimeZone; } + + // Get product identification from api using dxp-component + await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId) + .catch((error) => console.error(error)); }, unmounted() { emitter.off('presentLoader', this.presentLoader); diff --git a/src/adapter/index.ts b/src/adapter/index.ts index ca13603c..5caab417 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,12 +1,14 @@ -import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones, setUserLocale } from '@hotwax/oms-api' +import { api, client, getConfig, getProductIdentificationPref, initialise, logout, resetConfig, setProductIdentificationPref, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones, setUserLocale } from '@hotwax/oms-api' export { api, client, getConfig, + getProductIdentificationPref, initialise, logout, resetConfig, + setProductIdentificationPref, updateInstanceUrl, updateToken, setUserLocale, diff --git a/src/main.ts b/src/main.ts index 4d0c2871..a1431f8c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,8 +32,9 @@ import { login, logout, loader } from './user-utils'; import permissionPlugin, { Actions, hasPermission } from '@/authorization'; import permissionRules from '@/authorization/Rules'; import permissionActions from '@/authorization/Actions'; -import { getConfig, initialise, setUserTimeZone, getAvailableTimeZones, setUserLocale} from '@/adapter' +import { setUserTimeZone, getAvailableTimeZones, setUserLocale} from '@/adapter' import localeMessages from './i18n/locales'; +import { getConfig, getProductIdentificationPref, initialise, setProductIdentificationPref } from '@/adapter' const app = createApp(App) .use(IonicVue, { @@ -60,6 +61,8 @@ const app = createApp(App) setUserLocale, setUserTimeZone, getAvailableTimeZones, + getProductIdentificationPref, + setProductIdentificationPref, hasPermission }); diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index d1076e7e..6f90bdda 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -7,7 +7,7 @@ import { hasError, showToast } from '@/utils' import { translate } from '@/i18n' import { Settings } from 'luxon' import { updateInstanceUrl, updateToken, resetConfig, logout } from '@/adapter' -import { useAuthStore } from '@hotwax/dxp-components'; +import { useAuthStore, useProductIdentificationStore } from '@hotwax/dxp-components'; import { getServerPermissionsFromRules, prepareAppPermissions, resetPermissions, setPermissions } from '@/authorization' import emitter from '@/event-bus' @@ -21,13 +21,13 @@ const actions: ActionTree = { const { token, oms } = payload; dispatch("setUserInstanceUrl", oms); try { - if (token) { - // Getting the permissions list from server - const permissionId = process.env.VUE_APP_PERMISSION_ID; + if (token) { + // Getting the permissions list from server + const permissionId = process.env.VUE_APP_PERMISSION_ID; - // Prepare permissions list - const serverPermissionsFromRules = getServerPermissionsFromRules(); - if (permissionId) serverPermissionsFromRules.push(permissionId); + // Prepare permissions list + const serverPermissionsFromRules = getServerPermissionsFromRules(); + if (permissionId) serverPermissionsFromRules.push(permissionId); const serverPermissions = await UserService.getUserPermissions({ permissionIds: [...new Set(serverPermissionsFromRules)] @@ -74,7 +74,23 @@ const actions: ActionTree = { commit(types.USER_TOKEN_CHANGED, { newToken: token }); commit(types.USER_PERMISSIONS_UPDATED, appPermissions); updateToken(token); + + // Get product identification from api using dxp-component + await useProductIdentificationStore().getIdentificationPref(preferredStoreId) + .catch((error) => console.error(error)); + + setPermissions(appPermissions); + if (userProfile.userTimeZone) { + Settings.defaultZone = userProfile.userTimeZone; } + + // TODO user single mutation + commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); + commit(types.USER_INFO_UPDATED, userProfile); + commit(types.USER_TOKEN_CHANGED, { newToken: token }); + commit(types.USER_PERMISSIONS_UPDATED, appPermissions); + updateToken(token); + } } catch (err: any) { showToast(translate('Something went wrong')); console.error("error", err); @@ -157,6 +173,10 @@ const actions: ActionTree = { 'userPrefTypeId': 'SELECTED_BRAND', 'userPrefValue': payload.eComStore.productStoreId }); + + // Get product identification from api using dxp-component + await useProductIdentificationStore().getIdentificationPref(payload.eComStore.productStoreId) + .catch((error) => console.error(error)); }, /** diff --git a/src/views/catalog-product-details.vue b/src/views/catalog-product-details.vue index 2fe4f942..9df1c07b 100644 --- a/src/views/catalog-product-details.vue +++ b/src/views/catalog-product-details.vue @@ -17,8 +17,8 @@
-

{{ currentVariant.parentProductName }}

-

{{ currentVariant.sku }}

+

{{ getProductIdentificationValue(productIdentificationPref.primaryId, currentVariant) ? getProductIdentificationValue(productIdentificationPref.primaryId, currentVariant) : currentVariant.productName }}

+

{{ getProductIdentificationValue(productIdentificationPref.secondaryId, currentVariant) }}

@@ -386,7 +386,7 @@ import { IonRow, popoverController, } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { computed, defineComponent } from "vue"; import { alertCircleOutline, checkmarkCircleOutline, @@ -395,7 +395,7 @@ import { shirtOutline } from "ionicons/icons"; import { useStore } from "@/store"; -import { DxpShopifyImg } from "@hotwax/dxp-components"; +import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components"; import { mapGetters } from "vuex"; import { showToast, getFeature, hasError } from "@/utils"; import { translate } from "@/i18n"; @@ -434,7 +434,7 @@ export default defineComponent({ IonToggle, IonToolbar, IonTitle, - IonRow, + IonRow }, data() { return { @@ -1120,13 +1120,18 @@ export default defineComponent({ setup() { const store = useStore(); const router = useRouter(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + return { alertCircleOutline, Actions, checkmarkCircleOutline, chevronForwardOutline, copyOutline, + getProductIdentificationValue, hasPermission, + productIdentificationPref, router, shirtOutline, store diff --git a/src/views/catalog.vue b/src/views/catalog.vue index 68fb027f..dd258407 100644 --- a/src/views/catalog.vue +++ b/src/views/catalog.vue @@ -52,8 +52,8 @@ -
{{ product.parentProductName }}
-

{{ product.sku }}

+
{{ getProductIdentificationValue(productIdentificationPref.primaryId, product) ? getProductIdentificationValue(productIdentificationPref.primaryId, product) : product.productName }}
+

{{ getProductIdentificationValue(productIdentificationPref.secondaryId, product) }}

@@ -106,10 +106,10 @@ import { IonTitle, IonToolbar, } from '@ionic/vue'; -import { defineComponent } from 'vue'; +import { computed, defineComponent } from 'vue'; import { useRouter } from "vue-router"; import { useStore } from "@/store"; -import { DxpShopifyImg } from '@hotwax/dxp-components'; +import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from '@hotwax/dxp-components'; import { mapGetters } from 'vuex'; import { DateTime } from 'luxon'; import { JobService } from '@/services/JobService'; @@ -290,8 +290,12 @@ export default defineComponent({ setup() { const router = useRouter(); const store = useStore(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) return { + getProductIdentificationValue, + productIdentificationPref, router, store, }; diff --git a/src/views/orders.vue b/src/views/orders.vue index 6a0b553e..13c6edbb 100644 --- a/src/views/orders.vue +++ b/src/views/orders.vue @@ -119,7 +119,7 @@ -

{{ item.parentProductName ? item.parentProductName :item.productName }}

+

{{ getProductIdentificationValue(productIdentificationPref.primaryId, item) ? getProductIdentificationValue(productIdentificationPref.primaryId, item) : item.productName }}

{{ $t("Color") }} : {{ $filters.getFeature(getProduct(item.productId).featureHierarchy, '1/COLOR/') }}

{{ $t("Size") }} : {{ $filters.getFeature(getProduct(item.productId).featureHierarchy, '1/SIZE/') }}

@@ -208,7 +208,7 @@ import { modalController, popoverController, } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { computed, defineComponent } from "vue"; import WarehouseModal from "./warehouse-modal.vue"; import BackgroundJobModal from "./background-job-modal.vue"; import PromiseDateModal from "./promise-date-modal.vue"; @@ -228,7 +228,7 @@ import { useStore } from "@/store"; import { mapGetters } from "vuex"; import { showToast } from '@/utils' import { Plugins } from '@capacitor/core'; -import { DxpShopifyImg } from "@hotwax/dxp-components"; +import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components"; import emitter from "@/event-bus"; const { Clipboard } = Plugins; @@ -504,17 +504,22 @@ export default defineComponent({ }, setup() { const store = useStore(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) + return { - store, - pricetag, - ribbon, - ellipsisVertical, - send, business, calendar, + close, closeCircle, + ellipsisVertical, + getProductIdentificationValue, hourglass, - close, + pricetag, + productIdentificationPref, + ribbon, + send, + store }; }, }); diff --git a/src/views/product-details.vue b/src/views/product-details.vue index 2817bbfa..590db3fa 100644 --- a/src/views/product-details.vue +++ b/src/views/product-details.vue @@ -26,7 +26,7 @@
-

{{ current.product.productName }}

+

{{ getProductIdentificationValue(productIdentificationPref.primaryId, current.product) ? getProductIdentificationValue(productIdentificationPref.primaryId, current.product) : current.product.productName }}

@@ -193,7 +193,7 @@ import { alertController, modalController, } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { computed, defineComponent } from "vue"; import { informationCircle, send, @@ -211,7 +211,7 @@ import BackgroundJobModal from "./background-job-modal.vue"; import { useStore } from "@/store"; import { mapGetters } from "vuex"; import { ProductService } from '@/services/ProductService' -import { DxpShopifyImg } from "@hotwax/dxp-components"; +import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components"; import { sizeIndex } from "@/apparel-sorter" import { DateTime } from 'luxon'; import emitter from "@/event-bus"; @@ -577,15 +577,19 @@ export default defineComponent({ }, setup() { const store = useStore(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) return { informationCircle, send, business, closeCircle, + getProductIdentificationValue, hourglass, calendar, close, list, + productIdentificationPref, ribbon, refresh, store diff --git a/src/views/products.vue b/src/views/products.vue index 1fcab287..210c906a 100644 --- a/src/views/products.vue +++ b/src/views/products.vue @@ -32,7 +32,7 @@ -

{{ getProduct(product.groupValue).productName}}

+

{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(product.groupValue)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(product.groupValue)) : getProduct(product.groupValue).productName }}

{{ feature }}: {{ attribute }}

{{ product.doclist.numFound }} {{ $t("pieces preordered") }} @@ -66,13 +66,13 @@ import { IonToolbar, modalController, } from "@ionic/vue"; -import { defineComponent } from "vue"; +import { computed, defineComponent } from "vue"; import { hourglass } from "ionicons/icons"; import { useRouter } from "vue-router"; import BackgroundJobModal from "./background-job-modal.vue"; import { useStore } from "@/store"; import { mapGetters } from "vuex"; -import { DxpShopifyImg } from "@hotwax/dxp-components"; +import { getProductIdentificationValue, DxpShopifyImg, useProductIdentificationStore } from "@hotwax/dxp-components"; export default defineComponent({ name: "settings", @@ -178,10 +178,14 @@ export default defineComponent({ setup() { const router = useRouter(); const store = useStore(); + const productIdentificationStore = useProductIdentificationStore(); + let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref) return { - router, - store, + getProductIdentificationValue, hourglass, + productIdentificationPref, + router, + store }; }, }); diff --git a/src/views/settings.vue b/src/views/settings.vue index e437dffc..56553ea2 100644 --- a/src/views/settings.vue +++ b/src/views/settings.vue @@ -64,6 +64,7 @@
+
@@ -95,6 +96,7 @@ import { import { defineComponent } from "vue"; import { mapGetters } from 'vuex' import Image from '@/components/Image.vue'; +import { DxpProductIdentifier } from '@hotwax/dxp-components'; export default defineComponent({ name: "settings", @@ -180,4 +182,4 @@ export default defineComponent({ align-items: center; padding: var(--spacer-xs) 10px 0px; } - + \ No newline at end of file