diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 7cbff83d9..5c76e1d4e 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -147,6 +147,22 @@ const fetchEnumerations = async (payload: any): Promise => { }); } +const fetchCurrentFacilityLatLon = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }); +} + +const fetchStoreLookupByLatLon = async (payload: any): Promise => { + return api({ + url: "storeLookup", + method: "post", + data: payload + }); +} + export const UtilService = { createEnumeration, createProductStoreSetting, @@ -163,5 +179,7 @@ export const UtilService = { isEnumExists, resetPicker, updateProductStoreSetting, - fetchReservedQuantity + fetchReservedQuantity, + fetchCurrentFacilityLatLon, + fetchStoreLookupByLatLon } \ No newline at end of file diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index ed52feb8e..f7ff1c368 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -7,4 +7,6 @@ export default interface UtilState { cancelReasons: Array; facilities: any; enumerations: any; + currentFacilityLatLon: any; + storeLookupByLatLon: any; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index e4123c751..07d854805 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -378,7 +378,58 @@ const actions: ActionTree = { async clearEnumerations({ commit }) { commit(types.UTIL_ENUMERATIONS_UPDATED, {}) - } + }, + + async fetchCurrentFacilityLatLon({ commit }, facilityId) { + const payload = { + inputFields: { + facilityId: facilityId + }, + entityName: "FacilityContactDetailByPurpose", + orderBy: "fromDate DESC", + filterByDate: "Y", + fieldList: ["latitude", "longitude"], + viewSize: 5 + } + + try { + const resp = await UtilService.fetchCurrentFacilityLatLon(payload) + + if (!hasError(resp) && resp.data?.docs.length > 0) { + // Find first doc with non-null coordinates + const validCoords = resp.data.docs.find((doc: any) => + doc.latitude !== null && doc.longitude !== null + ) + + if (validCoords) { + commit(types.UTIL_CURRENT_FACILITY_LATLON_UPDATED, validCoords) + } + } else { + throw resp.data + } + } catch (err) { + console.error("Failed to fetch facility lat/long information", err) + } + }, + + async fetchStoreLookupByLatLon({ commit }, point) { + const payload = { + viewSize: 250, + filters: ["storeType: RETAIL_STORE"], + point: `${point.latitude},${point.longitude}` } + + try { + const resp = await UtilService.fetchStoreLookupByLatLon(payload) + + if (!hasError(resp) && resp.data?.response?.docs?.length > 0) { + commit(types.UTIL_STORE_LOOKUP_BY_LATLON_UPDATED, resp.data.response.docs) + } else { + throw resp.data + } + } catch (err) { + console.error("Failed to fetch stores by lat/lon information", err) + } + }, } export default actions; \ No newline at end of file diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index db6a9e91a..71c7513c9 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -27,5 +27,11 @@ const getters: GetterTree = { getEnumDescription: (state) => (enumId: string) => { return state.enumerations[enumId] ? state.enumerations[enumId] : enumId }, + getCurrentFacilityLatLon: (state) => { + return state.currentFacilityLatLon ? state.currentFacilityLatLon : {} + }, + getStoreLookupByLatLon: (state) => { + return state.storeLookupByLatLon ? state.storeLookupByLatLon : {} + } } 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 3d91b0aeb..862a40e26 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -15,7 +15,9 @@ const utilModule: Module = { partyNames: {}, cancelReasons: [], facilities: {}, - enumerations: {} + enumerations: {}, + currentFacilityLatLon: {}, + storeLookupByLatLon: {} }, getters, actions, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index 4ec560a08..94207ec6c 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -7,3 +7,5 @@ export const UTIL_PARTY_NAMES_UPDATED = SN_UTIL + '/PARTY_NAMES_UPDATED' export const UTIL_CANCEL_REASONS_UPDATED = SN_UTIL + '/CANCEL_REASONS_UPDATED' export const UTIL_FACILITIES_UPDATED = SN_UTIL + '/FACILITIES_UPDATED' export const UTIL_ENUMERATIONS_UPDATED = SN_UTIL + '/ENUMERATIONS_UPDATED' +export const UTIL_CURRENT_FACILITY_LATLON_UPDATED = SN_UTIL + '/CURRENT_FACILITY_LATLON_UPDATED' +export const UTIL_STORE_LOOKUP_BY_LATLON_UPDATED = SN_UTIL + '/STORE_LOOKUP_BY_LATLON_UPDATED' diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 31f36a0b3..c6308eaf5 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -27,5 +27,11 @@ const mutations: MutationTree = { [types.UTIL_ENUMERATIONS_UPDATED] (state, payload) { state.enumerations = payload }, + [types.UTIL_CURRENT_FACILITY_LATLON_UPDATED] (state, payload) { + state.currentFacilityLatLon = payload + }, + [types.UTIL_STORE_LOOKUP_BY_LATLON_UPDATED] (state, payload) { + state.storeLookupByLatLon = payload + } } export default mutations; \ No newline at end of file diff --git a/src/views/OtherStoresInventoryModal.vue b/src/views/OtherStoresInventoryModal.vue index 3cc393db3..02710aae1 100644 --- a/src/views/OtherStoresInventoryModal.vue +++ b/src/views/OtherStoresInventoryModal.vue @@ -6,25 +6,74 @@ - {{ translate("Other stores inventory") }} + {{ translate("Other stores") }} + + + + + + + + + - - - - - {{ storeInventory.facilityName }} - {{ translate('ATP', { count: storeInventory.stock}) }} + + + + Hide facilities without stock + + + + + +

{{ inventory.storeCode }}

+

{{ inventory.storeName }}

+ + {{ inventory.hoursDisplay }} + +

{{ Math.round(inventory.dist) }} miles

+
+ + {{ translate('ATP', { count: inventory.stock }) }} + +
+
+ + + +

{{ capitalizeFirst(day) }}

+
+ +

+ {{ formatTime(inventory[`${day}_open`]) }} - {{ formatTime(inventory[`${day}_close`]) }} +

+

Closed

+
+
+
+
+
+
-

{{ translate("No inventory details found")}}

+ +

{{ translate("No inventory details found") }}