diff --git a/src/components/AddAddressModal.vue b/src/components/AddAddressModal.vue deleted file mode 100644 index dd25a63a..00000000 --- a/src/components/AddAddressModal.vue +++ /dev/null @@ -1,96 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/AddGeoPointModal.vue b/src/components/AddGeoPointModal.vue deleted file mode 100644 index 02d57d96..00000000 --- a/src/components/AddGeoPointModal.vue +++ /dev/null @@ -1,88 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/FacilityAddressModal.vue b/src/components/FacilityAddressModal.vue new file mode 100644 index 00000000..a61bf78e --- /dev/null +++ b/src/components/FacilityAddressModal.vue @@ -0,0 +1,169 @@ + + + \ No newline at end of file diff --git a/src/components/FacilityGeoPointModal.vue b/src/components/FacilityGeoPointModal.vue new file mode 100644 index 00000000..c387653e --- /dev/null +++ b/src/components/FacilityGeoPointModal.vue @@ -0,0 +1,160 @@ + + + \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index cbb5c576..23a525a5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -42,7 +42,10 @@ "External mapping updated successfully": "External mapping updated successfully", "External mappings": "External mappings", "Facilities": "Facilities", + "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 location created successfully": "Facility location created successfully", "Facility location removed successfully": "Facility location removed successfully", @@ -54,6 +57,7 @@ "Failed to create shopify mapping": "Failed to create shopify mapping", "Failed to fetch facility information": "Failed to fetch facility information", "Failed to find the facility locations": "Failed to find the facility locations", + "Failed to generate latitude & Longitude.": "Failed to generate latitude & Longitude.", "Failed to make product store primary.": "Failed to make product store primary.", "Failed to remove facility location": "Failed to remove facility location", "Failed to remove facility mapping": "Failed to remove facility mapping", @@ -61,6 +65,8 @@ "Failed to remove shopify mapping": "Failed to remove shopify mapping", "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 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", diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index e0d61b74..94d624c4 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -2,6 +2,14 @@ import { api, hasError } from '@/adapter'; import logger from '@/logger'; import { DateTime } from 'luxon'; +const createFacilityPostalAddress = async (payload: any): Promise => { + return api({ + url: "service/createFacilityPostalAddress", + method: "post", + data: payload + }) +} + const fetchFacilities = async(query: any): Promise => { return api({ url: "performFind", @@ -142,6 +150,14 @@ const fetchFacilityOrderCounts = async(facilityId: string): Promise => { return facilityOrderCounts; } +const fetchFacilityContactDetails = async(payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }); +} + const addPartyToFacility = async (payload: any): Promise => { return api({ url: "service/addPartyToFacility", @@ -254,6 +270,14 @@ const updateFacilityToGroup = async (payload: any): Promise => { }) } +const updateFacilityPostalAddress = async (payload: any): Promise => { + return api({ + url: "service/updateFacilityPostalAddress", + method: "post", + data: payload + }) +} + const updateProductStoreFacility = async (payload: any): Promise => { return api({ url: "service/updateProductStoreFacility", @@ -330,17 +354,19 @@ export const FacilityService = { addFacilityToGroup, addPartyToFacility, createEnumeration, + createFacilityLocation, createFacilityGroup, createFacilityIdentification, - createFacilityLocation, + createFacilityPostalAddress, createProductStoreFacility, createShopifyShopLocation, deleteFacilityLocation, deleteShopifyShopLocation, fetchFacilities, fetchFacilitiesOrderCount, - fetchFacilityGroup, + fetchFacilityContactDetails, fetchFacilityGroupInformation, + fetchFacilityGroup, fetchFacilityLocations, fetchFacilityMappings, fetchFacilityOrderCounts, @@ -353,6 +379,7 @@ export const FacilityService = { updateFacility, updateFacilityIdentification, updateFacilityLocation, + updateFacilityPostalAddress, updateFacilityToGroup, updateProductStoreFacility, updateShopifyShopLocation diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 7fba2177..0978745b 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -18,6 +18,15 @@ const fetchProductStores = async (payload: any): Promise => { }) } +const generateLatLong = async (payload: any): Promise => { + return api({ + url: "postcodeLookup", + method: "POST", + data: payload, + cache: true + }) +} + const fetchPartyRoles = async (payload: any): Promise => { return api({ url: 'performFind', @@ -26,6 +35,7 @@ const fetchPartyRoles = async (payload: any): Promise => { cache: true }) } + const fetchLocationTypes = async (payload: any): Promise => { return api({ url: "performFind", @@ -35,6 +45,24 @@ const fetchLocationTypes = async (payload: any): Promise => { }) } +const fetchCountries = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "POST", + data: payload, + cache: true + }) +} + +const fetchStates = async (payload: any): Promise => { + return api({ + url: "performFind", + method: "POST", + data: payload, + cache: true + }) +} + const fetchExternalMappingTypes = async (payload: any): Promise => { return api({ url: "performFind", @@ -45,10 +73,13 @@ const fetchExternalMappingTypes = async (payload: any): Promise => { } export const UtilService = { + fetchCountries, fetchExternalMappingTypes, fetchFacilityTypes, fetchLocationTypes, fetchPartyRoles, - fetchProductStores + fetchProductStores, + fetchStates, + generateLatLong } diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index a94f1a23..d2552d12 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -209,6 +209,40 @@ const actions: ActionTree = { commit(types.FACILITY_CURRENT_UPDATED, facility); }, + async fetchFacilityContactDetails({ commit }, payload) { + let postalAddress = {} as any + const params = { + inputFields: { + contactMechPurposeTypeId: 'PRIMARY_LOCATION', + contactMechTypeId: 'POSTAL_ADDRESS', + facilityId: payload.facilityId + }, + entityName: "FacilityContactDetailByPurpose", + orderBy: 'fromDate DESC', + filterByDate: 'Y', + fieldList: ['address1', 'address2', 'city', 'contactMechId', 'countryGeoId', 'countryGeoName', 'latitude', 'longitude', 'postalCode', 'stateGeoId', 'stateGeoName'], + viewSize: 1 + } + + try { + const resp = await FacilityService.fetchFacilityContactDetails(params) + if(!hasError(resp)) { + postalAddress = resp.data.docs[0] + postalAddress = { + ...postalAddress, + stateProvinceGeoId: postalAddress.stateGeoId + } + delete postalAddress.stateGeoId + } else { + throw resp.data + } + } catch(err) { + logger.error('Failed to fetch the postal address for the facility', err) + } + + commit(types.FACILITY_POSTAL_ADDRESS_UPDATED , postalAddress); + }, + updateQuery({ commit }, query) { commit(types.FACILITY_QUERY_UPDATED, query) }, diff --git a/src/store/modules/facility/getters.ts b/src/store/modules/facility/getters.ts index c1a0fdfd..e0ef7c34 100644 --- a/src/store/modules/facility/getters.ts +++ b/src/store/modules/facility/getters.ts @@ -22,6 +22,9 @@ const getters: GetterTree = { }, getFacilityParties(state) { return state.current.parties + }, + getPostalAddress(state) { + return state.current?.postalAddress ? JSON.parse(JSON.stringify(state.current.postalAddress)) : {} } } 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 ae3af8e3..53fe19de 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -2,9 +2,10 @@ export const SN_FACILITY = 'facility' export const FACILITY_LIST_UPDATED = SN_FACILITY + '/LIST_UPDATED' export const FACILITY_QUERY_UPDATED = SN_FACILITY + '/QUERY_UPDATED' export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' +export const FACILITY_CURRENT_LOCATION_UPDATED = SN_FACILITY + '/CURRENT_LOCATION_UPDATED' 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_CURRENT_LOCATION_UPDATED = SN_FACILITY + '/CURRENT_LOCATION_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 41d4d56f..85722a06 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -19,6 +19,9 @@ const mutations: MutationTree = { [types.FACILITY_MAPPINGS_UPDATED](state, payload) { state.current.facilityMappings = payload }, + [types.FACILITY_POSTAL_ADDRESS_UPDATED](state, payload) { + state.current.postalAddress = payload + }, [types.FACILITY_SHOPIFY_MAPPINGS_UPDATED](state, payload) { state.current.shopifyFacilityMappings = payload }, diff --git a/src/store/modules/util/UtilState.ts b/src/store/modules/util/UtilState.ts index fda1accd..bf4937d6 100644 --- a/src/store/modules/util/UtilState.ts +++ b/src/store/modules/util/UtilState.ts @@ -4,4 +4,6 @@ export default interface UtilState { externalMappingTypes: object; productStores: any[]; partyRoles: any[]; + countries: any[]; + states: any; } \ No newline at end of file diff --git a/src/store/modules/util/actions.ts b/src/store/modules/util/actions.ts index 21f04cee..e01a9630 100644 --- a/src/store/modules/util/actions.ts +++ b/src/store/modules/util/actions.ts @@ -176,6 +176,67 @@ const actions: ActionTree = { commit(types.UTIL_EXTERNAL_MAPPING_TYPES_UPDATED, externalMappingTypes) }, + async fetchCountries({ commit, dispatch }, payload) { + let countries = [] as any + + const params = { + inputFields: { + geoIdTo: "DBIC" + }, + entityName: 'GeoAssocAndGeoFrom', + fieldList: ['geoName', 'geoId'], + noConditionFind: 'Y', + } as any + + try { + const resp = await UtilService.fetchCountries(params) + + if(!hasError(resp)) { + countries = resp.data.docs + dispatch('fetchStates', { geoId: payload.countryGeoId ? payload.countryGeoId : 'USA'}) + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } + + commit(types.UTIL_COUNTRIES_UPDATED, countries) + }, + + async fetchStates({ commit, state }, payload) { + if(payload.geoId in state.states){ + commit(types.UTIL_STATES_UPDATED, { countryGeoId: payload.geoId, states: state.states[payload.geoId] }) + return; + } + let states = [] as any + + const params = { + inputFields: { + geoIdFrom: payload.geoId + }, + entityName: 'GeoAssocAndGeoTo', + fieldList: ['geoName', 'geoId'], + noConditionFind: 'Y', + viewSize: 100 + } as any + + try { + const resp = await UtilService.fetchStates(params) + + if(!hasError(resp)) { + states = resp.data.docs + + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } + + commit(types.UTIL_STATES_UPDATED, { countryGeoId: payload.geoId, states }) + }, + clearUtilState({ commit }) { commit(types.UTIL_PRODUCT_STORES_UPDATED, []) commit(types.UTIL_FACILITY_TYPES_UPDATED, {}) diff --git a/src/store/modules/util/getters.ts b/src/store/modules/util/getters.ts index 9b263cbc..957e60be 100644 --- a/src/store/modules/util/getters.ts +++ b/src/store/modules/util/getters.ts @@ -21,5 +21,11 @@ const getters: GetterTree = { getProductStore: (state) => (productStoreId: string) => { return state.productStores.find((store: any) => store.productStoreId === productStoreId) }, + getCountries(state) { + return state.countries + }, + getStates(state) { + return state.states + } } export default getters; \ No newline at end of file diff --git a/src/store/modules/util/index.ts b/src/store/modules/util/index.ts index 6e3bfde4..fbf4cddc 100644 --- a/src/store/modules/util/index.ts +++ b/src/store/modules/util/index.ts @@ -12,7 +12,9 @@ const utilModule: Module = { productStores: [], facilityTypes: {}, locationTypes: {}, - externalMappingTypes: {} + externalMappingTypes: {}, + countries: [], + states: {} }, getters, actions, diff --git a/src/store/modules/util/mutation-types.ts b/src/store/modules/util/mutation-types.ts index 1d73909f..ba644e67 100644 --- a/src/store/modules/util/mutation-types.ts +++ b/src/store/modules/util/mutation-types.ts @@ -2,5 +2,7 @@ export const SN_UTIL = 'util' 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' +export const UTIL_COUNTRIES_UPDATED = SN_UTIL + '/COUNTRIES_UPDATED' export const UTIL_EXTERNAL_MAPPING_TYPES_UPDATED = SN_UTIL + '/EXTERNAL_MAPPING_TYPES_UPDATED' export const UTIL_PARTY_ROLES_UPDATED = SN_UTIL + '/PARTY_ROLES_UPDATED' +export const UTIL_STATES_UPDATED = SN_UTIL + '/STATES_UPDATED' diff --git a/src/store/modules/util/mutations.ts b/src/store/modules/util/mutations.ts index 060f0486..f202487d 100644 --- a/src/store/modules/util/mutations.ts +++ b/src/store/modules/util/mutations.ts @@ -17,6 +17,12 @@ const mutations: MutationTree = { }, [types.UTIL_PARTY_ROLES_UPDATED](state, payload) { state.partyRoles = payload + }, + [types.UTIL_COUNTRIES_UPDATED](state, payload) { + state.countries = payload + }, + [types.UTIL_STATES_UPDATED](state, payload) { + state.states[payload.countryGeoId] = payload.states } } export default mutations; \ No newline at end of file diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 31dc2eed..9b674890 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -23,16 +23,18 @@ {{ translate("Address") }} - - -

{{ "Address line 1" }}

-

{{ "Address line 2" }}

-

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

-

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

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

{{ postalAddress.address1 }}

+

{{ postalAddress.address2 }}

+

{{ postalAddress.postalCode ? `${postalAddress.city}, ${postalAddress.postalCode}` : postalAddress.city }}

+

{{ postalAddress.countryGeoName ? `${postalAddress.stateGeoName}, ${postalAddress.countryGeoName}` : postalAddress.stateGeoName }}

+
+
+ {{ translate("Edit") }} +
+ {{ translate("Add") }} @@ -47,16 +49,18 @@ {{ translate("These values are used to help customers lookup how close they are to your stores when they are finding nearby stores.") }} - - {{ translate("Latitude") }} -

{{ "" }}

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

{{ "" }}

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

{{ postalAddress.latitude }}

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

{{ postalAddress.longitude }}

+
+ {{ translate("Edit") }} +
+ {{ translate("Add") }} @@ -415,9 +419,9 @@ import { import { translate } from '@hotwax/dxp-components'; import FacilityMappingPopover from '@/components/FacilityMappingPopover.vue' import LocationDetailsPopover from '@/components/LocationDetailsPopover.vue'; +import FacilityAddressModal from '@/components/FacilityAddressModal.vue' +import FacilityGeoPointModal from '@/components/FacilityGeoPointModal.vue'; import ProductStorePopover from '@/components/ProductStorePopover.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 AddLocationModal from '@/components/AddLocationModal.vue'; @@ -478,13 +482,14 @@ export default defineComponent({ getProductStore: 'util/getProductStore', locationTypes: 'util/getLocationTypes', partyRoles: 'util/getPartyRoles', - productStores: 'util/getProductStores' + productStores: 'util/getProductStores', + postalAddress: 'facility/getPostalAddress' }) }, 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')]) + 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.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false this.fetchFacilityPrimaryMember() @@ -513,19 +518,21 @@ export default defineComponent({ return popover.present() }, - async addAddress() { - const addAddressModal = await modalController.create({ - component: AddAddressModal + async openAddressModal() { + const addressModal = await modalController.create({ + component: FacilityAddressModal, + componentProps: { facilityId: this.facilityId } }) - addAddressModal.present() + addressModal.present() }, - async addGeoPoint() { - const addGeoPointModal = await modalController.create({ - component: AddGeoPointModal + async openGeoPointModal() { + const geoPointModal = await modalController.create({ + component: FacilityGeoPointModal, + componentProps: { facilityId: this.facilityId } }) - addGeoPointModal.present() + geoPointModal.present() }, async selectProductStores() { const selectProductStoreModal = await modalController.create({