Skip to content

Commit

Permalink
VA-16652: separate phone extension for mental health numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
maxx1128 committed Feb 26, 2024
1 parent 9698bde commit 6c2e668
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/site/facilities/health_care_local_health_service.drupal.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@
</div>
{% else %}
{% if isMentalHealthService and fieldMentalHealthPhone %}
{% assign localHealthServiceMainNumber = fieldMentalHealthPhone %}
{% assign localHealthServiceMainNumber = fieldMentalHealthPhone | separatePhoneNumberExtension %}
{% else %}
{% assign localHealthServiceMainNumber = fieldPhoneNumber %}
{% assign localHealthServiceMainNumber = fieldPhoneNumber | separatePhoneNumberExtension %}
{% endif %}

<script>
console.log({{ isMentalHealthService }});
console.log({{ localHealthServiceMainNumber | json }});
console.log('-----');
</script>

<div class="vads-u-display--flex vads-u-flex-direction--column vads-u-margin-bottom--1" data-template="facilities/health_care_local_health_service">
{% include "src/site/components/phone-number.drupal.liquid" with
phoneNumber = localHealthServiceMainNumber
phoneNumber = localHealthServiceMainNumber.phoneNumber
phoneExtension = localHealthServiceMainNumber.extension
phoneLabel = 'Main Phone'
phoneHeaderLevel = 5
%}
Expand Down
18 changes: 17 additions & 1 deletion src/site/filters/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ module.exports = function registerFilters() {
return data;
};

liquid.filters.separatePhoneNumberExtension = phoneNumber => {
if (!phoneNumber.includes(', ext. ')) {
return {
phoneNumber,
extension: null,
};
}

const splitNumber = phoneNumber.split(', ext. ');

return {
phoneNumber: splitNumber[0],
extension: splitNumber[1],
};
};

liquid.filters.trackLinks = (html, eventDataString) => {
// Add calls to "recordEvent" to all links found in html
const eventData = JSON.parse(eventDataString);
Expand Down Expand Up @@ -866,7 +882,7 @@ module.exports = function registerFilters() {

/**
* Converts a string to camel case and removes a prefix
@param {string} prefix - prefix to be removed - make empty string not to change string
@param {string} prefix - prefix to be removed - make empty string not to change string
@param {string} string - string to be converted
*/
liquid.filters.trimAndCamelCase = (toRemove, string) => {
Expand Down

0 comments on commit 6c2e668

Please sign in to comment.