From 0d5604ed1ebbddd431f65eb6674eb3e4b8cdd9bf Mon Sep 17 00:00:00 2001 From: Stephen Hand Date: Mon, 26 Aug 2024 13:53:53 +0100 Subject: [PATCH] Fix mapping of site phone numbers to reflect source data changes --- .../resources/convertKHPResourceAttributes.ts | 7 ++++--- .../components/resources/resourceView/SiteDetails.tsx | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin-hrm-form/src/components/resources/convertKHPResourceAttributes.ts b/plugin-hrm-form/src/components/resources/convertKHPResourceAttributes.ts index a2f1ce6e1b..7aae370576 100644 --- a/plugin-hrm-form/src/components/resources/convertKHPResourceAttributes.ts +++ b/plugin-hrm-form/src/components/resources/convertKHPResourceAttributes.ts @@ -192,10 +192,11 @@ const extractSiteLocation = (site: Attributes) => { }; }; -const extractPhoneNumbers = (phoneObj: Attributes) => { +const extractPhoneNumbers = (phoneObj: Attributes): Record => { const phoneNumbers = {}; Object.keys(phoneObj ?? {}).forEach(key => { - phoneNumbers[key] = getAttributeValue(phoneObj, '', key); + const { info } = getAttributeData(phoneObj, '', key); + phoneNumbers[(info.type ?? key).toLowerCase()] = `${info.number}${info.name ? ` (${info.name})` : ''}`; }); return phoneNumbers; }; @@ -256,7 +257,7 @@ const extractSiteDetails = (resource: Attributes, sites: Attributes, language: L operations: extractSiteOperatingHours(siteId, operationsAttributes, siteOperations, language), isActive: getBooleanAttributeValue(site, 'isActive'), details: getAttributeData(site, language, 'details')?.info?.details ?? '', - phoneNumbers: extractPhoneNumbers(getAttributeNode(site, 'phoneNumbers')), + phoneNumbers: extractPhoneNumbers(getAttributeNode(site, 'phone')), coverage: extractCoverage(coverageAttributes, siteId), }); } diff --git a/plugin-hrm-form/src/components/resources/resourceView/SiteDetails.tsx b/plugin-hrm-form/src/components/resources/resourceView/SiteDetails.tsx index d40a221c0a..1f35b8080a 100644 --- a/plugin-hrm-form/src/components/resources/resourceView/SiteDetails.tsx +++ b/plugin-hrm-form/src/components/resources/resourceView/SiteDetails.tsx @@ -75,26 +75,26 @@ const SiteDetails: React.FC = ({ sites }) => { }; const PhoneNumbersDisplay = ({ phoneNumbers }) => { - const { businessLine, afterHoursLine, tty } = phoneNumbers; + const { business, 'after hours': afterHours, tty } = phoneNumbers; return ( - {businessLine && ( + {business && ( Business - {businessLine} + {business} )} - {afterHoursLine && ( + {afterHours && ( After Hours - {afterHoursLine} + {afterHours} )}