From f8554eb765ae64c66251934e8f016676bd8d02fc Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Fri, 23 May 2025 19:54:18 +0530 Subject: [PATCH 1/5] Implemented: Product Upload Identifier card on Settings page (#314) --- src/locales/en.json | 5 +++ src/services/UserService.ts | 2 +- src/services/UtilService.ts | 21 ++++++++- src/store/index.ts | 2 +- src/store/modules/util/UtilState.ts | 2 + src/store/modules/util/actions.ts | 46 ++++++++++++++++++++ src/store/modules/util/getters.ts | 6 +++ src/store/modules/util/index.ts | 4 +- src/store/modules/util/mutation-types.ts | 4 +- src/store/modules/util/mutations.ts | 6 +++ src/views/ScheduledRestock.vue | 16 +++++-- src/views/Settings.vue | 55 ++++++++++++++++++++++-- 12 files changed, 157 insertions(+), 12 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 12ba7dc1..01c86b38 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -37,6 +37,7 @@ "Configure date time format": "Configure date time format", "Check sample": "Check sample", "Choosing a product identifier allows you to view products with your preferred identifiers.": "Choosing a product identifier allows you to view products with your preferred identifiers.", + "Choosing an identifier to map products by when uploading documents. If not explicitly specified Import will default to the identifier used during product import from Shopify.": "Choosing an identifier to map products by when uploading documents. If not explicitly specified Import will default to the identifier used during product import from Shopify.", "Click the backdrop to dismiss.": "Click the backdrop to dismiss.", "Completed": "Completed", "Confirm": "Confirm", @@ -44,6 +45,7 @@ "CSV input": "CSV input", "CSV Mapping": "CSV Mapping", "Custom date format": "Custom date format", + "Currently set to": "Currently set to {productIdentifierEnumId}", "Cycle count": "Cycle count", "Cycle count or similar": "Cycle count or similar", "Date Format": "Date Format", @@ -179,6 +181,7 @@ "Product not found": "Product not found", "Product removed successfully": "Product removed successfully", "Product: Select the type of product identification used in the CSV. If the selected identification is not available on a row in the uploaded CSV, it will be skipped and presented in an error file.": "Product: Select the type of product identification used in the CSV. If the selected identification is not available on a row in the uploaded CSV, it will be skipped and presented in an error file.", + "Product Upload Identifier": "Product Upload Identifier", "Purchase order": "Purchase order", "Purchase orders": "Purchase orders", "Quantity": "Quantity", @@ -285,8 +288,10 @@ "Uploaded files will be processed immediately": "Uploaded files will be processed immediately", "Uploaded files will be processed": "Uploaded files will be processed {runTime}", "Uploaded files will not be processed until the bulk file processing job is enabled.": "Uploaded files will not be processed until the bulk file processing job is enabled.", + "Upload Identifier": "Upload Identifier", "Upload purchase order": "Upload purchase order", "Username": "Username", + "Use default identifier": "Use default identifier", "Version: ": "Version: {appVersion}", "View all date time formats supported by the HotWax Import app.": "View all date time formats supported by the HotWax Import app.", "View": "View", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 45ce81dd..af745e4d 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -145,7 +145,7 @@ const getUserPermissions = async (payload: any, token: any): Promise => { async function getEComStores(): Promise { const params = { "viewSize": 200, - "fieldList": ["productStoreId", "storeName"], + "fieldList": ["productStoreId", "storeName", "productIdentifierEnumId"], "entityName": "ProductStore", "distinct": "Y", "noConditionFind": "Y" diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 9b52e185..a295c887 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -33,6 +33,23 @@ const fetchShopifyShop = async (payload: any): Promise => { }) } +const fetchProductSelectorPref = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "GET", + params: payload, + cache: true + }) +} + +const updateProductSelectorPref = async (payload: any): Promise => { + return api({ + url: "service/updateProductStoreSetting", + method: "POST", + data: payload + }) +} + const fetchProductStores = async (payload: any): Promise => { return api({ url: "/performFind", @@ -137,6 +154,7 @@ export const UtilService = { fetchDataResource, fetchFileData, fetchProducts, + fetchProductSelectorPref, fetchProductStores, fetchShipmentItems, fetchGoodIdentificationTypes, @@ -146,5 +164,6 @@ export const UtilService = { getServiceStatusDesc, removeShipmentItem, updateShipmentItem, - updateDataManagerConfig + updateDataManagerConfig, + updateProductSelectorPref } \ No newline at end of file diff --git a/src/store/index.ts b/src/store/index.ts index 77a95b20..4245b6da 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -22,7 +22,7 @@ const state: any = { } const persistState = createPersistedState({ - paths: ['user', 'util.productStores', 'util.statusDesc'], + paths: ['user', 'util.productStores', 'util.statusDesc', 'util.useDefaultProductStoreIdentifier'], fetchBeforeUse: true }) diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index c69b77cf..08ec41b9 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -8,4 +8,6 @@ export default interface UserState { shipmentItems: [], statusDesc: any; configDetails: {} + productSelectorPref: any; + useDefaultProductStoreIdentifier: boolean; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 507e94ee..ccb1af2f 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -197,6 +197,52 @@ const actions: ActionTree = { } commit(types.UTIL_DATA_MANAGER_CONFIG_UPDATED, configDetails); }, + async fetchProductSelectorPref({ commit, dispatch }, eComStore){ + let productSelectorPref = ""; + const payload = { + "inputFields": { + "productStoreId": eComStore.productStoreId, + "settingTypeEnumId": "PRD_SELECTOR_PREF" + }, + "entityName": "ProductStoreSetting", + "fieldList": ["settingValue", "settingTypeEnumId"], + "viewSize": 1 + } + + try { + const resp = await UtilService.fetchProductSelectorPref(payload) + if(!hasError(resp) && resp.data.docs[0].settingValue) { + productSelectorPref = resp.data.docs[0].settingValue + } else { + throw resp.data + } + } catch(err) { + console.error(err) + } + commit(types.PRODUCT_SELECTOR_PREF_UPDATED, productSelectorPref); + }, + async updateProductSelectorPref({ commit }, payload) { + const params = { + "productStoreId": payload.productStoreId, + "settingTypeEnumId": "PRD_SELECTOR_PREF", + "settingValue": payload.productSelectorPref + } + + try { + const resp = await UtilService.updateProductSelectorPref(params) + if(!hasError(resp)) { + const productSelectorPref = payload.productSelectorPref + commit(types.PRODUCT_SELECTOR_PREF_UPDATED, productSelectorPref); + } else { + throw resp.data + } + } catch(err) { + console.error(err) + } + }, + async updateDefaultProductStoreSelector({ commit }, payload) { + commit(types.PRODUCT_STORE_SELECTOR_UPDATED, payload); + }, async updateExactInventoryType({ commit }, type) { commit(types.UTIL_EXACT_INVENTORY_TYPE_UPDATED, type); }, diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index ad0a90f6..87f53fbe 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -29,6 +29,12 @@ const getters: GetterTree = { }, getDataManagerConfig(state) { return state.configDetails + }, + getProductSelectorPref: (state) => { + return state.productSelectorPref; + }, + isDefaultProductStoreIdentifierSelected: (state) => { + return state.useDefaultProductStoreIdentifier; } } export default getters; \ No newline at end of file diff --git a/src/store/modules/util/index.ts b/src/store/modules/util/index.ts index 54262c9e..de05fa45 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -16,7 +16,9 @@ const userModule: Module = { exactInventoryType: {}, shipmentItems: [], statusDesc: {}, - configDetails: {} + configDetails: {}, + productSelectorPref: [], + useDefaultProductStoreIdentifier: false }, getters, actions, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index f31f6067..aa17f016 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -7,4 +7,6 @@ export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED' export const UTIL_DATA_MANAGER_CONFIG_UPDATED = SN_UTIL + '/DATA_MANAGER_CONFIG_UPDATED' export const UTIL_EXACT_INVENTORY_TYPE_UPDATED = SN_UTIL + '/EXACT_INVENTORY_TYPE_UPDATED' export const UTIL_SERVICE_STATUS_DESC_UPDATED = SN_UTIL + '/SERVICE_STATUS_DESC_UPDATED' -export const UTIL_SHIPMENT_ITEMS_UPDATED = SN_UTIL + '/SHIPMENT_ITEMS_UPDATED' \ No newline at end of file +export const UTIL_SHIPMENT_ITEMS_UPDATED = SN_UTIL + '/SHIPMENT_ITEMS_UPDATED' +export const PRODUCT_SELECTOR_PREF_UPDATED = SN_UTIL + '/SELECTOR_PREF_UPDATED' +export const PRODUCT_STORE_SELECTOR_UPDATED = SN_UTIL + '/PRODUCT_STORE_SELECTOR_UPDATED' \ No newline at end of file diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 13236f3b..25604372 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -31,6 +31,12 @@ const mutations: MutationTree = { }, [types.UTIL_DATA_MANAGER_CONFIG_UPDATED] (state, payload) { state.configDetails = payload; + }, + [types.PRODUCT_SELECTOR_PREF_UPDATED](state, payload) { + state.productSelectorPref = payload + }, + [types.PRODUCT_STORE_SELECTOR_UPDATED](state, payload) { + state.useDefaultProductStoreIdentifier = payload } } export default mutations; \ No newline at end of file diff --git a/src/views/ScheduledRestock.vue b/src/views/ScheduledRestock.vue index cde6aee5..b25fb12f 100644 --- a/src/views/ScheduledRestock.vue +++ b/src/views/ScheduledRestock.vue @@ -41,7 +41,7 @@