Skip to content

Commit

Permalink
Merge pull request #2503 from techmatters/CHI-2910-fix_site_phone_dis…
Browse files Browse the repository at this point in the history
…play

CHI-2910: Fix mapping of site phone numbers to reflect source data changes
  • Loading branch information
stephenhand authored Aug 29, 2024
2 parents 96a1c3c + 0d5604e commit f5523ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ const extractSiteLocation = (site: Attributes) => {
};
};

const extractPhoneNumbers = (phoneObj: Attributes) => {
const extractPhoneNumbers = (phoneObj: Attributes): Record<string, string> => {
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;
};
Expand Down Expand Up @@ -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),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,26 @@ const SiteDetails: React.FC<Props> = ({ sites }) => {
};

const PhoneNumbersDisplay = ({ phoneNumbers }) => {
const { businessLine, afterHoursLine, tty } = phoneNumbers;
const { business, 'after hours': afterHours, tty } = phoneNumbers;
return (
<ResourceAttributeContent>
{businessLine && (
{business && (
<tr>
<td style={{ padding: '0 4px', width: '0', lineBreak: 'anywhere' }}>
<ResourceSubtitle>Business</ResourceSubtitle>
</td>
<td style={{ padding: '0 4px', fontSize: '12px' }}>
<FontOpenSans>{businessLine}</FontOpenSans>
<FontOpenSans>{business}</FontOpenSans>
</td>
</tr>
)}
{afterHoursLine && (
{afterHours && (
<tr>
<td style={{ padding: '0 4px', width: '0' }}>
<ResourceSubtitle>After Hours</ResourceSubtitle>
</td>
<td style={{ padding: '0 4px', fontSize: '12px' }}>
<FontOpenSans>{afterHoursLine}</FontOpenSans>
<FontOpenSans>{afterHours}</FontOpenSans>
</td>
</tr>
)}
Expand Down

0 comments on commit f5523ae

Please sign in to comment.