diff --git a/src/locales/en.json b/src/locales/en.json index b6c56a40..1736e270 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -28,8 +28,9 @@ "Facilities": "Facilities", "Facility": "Facility", "Facility Management": "Facility Management", - "Fetching TimeZones": "Fetching TimeZones", "Facility details": "Facility details", + "Failed to fetch facility information": "Failed to fetch facility information", + "Fetching TimeZones": "Fetching TimeZones", "Find Facilities": "Find Facilities", "Friday": "Friday", "Fulfillment Capacity": "Fulfillment Capacity", diff --git a/src/store/index.ts b/src/store/index.ts index 9bc4a805..f8bc8d21 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,10 +3,10 @@ import mutations from './mutations' import getters from './getters' import actions from './actions' import RootState from './RootState' -import createPersistedState from "vuex-persistedstate"; +import createPersistedState from 'vuex-persistedstate'; import userModule from './modules/user'; import { setPermissions } from '@/authorization' -import facilityModule from "./modules/facility" +import facilityModule from './modules/facility' import utilModule from "./modules/util" diff --git a/src/store/modules/facility/FacilityState.ts b/src/store/modules/facility/FacilityState.ts index 416a59aa..2b9f8839 100644 --- a/src/store/modules/facility/FacilityState.ts +++ b/src/store/modules/facility/FacilityState.ts @@ -9,4 +9,5 @@ export default interface FacilityState { list: Array, total: number }; + current: any; } \ No newline at end of file diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 88ee6b76..874eb000 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -43,7 +43,7 @@ const actions: ActionTree = { "entityName": "FacilityAndProductStore", "noConditionFind": "Y", "distinct": "Y", - "fieldList": ['facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit'], + "fieldList": ['defaultDaysToShip', 'facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit'], ...payload } @@ -90,6 +90,46 @@ const actions: ActionTree = { commit(types.FACILITY_LIST_UPDATED , { facilities, total }); }, + async fetchCurrentFacility({ commit, state }, payload) { + // checking that if the list contains basic information for facility then not fetching the same information again + const cachedFacilities = JSON.parse(JSON.stringify(state.facilities.list)) + const current = cachedFacilities.find((facility: any) => facility.facilityId === payload.facilityId) + if(current?.facilityId) { + commit(types.FACILITY_CURRENT_UPDATED, current); + return; + } + + emitter.emit("presentLoader"); + + const params = { + inputFields: { + facilityId: payload.facilityId + }, + entityName: "FacilityAndProductStore", + noConditionFind: "Y", + distinct: "Y", + fieldList: ['defaultDaysToShip', 'facilityId', 'facilityName', 'facilityTypeId', 'maximumOrderLimit'], + viewSize: 1 + } + + let facility = {}; + + try { + const resp = await FacilityService.fetchFacilities(params) + + if(!hasError(resp) && resp.data.count > 0) { + facility = resp.data.docs[0] + } else { + throw resp.data + } + } catch(error) { + logger.error(error) + } + + emitter.emit("dismissLoader"); + commit(types.FACILITY_CURRENT_UPDATED, facility); + }, + updateQuery({ commit }, query) { commit(types.FACILITY_QUERY_UPDATED, query) }, diff --git a/src/store/modules/facility/getters.ts b/src/store/modules/facility/getters.ts index 211686f1..c3582cc9 100644 --- a/src/store/modules/facility/getters.ts +++ b/src/store/modules/facility/getters.ts @@ -14,5 +14,8 @@ const getters: GetterTree = { state.facilities.list?.length > 0 && state.facilities.list?.length < state.facilities.total ); }, + getCurrent(state) { + return state.current ? JSON.parse(JSON.stringify(state.current)) : {} + } } export default getters; \ No newline at end of file diff --git a/src/store/modules/facility/index.ts b/src/store/modules/facility/index.ts index 87d00f40..bc563c53 100644 --- a/src/store/modules/facility/index.ts +++ b/src/store/modules/facility/index.ts @@ -17,7 +17,8 @@ const facilityModule: Module = { facilities: { list: [], total: 0 - } + }, + current: {} }, getters, actions, diff --git a/src/store/modules/facility/mutation-types.ts b/src/store/modules/facility/mutation-types.ts index a6cb0882..4676bdb0 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -1,3 +1,4 @@ export const SN_FACILITY = 'facility' export const FACILITY_LIST_UPDATED = SN_FACILITY + '/LIST_UPDATED' -export const FACILITY_QUERY_UPDATED = SN_FACILITY + '/QUERY_UPDATED' \ No newline at end of file +export const FACILITY_QUERY_UPDATED = SN_FACILITY + '/QUERY_UPDATED' +export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' \ No newline at end of file diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index 157649ad..fab0e52c 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -9,6 +9,9 @@ const mutations: MutationTree = { }, [types.FACILITY_QUERY_UPDATED](state, payload) { state.query = payload + }, + [types.FACILITY_CURRENT_UPDATED](state, payload) { + state.current = payload } } export default mutations; \ No newline at end of file diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index a4c42f06..d09e9e33 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -7,218 +7,223 @@ - - -

{{ "Facility Name" }}

-

{{ "Facility Id" }}

-
-
- -
-
+
+ + +

{{ current.facilityName }}

+

{{ current.facilityId }}

+
+
+ +
+
+ + + + {{ translate("Address") }} + + + + +

{{ "Address line 1" }}

+

{{ "Address line 2" }}

+

{{ "City," }} {{ "Zipcode" }}

+

{{ "State," }} {{ "Country" }}

+
+
+ {{ translate("Edit") }} + + {{ translate("Add") }} + + +
+ + + + + {{ translate("Latitude & Longitude") }} + + + + {{ translate("These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.") }} + + + {{ translate("Latitude") }} +

{{ "" }}

+
+ + {{ translate("Longitude") }} +

{{ "" }}

+
+ {{ translate("Edit") }} + + {{ translate("Add") }} + + +
+
+ - {{ translate("Address") }} + {{ translate("Operating hours") }} - - -

{{ "Address line 1" }}

-

{{ "Address line 2" }}

-

{{ "City," }} {{ "Zipcode" }}

-

{{ "State," }} {{ "Country" }}

-
-
- {{ translate("Edit") }} - - {{ translate("Add") }} - - + + + +

{{ translate("Monday") }}

+
+ + {{ "7:30am - 8:00pm" }} + +
+ + +

{{ translate("Tuesday") }}

+
+ + + {{ translate("Add timings") }} + +
+ + +

{{ translate("Wednesday") }}

+
+ + + {{ translate("Add timings") }} + +
+ + +

{{ translate("Thursday") }}

+
+ + + {{ translate("Add timings") }} + +
+ + +

{{ translate("Friday") }}

+
+ + + {{ translate("Add timings") }} + +
+ + +

{{ translate("Saturday") }}

+
+ + + {{ translate("Add timings") }} + +
+ + +

{{ translate("Sunday") }}

+
+ + + {{ translate("Add timings") }} + +
+
- {{ translate("Latitude & Longitude") }} + {{ translate("Product Stores") }} + + + {{ translate("Add") }} + - - {{ translate("These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.") }} - - - {{ translate("Latitude") }} -

{{ "" }}

-
- - {{ translate("Longitude") }} -

{{ "" }}

-
- {{ translate("Edit") }} - - {{ translate("Add") }} - - -
-
- - - - - {{ translate("Operating hours") }} - - - - - -

{{ translate("Monday") }}

-
- - {{ "7:30am - 8:00pm" }} - -
- + + -

{{ translate("Tuesday") }}

+ {{ "NotNaked" }}
- - - {{ translate("Add timings") }} + {{ translate("primary store") }} + +
- + + -

{{ translate("Wednesday") }}

+ {{ "Wasatch Ski company" }}
- - - {{ translate("Add timings") }} + +
- - -

{{ translate("Thursday") }}

-
- - - {{ translate("Add timings") }} - +
+
+ +
+ + + + {{ translate("Fulfillment Settings") }} + + + + {{ translate("Sell Inventory Online") }} + - - -

{{ translate("Friday") }}

-
- - - {{ translate("Add timings") }} - + + {{ translate("Uses native fulfillment app") }} + - - -

{{ translate("Saturday") }}

-
- - - {{ translate("Add timings") }} - + + {{ translate("Generate shipping labels") }} + - - -

{{ translate("Sunday") }}

-
- - - {{ translate("Add timings") }} - + + {{ translate("Allow pickup") }} + - -
- - - - - {{ translate("Product Stores") }} - - - - {{ translate("Add") }} - - - - - - {{ "NotNaked" }} - - {{ translate("primary store") }} - - - - - - - - {{ "Wasatch Ski company" }} - - - + + {{ translate("Days to ship") }} + + + + {{ translate("Update days to ship") }} - - -
- -
- - - - {{ translate("Fulfillment Settings") }} - - - - {{ translate("Sell Inventory Online") }} - - - - {{ translate("Uses native fulfillment app") }} - - - - {{ translate("Generate shipping labels") }} - - - - {{ translate("Allow pickup") }} - - - - {{ translate("Days to ship") }} - - - - {{ translate("Update days to ship") }} - - + - - - - {{ translate("Online Order Fulfillment") }} - - - - {{ translate("Configure the order fulfillment capacity of your facility.") }} -

- {{ translate("Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.") }} -
- - {{ 10 }} - - {{ 20 }} - - - {{ translate("View order count history") }} - -
-
+ + + + {{ translate("Online Order Fulfillment") }} + + + + {{ translate("Configure the order fulfillment capacity of your facility.") }} +

+ {{ translate("Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.") }} +
+ + {{ 10 }} + + {{ 20 }} + + + {{ translate("View order count history") }} + +
+ + +
+ {{ translate("Failed to fetch facility information") }} +
@@ -257,6 +262,7 @@ import AddAddressModal from '@/components/AddAddressModal.vue' import AddGeoPointModal from '@/components/AddGeoPointModal.vue'; import SelectProductStoreModal from '@/components/SelectProductStoreModal.vue' import SelectOperatingTimeModal from '@/components/SelectOperatingTimeModal.vue'; +import { mapGetters, useStore } from 'vuex'; export default defineComponent({ name: 'FacilityDetails', @@ -285,9 +291,20 @@ export default defineComponent({ }, data() { return { - isTimeModalOpen: false as boolean + isTimeModalOpen: false as boolean, + isLoading: true // shows whether the facility information fetching is completed or not } }, + computed: { + ...mapGetters({ + current: 'facility/getCurrent' + }) + }, + props: ["facilityId"], + async ionViewWillEnter() { + await this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId }) + this.isLoading = false + }, methods: { async openStorePopover(ev: Event) { const popover = await popoverController.create({ @@ -327,11 +344,14 @@ export default defineComponent({ } }, setup() { + const store = useStore(); + return { addCircleOutline, addOutline, closeOutline, ellipsisVerticalOutline, + store, translate } }