diff --git a/src/components/AddOperatingHoursModal.vue b/src/components/AddOperatingHoursModal.vue new file mode 100644 index 00000000..dad87292 --- /dev/null +++ b/src/components/AddOperatingHoursModal.vue @@ -0,0 +1,239 @@ + + + + + \ No newline at end of file diff --git a/src/components/CustomScheduleModal.vue b/src/components/CustomScheduleModal.vue new file mode 100644 index 00000000..203e420f --- /dev/null +++ b/src/components/CustomScheduleModal.vue @@ -0,0 +1,265 @@ + + + + + \ No newline at end of file diff --git a/src/components/OperatingHoursPopover.vue b/src/components/OperatingHoursPopover.vue new file mode 100644 index 00000000..354cb183 --- /dev/null +++ b/src/components/OperatingHoursPopover.vue @@ -0,0 +1,116 @@ + + + diff --git a/src/components/SelectOperatingTimeModal.vue b/src/components/SelectOperatingTimeModal.vue deleted file mode 100644 index 22b55104..00000000 --- a/src/components/SelectOperatingTimeModal.vue +++ /dev/null @@ -1,116 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 14a00694..5cd4f7b9 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -10,6 +10,9 @@ "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", "Add your location ID from Shopify": "Add your location ID from Shopify", "Aisle": "Aisle", "aisle": "aisle", @@ -37,14 +40,18 @@ "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", "Dismiss": "Dismiss", + "Failed to associate calendar to the facility.": "Failed to associate calendar to the facility.", "Filters": "Filters", "Edit": "Edit", "Edit location": "Edit location", + "End Time": "End Time", "External ID": "External ID", "External mapping created successfully": "External mapping created successfully", "External mapping updated successfully": "External mapping updated successfully", @@ -65,6 +72,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.", @@ -142,14 +150,17 @@ "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", "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.", + "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", @@ -165,6 +176,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", @@ -178,11 +190,11 @@ "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", "Select country": "Select country", "Select state": "Select state", "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.", @@ -203,11 +215,13 @@ "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": "Store", "store name": "store name", "Store unlink failed.": "Store unlink failed.", "Store unlinked successfully.": "Store unlinked successfully.", + "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.", @@ -229,6 +243,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/services/FacilityService.ts b/src/services/FacilityService.ts index 9d80c162..23f1da34 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -220,6 +220,14 @@ const addFacilityToGroup = async (payload: any): Promise => { }) } +const associateCalendarToFacility = async (payload: any): Promise => { + return api({ + url: "service/createFacilityCalendar", + method: "post", + data: payload + }) +} + const createFacilityGroup = async(payload: any): Promise => { return api({ url: "service/createFacilityGroup", @@ -365,13 +373,39 @@ const createEnumeration = async (payload: any): Promise => { }) } +const fetchFacilityCalendar = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + +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", + method: "post", + data: payload + }) +} + export const FacilityService = { addFacilityToGroup, createFacilityGroup, createFacility, createFacilityLocation, addPartyToFacility, + associateCalendarToFacility, createEnumeration, + createFacilityCalendar, createFacilityIdentification, createFacilityPostalAddress, createProductStoreFacility, @@ -383,6 +417,7 @@ export const FacilityService = { deleteShopifyShopLocation, fetchFacilities, fetchFacilitiesOrderCount, + fetchFacilityCalendar, fetchFacilityGroupInformation, fetchFacilityMappings, fetchFacilityOrderCounts, @@ -391,6 +426,7 @@ export const FacilityService = { fetchShopifyFacilityMappings, getFacilityParties, getPartyRoleAndPartyDetails, + removeFacilityCalendar, removePartyFromFacility, updateFacility, updateFacilityIdentification, diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index a4cd929c..40942436 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -72,6 +72,22 @@ const fetchExternalMappingTypes = async (payload: any): Promise => { }) } +const fetchCalendars = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + +const fetchCalendarWeekTimings = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + const fetchShopifyShops = async (payload: any): Promise => { return api({ url: "performFind", @@ -82,6 +98,8 @@ const fetchShopifyShops = async (payload: any): Promise => { } export const UtilService = { + fetchCalendars, + fetchCalendarWeekTimings, fetchCountries, fetchExternalMappingTypes, fetchFacilityTypes, diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 8006cdd8..e614c4be 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -284,6 +284,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.fetchFacilityCalendar(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 getFacilityProductStores({ commit }, params) { let productStores = [] const payload = { diff --git a/src/store/modules/facility/getters.ts b/src/store/modules/facility/getters.ts index e0ef7c34..6e2ad64f 100644 --- a/src/store/modules/facility/getters.ts +++ b/src/store/modules/facility/getters.ts @@ -20,6 +20,9 @@ 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 }, diff --git a/src/store/modules/facility/mutation-types.ts b/src/store/modules/facility/mutation-types.ts index 53fe19de..864d31bf 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -7,5 +7,6 @@ export const FACILITY_LOCATIONS_UPDATED = SN_FACILITY + '/LOCATIONS_UPDATED' export const FACILITY_POSTAL_ADDRESS_UPDATED = SN_FACILITY + '/POSTAL_ADDRESS_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_PARTIES_UPDATED = SN_FACILITY + '/PARTIES_UPDATED' export const FACILITY_PRODUCT_STORES_UPDATED = SN_FACILITY + '/PRODUCT_STORES_UPDATED' diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index 7ba8747c..12a86eef 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 bf4937d6..a05db5ee 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 ef957054..100f0c4f 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -175,6 +175,49 @@ const actions: ActionTree = { commit(types.UTIL_EXTERNAL_MAPPING_TYPES_UPDATED, externalMappingTypes) }, + + async fetchCalendars({ commit }) { + let calendars = [] as any + let calendarWeekTimings = [] as any + let resp; + + try { + resp = await UtilService.fetchCalendars({ + entityName: "TechDataCalendar", + fieldList: ['calendarId', 'calendarWeekId', 'description'], + viewSize: 100, + noConditionFind: 'Y' + }) + + if(!hasError(resp) && resp.data.count) { + calendars = resp.data.docs + + resp = await UtilService.fetchCalendarWeekTimings({ + 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) { + logger.error('Failed to fetch facility calendars', err) + } + + commit(types.UTIL_CALENDARS_UPDATED, calendars) + }, async fetchCountries({ commit, dispatch }, payload) { let countries = [] as any diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index 957e60be..e1ceb958 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 fbf4cddc..7a93a224 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 ba644e67..25daa052 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 450a72e1..f2374282 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 3ae1bde4..3326eeab 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,74 +67,91 @@
- + - - {{ translate("Operating hours") }} - +
+ + {{ translate("Operating hours") }} + + + {{ translate("Select a saved calendar of store hours or create a new calendar") }} + +
+
+ + + {{ calendar.description }} + + + + + {{ calendars.length - 3 }} {{ translate("Others") }} + + + + {{ translate("Custom schedule") }} + + + + {{ translate("Add operating hours") }} + + +
+ + + +
+ {{ "Operating Hours" }} + + {{ facilityCalendar.description }} + +
+ + +
- +

{{ translate("Monday") }}

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

{{ translate("Tuesday") }}

- - - {{ translate("Add timings") }} - + {{ facilityCalendar.tuesdayStartTime ? getOpenEndTime(facilityCalendar.tuesdayStartTime, facilityCalendar.tuesdayCapacity) : '-' }}
- +

{{ translate("Wednesday") }}

- - - {{ translate("Add timings") }} - + {{ facilityCalendar.wednesdayStartTime ? getOpenEndTime(facilityCalendar.wednesdayStartTime, facilityCalendar.wednesdayCapacity) : '-' }}
- +

{{ translate("Thursday") }}

- - - {{ translate("Add timings") }} - + {{ facilityCalendar.thursdayStartTime ? getOpenEndTime(facilityCalendar.thursdayStartTime, facilityCalendar.thursdayCapacity) : '-' }}
- +

{{ translate("Friday") }}

- - - {{ translate("Add timings") }} - + {{ facilityCalendar.fridayStartTime ? getOpenEndTime(facilityCalendar.fridayStartTime, facilityCalendar.fridayCapacity) : '-' }}
- +

{{ translate("Saturday") }}

- - - {{ translate("Add timings") }} - + {{ facilityCalendar.saturdayStartTime ? getOpenEndTime(facilityCalendar.saturdayStartTime, facilityCalendar.saturdayCapacity) : '-' }}
- +

{{ translate("Sunday") }}

- - - {{ translate("Add timings") }} - + {{ facilityCalendar.sundayStartTime ? getOpenEndTime(facilityCalendar.sundayStartTime, facilityCalendar.sundayCapacity) : '-' }}
@@ -361,7 +378,7 @@ {{ location.positionId }}

{{ translate("sequence") }}

- + @@ -385,6 +402,7 @@ import { IonCard, IonCardContent, IonCardHeader, + IonCardSubtitle, IonCardTitle, IonChip, IonContent, @@ -396,6 +414,8 @@ import { IonList, IonPage, IonProgressBar, + IonRadio, + IonRadioGroup, IonSegment, IonSegmentButton, IonText, @@ -410,6 +430,7 @@ import { addOutline, closeCircleOutline, closeOutline, + chevronForwardOutline, ellipsisVerticalOutline, globeOutline, locationOutline, @@ -423,11 +444,12 @@ import FacilityAddressModal from '@/components/FacilityAddressModal.vue' import FacilityGeoPointModal from '@/components/FacilityGeoPointModal.vue'; import ProductStorePopover from '@/components/ProductStorePopover.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'; @@ -436,6 +458,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', @@ -446,6 +469,7 @@ export default defineComponent({ IonCard, IonCardContent, IonCardHeader, + IonCardSubtitle, IonCardTitle, IonChip, IonContent, @@ -457,6 +481,8 @@ export default defineComponent({ IonList, IonPage, IonProgressBar, + IonRadio, + IonRadioGroup, IonSegment, IonSegmentButton, IonText, @@ -466,30 +492,34 @@ 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, but actually defaultDays are not setup on the facility - primaryMember: {} as any + primaryMember: {} as any, + isCalendarFound: true, + selectedCalendarId: 'DEFAULT' } }, computed: { ...mapGetters({ + calendars: 'util/getCalendars', current: 'facility/getCurrent', externalMappingTypes: 'util/getExternalMappingTypes', + facilityCalendar: 'facility/getFacilityCalendar', facilityParties: 'facility/getFacilityParties', facilityProductStores: 'facility/getFacilityProductStores', getProductStore: 'util/getProductStore', locationTypes: 'util/getLocationTypes', partyRoles: 'util/getPartyRoles', productStores: 'util/getProductStores', - postalAddress: 'facility/getPostalAddress' + postalAddress: 'facility/getPostalAddress', + userProfile: 'user/getUserProfile', }) }, 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 })]) + 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() @@ -518,6 +548,28 @@ export default defineComponent({ return popover.present() }, + async associateCalendarToFacility() { + let resp; + + try { + resp = await FacilityService.associateCalendarToFacility({ + facilityId: this.facilityId, + calendarId: this.selectedCalendarId, + 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 + } + } catch(err) { + showToast(translate("Failed to associate calendar to the facility.")) + logger.error(err) + } + }, async openAddressModal() { const addressModal = await modalController.create({ component: FacilityAddressModal, @@ -526,6 +578,14 @@ export default defineComponent({ addressModal.present() }, + async addCustomSchedule() { + const customScheduleModal = await modalController.create({ + component: CustomScheduleModal, + componentProps: { facilityId: this.facilityId } + }) + + customScheduleModal.present() + }, async openGeoPointModal() { const geoPointModal = await modalController.create({ component: FacilityGeoPointModal, @@ -597,12 +657,13 @@ export default defineComponent({ addStaffModal.present() }, - async selectOperatingTime() { - const selectOperatingTimeModal = await modalController.create({ - component: SelectOperatingTimeModal + async addOperatingHours() { + const addOperatingHoursModal = await modalController.create({ + component: AddOperatingHoursModal, + componentProps: { facilityId: this.facilityId } }) - - selectOperatingTimeModal.present() + + addOperatingHoursModal.present() }, async openLocationDetailsPopover(ev: Event, location: any) { const locationDetailsPopover = await popoverController.create({ @@ -621,6 +682,16 @@ export default defineComponent({ }); return externalMappingPopover.present() }, + async openOperatingHoursPopover(ev: Event) { + const operatingHoursPopover = await popoverController.create({ + component: OperatingHoursPopover, + componentProps: { facilityId: this.facilityId }, + event: ev, + showBackdrop: false + }); + + operatingHoursPopover.present() + }, getDate(date: any) { return DateTime.fromMillis(date).toFormat('dd LLL yyyy') }, @@ -712,9 +783,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, @@ -862,6 +932,11 @@ export default defineComponent({ }) 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() { @@ -872,6 +947,7 @@ export default defineComponent({ addOutline, closeCircleOutline, closeOutline, + chevronForwardOutline, ellipsisVerticalOutline, globeOutline, locationOutline,