INSR-10111: Get carrier phone number earlier, add CMS helper for phone#

This commit is contained in:
Alex Humphries 2026-06-26 22:13:34 -04:00
parent 383830b776
commit 3f4e6ebf3a
4 changed files with 30 additions and 2 deletions

View file

@ -5,7 +5,8 @@ const dynamicStrings = Object.freeze({
MODAL_LINK: 'modalLink', MODAL_LINK: 'modalLink',
TEXT_LINK: 'textLink', TEXT_LINK: 'textLink',
EXTERNAL_LINK: 'externalLink', EXTERNAL_LINK: 'externalLink',
PHONE_LINK: 'phoneLink' PHONE_LINK: 'phoneLink',
PHONE_NUMBER: 'phoneNumber'
}); });
export default dynamicStrings; export default dynamicStrings;

View file

@ -1,5 +1,6 @@
import dynamicStrings from '@/constants/dynamic-strings'; import dynamicStrings from '@/constants/dynamic-strings';
import { useMainStore } from '@/store'; import { useMainStore } from '@/store';
import { toDisplayPhoneNumber } from './text-helper';
/** /**
* @function getStringWithCustomValues * @function getStringWithCustomValues
@ -45,6 +46,9 @@ function processWidgetItemForReplacement(widgetModel, key) {
if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) { if (widgetModel[key].includes(dynamicStrings.GLOBAL_STATE)) {
widgetModel[key] = mapStringToState(widgetModel[key]); widgetModel[key] = mapStringToState(widgetModel[key]);
} }
if (widgetModel[key].includes(dynamicStrings.PHONE_NUMBER)) {
widgetModel[key] = mapStringToPhoneNumber(widgetModel[key]);
}
return widgetModel[key]; return widgetModel[key];
} }
@ -317,6 +321,29 @@ function mapStringToState(str) {
return str.trimStart(); return str.trimStart();
} }
/**
* @function mapStringToPhoneNumber
* @param str
*/
function mapStringToPhoneNumber(str) {
const startIndex = str.indexOf(`{${dynamicStrings.PHONE_NUMBER}`);
console.log('startIndex', startIndex);
console.log('str', str);
let textToReplace = str.substring(startIndex, str.length);
textToReplace = textToReplace.substring(0, textToReplace.indexOf('}') + 1);
console.log('textToReplace', textToReplace);
const phoneNumber = textToReplace.substring(
dynamicStrings.PHONE_NUMBER.length + 2,
textToReplace.length - 1
);
console.log('phoneNumber', phoneNumber);
const displayPhoneNumber = toDisplayPhoneNumber(phoneNumber);
const returnVal = str.replace(textToReplace, displayPhoneNumber);
return returnVal;
}
/** /**
* @function getStoreValueFromString * @function getStoreValueFromString
* @param str * @param str

View file

@ -232,6 +232,7 @@ export default {
// Set order account number from the issConfig. // Set order account number from the issConfig.
mainStore.order.parentAccountNumber = mainStore.issConfig.parentAccountNumber; mainStore.order.parentAccountNumber = mainStore.issConfig.parentAccountNumber;
mainStore.getCarrierAccountInfo();
return { mainStore }; return { mainStore };
}, },

View file

@ -3162,7 +3162,6 @@ export const useMainStore = defineStore({
if (this.hasSubmittedOrder()) { if (this.hasSubmittedOrder()) {
return; return;
} }
await this.getCarrierAccountInfo();
const submittedOrder = this.order; const submittedOrder = this.order;
const { experiments } = this.applicationUser; const { experiments } = this.applicationUser;
const { issConfig, hasRecalibrationPart } = this; const { issConfig, hasRecalibrationPart } = this;