From 01076758a29c7262503185c2a728975b60bece7c Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 5 Dec 2024 11:41:22 +0530 Subject: [PATCH 1/6] Implemented: Added support for adding and updating the email address of a facility and formatted the country code (#337) --- src/components/FacilityAddressModal.vue | 70 +++++++++++++++++--- src/locales/en.json | 2 + src/services/FacilityService.ts | 18 +++++ src/store/modules/facility/actions.ts | 22 +++--- src/store/modules/facility/getters.ts | 4 +- src/store/modules/facility/mutation-types.ts | 2 +- src/store/modules/facility/mutations.ts | 4 +- src/views/AddFacilityAddress.vue | 35 +++++++++- src/views/FacilityDetails.vue | 7 +- 9 files changed, 134 insertions(+), 30 deletions(-) diff --git a/src/components/FacilityAddressModal.vue b/src/components/FacilityAddressModal.vue index 38a35a78..03c88f61 100644 --- a/src/components/FacilityAddressModal.vue +++ b/src/components/FacilityAddressModal.vue @@ -56,11 +56,16 @@ {{ telecomNumberValue?.countryCode }} + + +
{{ translate("Email address") }}
+
+
- + @@ -93,7 +98,7 @@ import { translate } from '@hotwax/dxp-components' import { FacilityService } from '@/services/FacilityService'; import { getTelecomCountryCode, hasError } from "@/adapter"; import logger from "@/logger"; -import { showToast } from "@/utils"; +import { showToast, isValidEmail } from "@/utils"; import emitter from "@/event-bus"; export default defineComponent({ @@ -121,19 +126,21 @@ export default defineComponent({ postalAddress: 'facility/getPostalAddress', countries: 'util/getCountries', states: 'util/getStates', - telecomNumber: 'facility/getTelecomNumber' + contactDetails: 'facility/getTelecomAndEmailAddress' }) }, data() { return { address: {} as any, - telecomNumberValue: {} as any + telecomNumberValue: {} as any, + emailAddress: {} as any } }, props: ['facilityId', 'facilityName'], beforeMount() { this.address = JSON.parse(JSON.stringify(this.postalAddress)) - this.telecomNumberValue = this.telecomNumber ? JSON.parse(JSON.stringify(this.telecomNumber)) : {} + this.telecomNumberValue = this.contactDetails?.telecomNumber ? JSON.parse(JSON.stringify(this.contactDetails.telecomNumber)) : {} + this.emailAddress = this.contactDetails?.emailAddress ? JSON.parse(JSON.stringify(this.contactDetails.emailAddress)) : {}; }, async mounted() { await this.store.dispatch('util/fetchCountries', { countryGeoId: this.address?.countryGeoId }) @@ -157,8 +164,14 @@ export default defineComponent({ return } + if(this.emailAddress.infoString && !isValidEmail(this.emailAddress.infoString)) { + showToast(translate("Invalid email address")) + return + } + emitter.emit('presentLoader') const isTelecomNumberUpdated = this.isTelecomNumberUpdated() + const isEmailAddressUpdated = this.isEmailAddressUpdated() if(this.isAddressUpdated()) { try { @@ -186,6 +199,7 @@ export default defineComponent({ } if(isTelecomNumberUpdated) await this.saveTelecomNumber() + if(isEmailAddressUpdated) await this.saveEmailAddress() modalController.dismiss({ postalAddress }) emitter.emit('dismissLoader') @@ -197,21 +211,52 @@ export default defineComponent({ facilityId: this.facilityId, contactMechPurposeTypeId: 'PRIMARY_PHONE', contactNumber: this.telecomNumberValue.contactNumber.trim(), - countryCode: this.telecomNumberValue.countryCode + countryCode: this.telecomNumberValue.countryCode.replace('+', '') } try { - if(this.telecomNumber?.contactMechId) { + if(this.contactDetails.telecomNumber?.contactMechId) { resp = await FacilityService.updateFacilityTelecomNumber({ ...payload, - contactMechId: this.telecomNumber.contactMechId, + contactMechId: this.contactDetails.telecomNumber.contactMechId, }) } else { resp = await FacilityService.createFacilityTelecomNumber(payload) } if(!hasError(resp)) { - await this.store.dispatch('facility/fetchFacilityTelecomNumber', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityTelecomAndEmailAddress', { facilityId: this.facilityId }) + } else { + throw resp.data + } + } catch(err) { + logger.error(err) + } + }, + async saveEmailAddress() { + let resp = {} as any; + + const payload = { + facilityId: this.facilityId, + emailAddress: this.emailAddress.infoString + } + + try { + if(this.contactDetails.emailAddress?.contactMechId) { + resp = await FacilityService.updateFacilityEmailAddress({ + ...payload, + contactMechId: this.emailAddress.contactMechId, + }) + } else { + resp = await FacilityService.createFacilityEmailAddress({ + ...payload, + contactMechTypeId: 'EMAIL_ADDRESS', + contactMechPurposeTypeId: 'PRIMARY_EMAIL', + }) + } + + if(!hasError(resp)) { + await this.store.dispatch('facility/fetchFacilityTelecomAndEmailAddress', { facilityId: this.facilityId }) } else { throw resp.data } @@ -232,8 +277,11 @@ export default defineComponent({ : true }, isTelecomNumberUpdated() { - return this.telecomNumberValue.contactNumber && JSON.stringify(this.telecomNumberValue) !== JSON.stringify(this.telecomNumber) - } + return this.telecomNumberValue?.contactNumber && JSON.stringify(this.telecomNumberValue.contactNumber) !== JSON.stringify(this.contactDetails?.telecomNumber?.contactNumber) + }, + isEmailAddressUpdated() { + return this.emailAddress?.infoString && JSON.stringify(this.emailAddress.infoString) !== JSON.stringify(this.contactDetails?.emailAddress?.infoString); + }, }, setup() { const store = useStore() diff --git a/src/locales/en.json b/src/locales/en.json index 6aff2688..1badf31f 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -87,6 +87,7 @@ "Edit location": "Edit location", "End Time": "End Time", "Facility group created.": "Facility group created.", + "Email address": "Email address", "External ID": "External ID", "External mapping created successfully": "External mapping created successfully", "External mapping updated successfully": "External mapping updated successfully", @@ -202,6 +203,7 @@ "Internal ID": "Internal ID", "Internal ID cannot be more than 20 characters.": "Internal ID cannot be more than 20 characters.", "Internal locations": "Internal locations", + "Invalid email address": "Invalid email address", "is now selling on": "{facilityName} is now selling on {facilityGroupId}.", "Instance Url": "Instance Url", "Language": "Language", diff --git a/src/services/FacilityService.ts b/src/services/FacilityService.ts index dd8e7335..fc7352c8 100644 --- a/src/services/FacilityService.ts +++ b/src/services/FacilityService.ts @@ -779,6 +779,22 @@ const updateFacilityTelecomNumber = async (payload: any): Promise => { }) } +const createFacilityEmailAddress = async (payload: any): Promise => { + return api({ + url: "service/createFacilityEmailAddress", + method: "post", + data: payload + }) +} + +const updateFacilityEmailAddress = async (payload: any): Promise => { + return api({ + url: "service/updateFacilityEmailAddress", + method: "post", + data: payload + }) +} + const createProductStoreFacilityGroup = async (payload: any): Promise => { return api({ url: "service/createProductStoreFacilityGroup", @@ -804,6 +820,7 @@ export const FacilityService = { createFacilityLocation, createVirtualFacility, createEnumeration, + createFacilityEmailAddress, createFacilityCalendar, createFacilityIdentification, createFacilityPostalAddress, @@ -841,6 +858,7 @@ export const FacilityService = { removeFacilityFromGroup, removePartyFromFacility, updateFacility, + updateFacilityEmailAddress, updateFacilityGroup, updateFacilityIdentification, updateFacilityLocation, diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index e103f4bd..eb81b25d 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -260,26 +260,32 @@ const actions: ActionTree = { commit(types.FACILITY_POSTAL_ADDRESS_UPDATED , postalAddress); }, - async fetchFacilityTelecomNumber({ commit }, payload) { - let telecomNumber; + async fetchFacilityTelecomAndEmailAddress({ commit }, payload) { const params = { inputFields: { - contactMechPurposeTypeId: 'PRIMARY_PHONE', - contactMechTypeId: 'TELECOM_NUMBER', + contactMechPurposeTypeId: ['PRIMARY_PHONE', 'PRIMARY_EMAIL'], + contactMechPurposeTypeId_op: 'in', + contactMechTypeId: ['TELECOM_NUMBER', 'EMAIL_ADDRESS'], + contactMechTypeId_op: 'in', facilityId: payload.facilityId }, entityName: "FacilityContactDetailByPurpose", orderBy: 'fromDate DESC', filterByDate: 'Y', - fieldList: ['contactMechId', 'contactNumber', 'countryCode'], - viewSize: 1 + fieldList: ['contactMechId', 'contactNumber', 'countryCode', 'infoString'], + viewSize: 2 } try { const resp = await FacilityService.fetchFacilityContactDetails(params) if(!hasError(resp)) { - telecomNumber = resp.data.docs[0] - commit(types.FACILITY_TELECOM_NUMBER_UPDATED , telecomNumber); + const response = resp.data.docs + const contactDetails = { + telecomNumber: response.find((item: any) => item.infoString === null), + emailAddress: response.find((item: any) => item.infoString !== null) + }; + + commit(types.FACILITY_TELECOM_AND_EMAIL_ADDRESS_UPDATED , contactDetails); } else { throw resp.data } diff --git a/src/store/modules/facility/getters.ts b/src/store/modules/facility/getters.ts index 8a071f85..8f95fcaf 100644 --- a/src/store/modules/facility/getters.ts +++ b/src/store/modules/facility/getters.ts @@ -51,8 +51,8 @@ const getters: GetterTree = { getPostalAddress(state) { return state.current?.postalAddress ? JSON.parse(JSON.stringify(state.current.postalAddress)) : {} }, - getTelecomNumber(state) { - return state.current?.telecomNumber + getTelecomAndEmailAddress(state) { + return state.current?.contactDetails } } 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 07bcc8f4..a1ad6bf6 100644 --- a/src/store/modules/facility/mutation-types.ts +++ b/src/store/modules/facility/mutation-types.ts @@ -5,7 +5,7 @@ export const FACILITY_GROUP_QUERY_UPDATED = SN_FACILITY + '/GROUP_QUERY_UPDATED' export const FACILITY_CURRENT_UPDATED = SN_FACILITY + '/CURRENT_UPDATED' export const FACILITY_LOCATIONS_UPDATED = SN_FACILITY + '/LOCATIONS_UPDATED' export const FACILITY_POSTAL_ADDRESS_UPDATED = SN_FACILITY + '/POSTAL_ADDRESS_UPDATED' -export const FACILITY_TELECOM_NUMBER_UPDATED = SN_FACILITY + '/CONTACT_NUMBER_UPDATED' +export const FACILITY_TELECOM_AND_EMAIL_ADDRESS_UPDATED = SN_FACILITY + '/TELECOM_AND_EMAIL_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' diff --git a/src/store/modules/facility/mutations.ts b/src/store/modules/facility/mutations.ts index 6c567c02..7fe45e09 100644 --- a/src/store/modules/facility/mutations.ts +++ b/src/store/modules/facility/mutations.ts @@ -19,8 +19,8 @@ const mutations: MutationTree = { [types.FACILITY_CURRENT_UPDATED](state, payload) { state.current = payload }, - [types.FACILITY_TELECOM_NUMBER_UPDATED](state, payload) { - state.current.telecomNumber = payload + [types.FACILITY_TELECOM_AND_EMAIL_ADDRESS_UPDATED](state, payload) { + state.current.contactDetails = payload }, [types.FACILITY_POSTAL_ADDRESS_UPDATED](state, payload) { state.current.postalAddress = payload diff --git a/src/views/AddFacilityAddress.vue b/src/views/AddFacilityAddress.vue index 1c1188e6..234f3394 100644 --- a/src/views/AddFacilityAddress.vue +++ b/src/views/AddFacilityAddress.vue @@ -53,6 +53,11 @@ {{ countryCode }} + + +
{{ translate('Email address') }}
+
+
@@ -116,7 +121,7 @@ import { mapGetters, useStore } from "vuex"; import { useRouter } from 'vue-router' import { colorWandOutline, locationOutline } from 'ionicons/icons'; import { translate } from "@hotwax/dxp-components"; -import { showToast } from "@/utils"; +import { showToast, isValidEmail } from "@/utils"; import logger from "@/logger"; import { getTelecomCountryCode, hasError } from "@/adapter"; import { FacilityService } from "@/services/FacilityService"; @@ -164,7 +169,8 @@ export default defineComponent({ longitude: '', }, contactNumber: '', - countryCode: '' + countryCode: '', + emailAddress: '' } }, props: ['facilityId'], @@ -179,6 +185,12 @@ export default defineComponent({ showToast("Please fill all the required fields.") return } + + if(this.emailAddress && !isValidEmail(this.emailAddress)) { + showToast(translate("Invalid email address")) + return + } + const payload = { facilityId: this.facilityId, contactMechPurposeTypeId: 'PRIMARY_LOCATION', @@ -198,6 +210,7 @@ export default defineComponent({ logger.error("Failed to create facility address.", error) } if(this.contactNumber) this.saveTelecomNumber() + if(this.emailAddress) this.saveEmailAddress() }, async generateLatLong() { const postalCode = this.formData.postalCode; @@ -235,7 +248,7 @@ export default defineComponent({ facilityId: this.facilityId, contactMechPurposeTypeId: 'PRIMARY_PHONE', contactNumber: this.contactNumber.trim(), - countryCode: this.countryCode + countryCode: this.countryCode.replace('+', '') }) if(hasError(resp)) { @@ -245,6 +258,22 @@ export default defineComponent({ logger.error(err) } }, + async saveEmailAddress() { + try { + const resp = await FacilityService.createFacilityEmailAddress({ + facilityId: this.facilityId, + contactMechTypeId: 'EMAIL_ADDRESS', + contactMechPurposeTypeId: 'PRIMARY_EMAIL', + emailAddress: this.emailAddress, + }) + + if(hasError(resp)) { + throw resp.data; + } + } catch(err) { + logger.error(err) + } + } }, setup() { const store = useStore(); diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 0ef9b8b0..6b58b134 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -53,7 +53,8 @@

{{ postalAddress.address2 }}

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

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

-

{{ `${telecomNumber.countryCode}-${telecomNumber.contactNumber}` }}

+

{{ `${contactDetails.telecomNumber?.countryCode}-${contactDetails.telecomNumber?.contactNumber}` }}

+

{{ contactDetails.emailAddress?.infoString }}

{{ translate("Edit") }} @@ -639,7 +640,7 @@ export default defineComponent({ baseUrl: "user/getBaseUrl", facilityGroupTypes: 'util/getFacilityGroupTypes', inventoryGroups: 'util/getInventoryGroups', - telecomNumber: 'facility/getTelecomNumber' + contactDetails: 'facility/getTelecomAndEmailAddress' }) }, props: ["facilityId"], @@ -651,7 +652,7 @@ export default defineComponent({ facilityTypeId: 'VIRTUAL_FACILITY', facilityTypeId_op: 'notEqual' })]) - 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.store.dispatch('facility/fetchFacilityLogins', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityTelecomNumber', { 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.store.dispatch('facility/fetchFacilityLogins', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityTelecomAndEmailAddress', { facilityId: this.facilityId })]) this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false this.parentFacilityTypeId = this.current.parentFacilityTypeId From 60504d907e34ed57d733c61be9a08620249bfd32 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 5 Dec 2024 11:49:04 +0530 Subject: [PATCH 2/6] Improved: removed the lines "none" property from contact number while creating facility(#337) --- src/views/AddFacilityAddress.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/AddFacilityAddress.vue b/src/views/AddFacilityAddress.vue index 234f3394..90d566e8 100644 --- a/src/views/AddFacilityAddress.vue +++ b/src/views/AddFacilityAddress.vue @@ -48,7 +48,7 @@ - + {{ countryCode }} From 49bb53be7537267a84f1dde204e5bc974d8060bf Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 5 Dec 2024 11:50:36 +0530 Subject: [PATCH 3/6] Improved: reomved the lines "none" property from the longitude input(#337) --- src/views/AddFacilityAddress.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/AddFacilityAddress.vue b/src/views/AddFacilityAddress.vue index 90d566e8..b02dc0af 100644 --- a/src/views/AddFacilityAddress.vue +++ b/src/views/AddFacilityAddress.vue @@ -77,7 +77,7 @@ - + From a95ef7c9f68a4abec39ab5571dc2c383a749a536 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Tue, 10 Dec 2024 11:38:23 +0530 Subject: [PATCH 4/6] Improved: Updated the logic for fetching contact details of a facility to use a single action for retrieving address info, contact info, and email address (#337) --- src/components/FacilityAddressModal.vue | 6 +- src/components/FacilityGeoPointModal.vue | 2 +- src/components/GeoPointPopover.vue | 4 +- src/store/modules/facility/actions.ts | 86 ++++++++++-------------- src/views/FacilityDetails.vue | 2 +- 5 files changed, 44 insertions(+), 56 deletions(-) diff --git a/src/components/FacilityAddressModal.vue b/src/components/FacilityAddressModal.vue index 03c88f61..cafa9460 100644 --- a/src/components/FacilityAddressModal.vue +++ b/src/components/FacilityAddressModal.vue @@ -187,7 +187,7 @@ export default defineComponent({ if(!hasError(resp)) { postalAddress = this.address - await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }) showToast(translate("Facility contact updated successfully.")) } else { throw resp.data @@ -225,7 +225,7 @@ export default defineComponent({ } if(!hasError(resp)) { - await this.store.dispatch('facility/fetchFacilityTelecomAndEmailAddress', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }) } else { throw resp.data } @@ -256,7 +256,7 @@ export default defineComponent({ } if(!hasError(resp)) { - await this.store.dispatch('facility/fetchFacilityTelecomAndEmailAddress', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }) } else { throw resp.data } diff --git a/src/components/FacilityGeoPointModal.vue b/src/components/FacilityGeoPointModal.vue index 51cd9ac8..9b97f104 100644 --- a/src/components/FacilityGeoPointModal.vue +++ b/src/components/FacilityGeoPointModal.vue @@ -145,7 +145,7 @@ export default defineComponent({ if(!hasError(resp)) { geoPoints = this.geoPoint showToast(translate("Facility latitude and longitude updated successfully.")) - await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }) } else { throw resp.data } diff --git a/src/components/GeoPointPopover.vue b/src/components/GeoPointPopover.vue index 196236e7..cd7bb57a 100644 --- a/src/components/GeoPointPopover.vue +++ b/src/components/GeoPointPopover.vue @@ -72,7 +72,7 @@ export default defineComponent({ if(!hasError(resp)) { showToast(translate("Successfully regenerated latitude and longitude for the facility.")) - await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }) } else { throw resp.data } @@ -103,7 +103,7 @@ export default defineComponent({ if(!hasError(resp)) { showToast(translate("Facility latitude and longitude removed successfully.")) - await this.store.dispatch('facility/fetchFacilityContactDetails', { facilityId: this.facilityId }) + await this.store.dispatch('facility/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }) } else { throw resp.data } diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index eb81b25d..98de53f9 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -227,70 +227,58 @@ 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', 'toName'], - 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); - }, - async fetchFacilityTelecomAndEmailAddress({ commit }, payload) { - const params = { + async fetchFacilityContactDetailsAndTelecom({ commit }, facility) { + let postalAddress = {} as any; + const contactDetails = {} as any; + + const payload = { inputFields: { - contactMechPurposeTypeId: ['PRIMARY_PHONE', 'PRIMARY_EMAIL'], + contactMechPurposeTypeId: ['PRIMARY_PHONE', 'PRIMARY_EMAIL', 'PRIMARY_LOCATION'], contactMechPurposeTypeId_op: 'in', - contactMechTypeId: ['TELECOM_NUMBER', 'EMAIL_ADDRESS'], + contactMechTypeId: ['TELECOM_NUMBER', 'EMAIL_ADDRESS', 'POSTAL_ADDRESS'], contactMechTypeId_op: 'in', - facilityId: payload.facilityId + facilityId: facility.facilityId }, entityName: "FacilityContactDetailByPurpose", orderBy: 'fromDate DESC', filterByDate: 'Y', - fieldList: ['contactMechId', 'contactNumber', 'countryCode', 'infoString'], - viewSize: 2 + fieldList: ['address1', 'address2', 'city', 'contactMechId', 'contactMechId', 'contactMechTypeId', 'contactNumber', 'countryCode', 'countryGeoId', 'countryGeoName', 'infoString', 'latitude', 'longitude', 'postalCode', 'stateGeoId', 'stateGeoName', 'toName'], + viewSize: 3 } try { - const resp = await FacilityService.fetchFacilityContactDetails(params) + const resp = await FacilityService.fetchFacilityContactDetails(payload); if(!hasError(resp)) { - const response = resp.data.docs - const contactDetails = { - telecomNumber: response.find((item: any) => item.infoString === null), - emailAddress: response.find((item: any) => item.infoString !== null) - }; - - commit(types.FACILITY_TELECOM_AND_EMAIL_ADDRESS_UPDATED , contactDetails); + const docs = resp.data.docs + + docs.map((item: any) => { + if(item.contactMechTypeId === "POSTAL_ADDRESS") { + postalAddress = { + ...item, + stateProvinceGeoId: item.stateGeoId + } + delete postalAddress.stateGeoId + } else if (item.contactMechTypeId === 'TELECOM_NUMBER') { + contactDetails.telecomNumber = { + contactMechId: item.contactMechId, + contactNumber: item.contactNumber, + countryCode: item.countryCode, + } + } else if (item.contactMechTypeId === 'EMAIL_ADDRESS') { + contactDetails.emailAddress = { + contactMechId: item.contactMechId, + infoString: item.infoString + } + } + }) + + commit(types.FACILITY_POSTAL_ADDRESS_UPDATED, postalAddress) + commit(types.FACILITY_TELECOM_AND_EMAIL_ADDRESS_UPDATED, contactDetails) } else { throw resp.data } } catch(err) { - logger.error('Failed to fetch the contact number for the facility', err) + logger.error('Failed to fetch facility contact details and telecom information', err) } }, diff --git a/src/views/FacilityDetails.vue b/src/views/FacilityDetails.vue index 6b58b134..8b86f08b 100644 --- a/src/views/FacilityDetails.vue +++ b/src/views/FacilityDetails.vue @@ -652,7 +652,7 @@ export default defineComponent({ facilityTypeId: 'VIRTUAL_FACILITY', facilityTypeId_op: 'notEqual' })]) - 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.store.dispatch('facility/fetchFacilityLogins', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityTelecomAndEmailAddress', { 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/fetchFacilityContactDetailsAndTelecom', { facilityId: this.facilityId }), this.store.dispatch('util/fetchCalendars'), this.store.dispatch('facility/fetchFacilityCalendar', { facilityId: this.facilityId }), this.store.dispatch('facility/fetchFacilityLogins', { facilityId: this.facilityId })]) this.defaultDaysToShip = this.current.defaultDaysToShip this.isLoading = false this.parentFacilityTypeId = this.current.parentFacilityTypeId From fee9ed77bca789c6e25584adeea74801243f8183 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Wed, 18 Dec 2024 16:44:12 +0530 Subject: [PATCH 5/6] Improved: used inline label for Email address in ionInput(#337) --- src/components/FacilityAddressModal.vue | 4 +--- src/views/AddFacilityAddress.vue | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/FacilityAddressModal.vue b/src/components/FacilityAddressModal.vue index cafa9460..f16e2c22 100644 --- a/src/components/FacilityAddressModal.vue +++ b/src/components/FacilityAddressModal.vue @@ -57,9 +57,7 @@ - -
{{ translate("Email address") }}
-
+
diff --git a/src/views/AddFacilityAddress.vue b/src/views/AddFacilityAddress.vue index b02dc0af..e0605ff6 100644 --- a/src/views/AddFacilityAddress.vue +++ b/src/views/AddFacilityAddress.vue @@ -54,9 +54,7 @@
- -
{{ translate('Email address') }}
-
+
From e9a54fb25fe015740a23ec85c7d18bb0096b500e Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Wed, 18 Dec 2024 19:04:08 +0530 Subject: [PATCH 6/6] Improved: removed duplicate field in fieldList of fetchFacilityContactDetails action and postalAddress deletion (#337) --- src/store/modules/facility/actions.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/store/modules/facility/actions.ts b/src/store/modules/facility/actions.ts index 98de53f9..dca46ac0 100644 --- a/src/store/modules/facility/actions.ts +++ b/src/store/modules/facility/actions.ts @@ -242,7 +242,7 @@ const actions: ActionTree = { entityName: "FacilityContactDetailByPurpose", orderBy: 'fromDate DESC', filterByDate: 'Y', - fieldList: ['address1', 'address2', 'city', 'contactMechId', 'contactMechId', 'contactMechTypeId', 'contactNumber', 'countryCode', 'countryGeoId', 'countryGeoName', 'infoString', 'latitude', 'longitude', 'postalCode', 'stateGeoId', 'stateGeoName', 'toName'], + fieldList: ['address1', 'address2', 'city', 'contactMechId', 'contactMechTypeId', 'contactNumber', 'countryCode', 'countryGeoId', 'countryGeoName', 'infoString', 'latitude', 'longitude', 'postalCode', 'stateGeoId', 'stateGeoName', 'toName'], viewSize: 3 } @@ -257,7 +257,6 @@ const actions: ActionTree = { ...item, stateProvinceGeoId: item.stateGeoId } - delete postalAddress.stateGeoId } else if (item.contactMechTypeId === 'TELECOM_NUMBER') { contactDetails.telecomNumber = { contactMechId: item.contactMechId,