From 7f59b7bf524407bf99ba5947eeea166dc7cc759a Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Fri, 25 Oct 2024 10:48:18 +0530 Subject: [PATCH 1/2] Improved: Fetched product identifier options dynamically (#345). --- src/components/DxpProductIdentifier.vue | 3 ++- src/index.ts | 1 + src/store/productIdentification.ts | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/DxpProductIdentifier.vue b/src/components/DxpProductIdentifier.vue index 320dbd7..e1f1de7 100644 --- a/src/components/DxpProductIdentifier.vue +++ b/src/components/DxpProductIdentifier.vue @@ -37,9 +37,10 @@ const userStore = useUserStore() const currentEComStore = computed(() => userStore.getCurrentEComStore) const productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref); -const productIdentificationOptions = productIdentificationStore.getProductIdentificationOptions; +const productIdentificationOptions = computed(() => productIdentificationStore.getProductIdentificationOptions); onMounted(() => { + productIdentificationStore.prepareGoodIdentificationTypeOptions(); productIdentificationStore.getIdentificationPref(currentEComStore.value.productStoreId); }) diff --git a/src/index.ts b/src/index.ts index ed451aa..c9c5753 100644 --- a/src/index.ts +++ b/src/index.ts @@ -100,6 +100,7 @@ export let dxpComponents = { productIdentificationContext.getProductIdentificationPref = options.getProductIdentificationPref productIdentificationContext.setProductIdentificationPref = options.setProductIdentificationPref + productIdentificationContext.fetchGoodIdentificationTypes = options.fetchGoodIdentificationTypes facilityContext.getUserFacilities = options.getUserFacilities facilityContext.setUserPreference = options.setUserPreference diff --git a/src/store/productIdentification.ts b/src/store/productIdentification.ts index b6d87f4..6bf4fc4 100644 --- a/src/store/productIdentification.ts +++ b/src/store/productIdentification.ts @@ -8,7 +8,7 @@ export const useProductIdentificationStore = defineStore('productIdentification' primaryId: '', secondaryId: '' }, - productIdentificationOptions: ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "sku", "title", "SHOPIFY_PROD_SKU", "upc"] + productIdentificationOptions: [] } }, getters: { @@ -44,6 +44,17 @@ export const useProductIdentificationStore = defineStore('productIdentification' } this.productIdentificationPref = await productIdentificationContext.getProductIdentificationPref(eComStoreId) + }, + async prepareGoodIdentificationTypeOptions() { + //static identifications + const productIdentificationOptions = ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "title"]; + + //good identification types + const fetchedGoodIdentificationTypes = await productIdentificationContext.fetchGoodIdentificationTypes("HC_GOOD_ID_TYPE"); + const fetchedGoodIdentificationOptions = fetchedGoodIdentificationTypes?.map((fetchedGoodIdentificationType: any) => fetchedGoodIdentificationType.goodIdentificationTypeId) || []; + + // Merge the arrays and remove duplicates + this.productIdentificationOptions = Array.from(new Set([...productIdentificationOptions, ...fetchedGoodIdentificationOptions])).sort(); } } }) From 4e3d42649ae0aec3813aea2e1245b15617c7d819 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Fri, 25 Oct 2024 10:56:21 +0530 Subject: [PATCH 2/2] Improved: Renamed method (#345). --- src/components/DxpProductIdentifier.vue | 2 +- src/store/productIdentification.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DxpProductIdentifier.vue b/src/components/DxpProductIdentifier.vue index e1f1de7..a1c337a 100644 --- a/src/components/DxpProductIdentifier.vue +++ b/src/components/DxpProductIdentifier.vue @@ -40,7 +40,7 @@ const productIdentificationPref = computed(() => productIdentificationStore.getP const productIdentificationOptions = computed(() => productIdentificationStore.getProductIdentificationOptions); onMounted(() => { - productIdentificationStore.prepareGoodIdentificationTypeOptions(); + productIdentificationStore.prepareProductIdentifierOptions(); productIdentificationStore.getIdentificationPref(currentEComStore.value.productStoreId); }) diff --git a/src/store/productIdentification.ts b/src/store/productIdentification.ts index 6bf4fc4..69093a4 100644 --- a/src/store/productIdentification.ts +++ b/src/store/productIdentification.ts @@ -45,7 +45,7 @@ export const useProductIdentificationStore = defineStore('productIdentification' this.productIdentificationPref = await productIdentificationContext.getProductIdentificationPref(eComStoreId) }, - async prepareGoodIdentificationTypeOptions() { + async prepareProductIdentifierOptions() { //static identifications const productIdentificationOptions = ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "title"];