diff --git a/src/components/FacilityGeoPointModal.vue b/src/components/FacilityGeoPointModal.vue index 5734a632..ede70c75 100644 --- a/src/components/FacilityGeoPointModal.vue +++ b/src/components/FacilityGeoPointModal.vue @@ -101,7 +101,7 @@ export default defineComponent({ const payload = { json: { params: { - q: `postcode: ${this.postalAddress.postalCode}` + q: `postcode: ${this.geoPoint.postalCode}` } } } @@ -117,12 +117,12 @@ export default defineComponent({ throw resp.data } } catch(err) { - showToast(translate("Failed to generate latitude & Longitude.")) + showToast(translate("Failed to generate latitude and longitude.")) logger.error(err) } }, async saveGeoPoint() { - if(!this.geoPoint.latitude || !this.geoPoint.longitude || !this.geoPoint.postalCode) { + if(!this.geoPoint.latitude || !this.geoPoint.longitude) { showToast("Please fill all the required fields") return; } @@ -130,16 +130,16 @@ export default defineComponent({ let resp; try { - resp = await FacilityService.updateFacilityPostalAddress({...this.geoPoint, facilityId: this.facilityId}) + resp = await FacilityService.updateFacilityPostalAddress({...this.geoPoint, postalCode: this.postalAddress.postalCode, facilityId: this.facilityId}) if(!hasError(resp)) { - showToast(translate("Facility latitude & longitude updated successfully.")) + showToast(translate("Facility latitude and longitude updated successfully.")) await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) } else { throw resp.data } } catch(err) { - showToast(translate("Failed to update facility latitude & longitude.")) + showToast(translate("Failed to update facility latitude and longitude.")) logger.error(err) } modalController.dismiss() diff --git a/src/components/GeoPointPopover.vue b/src/components/GeoPointPopover.vue new file mode 100644 index 00000000..f0a18bc7 --- /dev/null +++ b/src/components/GeoPointPopover.vue @@ -0,0 +1,118 @@ + + + diff --git a/src/locales/en.json b/src/locales/en.json index 5cd4f7b9..d9945661 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -63,29 +63,32 @@ "Facility": "Facility", "Facility address updated successfully.": "Facility address updated successfully.", "Facility details": "Facility details", - "Facility latitude & longitude updated successfully.": "Facility latitude & longitude updated successfully.", "Facility ID": "Facility ID", + "Facility latitude and longitude removed successfully.": "Facility latitude and longitude removed successfully.", + "Facility latitude and longitude updated successfully.": "Facility latitude and longitude updated successfully.", "Facility location created successfully": "Facility location created successfully", "Facility location removed successfully": "Facility location removed successfully", "Facility location updated successfully": "Facility location updated successfully", "Facility name": "Facility name", "Facility name is required.": "Facility name is required.", "Facility Management": "Facility Management", + "Facility zipcode": "Facility zipcode", "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.", "Failed to create facility location": "Failed to create facility location", + "Failed to create facility login credentials.": "Failed to create facility login credentials.", "Failed to create shopify mapping": "Failed to create shopify mapping", "Failed to fetch facility information": "Failed to fetch facility information", + "Failed to fetch shopify shops.": "Failed to fetch shopify shops.", "Failed to find the facility locations": "Failed to find the facility locations", "Failed to generate latitude and longitude.": "Failed to generate latitude and longitude.", "Failed to make product store as primary.": "Failed to make product store as primary.", - "Failed to create facility login credentials.": "Failed to create facility login credentials.", - "Failed to fetch shopify shops.": "Failed to fetch shopify shops.", - "Failed to generate latitude & Longitude.": "Failed to generate latitude & Longitude.", "Failed to make product store primary.": "Failed to make product store primary.", + "Failed to regenerate latitude and longitude for the facility.": "Failed to regenerate latitude and longitude for the facility.", + "Failed to remove facility latitude and longitude.": "Failed to remove facility latitude and longitude.", "Failed to remove facility location": "Failed to remove facility location", "Failed to remove facility mapping": "Failed to remove facility mapping", "Failed to remove party from facility.": "Failed to remove party from facility.", @@ -93,7 +96,7 @@ "Failed to update default days to ship": "Failed to update default days to ship", "Failed to update external mapping": "Failed to update external mapping", "Failed to update facility address.": "Failed to update facility address.", - "Failed to update facility latitude & longitude.": "Failed to update facility latitude & longitude.", + "Failed to update facility latitude and longitude.": "Failed to update facility latitude and longitude.", "Failed to update facility location": "Failed to update facility location", "Failed to update fulfillment capacity for ": "Failed to update fulfillment capacity for {facilityName}", "Failed to update fulfillment setting": "Failed to update fulfillment setting", @@ -174,6 +177,7 @@ "Product Stores": "Product Stores", "Product stores updated successfully.": "Product stores updated successfully.", "Reason:": "Reason:", + "Regenerate": "Regenerate", "Remove": "Remove", "Remove location": "Remove location", "Remove schedules": "Remove schedules", @@ -222,6 +226,7 @@ "Store unlink failed.": "Store unlink failed.", "Store unlinked successfully.": "Store unlinked successfully.", "Successfully associated calendar to the facility.": "Successfully associated calendar to the facility.", + "Successfully regenerated latitude and longitude for the facility.": "Successfully regenerated latitude and longitude for 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/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index ccb086af..07e70d87 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -50,6 +50,10 @@ {{ translate("These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.") }} + + {{ translate("Facility zipcode") }} +

{{ postalAddress.postalCode }}

+
{{ translate("Latitude") }}

{{ postalAddress.latitude }}

@@ -58,7 +62,12 @@ {{ translate("Longitude") }}

{{ postalAddress.longitude }}

- {{ translate("Edit") }} +
+ {{ translate("Edit") }} + + + +
{{ translate("Add") }} @@ -459,6 +468,8 @@ import FacilityShopifyMappingModal from '@/components/FacilityShopifyMappingModa import FacilityMappingModal from '@/components/FacilityMappingModal.vue' import { showToast } from '@/utils'; import OperatingHoursPopover from '@/components/OperatingHoursPopover.vue' +import GeoPointPopover from '@/components/GeoPointPopover.vue' +import { UtilService } from '@/services/UtilService'; export default defineComponent({ name: 'FacilityDetails', @@ -497,7 +508,8 @@ export default defineComponent({ 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: '' + selectedCalendarId: '', + isRegenerationRequired: true } }, computed: { @@ -523,6 +535,7 @@ export default defineComponent({ this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false this.fetchFacilityPrimaryMember() + if(this.postalAddress.latitude) this.fetchPostalCodeByGeoPoints() }, methods: { goToLink(link: string) { @@ -548,6 +561,20 @@ export default defineComponent({ return popover.present() }, + async openLatLongPopover(event: Event) { + const popover = await popoverController.create({ + component: GeoPointPopover, + componentProps: { facilityId: this.facilityId, isRegenerationRequired: this.isRegenerationRequired }, + event, + showBackdrop: false + }); + + popover.onDidDismiss().then(async() => { + await this.fetchPostalCodeByGeoPoints() + }) + + return popover.present() + }, async associateCalendarToFacility() { let resp; @@ -592,6 +619,10 @@ export default defineComponent({ componentProps: { facilityId: this.facilityId } }) + geoPointModal.onDidDismiss().then(async() => { + await this.fetchPostalCodeByGeoPoints() + } ) + geoPointModal.present() }, async selectProductStores() { @@ -784,7 +815,7 @@ export default defineComponent({ }, async revokePrimaryStatusFromStore() { try { - const resp = await FacilityService.updateFacilityToGroup({ + await FacilityService.updateFacilityToGroup({ "facilityId": this.facilityId, "facilityGroupId": this.primaryMember.facilityGroupId, "fromDate": this.primaryMember.fromDate, @@ -937,6 +968,32 @@ export default defineComponent({ 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}` + }, + async fetchPostalCodeByGeoPoints() { + const payload = { + json: { + "query": "*:*", + "filter": "{!geofilt sfield=location}", + "params": { + "pt": `${this.postalAddress.latitude}, ${this.postalAddress.longitude}`, + "d": "10" + }, + sort: 'geodist(location, ' + this.postalAddress.latitude + ',' + this.postalAddress.longitude + ') asc', + "limit": 1 + } + } + + try { + const resp = await UtilService.generateLatLong(payload) + + if(!hasError(resp)) { + this.isRegenerationRequired = !(this.postalAddress.postalCode === resp.data.response.docs[0].postcode) + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } } }, setup() { @@ -1008,4 +1065,9 @@ ion-segment { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; } + +.actions { + display: flex; + justify-content: space-between; +} diff --git a/src/views/FindFacilities.vue b/src/views/FindFacilities.vue index 5801b9a9..e93465d0 100644 --- a/src/views/FindFacilities.vue +++ b/src/views/FindFacilities.vue @@ -46,7 +46,7 @@
- +

{{ facility.facilityTypeId ? facilityTypes[facility.facilityTypeId] ? facilityTypes[facility.facilityTypeId].description : facilityTypes.facilityTypeId : '' }}

{{ facility.facilityName }}