From aaf886d8ae00cc5737917192f6bf4e0400a69cbd Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 24 Nov 2023 12:51:09 +0530 Subject: [PATCH 01/16] Implemented: UI for operating hours card, addOperatingHours modal, customSchedule modal and operating hours popover (#28) --- ...meModal.vue => AddOperatingHoursModal.vue} | 77 ++++---- src/components/CustomScheduleModal.vue | 164 ++++++++++++++++++ src/components/OperatingHoursPopover.vue | 69 ++++++++ src/locales/en.json | 9 + src/views/FacilityDetails.vue | 145 +++++++++++----- 5 files changed, 378 insertions(+), 86 deletions(-) rename src/components/{SelectOperatingTimeModal.vue => AddOperatingHoursModal.vue} (50%) create mode 100644 src/components/CustomScheduleModal.vue create mode 100644 src/components/OperatingHoursPopover.vue diff --git a/src/components/SelectOperatingTimeModal.vue b/src/components/AddOperatingHoursModal.vue similarity index 50% rename from src/components/SelectOperatingTimeModal.vue rename to src/components/AddOperatingHoursModal.vue index 22b55104..51279432 100644 --- a/src/components/SelectOperatingTimeModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -6,35 +6,35 @@ - {{ translate("Select time") }} + {{ translate("Add operating hours") }} - - - {{ translate("Opening Time") }} - - - - {{ translate("Closing Time") }} - - - - {{ translate("Reset") }} - - + + + + + + + {{ "Calendar 1" }} + + +
First Content
+
+ + + + + {{ "Calendar 2" }} + + +
Second Content
+
+
+
- - - - - - - - - @@ -44,19 +44,19 @@ \ No newline at end of file diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue new file mode 100644 index 00000000..7d856cd7 --- /dev/null +++ b/src/components/CustomScheduleModal.vue @@ -0,0 +1,164 @@ + + + + + + \ No newline at end of file diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue new file mode 100644 index 00000000..e460ba33 --- /dev/null +++ b/src/components/OperatingHoursPopover.vue @@ -0,0 +1,69 @@ + + + diff --git a/src/locales/en.json b/src/locales/en.json index e3d6663c..a4cac759 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -6,6 +6,8 @@ "Address": "Address", "Address line 1": "Address line 1", "Address line 2": "Address line 2", + "Add custom schedules": "Add custom schedules", + "Add operating hours": "Add operating hours", "add your location ID from Shopify": "add your location ID from Shopify", "Aisle": "Aisle", "aisle": "aisle", @@ -30,7 +32,9 @@ "Custom": "Custom", "Custom fulfillment capacity": "Custom fulfillment capacity", "Custom mapping": "Custom mapping", + "Custom schedule": "Custom schedule", "Country": "Country", + "Daily timings": "Daily timings", "Days to ship": "Days to ship", "days to ship": "days to ship", "Default days to ship updated successfully": "Default days to ship updated successfully", @@ -100,6 +104,7 @@ "Mapping Name": "Mapping Name", "Map facility to an external system": "Map facility to an external system", "Monday": "Monday", + "Name": "Name", "Netsuite": "Netsuite", "No Capacity": "No Capacity", "No capacity": "No capacity", @@ -112,6 +117,7 @@ "OMS": "OMS", "OMS instance": "OMS instance", "Online Order Fulfillment": "Online Order Fulfillment", + "Open and close time": "Open and close time", "Opening Time": "Opening Time", "Operating hours": "Operating hours", "Order fulfillment capacity": "Order fulfillment capacity", @@ -132,6 +138,7 @@ "Reason:": "Reason:", "Remove": "Remove", "Remove location": "Remove location", + "Remove schedules": "Remove schedules", "Removed facility mapping successfully": "Removed facility mapping successfully", "Removed shopify mapping successfully": "Removed shopify mapping successfully", "Reset": "Reset", @@ -143,6 +150,7 @@ "Section": "Section", "section": "section", "Select": "Select", + "Select a saved calendar of store hours or create a new calendar": "Select a saved calendar of store hours or create a new calendar", "Search facilities": "Search facilities", "Search time zones": "Search time zones", "Select time": "Select time", @@ -188,6 +196,7 @@ "Uses native fulfillment app": "Uses native fulfillment app", "Version: ": "Version: { appVersion }", "View order count history": "View order count history", + "View other schedules": "View other schedules", "Wednesday": "Wednesday", "Would you like to update your time zone to . Your profile is currently set to . This setting can always be changed from the settings menu.": "Would you like to update your time zone to {localTimeZone}. Your profile is currently set to {profileTimeZone}. This setting can always be changed from the settings menu.", "Zipcode": "Zipcode" diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index da1261b9..30b6cf42 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -63,74 +63,99 @@ - + - - {{ translate("Operating hours") }} - +
+ + {{ translate("Operating hours") }} + + + {{ translate("Select a saved calendar of store hours or create a new calendar") }} + +
+
+ + + calendar name + + + + calendar name + + + + calendar name + + + + + {{ "5 Others" }} + + + + {{ translate("Custom schedule") }} + + + + {{ translate("Add operating hours") }} + + +
+ + + +
+ {{ "Operating Hours" }} + + {{ "" }} + +
+ + +
- +

{{ translate("Monday") }}

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

{{ translate("Tuesday") }}

- - - {{ translate("Add timings") }} - + {{ "7:30am - 8:00pm" }}
- +

{{ translate("Wednesday") }}

- - - {{ translate("Add timings") }} - + {{ "7:30am - 8:00pm" }}
- +

{{ translate("Thursday") }}

- - - {{ translate("Add timings") }} - + {{ "7:30am - 8:00pm" }}
- +

{{ translate("Friday") }}

- - - {{ translate("Add timings") }} - + {{ "7:30am - 8:00pm" }}
- +

{{ translate("Saturday") }}

- - - {{ translate("Add timings") }} - + {{ "7:30am - 8:00pm" }}
- +

{{ translate("Sunday") }}

- - - {{ translate("Add timings") }} - + {{ "7:30am - 8:00pm" }}
@@ -367,7 +392,7 @@ {{ location.positionId }}

{{ translate("sequence") }}

- + @@ -391,6 +416,7 @@ import { IonCard, IonCardContent, IonCardHeader, + IonCardSubtitle, IonCardTitle, IonChip, IonContent, @@ -402,6 +428,8 @@ import { IonList, IonPage, IonProgressBar, + IonRadio, + IonRadioGroup, IonSegment, IonSegmentButton, IonText, @@ -416,6 +444,7 @@ import { addOutline, closeCircleOutline, closeOutline, + chevronForwardOutline, ellipsisVerticalOutline, globeOutline, locationOutline, @@ -429,11 +458,12 @@ import OpenStorePopover from '@/components/OpenStorePopover.vue'; 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 AddOperatingHoursModal from '@/components/AddOperatingHoursModal.vue' import AddLocationModal from '@/components/AddLocationModal.vue'; import AddStaffMemberModal from '@/components/AddStaffMemberModal.vue'; import ViewFacilityOrderCountModal from '@/components/ViewFacilityOrderCountModal.vue' import OrderLimitPopover from '@/components/OrderLimitPopover.vue'; +import CustomScheduleModal from '@/components/CustomScheduleModal.vue'; import { mapGetters, useStore } from 'vuex'; import { DateTime } from 'luxon'; import { FacilityService } from '@/services/FacilityService'; @@ -442,6 +472,7 @@ import logger from '@/logger'; import FacilityShopifyMappingModal from '@/components/FacilityShopifyMappingModal.vue' import FacilityMappingModal from '@/components/FacilityMappingModal.vue' import { showToast } from '@/utils'; +import OperatingHoursPopover from '@/components/OperatingHoursPopover.vue' export default defineComponent({ name: 'FacilityDetails', @@ -452,6 +483,7 @@ export default defineComponent({ IonCard, IonCardContent, IonCardHeader, + IonCardSubtitle, IonCardTitle, IonChip, IonContent, @@ -463,6 +495,8 @@ export default defineComponent({ IonList, IonPage, IonProgressBar, + IonRadio, + IonRadioGroup, IonSegment, IonSegmentButton, IonText, @@ -472,10 +506,10 @@ export default defineComponent({ }, data() { return { - isTimeModalOpen: false as boolean, isLoading: true, // shows whether the facility information fetching is completed or not segment: 'external-mappings', - defaultDaysToShip: '' // not assinging 0 by default as it will convey the user that the facility can ship same day(as the value is 0), but actually defaultDays are not setup on the facility + defaultDaysToShip: '', // not assinging 0 by default as it will convey the user that the facility can ship same day(as the value is 0), but actually defaultDays are not setup on the facility + isCalendarFound: true } }, computed: { @@ -515,6 +549,13 @@ export default defineComponent({ addAddressModal.present() }, + async addCustomSchedule() { + const customScheduleModal = await modalController.create({ + component: CustomScheduleModal + }) + + customScheduleModal.present() + }, async addGeoPoint() { const addGeoPointModal = await modalController.create({ component: AddGeoPointModal @@ -544,12 +585,12 @@ export default defineComponent({ addStaffModal.present() }, - async selectOperatingTime() { - const selectOperatingTimeModal = await modalController.create({ - component: SelectOperatingTimeModal + async addOperatingHours() { + const addOperatingHoursModal = await modalController.create({ + component: AddOperatingHoursModal }) - - selectOperatingTimeModal.present() + + addOperatingHoursModal.present() }, async openLocationDetailsPopover(ev: Event, location: any) { const locationDetailsPopover = await popoverController.create({ @@ -568,6 +609,15 @@ export default defineComponent({ }); return externalMappingPopover.present() }, + async openOperatingHoursPopover(ev: Event) { + const operatingHoursPopover = await popoverController.create({ + component: OperatingHoursPopover, + event: ev, + showBackdrop: false + }); + + operatingHoursPopover.present() + }, getDate(date: any) { return DateTime.fromMillis(date).toFormat('dd LLL yyyy') }, @@ -779,6 +829,7 @@ export default defineComponent({ addOutline, closeCircleOutline, closeOutline, + chevronForwardOutline, ellipsisVerticalOutline, globeOutline, locationOutline, From 0c5ee1f536ee9ba8e478e0bdf4365d74da9f45e2 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 24 Nov 2023 13:02:51 +0530 Subject: [PATCH 02/16] Improved: unused translation entry reverted (#28) --- src/locales/en.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index a4cac759..d2dd71a4 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -153,7 +153,6 @@ "Select a saved calendar of store hours or create a new calendar": "Select a saved calendar of store hours or create a new calendar", "Search facilities": "Search facilities", "Search time zones": "Search time zones", - "Select time": "Select time", "Select time zone": "Select time zone", "Select product stores": "Select product stores", "Select your preferred language.": "Select your preferred language.", From 24d4d760f6bc334bf1c6f97499005ea1377649a0 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 27 Nov 2023 10:45:23 +0530 Subject: [PATCH 03/16] Improved: syntax, comments and added css to date time modal (#28) --- src/components/AddOperatingHoursModal.vue | 2 +- src/components/CustomScheduleModal.vue | 10 +++++++--- src/views/FacilityDetails.vue | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index 51279432..87763af0 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -94,7 +94,7 @@ export default defineComponent({ modalController.dismiss({ dismissed: true}); }, updateSelectedCalendar(ev: CustomEvent) { - this.selectedCalendarId= ev.detail.value + this.selectedCalendarId = ev.detail.value } }, diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 7d856cd7..7f31bd82 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -75,11 +75,11 @@ - + - + @@ -156,9 +156,13 @@ export default defineComponent({ }); - \ No newline at end of file diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 30b6cf42..7ded7950 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -63,6 +63,7 @@
+
@@ -115,7 +116,7 @@ - +

{{ translate("Monday") }}

From c183c17e126c0bfb689df61d8b61444e5fd427d9 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 28 Nov 2023 09:39:45 +0530 Subject: [PATCH 04/16] Implemented: logic for fetching all calendars on the card and modal (#28) --- src/components/AddOperatingHoursModal.vue | 90 +++++++++++++++----- src/components/CustomScheduleModal.vue | 67 +++++---------- src/components/OperatingHoursPopover.vue | 11 ++- src/locales/en.json | 2 + src/services/FacilityService.ts | 18 ++++ src/services/UtilService.ts | 18 ++++ src/store/modules/facility/actions.ts | 27 ++++++ src/store/modules/facility/getters.ts | 5 +- src/store/modules/facility/mutation-types.ts | 1 + src/store/modules/facility/mutations.ts | 3 + src/store/modules/util/UtilState.ts | 1 + src/store/modules/util/actions.ts | 56 ++++++++++++ src/store/modules/util/getters.ts | 3 + src/store/modules/util/index.ts | 1 + src/store/modules/util/mutation-types.ts | 1 + src/store/modules/util/mutations.ts | 3 + src/views/FacilityDetails.vue | 77 +++++++++++------ 17 files changed, 288 insertions(+), 96 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index 87763af0..aae13abd 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -9,34 +9,24 @@ {{ translate("Add operating hours") }} - - - - + + + - - - {{ "Calendar 1" }} + + + {{ calendar.description }}
First Content
- - - - - {{ "Calendar 2" }} - - -
Second Content
-
- + @@ -62,8 +52,14 @@ import { modalController } from "@ionic/vue"; import { defineComponent } from "vue"; +import { mapGetters, useStore } from "vuex"; import { closeOutline, saveOutline } from "ionicons/icons"; import { translate } from '@hotwax/dxp-components' +import { FacilityService } from "@/services/FacilityService"; +import { DateTime } from "luxon"; +import { hasError } from "@/adapter"; +import logger from "@/logger"; +import { showToast } from "@/utils"; export default defineComponent({ name: "AddOperatingHoursModal", @@ -86,22 +82,74 @@ export default defineComponent({ }, data() { return { - selectedCalendarId:'second' + selectedCalendarId: 'DEFAULT' } }, + props: ["facilityId"], + computed: { + ...mapGetters({ + calendars: 'util/getCalendars', + facilityCalendar: 'facility/getFacilityCalendar' + }) + }, methods: { closeModal() { modalController.dismiss({ dismissed: true}); }, - updateSelectedCalendar(ev: CustomEvent) { - this.selectedCalendarId = ev.detail.value - + async addOperatingHours() { + let resp; + try { + resp = await this.removeCalendarFromFacility() + + if(hasError(resp)) { + throw resp.data; + } + } catch(err) { + showToast(translate("Failed to associate calendar to the facility.")) + logger.error(err) + modalController.dismiss() + return; + } + + if(this.selectedCalendarId && this.selectedCalendarId !== this.facilityCalendar.calendarId) { + try { + resp = await FacilityService.associateCalendarToFacility({ + storeId: this.facilityId, + calendarId: this.selectedCalendarId, + fromDateStr: DateTime.now().toFormat('MM/dd/yyyy') + }) + + if(!hasError(resp)) { + showToast(translate("Successfully associated calendar to the facility.")) + } else { + throw resp.data + } + } catch(err) { + showToast(translate("Failed to associate calendar to the facility.")) + logger.error(err) + } + } + + this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) + modalController.dismiss() + }, + async removeCalendarFromFacility() { + return await FacilityService.associateCalendarToFacility({ + storeId: this.facilityId, + calendarId: this.facilityCalendar.calendarId, + thruDateStr: DateTime.now().toFormat('MM/dd/yyyy'), + facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, + fromDateStr: DateTime.fromMillis(this.facilityCalendar.fromDate).toFormat('MM/dd/yyyy') + }) } }, setup() { + const store = useStore(); + return { closeOutline, saveOutline, + store, translate }; }, diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 7f31bd82..93fc4ec6 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -17,51 +17,15 @@
{{ translate("Daily timings") }} - + - + -

{{ translate("Monday") }}

+

{{ translate(day) }}

- - -
- - -

{{ translate("Tuesday") }}

-
- - -
- - -

{{ translate("Wednesday") }}

-
- - -
- - -

{{ translate("Thursday") }}

-
- - -
- - -

{{ translate("Friday") }}

-
- - -
- - -

{{ translate("Saturday") }}

-
- - -
- - -

{{ translate("Sunday") }}

-
- - + -
@@ -70,17 +34,17 @@

{{ translate("Open and close time") }}

- - + -
- - + + - - + + @@ -138,13 +102,22 @@ export default defineComponent({ }, data() { return { - isDailyTimingsChecked: false as boolean + isDailyTimingsChecked: false as boolean, + days: ['Time'], + selectedDay: '' } }, methods: { closeModal() { modalController.dismiss({ dismissed: true}); - } + }, + updateDailyTimings() { + this.isDailyTimingsChecked = !this.isDailyTimingsChecked + this.days = this.isDailyTimingsChecked ? ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] : ['Time'] + }, + updateTime(ev: CustomEvent) { + console.log('Selected: ', this.selectedDay, " - ", ev.detail.value); + } }, setup() { return { diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue index e460ba33..825509f1 100644 --- a/src/components/OperatingHoursPopover.vue +++ b/src/components/OperatingHoursPopover.vue @@ -28,7 +28,8 @@ import { IonLabel, IonList, IonListHeader, - modalController + modalController, + popoverController } from "@ionic/vue"; import { defineComponent } from "vue"; import { translate } from "@hotwax/dxp-components"; @@ -44,10 +45,16 @@ export default defineComponent({ IonList, IonListHeader }, + props: ["facilityId"], methods: { async addOperatingHours() { const addOperatingHoursModal = await modalController.create({ - component: AddOperatingHoursModal + component: AddOperatingHoursModal, + componentProps: { facilityId: this.facilityId } + }) + + addOperatingHoursModal.onDidDismiss().then(() => { + popoverController.dismiss() }) addOperatingHoursModal.present() diff --git a/src/locales/en.json b/src/locales/en.json index d2dd71a4..eb73c425 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -39,6 +39,7 @@ "days to ship": "days to ship", "Default days to ship updated successfully": "Default days to ship updated successfully", "Dismiss": "Dismiss", + "Failed to associate calendar to the facility.": "Failed to associate calendar to the facility.", "Filters": "Filters", "Edit": "Edit", "Edit location": "Edit location", @@ -174,6 +175,7 @@ "Staff": "Staff", "State": "State", "store name": "store name", + "Successfully associated calendar to the facility.": "Successfully associated calendar to the facility.", "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/FacilityService.ts b/src/services/FacilityService.ts index a1204239..1624c4e3 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -182,6 +182,14 @@ const addFacilityToGroup = async (payload: any): Promise => { }) } +const associateCalendarToFacility = async (payload: any): Promise => { + return api({ + url: "service/storeCalendarAssocDataSetup", + method: "post", + data: payload + }) +} + const createFacilityLocation = async(payload: any): Promise => { return api({ url: "service/createFacilityLocation", @@ -278,9 +286,18 @@ const createEnumeration = async (payload: any): Promise => { }) } +const fetchFacilityCalendars = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + export const FacilityService = { addFacilityToGroup, addPartyToFacility, + associateCalendarToFacility, createEnumeration, createFacilityIdentification, createFacilityLocation, @@ -289,6 +306,7 @@ export const FacilityService = { deleteShopifyShopLocation, fetchFacilities, fetchFacilitiesOrderCount, + fetchFacilityCalendars, fetchFacilityGroupInformation, fetchFacilityLocations, fetchFacilityMappings, diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 7fba2177..64e37f14 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -44,7 +44,25 @@ const fetchExternalMappingTypes = async (payload: any): Promise => { }) } +const fetchCalendars = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + +const fetchCalendarWeek = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + export const UtilService = { + fetchCalendars, + fetchCalendarWeek, fetchExternalMappingTypes, fetchFacilityTypes, fetchLocationTypes, diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 513a37a5..b2d5e676 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -195,6 +195,33 @@ const actions: ActionTree = { } }, + async fetchFacilityCalendar({commit}, payload) { + let resp; + let facilityCalendar = {} + try { + const params = { + inputFields: { + facilityId: payload.facilityId + }, + entityName: "StoreOperatingHours", + filterByDate: 'Y', + // viewSize: 1 + } + + resp = await FacilityService.fetchFacilityCalendars(params) + + if(!hasError(resp) && resp.data.count) { + facilityCalendar = resp.data.docs[0] + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } + + commit(types.FACILITY_CALENDAR_UPDATED, facilityCalendar) + }, + async fetchFacilityMappings({ commit }, payload) { let mappings = [] try { diff --git a/src/store/modules/facility/getters.ts b/src/store/modules/facility/getters.ts index e60df7a8..d83f2970 100644 --- a/src/store/modules/facility/getters.ts +++ b/src/store/modules/facility/getters.ts @@ -17,8 +17,11 @@ const getters: GetterTree = { getCurrent(state) { return state.current ? JSON.parse(JSON.stringify(state.current)) : {} }, + getFacilityCalendar(state) { + return state.current?.calendar ? JSON.parse(JSON.stringify(state.current.calendar)) : {} + }, getFacilityParties(state) { return state.current.parties - } + }, } export default getters; \ No newline at end of file diff --git a/src/store/modules/facility/mutation-types.ts b/src/store/modules/facility/mutation-types.ts index 02f14ea3..40ceb51e 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -5,5 +5,6 @@ export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' export const FACILITY_LOCATIONS_UPDATED = SN_FACILITY + '/LOCATIONS_UPDATED' export const FACILITY_MAPPINGS_UPDATED = SN_FACILITY + '/MAPPINGS_UPDATED' export const FACILITY_SHOPIFY_MAPPINGS_UPDATED = SN_FACILITY + '/SHOPIFY_MAPPINGS_UPDATED' +export const FACILITY_CALENDAR_UPDATED = SN_FACILITY + '/CALENDAR_UPDATED' export const FACILITY_CURRENT_LOCATION_UPDATED = SN_FACILITY + '/CURRENT_LOCATION_UPDATED' export const FACILITY_PARTIES_UPDATED = SN_FACILITY + '/PARTIES_UPDATED' diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index d09530d5..a2ce1f0d 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -10,6 +10,9 @@ const mutations: MutationTree = { [types.FACILITY_QUERY_UPDATED](state, payload) { state.query = payload }, + [types.FACILITY_CALENDAR_UPDATED](state, payload) { + state.current.calendar = payload + }, [types.FACILITY_CURRENT_UPDATED](state, payload) { state.current = payload }, diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index fda1accd..119957e9 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -1,4 +1,5 @@ export default interface UtilState { + calendars: any[]; facilityTypes: object; locationTypes: object; externalMappingTypes: object; diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 21f04cee..154abbfa 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -5,6 +5,8 @@ import UtilState from './UtilState' import * as types from './mutation-types' import { hasError } from '@/adapter' import logger from '@/logger' +import { showToast } from '@/utils' +import { translate } from '@hotwax/dxp-components' const actions: ActionTree = { async fetchProductStores({ commit }) { @@ -175,6 +177,60 @@ const actions: ActionTree = { commit(types.UTIL_EXTERNAL_MAPPING_TYPES_UPDATED, externalMappingTypes) }, + + async fetchUtilCalendars({ commit, dispatch }, payload) { + let calendars = [] + const params = { + inputFields: { + facilityId: payload.facilityId + }, + entityName: "TechDataCalendar", + viewSize: 100, + noConditionFind: 'Y' + } + + try { + const resp = await UtilService.fetchCalendars(params) + + if(!hasError(resp) && resp.data.count) { + calendars = resp.data.docs + dispatch('fetchCalendarWeek', {calendWeekId: calendars[0].calendarWeekId}) + } else { + throw resp.data + } + } catch(err) { + showToast(translate("Something went wrong")) + logger.error('Failed to fetch facility calendars', err) + } + + commit(types.UTIL_CALENDARS_UPDATED, calendars) + }, + + async fetchCalendarWeek({ commit }, payload) { + let calendars = [] + + const params = { + inputFields: { + calendarWeekId: payload.calendarWeekId + }, + entityName: "TechDataCalendarWeek", + viewSize: 100, + noConditionFind: 'Y' + } + + try { + const resp = await UtilService.fetchCalendarWeek(params) + + if(!hasError(resp) && resp.data.count) { + calendars = resp.data.docs + } else { + throw resp.data + } + } catch(err) { + showToast(translate("Something went wrong")) + logger.error('Failed to fetch facility calendars', err) + } + }, clearUtilState({ commit }) { commit(types.UTIL_PRODUCT_STORES_UPDATED, []) diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index c351ece6..ebb89758 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -3,6 +3,9 @@ import UtilState from './UtilState' import RootState from '@/store/RootState' const getters: GetterTree = { + getCalendars(state) { + return state.calendars; + }, getProductStores(state) { return state.productStores; }, diff --git a/src/store/modules/util/index.ts b/src/store/modules/util/index.ts index 6e3bfde4..47c4761e 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -8,6 +8,7 @@ import RootState from '@/store/RootState' const utilModule: Module = { namespaced: true, state: { + calendars: [], partyRoles: [], productStores: [], facilityTypes: {}, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index 1d73909f..9d174179 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -1,4 +1,5 @@ export const SN_UTIL = 'util' +export const UTIL_CALENDARS_UPDATED = SN_UTIL + '/CALENDARS_UPDATED' export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED' export const UTIL_FACILITY_TYPES_UPDATED = SN_UTIL + '/FACILITY_TYPES_UPDATED' export const UTIL_LOCATION_TYPES_UPDATED = SN_UTIL + '/LOCATION_TYPES_UPDATED' diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 060f0486..ac177d83 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -3,6 +3,9 @@ import UtilState from './UtilState' import * as types from './mutation-types' const mutations: MutationTree = { + [types.UTIL_CALENDARS_UPDATED](state, payload) { + state.calendars = payload + }, [types.UTIL_PRODUCT_STORES_UPDATED](state, payload) { state.productStores = payload }, diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 7ded7950..a72c7a2f 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -64,7 +64,7 @@
- +
@@ -75,29 +75,21 @@
- - - calendar name - - - - calendar name - - - - calendar name - + + + {{ calendar.description }} + - - {{ "5 Others" }} + + {{ calendars.length - 3 }} {{ "Others" }} {{ translate("Custom schedule") }} - + {{ translate("Add operating hours") }} @@ -108,7 +100,7 @@
{{ "Operating Hours" }} - {{ "" }} + {{ facilityCalendar.description }}
@@ -120,43 +112,43 @@

{{ translate("Monday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.mondayStartTime ? getOpenEndTime(facilityCalendar.mondayStartTime, facilityCalendar.mondayCapacity) : '-' }}

{{ translate("Tuesday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.tuesdayStartTime ? getOpenEndTime(facilityCalendar.tuesdayStartTime, facilityCalendar.tuesdayCapacity) : '-' }}

{{ translate("Wednesday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.wednesdayStartTime ? getOpenEndTime(facilityCalendar.wednesdayStartTime, facilityCalendar.wednesdayCapacity) : '-' }}

{{ translate("Thursday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.thursdayStartTime ? getOpenEndTime(facilityCalendar.thursdayStartTime, facilityCalendar.thursdayCapacity) : '-' }}

{{ translate("Friday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.fridayStartTime ? getOpenEndTime(facilityCalendar.fridayStartTime, facilityCalendar.fridayCapacity) : '-' }}

{{ translate("Saturday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.saturdayStartTime ? getOpenEndTime(facilityCalendar.saturdayStartTime, facilityCalendar.saturdayCapacity) : '-' }}

{{ translate("Sunday") }}

- {{ "7:30am - 8:00pm" }} + {{ facilityCalendar.sundayStartTime ? getOpenEndTime(facilityCalendar.sundayStartTime, facilityCalendar.sundayCapacity) : '-' }}
@@ -510,14 +502,17 @@ export default defineComponent({ isLoading: true, // shows whether the facility information fetching is completed or not segment: 'external-mappings', defaultDaysToShip: '', // not assinging 0 by default as it will convey the user that the facility can ship same day(as the value is 0), but actually defaultDays are not setup on the facility - isCalendarFound: true + isCalendarFound: true, + selectedCalendarId: 'DEFAULT' } }, computed: { ...mapGetters({ current: 'facility/getCurrent', + calendars: 'util/getCalendars', locationTypes: 'util/getLocationTypes', externalMappingTypes: 'util/getExternalMappingTypes', + facilityCalendar: 'facility/getFacilityCalendar', facilityParties: 'facility/getFacilityParties', partyRoles: 'util/getPartyRoles' }) @@ -526,8 +521,11 @@ export default defineComponent({ async ionViewWillEnter() { await Promise.all([this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId }), this.store.dispatch('util/fetchExternalMappingTypes'), this.store.dispatch('util/fetchLocationTypes'), this.store.dispatch('util/fetchPartyRoles')]) await Promise.all([this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityParties', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.facilityId, facilityIdenTypeIds: Object.keys(this.externalMappingTypes)}), this.store.dispatch('facility/fetchShopifyFacilityMappings', { facilityId: this.facilityId })]) + await this.store.dispatch('util/fetchUtilCalendars', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false + this.facilityCalendar }, methods: { goToLink(link: string) { @@ -543,6 +541,28 @@ export default defineComponent({ }); return popover.present() }, + async associateCalendarToFacility() { + let resp; + + try { + resp = await FacilityService.associateCalendarToFacility({ + storeId: this.facilityId, + calendarId: this.selectedCalendarId, + fromDateStr: DateTime.now().toFormat('MM/dd/yyyy'), + }) + + if(!hasError(resp)) { + showToast(translate("Successfully associated calendar to the facility.")) + + await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) + } else { + throw resp.data + } + } catch(err) { + showToast(translate("Failed to associate calendar to the facility.")) + logger.error(err) + } + }, async addAddress() { const addAddressModal = await modalController.create({ component: AddAddressModal @@ -613,6 +633,7 @@ export default defineComponent({ async openOperatingHoursPopover(ev: Event) { const operatingHoursPopover = await popoverController.create({ component: OperatingHoursPopover, + componentProps: { facilityId: this.facilityId }, event: ev, showBackdrop: false }); @@ -820,6 +841,12 @@ export default defineComponent({ await popoverController.dismiss() customMappingModal.present() + }, + getOpenEndTime(startTime: any, capacity: any) { + const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); + const endTime = DateTime.fromMillis(DateTime.fromFormat(startTime, 'HH:mm:ss').toMillis() + capacity).toFormat('hh:mm a') + return `${openTime} - ${endTime}` + } }, setup() { From 2717f85a664c2135bf60d48e53e0dafbc9d2528e Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 28 Nov 2023 12:10:44 +0530 Subject: [PATCH 05/16] Implemented: remove calendar from facility feature in popover (#28) --- src/components/CustomScheduleModal.vue | 14 +++++---- src/components/OperatingHoursPopover.vue | 39 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 93fc4ec6..5d8a1c8b 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -25,7 +25,7 @@

{{ translate(day) }}

- - + - @@ -34,13 +34,13 @@

{{ translate("Open and close time") }}

- - + - - + @@ -104,7 +104,7 @@ export default defineComponent({ return { isDailyTimingsChecked: false as boolean, days: ['Time'], - selectedDay: '' + week: {} as any } }, methods: { @@ -115,8 +115,10 @@ export default defineComponent({ this.isDailyTimingsChecked = !this.isDailyTimingsChecked this.days = this.isDailyTimingsChecked ? ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] : ['Time'] }, - updateTime(ev: CustomEvent) { - console.log('Selected: ', this.selectedDay, " - ", ev.detail.value); + updateTime(ev: CustomEvent, day: any) { + if(this.week[day]) { + this.week.day = ev.detail.value + } } }, setup() { diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue index 825509f1..c59ad2c4 100644 --- a/src/components/OperatingHoursPopover.vue +++ b/src/components/OperatingHoursPopover.vue @@ -12,7 +12,7 @@ {{ translate("Add custom schedules") }} - + {{ translate("Remove schedules") }} @@ -33,8 +33,14 @@ import { } from "@ionic/vue"; import { defineComponent } from "vue"; import { translate } from "@hotwax/dxp-components"; +import { mapGetters, useStore } from "vuex"; import AddOperatingHoursModal from "@/components/AddOperatingHoursModal.vue"; import CustomScheduleModal from "@/components/CustomScheduleModal.vue"; +import { FacilityService } from "@/services/FacilityService"; +import { DateTime } from "luxon"; +import { showToast } from "@/utils"; +import logger from "@/logger"; +import { hasError } from "@/adapter"; export default defineComponent({ name: "FacilityMappingPopover", @@ -46,6 +52,11 @@ export default defineComponent({ IonListHeader }, props: ["facilityId"], + computed: { + ...mapGetters({ + facilityCalendar: 'facility/getFacilityCalendar' + }) + }, methods: { async addOperatingHours() { const addOperatingHoursModal = await modalController.create({ @@ -65,10 +76,36 @@ export default defineComponent({ }) customScheduleModal.present() + }, + async removeCalendarFromFacility() { + let resp; + try { + resp = await FacilityService.associateCalendarToFacility({ + storeId: this.facilityId, + calendarId: this.facilityCalendar.calendarId, + thruDateStr: DateTime.now().toFormat('MM/dd/yyyy'), + facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, + fromDateStr: DateTime.fromMillis(this.facilityCalendar.fromDate).toFormat('MM/dd/yyyy') + }) + + if(!hasError(resp)) { + showToast("Successfully revoked calendar associativity with the facility.") + this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) + } else { + throw resp.data; + } + } catch(err) { + showToast(translate("Failed to revoke calendar associativity with the facility.")) + logger.error(err) + } + + popoverController.dismiss() } }, setup() { + const store = useStore(); return { + store, translate }; } From f3e616d756b1b4150892a25b714e6c9eebecac47 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 28 Nov 2023 15:32:25 +0530 Subject: [PATCH 06/16] Improved: api endpoints for creating and removing calendar to facility (#28) --- src/components/AddOperatingHoursModal.vue | 12 ++++++------ src/components/CustomScheduleModal.vue | 12 ++++++------ src/components/OperatingHoursPopover.vue | 8 ++++---- src/services/FacilityService.ts | 11 ++++++++++- src/store/modules/util/actions.ts | 1 - src/views/FacilityDetails.vue | 6 +++--- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index aae13abd..3c882bbd 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -114,9 +114,10 @@ export default defineComponent({ if(this.selectedCalendarId && this.selectedCalendarId !== this.facilityCalendar.calendarId) { try { resp = await FacilityService.associateCalendarToFacility({ - storeId: this.facilityId, + facilityId: this.facilityId, calendarId: this.selectedCalendarId, - fromDateStr: DateTime.now().toFormat('MM/dd/yyyy') + fromDate: DateTime.now().toMillis(), + facilityCalendarTypeId: 'OPERATING_HOURS' }) if(!hasError(resp)) { @@ -134,12 +135,11 @@ export default defineComponent({ modalController.dismiss() }, async removeCalendarFromFacility() { - return await FacilityService.associateCalendarToFacility({ - storeId: this.facilityId, + return await FacilityService.removeFacilityCalendar({ + facilityId: this.facilityId, calendarId: this.facilityCalendar.calendarId, - thruDateStr: DateTime.now().toFormat('MM/dd/yyyy'), facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, - fromDateStr: DateTime.fromMillis(this.facilityCalendar.fromDate).toFormat('MM/dd/yyyy') + fromDate: this.facilityCalendar.fromDate }) } }, diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 5d8a1c8b..5a7c02ea 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -34,17 +34,17 @@

{{ translate("Open and close time") }}

- - + -
- - + + - - + + @@ -104,7 +104,7 @@ export default defineComponent({ return { isDailyTimingsChecked: false as boolean, days: ['Time'], - week: {} as any + week: {} as any, } }, methods: { diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue index c59ad2c4..92fc30c4 100644 --- a/src/components/OperatingHoursPopover.vue +++ b/src/components/OperatingHoursPopover.vue @@ -80,12 +80,12 @@ export default defineComponent({ async removeCalendarFromFacility() { let resp; try { - resp = await FacilityService.associateCalendarToFacility({ - storeId: this.facilityId, + resp = await FacilityService.removeFacilityCalendar({ + facilityId: this.facilityId, calendarId: this.facilityCalendar.calendarId, - thruDateStr: DateTime.now().toFormat('MM/dd/yyyy'), + // thruDate: DateTime.now().toFormat('MM/dd/yyyy'), facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, - fromDateStr: DateTime.fromMillis(this.facilityCalendar.fromDate).toFormat('MM/dd/yyyy') + fromDate: this.facilityCalendar.fromDate }) if(!hasError(resp)) { diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index 1624c4e3..383967f3 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -184,7 +184,7 @@ const addFacilityToGroup = async (payload: any): Promise => { const associateCalendarToFacility = async (payload: any): Promise => { return api({ - url: "service/storeCalendarAssocDataSetup", + url: "service/createFacilityCalendar", method: "post", data: payload }) @@ -294,6 +294,14 @@ const fetchFacilityCalendars = async (payload: any): Promise => { }) } +const removeFacilityCalendar = async (payload: any): Promise => { + return api({ + url: "service/expireFacilityCalendar", + method: "post", + data: payload + }) +} + export const FacilityService = { addFacilityToGroup, addPartyToFacility, @@ -314,6 +322,7 @@ export const FacilityService = { fetchShopifyFacilityMappings, getFacilityParties, getPartyRoleAndPartyDetails, + removeFacilityCalendar, removePartyFromFacility, updateFacility, updateFacilityIdentification, diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 154abbfa..939f1d74 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -194,7 +194,6 @@ const actions: ActionTree = { if(!hasError(resp) && resp.data.count) { calendars = resp.data.docs - dispatch('fetchCalendarWeek', {calendWeekId: calendars[0].calendarWeekId}) } else { throw resp.data } diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index a72c7a2f..44a52577 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -546,14 +546,14 @@ export default defineComponent({ try { resp = await FacilityService.associateCalendarToFacility({ - storeId: this.facilityId, + facilityId: this.facilityId, calendarId: this.selectedCalendarId, - fromDateStr: DateTime.now().toFormat('MM/dd/yyyy'), + fromDate: DateTime.now().toMillis(), + facilityCalendarTypeId: 'OPERATING_HOURS' }) if(!hasError(resp)) { showToast(translate("Successfully associated calendar to the facility.")) - await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) } else { throw resp.data From ae5ea70df942d0612918df7d264e877d48354b17 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 28 Nov 2023 19:10:50 +0530 Subject: [PATCH 07/16] Implemented: logic for custom start-end time selection (#28) --- src/components/CustomScheduleModal.vue | 73 ++++++++++++++++++++++---- src/services/FacilityService.ts | 9 ++++ src/store/modules/util/actions.ts | 1 + src/views/FacilityDetails.vue | 7 +-- 4 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 5a7c02ea..a7489ae8 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -13,7 +13,7 @@ {{ translate("Name") }} - + {{ translate("Daily timings") }} @@ -25,7 +25,13 @@

{{ translate(day) }}

- - + + {{ "Start Time" }} + + - + + {{ "End Time" }} +
@@ -34,21 +40,27 @@

{{ translate("Open and close time") }}

- - + + {{ "Start Time" }} + + - + + {{ "End Time" }} +
- - + + - - + + - + @@ -78,6 +90,11 @@ import { import { defineComponent } from "vue"; import { closeOutline, saveOutline } from "ionicons/icons"; import { translate } from '@hotwax/dxp-components' +import { FacilityService } from "@/services/FacilityService"; +import logger from "@/logger"; +import { hasError } from "@hotwax/oms-api"; +import { DateTime } from "luxon"; +import { mapGetters } from "vuex"; export default defineComponent({ name: "CustomScheduleModal", @@ -103,23 +120,57 @@ export default defineComponent({ data() { return { isDailyTimingsChecked: false as boolean, - days: ['Time'], + days: ['Daily'], week: {} as any, } }, + computed: { + ...mapGetters({ + userProfile: 'user/getUserProfile' + }) + }, methods: { closeModal() { modalController.dismiss({ dismissed: true}); }, updateDailyTimings() { this.isDailyTimingsChecked = !this.isDailyTimingsChecked - this.days = this.isDailyTimingsChecked ? ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] : ['Time'] + this.days = this.isDailyTimingsChecked ? ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] : ['Daily'] }, updateTime(ev: CustomEvent, day: any) { if(this.week[day]) { this.week.day = ev.detail.value } - } + }, + async saveCustomSchedule() { + let resp; + let payload = { + description: this.week.description + } as any + + this.days.map((day: string) => { + if(this.week[day+'StartTime']) { + payload[day+'StartTime'] = DateTime.fromISO(this.week[day+'StartTime'], {setZone: true}).toFormat('HH:mm:ss') + payload[day+'Capacity'] = this.getCapacity(this.week[day+'StartTime'], this.week[day+'EndTime']) + } + }) + + try { + resp = await FacilityService.createFacilityCalendar(payload) + + if(!hasError(resp)) { + console.log(resp); + + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } + }, + getCapacity(startTime: string, endTime: any) { + return DateTime.fromISO(endTime, {setZone: true}).toMillis() - DateTime.fromISO(startTime, {setZone: true}).toMillis() + }, }, setup() { return { diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index 383967f3..b2711dd9 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -294,6 +294,14 @@ const fetchFacilityCalendars = async (payload: any): Promise => { }) } +const createFacilityCalendar = async (payload: any): Promise => { + return api({ + url: "service/calendarDataSetup", + method: "post", + data: payload + }) +} + const removeFacilityCalendar = async (payload: any): Promise => { return api({ url: "service/expireFacilityCalendar", @@ -307,6 +315,7 @@ export const FacilityService = { addPartyToFacility, associateCalendarToFacility, createEnumeration, + createFacilityCalendar, createFacilityIdentification, createFacilityLocation, createShopifyShopLocation, diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 939f1d74..de1878fb 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -222,6 +222,7 @@ const actions: ActionTree = { if(!hasError(resp) && resp.data.count) { calendars = resp.data.docs + } else { throw resp.data } diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 44a52577..b9766ffb 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -514,7 +514,8 @@ export default defineComponent({ externalMappingTypes: 'util/getExternalMappingTypes', facilityCalendar: 'facility/getFacilityCalendar', facilityParties: 'facility/getFacilityParties', - partyRoles: 'util/getPartyRoles' + partyRoles: 'util/getPartyRoles', + userProfile: 'user/getUserProfile' }) }, props: ["facilityId"], @@ -525,7 +526,7 @@ export default defineComponent({ await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false - this.facilityCalendar + }, methods: { goToLink(link: string) { @@ -843,7 +844,7 @@ export default defineComponent({ customMappingModal.present() }, getOpenEndTime(startTime: any, capacity: any) { - const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); + const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').setZone(this.userProfile.userTimeZone).toFormat('HH:mm a'); const endTime = DateTime.fromMillis(DateTime.fromFormat(startTime, 'HH:mm:ss').toMillis() + capacity).toFormat('hh:mm a') return `${openTime} - ${endTime}` From 1e2718baeaa03da76532c3e968b1ddc915b6b299 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 11:46:15 +0530 Subject: [PATCH 08/16] Implemented: create customSchedule calendar functionality, logic for fetching calendar timings with calendar list (#28) --- src/components/AddOperatingHoursModal.vue | 59 ++++++++++++++++++- src/components/CustomScheduleModal.vue | 70 +++++++++++++++++----- src/components/OperatingHoursPopover.vue | 11 +++- src/store/modules/util/actions.ts | 72 +++++++++++------------ src/views/FacilityDetails.vue | 8 +-- 5 files changed, 159 insertions(+), 61 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index 3c882bbd..0221fe1b 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -19,7 +19,54 @@ {{ calendar.description }} -
First Content
+
+ + + + +

{{ translate("Monday") }}

+
+ {{ calendar.mondayStartTime ? getOpenEndTime(calendar.mondayStartTime, calendar.mondayCapacity) : '-' }} +
+ + +

{{ translate("Tuesday") }}

+
+ {{ calendar.tuesdayStartTime ? getOpenEndTime(calendar.tuesdayStartTime, calendar.tuesdayCapacity) : '-' }} +
+ + +

{{ translate("Wednesday") }}

+
+ {{ calendar.wednesdayStartTime ? getOpenEndTime(calendar.wednesdayStartTime, calendar.wednesdayCapacity) : '-' }} +
+ + +

{{ translate("Thursday") }}

+
+ {{ calendar.thursdayStartTime ? getOpenEndTime(calendar.thursdayStartTime, calendar.thursdayCapacity) : '-' }} +
+ + +

{{ translate("Friday") }}

+
+ {{ calendar.fridayStartTime ? getOpenEndTime(calendar.fridayStartTime, calendar.fridayCapacity) : '-' }} +
+ + +

{{ translate("Saturday") }}

+
+ {{ calendar.saturdayStartTime ? getOpenEndTime(calendar.saturdayStartTime, calendar.saturdayCapacity) : '-' }} +
+ + +

{{ translate("Sunday") }}

+
+ {{ calendar.sundayStartTime ? getOpenEndTime(calendar.sundayStartTime, calendar.sundayCapacity) : '-' }} +
+
+
+
@@ -82,7 +129,7 @@ export default defineComponent({ }, data() { return { - selectedCalendarId: 'DEFAULT' + selectedCalendarId: '' as any } }, props: ["facilityId"], @@ -92,6 +139,9 @@ export default defineComponent({ facilityCalendar: 'facility/getFacilityCalendar' }) }, + beforeMount() { + this.selectedCalendarId = this.facilityCalendar.calendarId + }, methods: { closeModal() { modalController.dismiss({ dismissed: true}); @@ -141,6 +191,11 @@ export default defineComponent({ facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, fromDate: this.facilityCalendar.fromDate }) + }, + getOpenEndTime(startTime: any, capacity: any) { + const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); + const endTime = DateTime.fromMillis(DateTime.fromFormat(startTime, 'HH:mm:ss').toMillis() + capacity).toFormat('hh:mm a') + return `${openTime} - ${endTime}` } }, setup() { diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index a7489ae8..b0370a46 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -94,7 +94,8 @@ import { FacilityService } from "@/services/FacilityService"; import logger from "@/logger"; import { hasError } from "@hotwax/oms-api"; import { DateTime } from "luxon"; -import { mapGetters } from "vuex"; +import { mapGetters, useStore } from "vuex"; +import { showToast } from "@/utils"; export default defineComponent({ name: "CustomScheduleModal", @@ -124,6 +125,7 @@ export default defineComponent({ week: {} as any, } }, + props: ['facilityId'], computed: { ...mapGetters({ userProfile: 'user/getUserProfile' @@ -144,38 +146,78 @@ export default defineComponent({ }, async saveCustomSchedule() { let resp; - let payload = { - description: this.week.description - } as any + let calendarId; + let payload = {} as any - this.days.map((day: string) => { - if(this.week[day+'StartTime']) { - payload[day+'StartTime'] = DateTime.fromISO(this.week[day+'StartTime'], {setZone: true}).toFormat('HH:mm:ss') - payload[day+'Capacity'] = this.getCapacity(this.week[day+'StartTime'], this.week[day+'EndTime']) + if(this.days.length === 1) { + const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] + const dailyStartTime = DateTime.fromISO(this.week['DailyStartTime'], {setZone: true}).toFormat('HH:mm:ss') + const dailyCapacity = this.getCapacity(this.week['DailyStartTime'], this.week['DailyEndTime']) + if(dailyStartTime && dailyCapacity) { + days.map((day: string) => { + payload[day+'StartTime'] = dailyStartTime + payload[day+'Capacity'] = dailyCapacity + }) } - }) + } else { + this.days.map((day: string) => { + if(this.week[day+'StartTime'] && this.week[day+'EndTime']) { + payload[day+'StartTime'] = DateTime.fromISO(this.week[day+'StartTime'], {setZone: true}).toFormat('HH:mm:ss') + payload[day+'Capacity'] = this.getCapacity(this.week[day+'StartTime'], this.week[day+'EndTime']) + } + }) + } try { - resp = await FacilityService.createFacilityCalendar(payload) + resp = await FacilityService.createFacilityCalendar({ ...payload, description: this.week.description}) + if(!hasError(resp)) { + calendarId = resp.data.calendarId + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } + + try { + resp = await FacilityService.associateCalendarToFacility({ + facilityId: this.facilityId, + calendarId: 10031, + fromDate: DateTime.now().toMillis(), + facilityCalendarTypeId: 'OPERATING_HOURS' + }) if(!hasError(resp)) { - console.log(resp); - + showToast(translate("Successfully created and associated calendar to the facility.")) + await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) + await this.store.dispatch('util/fetchUtilCalendars', { facilityId: this.facilityId }) + modalController.dismiss() } else { throw resp.data } } catch(err) { + showToast(translate("Failed to create or associate calendar to the facility.")) logger.error(err) } }, - getCapacity(startTime: string, endTime: any) { - return DateTime.fromISO(endTime, {setZone: true}).toMillis() - DateTime.fromISO(startTime, {setZone: true}).toMillis() + getCapacity(startTime: any, endTime: any) { + endTime = DateTime.fromISO(endTime, {setZone: true}).toMillis() + startTime = DateTime.fromISO(startTime, {setZone: true}).toMillis() + + if(endTime <= startTime) { + return null; + } + + return endTime - startTime }, }, setup() { + const store = useStore(); + return { closeOutline, saveOutline, + store, translate }; }, diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue index 92fc30c4..71aa59d8 100644 --- a/src/components/OperatingHoursPopover.vue +++ b/src/components/OperatingHoursPopover.vue @@ -67,14 +67,19 @@ export default defineComponent({ addOperatingHoursModal.onDidDismiss().then(() => { popoverController.dismiss() }) - + addOperatingHoursModal.present() }, async addCustomSchedule() { const customScheduleModal = await modalController.create({ - component: CustomScheduleModal + component: CustomScheduleModal, + componentProps: { facilityId: this.facilityId } + }) + + customScheduleModal.onDidDismiss().then(() => { + popoverController.dismiss() }) - + customScheduleModal.present() }, async removeCalendarFromFacility() { diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index de1878fb..3a033c6b 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -179,57 +179,53 @@ const actions: ActionTree = { }, async fetchUtilCalendars({ commit, dispatch }, payload) { - let calendars = [] - const params = { - inputFields: { - facilityId: payload.facilityId - }, - entityName: "TechDataCalendar", - viewSize: 100, - noConditionFind: 'Y' - } + let calendars = [] as any + let calendarWeekTimings = [] as any + let resp; try { - const resp = await UtilService.fetchCalendars(params) + resp = await UtilService.fetchCalendars({ + inputFields: { + facilityId: payload.facilityId + }, + entityName: "TechDataCalendar", + fieldList: ['calendarId', 'calendarWeekId', 'description'], + viewSize: 100, + noConditionFind: 'Y' + }) if(!hasError(resp) && resp.data.count) { calendars = resp.data.docs - } else { - throw resp.data - } - } catch(err) { - showToast(translate("Something went wrong")) - logger.error('Failed to fetch facility calendars', err) - } - - commit(types.UTIL_CALENDARS_UPDATED, calendars) - }, - - async fetchCalendarWeek({ commit }, payload) { - let calendars = [] - - const params = { - inputFields: { - calendarWeekId: payload.calendarWeekId - }, - entityName: "TechDataCalendarWeek", - viewSize: 100, - noConditionFind: 'Y' - } - try { - const resp = await UtilService.fetchCalendarWeek(params) - - if(!hasError(resp) && resp.data.count) { - calendars = resp.data.docs + resp = await UtilService.fetchCalendarWeek({ + inputFields: { + calendarWeekId: payload.calendarWeekId + }, + entityName: "TechDataCalendarWeek", + fieldList: ['calendarWeekId', 'mondayStartTime', 'mondayCapacity', 'tuesdayStartTime', 'tuesdayCapacity', 'wednesdayStartTime', 'wednesdayCapacity', 'thursdayStartTime', 'thursdayCapacity', 'fridayStartTime', 'fridayCapacity', 'saturdayStartTime', 'saturdayCapacity', 'sundayStartTime', 'sundayCapacity'], + viewSize: 100, + noConditionFind: 'Y' + }) + if(!hasError(resp) && resp.data.count) { + calendarWeekTimings = resp.data.docs + + calendars = calendars.map((calendar: any) => ({ + ...calendar, + ...calendarWeekTimings.find((calendarWeekTime: any) => calendarWeekTime.calendarWeekId === calendar.calendarWeekId) + })); + } else { + throw resp.data + } } else { throw resp.data } } catch(err) { - showToast(translate("Something went wrong")) logger.error('Failed to fetch facility calendars', err) } + + + commit(types.UTIL_CALENDARS_UPDATED, calendars) }, clearUtilState({ commit }) { diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index b9766ffb..a17737e1 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -76,7 +76,7 @@
- + {{ calendar.description }} @@ -573,7 +573,8 @@ export default defineComponent({ }, async addCustomSchedule() { const customScheduleModal = await modalController.create({ - component: CustomScheduleModal + component: CustomScheduleModal, + componentProps: { facilityId: this.facilityId } }) customScheduleModal.present() @@ -844,10 +845,9 @@ export default defineComponent({ customMappingModal.present() }, getOpenEndTime(startTime: any, capacity: any) { - const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').setZone(this.userProfile.userTimeZone).toFormat('HH:mm a'); + const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); const endTime = DateTime.fromMillis(DateTime.fromFormat(startTime, 'HH:mm:ss').toMillis() + capacity).toFormat('hh:mm a') return `${openTime} - ${endTime}` - } }, setup() { From 7d412f60d8ba0f5267a665485527a5f97705c35c Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 12:17:06 +0530 Subject: [PATCH 09/16] Improved: code for adding translation to static text, properly imported and registered ion-components (#28) --- src/components/AddOperatingHoursModal.vue | 4 ++++ src/components/CustomScheduleModal.vue | 18 +++++++++++++----- src/locales/en.json | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index 0221fe1b..ea838564 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -85,6 +85,7 @@ import { IonAccordionGroup, IonButton, IonButtons, + IonCard, IonContent, IonFab, IonFabButton, @@ -92,6 +93,7 @@ import { IonIcon, IonItem, IonLabel, + IonList, IonRadio, IonRadioGroup, IonTitle, @@ -115,6 +117,7 @@ export default defineComponent({ IonAccordionGroup, IonButton, IonButtons, + IonCard, IonContent, IonFab, IonFabButton, @@ -122,6 +125,7 @@ export default defineComponent({ IonIcon, IonItem, IonLabel, + IonList, IonRadio, IonRadioGroup, IonTitle, diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index b0370a46..5ac26066 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -23,14 +23,18 @@ -

{{ translate(day) }}

+

{{ translate(day.charAt(0).toUpperCase() + day.slice(1)) }}

- {{ "Start Time" }} + +

{{ translate("Start Time") }}

+
- - {{ "End Time" }} + +

{{ translate("End Time") }}

+
@@ -41,11 +45,15 @@

{{ translate("Open and close time") }}

- {{ "Start Time" }} + +

{{ translate("Start Time") }}

+
- - {{ "End Time" }} + +

{{ translate("End Time") }}

+
diff --git a/src/locales/en.json b/src/locales/en.json index eb73c425..18c9c7e7 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -43,6 +43,7 @@ "Filters": "Filters", "Edit": "Edit", "Edit location": "Edit location", + "End Time": "End Time", "External mapping created successfully": "External mapping created successfully", "External mapping updated successfully": "External mapping updated successfully", "External mappings": "External mappings", @@ -173,6 +174,7 @@ "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.", "Staff": "Staff", + "Start Time": "Start Time", "State": "State", "store name": "store name", "Successfully associated calendar to the facility.": "Successfully associated calendar to the facility.", From c549503f5790092482891f152f57efd3a023a4e6 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 14:31:45 +0530 Subject: [PATCH 10/16] Improved: api logic, syntax, and disabled conditions in favbutton (#28) --- src/components/AddOperatingHoursModal.vue | 21 ++++----- src/components/CustomScheduleModal.vue | 56 +++++++++-------------- src/components/OperatingHoursPopover.vue | 2 - src/locales/en.json | 1 + src/services/FacilityService.ts | 4 +- src/services/UtilService.ts | 4 +- src/store/modules/facility/actions.ts | 4 +- src/store/modules/util/actions.ts | 5 +- src/views/FacilityDetails.vue | 16 +++---- 9 files changed, 46 insertions(+), 67 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index ea838564..92aad448 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -13,7 +13,7 @@ - + {{ calendar.description }} @@ -73,7 +73,7 @@ - + @@ -153,7 +153,12 @@ export default defineComponent({ async addOperatingHours() { let resp; try { - resp = await this.removeCalendarFromFacility() + resp = await FacilityService.removeFacilityCalendar({ + facilityId: this.facilityId, + calendarId: this.facilityCalendar.calendarId, + facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, + fromDate: this.facilityCalendar.fromDate + }) if(hasError(resp)) { throw resp.data; @@ -165,7 +170,7 @@ export default defineComponent({ return; } - if(this.selectedCalendarId && this.selectedCalendarId !== this.facilityCalendar.calendarId) { + if(this.selectedCalendarId) { try { resp = await FacilityService.associateCalendarToFacility({ facilityId: this.facilityId, @@ -188,14 +193,6 @@ export default defineComponent({ this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) modalController.dismiss() }, - async removeCalendarFromFacility() { - return await FacilityService.removeFacilityCalendar({ - facilityId: this.facilityId, - calendarId: this.facilityCalendar.calendarId, - facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, - fromDate: this.facilityCalendar.fromDate - }) - }, getOpenEndTime(startTime: any, capacity: any) { const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); const endTime = DateTime.fromMillis(DateTime.fromFormat(startTime, 'HH:mm:ss').toMillis() + capacity).toFormat('hh:mm a') diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 5ac26066..b9f50f47 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -17,7 +17,7 @@ {{ translate("Daily timings") }} - + @@ -45,13 +45,13 @@

{{ translate("Open and close time") }}

- +

{{ translate("Start Time") }}

- - +

{{ translate("End Time") }}

@@ -60,11 +60,11 @@ - + - + @@ -102,7 +102,7 @@ import { FacilityService } from "@/services/FacilityService"; import logger from "@/logger"; import { hasError } from "@hotwax/oms-api"; import { DateTime } from "luxon"; -import { mapGetters, useStore } from "vuex"; +import { useStore } from "vuex"; import { showToast } from "@/utils"; export default defineComponent({ @@ -134,11 +134,6 @@ export default defineComponent({ } }, props: ['facilityId'], - computed: { - ...mapGetters({ - userProfile: 'user/getUserProfile' - }) - }, methods: { closeModal() { modalController.dismiss({ dismissed: true}); @@ -147,11 +142,6 @@ export default defineComponent({ this.isDailyTimingsChecked = !this.isDailyTimingsChecked this.days = this.isDailyTimingsChecked ? ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] : ['Daily'] }, - updateTime(ev: CustomEvent, day: any) { - if(this.week[day]) { - this.week.day = ev.detail.value - } - }, async saveCustomSchedule() { let resp; let calendarId; @@ -180,26 +170,22 @@ export default defineComponent({ resp = await FacilityService.createFacilityCalendar({ ...payload, description: this.week.description}) if(!hasError(resp)) { calendarId = resp.data.calendarId - } else { - throw resp.data - } - } catch(err) { - logger.error(err) - } - - try { - resp = await FacilityService.associateCalendarToFacility({ - facilityId: this.facilityId, - calendarId: 10031, - fromDate: DateTime.now().toMillis(), - facilityCalendarTypeId: 'OPERATING_HOURS' - }) - if(!hasError(resp)) { - showToast(translate("Successfully created and associated calendar to the facility.")) - await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) - await this.store.dispatch('util/fetchUtilCalendars', { facilityId: this.facilityId }) - modalController.dismiss() + resp = await FacilityService.associateCalendarToFacility({ + facilityId: this.facilityId, + calendarId: 10031, + fromDate: DateTime.now().toMillis(), + facilityCalendarTypeId: 'OPERATING_HOURS' + }) + + if(!hasError(resp)) { + showToast(translate("Successfully created and associated calendar to the facility.")) + await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) + await this.store.dispatch('util/fetchCalendars', { facilityId: this.facilityId }) + modalController.dismiss() + } else { + throw resp.data + } } else { throw resp.data } diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue index 71aa59d8..a9a55c79 100644 --- a/src/components/OperatingHoursPopover.vue +++ b/src/components/OperatingHoursPopover.vue @@ -37,7 +37,6 @@ import { mapGetters, useStore } from "vuex"; import AddOperatingHoursModal from "@/components/AddOperatingHoursModal.vue"; import CustomScheduleModal from "@/components/CustomScheduleModal.vue"; import { FacilityService } from "@/services/FacilityService"; -import { DateTime } from "luxon"; import { showToast } from "@/utils"; import logger from "@/logger"; import { hasError } from "@/adapter"; @@ -88,7 +87,6 @@ export default defineComponent({ resp = await FacilityService.removeFacilityCalendar({ facilityId: this.facilityId, calendarId: this.facilityCalendar.calendarId, - // thruDate: DateTime.now().toFormat('MM/dd/yyyy'), facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, fromDate: this.facilityCalendar.fromDate }) diff --git a/src/locales/en.json b/src/locales/en.json index dcae1d03..7f9fba87 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -153,6 +153,7 @@ "Order fulfillment capacity": "Order fulfillment capacity", "orders allocated today": "{orderCount} orders allocated today", "orders in fulfillment queue": "{orderCount} orders in fulfillment queue", + "Others": "Others", "Parking": "Parking", "Party Id": "Party Id", "Party successfully removed from facility.": "Party successfully removed from facility.", diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index 4a644950..23f1da34 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -373,7 +373,7 @@ const createEnumeration = async (payload: any): Promise => { }) } -const fetchFacilityCalendars = async (payload: any): Promise => { +const fetchFacilityCalendar = async (payload: any): Promise => { return api({ url: "performFind", method: "post", @@ -417,7 +417,7 @@ export const FacilityService = { deleteShopifyShopLocation, fetchFacilities, fetchFacilitiesOrderCount, - fetchFacilityCalendars, + fetchFacilityCalendar, fetchFacilityGroupInformation, fetchFacilityMappings, fetchFacilityOrderCounts, diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index c819fa42..2aa1725a 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -80,7 +80,7 @@ const fetchCalendars = async (payload: any): Promise => { }) } -const fetchCalendarWeek = async (payload: any): Promise => { +const fetchCalendarWeekTimings = async (payload: any): Promise => { return api({ url: "performFind", method: "post", @@ -90,7 +90,7 @@ const fetchCalendarWeek = async (payload: any): Promise => { export const UtilService = { fetchCalendars, - fetchCalendarWeek, + fetchCalendarWeekTimings, fetchCountries, fetchExternalMappingTypes, fetchFacilityTypes, diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index b0022279..e614c4be 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -294,10 +294,10 @@ const actions: ActionTree = { }, entityName: "StoreOperatingHours", filterByDate: 'Y', - // viewSize: 1 + viewSize: 1 } - resp = await FacilityService.fetchFacilityCalendars(params) + resp = await FacilityService.fetchFacilityCalendar(params) if(!hasError(resp) && resp.data.count) { facilityCalendar = resp.data.docs[0] diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index b45136de..bf7455ef 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -178,7 +178,7 @@ const actions: ActionTree = { commit(types.UTIL_EXTERNAL_MAPPING_TYPES_UPDATED, externalMappingTypes) }, - async fetchUtilCalendars({ commit, dispatch }, payload) { + async fetchCalendars({ commit, dispatch }, payload) { let calendars = [] as any let calendarWeekTimings = [] as any let resp; @@ -197,7 +197,7 @@ const actions: ActionTree = { if(!hasError(resp) && resp.data.count) { calendars = resp.data.docs - resp = await UtilService.fetchCalendarWeek({ + resp = await UtilService.fetchCalendarWeekTimings({ inputFields: { calendarWeekId: payload.calendarWeekId }, @@ -224,7 +224,6 @@ const actions: ActionTree = { logger.error('Failed to fetch facility calendars', err) } - commit(types.UTIL_CALENDARS_UPDATED, calendars) }, diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index b47244f3..8edd4196 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -46,10 +46,10 @@ {{ 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("These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.") }} + {{ translate("Latitude") }}

{{ postalAddress.latitude }}

@@ -67,7 +67,6 @@
-
@@ -86,7 +85,7 @@ - {{ calendars.length - 3 }} {{ "Others" }} + {{ calendars.length - 3 }} {{ translate("Others") }} @@ -495,7 +494,7 @@ export default defineComponent({ return { isLoading: true, // shows whether the facility information fetching is completed or not segment: 'external-mappings', - defaultDaysToShip: '', // not assinging 0 by default as it will convey the user that the facility can ship same day(as the value is 0), but actually defaultDays are not setup on the facility + defaultDaysToShip: '', // not assinging 0 by default as it will convey the user that the facility can ship same day, but actually defaultDays are not setup on the facility primaryMember: {} as any, isCalendarFound: true, selectedCalendarId: 'DEFAULT' @@ -520,7 +519,7 @@ export default defineComponent({ props: ["facilityId"], async ionViewWillEnter() { await Promise.all([this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId }), this.store.dispatch('util/fetchExternalMappingTypes'), this.store.dispatch('util/fetchLocationTypes'), this.store.dispatch('util/fetchPartyRoles')]) - await Promise.all([this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityParties', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.facilityId, facilityIdenTypeIds: Object.keys(this.externalMappingTypes)}), this.store.dispatch('facility/fetchShopifyFacilityMappings', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId }), this.store.dispatch('util/fetchProductStores'), this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }), this.store.dispatch('util/fetchUtilCalendars', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId })]) + await Promise.all([this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityParties', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.facilityId, facilityIdenTypeIds: Object.keys(this.externalMappingTypes)}), this.store.dispatch('facility/fetchShopifyFacilityMappings', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId }), this.store.dispatch('util/fetchProductStores'), this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }), this.store.dispatch('util/fetchCalendars', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId })]) this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false this.fetchFacilityPrimaryMember() @@ -781,9 +780,8 @@ export default defineComponent({ } }, async revokePrimaryStatusFromStore() { - let resp; try { - resp = await FacilityService.updateFacilityToGroup({ + const resp = await FacilityService.updateFacilityToGroup({ "facilityId": this.facilityId, "facilityGroupId": this.primaryMember.facilityGroupId, "fromDate": this.primaryMember.fromDate, From dcaf2ba0d84d68307297f0f583520fdecc9c026f Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 14:34:43 +0530 Subject: [PATCH 11/16] Improved: calendarId in payload from api resp (#28) --- src/components/CustomScheduleModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index b9f50f47..8b05bf28 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -173,7 +173,7 @@ export default defineComponent({ resp = await FacilityService.associateCalendarToFacility({ facilityId: this.facilityId, - calendarId: 10031, + calendarId: calendarId, fromDate: DateTime.now().toMillis(), facilityCalendarTypeId: 'OPERATING_HOURS' }) From 7544cda8e48b2975f42b3a145cdd429ba33ca7b2 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 15:08:48 +0530 Subject: [PATCH 12/16] Improved: logic for addOperating Hours updation handling (#28) --- src/components/AddOperatingHoursModal.vue | 72 +++++++++++++++-------- src/views/FacilityDetails.vue | 3 +- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue index 92aad448..dad87292 100644 --- a/src/components/AddOperatingHoursModal.vue +++ b/src/components/AddOperatingHoursModal.vue @@ -26,43 +26,43 @@

{{ translate("Monday") }}

- {{ calendar.mondayStartTime ? getOpenEndTime(calendar.mondayStartTime, calendar.mondayCapacity) : '-' }} + {{ calendar.mondayStartTime ? getStartAndEndTime(calendar.mondayStartTime, calendar.mondayCapacity) : '-' }}

{{ translate("Tuesday") }}

- {{ calendar.tuesdayStartTime ? getOpenEndTime(calendar.tuesdayStartTime, calendar.tuesdayCapacity) : '-' }} + {{ calendar.tuesdayStartTime ? getStartAndEndTime(calendar.tuesdayStartTime, calendar.tuesdayCapacity) : '-' }}

{{ translate("Wednesday") }}

- {{ calendar.wednesdayStartTime ? getOpenEndTime(calendar.wednesdayStartTime, calendar.wednesdayCapacity) : '-' }} + {{ calendar.wednesdayStartTime ? getStartAndEndTime(calendar.wednesdayStartTime, calendar.wednesdayCapacity) : '-' }}

{{ translate("Thursday") }}

- {{ calendar.thursdayStartTime ? getOpenEndTime(calendar.thursdayStartTime, calendar.thursdayCapacity) : '-' }} + {{ calendar.thursdayStartTime ? getStartAndEndTime(calendar.thursdayStartTime, calendar.thursdayCapacity) : '-' }}

{{ translate("Friday") }}

- {{ calendar.fridayStartTime ? getOpenEndTime(calendar.fridayStartTime, calendar.fridayCapacity) : '-' }} + {{ calendar.fridayStartTime ? getStartAndEndTime(calendar.fridayStartTime, calendar.fridayCapacity) : '-' }}

{{ translate("Saturday") }}

- {{ calendar.saturdayStartTime ? getOpenEndTime(calendar.saturdayStartTime, calendar.saturdayCapacity) : '-' }} + {{ calendar.saturdayStartTime ? getStartAndEndTime(calendar.saturdayStartTime, calendar.saturdayCapacity) : '-' }}

{{ translate("Sunday") }}

- {{ calendar.sundayStartTime ? getOpenEndTime(calendar.sundayStartTime, calendar.sundayCapacity) : '-' }} + {{ calendar.sundayStartTime ? getStartAndEndTime(calendar.sundayStartTime, calendar.sundayCapacity) : '-' }}
@@ -73,7 +73,7 @@ - + @@ -150,28 +150,46 @@ export default defineComponent({ closeModal() { modalController.dismiss({ dismissed: true}); }, + saveOperatingHours() { + if(this.facilityCalendar?.calendarId) { + this.updateOperatingHours() + } else { + this.addOperatingHours() + } + }, async addOperatingHours() { - let resp; try { - resp = await FacilityService.removeFacilityCalendar({ + const resp = await FacilityService.associateCalendarToFacility({ facilityId: this.facilityId, - calendarId: this.facilityCalendar.calendarId, - facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, - fromDate: this.facilityCalendar.fromDate + calendarId: this.selectedCalendarId, + fromDate: DateTime.now().toMillis(), + facilityCalendarTypeId: 'OPERATING_HOURS' }) - if(hasError(resp)) { - throw resp.data; + if(!hasError(resp)) { + showToast(translate("Successfully associated calendar to the facility.")) + await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) + } else { + throw resp.data } } catch(err) { showToast(translate("Failed to associate calendar to the facility.")) logger.error(err) - modalController.dismiss() - return; } - if(this.selectedCalendarId) { - try { + modalController.dismiss() + }, + async updateOperatingHours() { + let resp; + try { + resp = await FacilityService.removeFacilityCalendar({ + facilityId: this.facilityId, + calendarId: this.facilityCalendar.calendarId, + facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, + fromDate: this.facilityCalendar.fromDate + }) + + if(!hasError(resp)) { resp = await FacilityService.associateCalendarToFacility({ facilityId: this.facilityId, calendarId: this.selectedCalendarId, @@ -181,22 +199,24 @@ export default defineComponent({ if(!hasError(resp)) { showToast(translate("Successfully associated calendar to the facility.")) + await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) } else { throw resp.data } - } catch(err) { - showToast(translate("Failed to associate calendar to the facility.")) - logger.error(err) + } else { + throw resp.data; } + } catch(err) { + showToast(translate("Failed to associate calendar to the facility.")) + logger.error(err) } - this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) modalController.dismiss() }, - getOpenEndTime(startTime: any, capacity: any) { - const openTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); + getStartAndEndTime(startTime: any, capacity: any) { + const formatedStartTime = DateTime.fromFormat(startTime, 'HH:mm:ss').toFormat('HH:mm a'); const endTime = DateTime.fromMillis(DateTime.fromFormat(startTime, 'HH:mm:ss').toMillis() + capacity).toFormat('hh:mm a') - return `${openTime} - ${endTime}` + return `${formatedStartTime} - ${endTime}` } }, setup() { diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 8edd4196..3e684880 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -659,7 +659,8 @@ export default defineComponent({ }, async addOperatingHours() { const addOperatingHoursModal = await modalController.create({ - component: AddOperatingHoursModal + component: AddOperatingHoursModal, + componentProps: { facilityId: this.facilityId } }) addOperatingHoursModal.present() From 54bb446eeb7029da6116a82f7d84b0da064fcec5 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 16:08:36 +0530 Subject: [PATCH 13/16] Improved: added flow to remove already associated calendar before creating custom (#28) --- src/components/CustomScheduleModal.vue | 84 +++++++++++++++++------- src/components/OperatingHoursPopover.vue | 8 +-- src/locales/en.json | 2 + src/store/modules/util/actions.ts | 2 +- 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 8b05bf28..81d26367 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -13,7 +13,7 @@ {{ translate("Name") }} - + {{ translate("Daily timings") }} @@ -26,13 +26,13 @@

{{ translate(day.charAt(0).toUpperCase() + day.slice(1)) }}

- +

{{ translate("Start Time") }}

- - +

{{ translate("End Time") }}

@@ -45,13 +45,13 @@

{{ translate("Open and close time") }}

- +

{{ translate("Start Time") }}

- - +

{{ translate("End Time") }}

@@ -60,15 +60,15 @@
- + - + - + @@ -102,7 +102,7 @@ import { FacilityService } from "@/services/FacilityService"; import logger from "@/logger"; import { hasError } from "@hotwax/oms-api"; import { DateTime } from "luxon"; -import { useStore } from "vuex"; +import { mapGetters, useStore } from "vuex"; import { showToast } from "@/utils"; export default defineComponent({ @@ -130,10 +130,15 @@ export default defineComponent({ return { isDailyTimingsChecked: false as boolean, days: ['Daily'], - week: {} as any, + selectedTimesForWeek: {} as any, } }, props: ['facilityId'], + computed: { + ...mapGetters({ + facilityCalendar: 'facility/getFacilityCalendar' + }) + }, methods: { closeModal() { modalController.dismiss({ dismissed: true}); @@ -142,15 +147,37 @@ export default defineComponent({ this.isDailyTimingsChecked = !this.isDailyTimingsChecked this.days = this.isDailyTimingsChecked ? ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] : ['Daily'] }, - async saveCustomSchedule() { + async saveCustomSchedule() { + if(this.facilityCalendar?.calendarId) { + try { + const resp = await FacilityService.removeFacilityCalendar({ + facilityId: this.facilityId, + calendarId: this.facilityCalendar.calendarId, + facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, + fromDate: this.facilityCalendar.fromDate + }) + + if(!hasError(resp)) { + await this.addCustomSchedule() + } else { + throw resp.data; + } + } catch(err) { + logger.error(err) + } + } else { + await this.addCustomSchedule() + } + }, + async addCustomSchedule() { let resp; let calendarId; - let payload = {} as any - + let payload = {} as any + if(this.days.length === 1) { const days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] - const dailyStartTime = DateTime.fromISO(this.week['DailyStartTime'], {setZone: true}).toFormat('HH:mm:ss') - const dailyCapacity = this.getCapacity(this.week['DailyStartTime'], this.week['DailyEndTime']) + const dailyStartTime = DateTime.fromISO(this.selectedTimesForWeek['DailyStartTime'], {setZone: true}).toFormat('HH:mm:ss') + const dailyCapacity = this.getCapacity(this.selectedTimesForWeek['DailyStartTime'], this.selectedTimesForWeek['DailyEndTime']) if(dailyStartTime && dailyCapacity) { days.map((day: string) => { payload[day+'StartTime'] = dailyStartTime @@ -159,15 +186,22 @@ export default defineComponent({ } } else { this.days.map((day: string) => { - if(this.week[day+'StartTime'] && this.week[day+'EndTime']) { - payload[day+'StartTime'] = DateTime.fromISO(this.week[day+'StartTime'], {setZone: true}).toFormat('HH:mm:ss') - payload[day+'Capacity'] = this.getCapacity(this.week[day+'StartTime'], this.week[day+'EndTime']) + const startTime = this.selectedTimesForWeek[day+'StartTime'] + const capacity = this.getCapacity(this.selectedTimesForWeek[day+'StartTime'], this.selectedTimesForWeek[day+'EndTime']) + if(startTime && capacity) { + payload[day+'StartTime'] = startTime + payload[day+'Capacity'] = capacity } }) } + if(!Object.keys(payload).length) { + showToast(translate("Please check all the selected start time and end time entries.")) + return; + } + try { - resp = await FacilityService.createFacilityCalendar({ ...payload, description: this.week.description}) + resp = await FacilityService.createFacilityCalendar({ ...payload, description: this.selectedTimesForWeek.description}) if(!hasError(resp)) { calendarId = resp.data.calendarId @@ -190,20 +224,20 @@ export default defineComponent({ throw resp.data } } catch(err) { - showToast(translate("Failed to create or associate calendar to the facility.")) + showToast(translate("Failed to create calendar to the facility.")) logger.error(err) } }, getCapacity(startTime: any, endTime: any) { - endTime = DateTime.fromISO(endTime, {setZone: true}).toMillis() - startTime = DateTime.fromISO(startTime, {setZone: true}).toMillis() + const formatedStartTime = DateTime.fromISO(startTime, {setZone: true}).toMillis() + const formatedEndTime = DateTime.fromISO(endTime, {setZone: true}).toMillis() - if(endTime <= startTime) { + if(formatedEndTime <= formatedStartTime) { return null; } - return endTime - startTime - }, + return formatedEndTime - formatedStartTime + } }, setup() { const store = useStore(); diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue index a9a55c79..354cb183 100644 --- a/src/components/OperatingHoursPopover.vue +++ b/src/components/OperatingHoursPopover.vue @@ -85,10 +85,10 @@ export default defineComponent({ let resp; try { resp = await FacilityService.removeFacilityCalendar({ - facilityId: this.facilityId, - calendarId: this.facilityCalendar.calendarId, - facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, - fromDate: this.facilityCalendar.fromDate + facilityId: this.facilityId, + calendarId: this.facilityCalendar.calendarId, + facilityCalendarTypeId: this.facilityCalendar.facilityCalendarTypeId, + fromDate: this.facilityCalendar.fromDate }) if(!hasError(resp)) { diff --git a/src/locales/en.json b/src/locales/en.json index 7f9fba87..c54c0201 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -71,6 +71,7 @@ "Facility name is required.": "Facility name is required.", "Facility Management": "Facility Management", "Failed to add some product stores to the facility.": "Failed to add some product stores to the facility.", + "Failed to create calendar to the facility.": "Failed to create calendar to the facility.", "Failed to create external mapping": "Failed to create external mapping", "Failed to create facility.": "Failed to create facility.", "Failed to create facility address.": "Failed to create facility address.", @@ -157,6 +158,7 @@ "Parking": "Parking", "Party Id": "Party Id", "Party successfully removed from facility.": "Party successfully removed from facility.", + "Please check all the selected start time and end time entries.": "Please check all the selected start time and end time entries.", "Please update atleast one party role.": "Please update atleast one party role.", "Password": "Password", "party id": "party id", diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index bf7455ef..eaec7d3b 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -178,7 +178,7 @@ const actions: ActionTree = { commit(types.UTIL_EXTERNAL_MAPPING_TYPES_UPDATED, externalMappingTypes) }, - async fetchCalendars({ commit, dispatch }, payload) { + async fetchCalendars({ commit }, payload) { let calendars = [] as any let calendarWeekTimings = [] as any let resp; From 72fdd208205cbfe8da13e0ddaaf9e99afab7c221 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 16:33:00 +0530 Subject: [PATCH 14/16] Improved: code of custom schedule modal to only save if calendar name is filled (#28) --- src/components/CustomScheduleModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 81d26367..6804fd12 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -68,7 +68,7 @@ - + From 19ce20924bf4d38fac08b91d502466ac6b3413d3 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 17:05:16 +0530 Subject: [PATCH 15/16] Improved: checked attribute in ion-toggle (#28) --- src/components/CustomScheduleModal.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 6804fd12..394a662f 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -17,7 +17,8 @@ {{ translate("Daily timings") }} - + {{ isDailyTimingsChecked }} + From 506422a3e29e57852cb3bd5b3cb52af67e41b608 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 29 Nov 2023 18:06:25 +0530 Subject: [PATCH 16/16] Improved: payload for fetching calendars, and removed unused imports (#28) --- src/components/CustomScheduleModal.vue | 2 +- src/store/modules/util/actions.ts | 10 +--------- src/views/FacilityDetails.vue | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue index 394a662f..203e420f 100644 --- a/src/components/CustomScheduleModal.vue +++ b/src/components/CustomScheduleModal.vue @@ -216,7 +216,7 @@ export default defineComponent({ if(!hasError(resp)) { showToast(translate("Successfully created and associated calendar to the facility.")) await this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }) - await this.store.dispatch('util/fetchCalendars', { facilityId: this.facilityId }) + await this.store.dispatch('util/fetchCalendars') modalController.dismiss() } else { throw resp.data diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index eaec7d3b..100f0c4f 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -5,8 +5,6 @@ import UtilState from './UtilState' import * as types from './mutation-types' import { hasError } from '@/adapter' import logger from '@/logger' -import { showToast } from '@/utils' -import { translate } from '@hotwax/dxp-components' const actions: ActionTree = { async fetchProductStores({ commit }) { @@ -178,16 +176,13 @@ const actions: ActionTree = { commit(types.UTIL_EXTERNAL_MAPPING_TYPES_UPDATED, externalMappingTypes) }, - async fetchCalendars({ commit }, payload) { + async fetchCalendars({ commit }) { let calendars = [] as any let calendarWeekTimings = [] as any let resp; try { resp = await UtilService.fetchCalendars({ - inputFields: { - facilityId: payload.facilityId - }, entityName: "TechDataCalendar", fieldList: ['calendarId', 'calendarWeekId', 'description'], viewSize: 100, @@ -198,9 +193,6 @@ const actions: ActionTree = { calendars = resp.data.docs resp = await UtilService.fetchCalendarWeekTimings({ - inputFields: { - calendarWeekId: payload.calendarWeekId - }, entityName: "TechDataCalendarWeek", fieldList: ['calendarWeekId', 'mondayStartTime', 'mondayCapacity', 'tuesdayStartTime', 'tuesdayCapacity', 'wednesdayStartTime', 'wednesdayCapacity', 'thursdayStartTime', 'thursdayCapacity', 'fridayStartTime', 'fridayCapacity', 'saturdayStartTime', 'saturdayCapacity', 'sundayStartTime', 'sundayCapacity'], viewSize: 100, diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index cff6d6b3..3326eeab 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -519,7 +519,7 @@ export default defineComponent({ props: ["facilityId"], async ionViewWillEnter() { await Promise.all([this.store.dispatch('facility/fetchCurrentFacility', { facilityId: this.facilityId }), this.store.dispatch('util/fetchExternalMappingTypes'), this.store.dispatch('util/fetchLocationTypes'), this.store.dispatch('util/fetchPartyRoles')]) - await Promise.all([this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityParties', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.facilityId, facilityIdenTypeIds: Object.keys(this.externalMappingTypes)}), this.store.dispatch('facility/fetchShopifyFacilityMappings', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId }), this.store.dispatch('util/fetchProductStores'), this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }), this.store.dispatch('util/fetchCalendars', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId })]) + await Promise.all([this.store.dispatch('facility/fetchFacilityLocations', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityParties', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityMappings', { facilityId: this.facilityId, facilityIdenTypeIds: Object.keys(this.externalMappingTypes)}), this.store.dispatch('facility/fetchShopifyFacilityMappings', { facilityId: this.facilityId }), this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId }), this.store.dispatch('util/fetchProductStores'), this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }), this.store.dispatch('util/fetchCalendars'), this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId })]) this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false this.fetchFacilityPrimaryMember()