From e4e9a995284f640c1bd9d9cd57b40776ba8e6342 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 21 Nov 2023 16:36:17 +0530 Subject: [PATCH 1/8] Removed: support for product store and facility --- .env.example | 1 - src/locales/en.json | 6 -- src/services/UserService.ts | 81 ++------------------- src/store/modules/user/UserState.ts | 13 ---- src/store/modules/user/actions.ts | 72 ------------------- src/store/modules/user/getters.ts | 9 --- src/store/modules/user/index.ts | 13 ---- src/store/modules/user/mutation-types.ts | 3 - src/store/modules/user/mutations.ts | 11 --- src/views/Settings.vue | 89 +++--------------------- 10 files changed, 14 insertions(+), 284 deletions(-) diff --git a/.env.example b/.env.example index 335c96a2..2d1de397 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,6 @@ VUE_APP_CACHE_MAX_AGE=3600 VUE_APP_VIEW_SIZE=10 VUE_APP_BASE_URL= VUE_APP_PERMISSION_ID= -VUE_APP_ALIAS={} VUE_APP_LOCALES={"en-US": "English"} VUE_APP_DEFAULT_LOG_LEVEL="error" VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login" \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 824f3c78..412ee6ee 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,5 +1,4 @@ { - "A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.": "A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.", "Add": "Add", "Add locations to facility": "Add locations to facility", "Add staff member to facility": "Add staff member to facility", @@ -37,7 +36,6 @@ "Edit location": "Edit location", "External mappings": "External mappings", "Facilities": "Facilities", - "Facility": "Facility", "Facility details": "Facility details", "Facility ID": "Facility ID", "Facility location created successfully": "Facility location created successfully", @@ -119,10 +117,8 @@ "Select": "Select", "Search facilities": "Search facilities", "Search time zones": "Search time zones", - "Select store": "Select store", "Select time": "Select time", "Select time zone": "Select time zone", - "Select facility": "Select facility", "Select product stores": "Select product stores", "Select your preferred language.": "Select your preferred language.", "Sell Online": "Sell Online", @@ -136,11 +132,9 @@ "Something went wrong": "Something went wrong", "Something went wrong while login. Please contact administrator.": "Something went wrong while login. Please contact administrator.", "Sorry, your username or password is incorrect. Please try again.": "Sorry, your username or password is incorrect. Please try again.", - "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.", "Staff": "Staff", "State": "State", "store name": "store name", - "Store": "Store", "Sunday": "Sunday", "The timezone you select is used to ensure automations you schedule are always accurate to the time you select.": "The timezone you select is used to ensure automations you schedule are always accurate to the time you select.", "These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.": "These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 36d21ebb..be353c14 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -28,66 +28,6 @@ const setUserTimeZone = async (payload: any): Promise => { }); } -const getEComStores = async (token: any, facilityId: any): Promise => { - try { - const params = { - "inputFields": { - "storeName_op": "not-empty", - facilityId - }, - "fieldList": ["productStoreId", "storeName"], - "entityName": "ProductStoreFacilityDetail", - "distinct": "Y", - "noConditionFind": "Y", - "filterByDate": 'Y', - } - const baseURL = store.getters['user/getBaseUrl']; - const resp = await client({ - url: "performFind", - method: "get", - baseURL, - params, - headers: { - Authorization: 'Bearer ' + token, - 'Content-Type': 'application/json' - } - }); - if (hasError(resp)) { - return Promise.reject(resp.data); - } else { - return Promise.resolve(resp.data.docs); - } - } catch(error: any) { - return Promise.reject(error) - } -} - -const getPreferredStore = async (token: any): Promise => { - const baseURL = store.getters['user/getBaseUrl']; - try { - const resp = await client({ - url: "service/getUserPreference", - //TODO Due to security reasons service model of OMS 1.0 does not support sending parameters in get request that's why we use post here - method: "post", - baseURL, - headers: { - Authorization: 'Bearer ' + token, - 'Content-Type': 'application/json' - }, - data: { - 'userPrefTypeId': 'SELECTED_BRAND' - }, - }); - if (hasError(resp)) { - return Promise.reject(resp.data); - } else { - return Promise.resolve(resp.data.userPrefValue); - } - } catch (error: any) { - return Promise.reject(error) - } -} - const getUserPermissions = async (payload: any, token: any): Promise => { const baseURL = store.getters['user/getBaseUrl']; let serverPermissions = [] as any; @@ -196,21 +136,10 @@ const getUserProfile = async (token: any): Promise => { } } -const setUserPreference = async (payload: any): Promise => { - return api({ - url: "service/setUserPreference", - method: "post", - data: payload - }); -} - export const UserService = { - login, - getAvailableTimeZones, - getEComStores, - getUserProfile, - getPreferredStore, - setUserPreference, - setUserTimeZone, - getUserPermissions + login, + getAvailableTimeZones, + getUserProfile, + setUserTimeZone, + getUserPermissions } \ No newline at end of file diff --git a/src/store/modules/user/UserState.ts b/src/store/modules/user/UserState.ts index 593cd127..c1eebd98 100644 --- a/src/store/modules/user/UserState.ts +++ b/src/store/modules/user/UserState.ts @@ -2,19 +2,6 @@ export default interface UserState { token: string; current: object | null; permissions: any; - currentFacility: object; instanceUrl: string; - currentEComStore: object; - preference: { - printShippingLabel: boolean, - printPackingSlip: boolean - }; - fieldMappings: object | null; - currentMapping: { - id: string; - mappingType: string; - name: string; - value: object; - }; pwaState: any; } \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index bdf6c9e0..2c8442de 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -49,44 +49,6 @@ const actions: ActionTree = { } const userProfile = await UserService.getUserProfile(token); - - //fetching user facilities - const baseURL = store.getters['user/getBaseUrl']; - - try { - const facilities = await getUserFacilities(token, baseURL, userProfile?.partyId, ""); - - // if (!facilities.length) throw 'Unable to login. User is not assocaited with any facility' - - userProfile.facilities = facilities; - userProfile.facilities.reduce((uniqueFacilities: any, facility: any, index: number) => { - if (uniqueFacilities.includes(facility.facilityId)) userProfile.facilities.splice(index, 1); - else uniqueFacilities.push(facility.facilityId); - return uniqueFacilities - }, []); - const currentFacility = userProfile.facilities[0]; - userProfile.stores = await UserService.getEComStores(token, currentFacility.facilityId); - - // In Job Manager application, we have jobs which may not be associated with any product store - userProfile.stores.push({ - productStoreId: "", - storeName: "None" - }) - let preferredStore = userProfile.stores[0] - - const preferredStoreId = await UserService.getPreferredStore(token); - if (preferredStoreId) { - const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId); - store && (preferredStore = store) - } - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); - commit(types.USER_CURRENT_FACILITY_UPDATED, currentFacility); - } catch(err) { - logger.error(err) - } - // Getting unique facilities - - // TODO Use a separate API for getting facilities, this should handle user like admin accessing the app /* ---- Guard clauses ends here --- */ @@ -160,25 +122,6 @@ const actions: ActionTree = { emitter.emit('dismissLoader') return redirectionUrl; }, - - /** - * update current facility information - */ - async setFacility ({ commit, state }, payload) { - const userProfile = JSON.parse(JSON.stringify(state.current as any)); - userProfile.stores = await UserService.getEComStores(undefined, payload.facility.facilityId); - - let preferredStore = userProfile.stores[0]; - const preferredStoreId = await UserService.getPreferredStore(undefined); - - if (preferredStoreId) { - const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId); - store && (preferredStore = store) - } - commit(types.USER_INFO_UPDATED, userProfile); - commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility); - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore); - }, /** * Update user timeZone @@ -207,21 +150,6 @@ const actions: ActionTree = { updateInstanceUrl(payload) }, - /** - * update current eComStore information - */ - async setEComStore({ commit }, payload) { - commit(types.USER_CURRENT_ECOM_STORE_UPDATED, payload.eComStore); - await UserService.setUserPreference({ - 'userPrefTypeId': 'SELECTED_BRAND', - 'userPrefValue': payload.eComStore.productStoreId - }); - }, - - setUserPreference({ commit }, payload){ - commit(types.USER_PREFERENCE_UPDATED, payload) - }, - updatePwaState({commit}, payload) { commit(types.USER_PWA_STATE_UPDATED, payload); } diff --git a/src/store/modules/user/getters.ts b/src/store/modules/user/getters.ts index b5185ea6..28e56af8 100644 --- a/src/store/modules/user/getters.ts +++ b/src/store/modules/user/getters.ts @@ -18,9 +18,6 @@ const getters: GetterTree = { getUserProfile (state) { return state.current }, - getCurrentFacility (state){ - return state.currentFacility - }, getInstanceUrl (state) { const baseUrl = process.env.VUE_APP_BASE_URL; return baseUrl ? baseUrl : state.instanceUrl; @@ -30,12 +27,6 @@ const getters: GetterTree = { if (!baseURL) baseURL = state.instanceUrl; return baseURL.startsWith('http') ? baseURL : `https://${baseURL}.hotwax.io/api/`; }, - getCurrentEComStore(state) { - return state.currentEComStore - }, - getUserPreference(state) { - return state.preference - }, getPwaState (state) { return state.pwaState; } diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 0047ee48..a0f8cea0 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -11,20 +11,7 @@ const userModule: Module = { token: '', permissions: [], current: {}, - currentFacility: {}, instanceUrl: '', - currentEComStore: {}, - preference: { - printShippingLabel: false, - printPackingSlip: false - }, - fieldMappings: {}, - currentMapping: { - id: '', - mappingType: '', - name: '', - value: {} - }, pwaState: { updateExists: false, registration: null, diff --git a/src/store/modules/user/mutation-types.ts b/src/store/modules/user/mutation-types.ts index 9edb8df0..fbf550a0 100644 --- a/src/store/modules/user/mutation-types.ts +++ b/src/store/modules/user/mutation-types.ts @@ -2,9 +2,6 @@ export const SN_USER = 'user' export const USER_TOKEN_CHANGED = SN_USER + '/TOKEN_CHANGED' export const USER_END_SESSION = SN_USER + '/END_SESSION' export const USER_INFO_UPDATED = SN_USER + '/INFO_UPDATED' -export const USER_CURRENT_FACILITY_UPDATED = SN_USER + '/CURRENT_FACILITY_UPDATED' export const USER_INSTANCE_URL_UPDATED = SN_USER + '/INSTANCE_URL_UPDATED' -export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED' -export const USER_PREFERENCE_UPDATED = SN_USER + '/PREFERENCE_UPDATED' export const USER_PERMISSIONS_UPDATED = SN_USER + '/PERMISSIONS_UPDATED' export const USER_PWA_STATE_UPDATED = SN_USER + '/PWA_STATE_UPDATED' \ No newline at end of file diff --git a/src/store/modules/user/mutations.ts b/src/store/modules/user/mutations.ts index b87ce9aa..9a8e7c14 100644 --- a/src/store/modules/user/mutations.ts +++ b/src/store/modules/user/mutations.ts @@ -9,25 +9,14 @@ const mutations: MutationTree = { [types.USER_END_SESSION] (state) { state.token = '' state.current = {}, - state.currentFacility = {} - state.currentEComStore = {} state.permissions = [] }, [types.USER_INFO_UPDATED] (state, payload) { state.current = { ...state.current, ...payload} }, - [types.USER_CURRENT_FACILITY_UPDATED] (state, payload) { - state.currentFacility = payload; - }, [types.USER_INSTANCE_URL_UPDATED] (state, payload) { state.instanceUrl = payload; }, - [types.USER_CURRENT_ECOM_STORE_UPDATED](state, payload) { - state.currentEComStore = payload; - }, - [types.USER_PREFERENCE_UPDATED] (state, payload) { - state.preference = {...state.preference, ...payload}; - }, [types.USER_PERMISSIONS_UPDATED] (state, payload) { state.permissions = payload }, diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 4ad4209e..4ff10e0b 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -2,7 +2,7 @@ - + {{ translate("Settings") }} @@ -38,43 +38,6 @@
- - - - - {{ translate("Product Store") }} - - - {{ translate("Store") }} - - - - {{ translate('A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.') }} - - - {{ translate("Select store") }} - - {{ store.storeName }} - - - - - - - - {{ translate("Facility") }} - - - - {{ translate('Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.') }} - - - {{ translate("Select facility") }} - - {{ facility.facilityName }} - - -

@@ -108,22 +71,20 @@ \ No newline at end of file diff --git a/src/components/LocationDetailsPopover.vue b/src/components/LocationDetailsPopover.vue index 2a05110c..2bd249a5 100644 --- a/src/components/LocationDetailsPopover.vue +++ b/src/components/LocationDetailsPopover.vue @@ -53,10 +53,8 @@ export default defineComponent({ addLocationModal.present() - addLocationModal.onDidDismiss().then((result: any) => { - if(result.data?.result) { - popoverController.dismiss(); - } + addLocationModal.onDidDismiss().then(() => { + popoverController.dismiss(); }) }, async removeLocation() { @@ -69,8 +67,8 @@ export default defineComponent({ const resp = await FacilityService.deleteFacilityLocation(params) if(!hasError(resp)) { - this.store.dispatch('facility/fetchFacilityLocation') - popoverController.dismiss(); + showToast(translate('Facility location removed successfully')) + await this.store.dispatch('facility/fetchFacilityLocations') } else { throw resp.data } @@ -78,6 +76,7 @@ export default defineComponent({ showToast(translate('Failed to remove facility location')) logger.error('Failed to remove facility location', err) } + popoverController.dismiss(); } }, setup() { diff --git a/src/locales/en.json b/src/locales/en.json index 412ee6ee..1640364c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -25,13 +25,16 @@ "Click the backdrop to dismiss.": "Click the backdrop to dismiss.", "Closing Time": "Closing Time", "Configure the order fulfillment capacity of your facility.": "Configure the order fulfillment capacity of your facility.", + "Consumed Order Limit": "Consumed Order Limit", "Custom": "Custom", "Custom fulfillment capacity": "Custom fulfillment capacity", "Custom mapping": "Custom mapping", "Country": "Country", "Days to ship": "Days to ship", "days to ship": "days to ship", + "Default days to ship updated successfully": "Default days to ship updated successfully", "Dismiss": "Dismiss", + "Filters": "Filters", "Edit": "Edit", "Edit location": "Edit location", "External mappings": "External mappings", @@ -39,6 +42,7 @@ "Facility details": "Facility details", "Facility ID": "Facility ID", "Facility location created successfully": "Facility location created successfully", + "Facility location removed successfully": "Facility location removed successfully", "Facility location updated successfully": "Facility location updated successfully", "Facility name": "Facility name", "Facility Management": "Facility Management", @@ -46,13 +50,17 @@ "Failed to fetch facility information": "Failed to fetch facility information", "Failed to find the facility locations": "Failed to find the facility locations", "Failed to remove facility location": "Failed to remove facility location", + "Failed to update default days to ship": "Failed to update default days to ship", "Failed to update facility location": "Failed to update facility location", + "Failed to update fulfillment capacity for ": "Failed to update fulfillment capacity for {facilityName}", + "Failed to update fulfillment setting": "Failed to update fulfillment setting", "Fetching TimeZones": "Fetching TimeZones", "Find Facilities": "Find Facilities", "Friday": "Friday", "Fulfillment Capacity": "Fulfillment Capacity", "Fulfillment capacity updated successfully for ": "Fulfillment capacity updated successfully for {facilityName}", "Fulfillment Settings": "Fulfillment Settings", + "Fulfillment setting updated successfully": "Fulfillment setting updated successfully", "Generate": "Generate", "Generate shipping labels": "Generate shipping labels", "Go to Launchpad": "Go to Launchpad", @@ -83,9 +91,10 @@ "Netsuite": "Netsuite", "No Capacity": "No Capacity", "No capacity": "No capacity", + "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.", "No facilities found": "No facilities found", "No fulfillment capacity": "No fulfillment capacity", - "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.", + "No records found": "No records found", "No time zone found": "No time zone found", "OMS": "OMS", "OMS instance": "OMS instance", diff --git a/src/theme/variables.css b/src/theme/variables.css index 5fbb21f2..820eae8b 100644 --- a/src/theme/variables.css +++ b/src/theme/variables.css @@ -326,7 +326,7 @@ hr { .list-item { --columns-mobile: 2; - --columns-tablet: 5; + --columns-tablet: 4; --columns-desktop: 7; --col-calc: var(--columns-mobile); --implicit-columns: calc(var(--col-calc) - 1); diff --git a/src/views/FindFacilities.vue b/src/views/FindFacilities.vue index 1056add6..1fa1c2b5 100644 --- a/src/views/FindFacilities.vue +++ b/src/views/FindFacilities.vue @@ -1,13 +1,20 @@