diff --git a/src/helpers/cms-content-helper.js b/src/helpers/cms-content-helper.js index e207a52a..b036cc0f 100644 --- a/src/helpers/cms-content-helper.js +++ b/src/helpers/cms-content-helper.js @@ -10,8 +10,8 @@ import { useMainStore } from '@/store'; */ export function getStringWithCustomValues(str, customValueMap) { let newString = str; - Object.entries(customValueMap).forEach((key, value) => { - newString = newString.replaceAll(`{custom:${key}}`, value); + Object.keys(customValueMap).forEach((key) => { + newString = newString.replaceAll(`{custom:${key}}`, customValueMap[key]); }); return newString; } diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index 04c4c1fc..d923da15 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -118,7 +118,7 @@ import loadingModal from '@/iss-components/loading-modal/loading-modal.vue'; import textBlock from '@/digital-components/text-block/text-block.vue'; // Import Supporting Files -import { fetchCmsContentForPage, setupModalLinks, setupModalLink, processIfStatements } from '@/helpers/cms-content-helper.js'; +import { fetchCmsContentForPage, setupModalLinks, processIfStatements } from '@/helpers/cms-content-helper.js'; import settleAllPromises from '@/helpers/layout-helper.js'; import { getDamageString } from '@/helpers/damage-helper.js'; import { useMainStore } from '@/store/index.js'; diff --git a/src/layouts/tpa-search/tpa-search.vue b/src/layouts/tpa-search/tpa-search.vue index 9ab2f3fe..0cf3e9fc 100644 --- a/src/layouts/tpa-search/tpa-search.vue +++ b/src/layouts/tpa-search/tpa-search.vue @@ -280,6 +280,25 @@ export default { this.selectedProviderNumber = newProviders?.length === 1 ?? false ? newProviders[0]?.providerNumber ?? '' : ''; + }, + selectedProviderNumber(newNumber) { + const provider = this.providers?.find((p) => p.providerNumber === newNumber); + if (provider) { + useMainStore().updateServiceLocation({ + provider: { + providerNumber: provider.providerNumber, + address: { + streetAddress: provider.address.streetAddress, + city: provider.address.city, + state: provider.address.state, + zipCode: provider.address.zipCode, + zipCodeCtu: provider.address.zipCodeCtu + }, + companyName: provider.companyName, + phoneNumber: provider.phoneNumber + } + }); + } } }, beforeUpdate() { diff --git a/src/layouts/tpa-submit/tpa-submit.vue b/src/layouts/tpa-submit/tpa-submit.vue index 05e0d833..35cd1e96 100644 --- a/src/layouts/tpa-submit/tpa-submit.vue +++ b/src/layouts/tpa-submit/tpa-submit.vue @@ -34,7 +34,7 @@ isPrimary :buttonText="forwardButtonText" loaderColor="white" - class="w-100 mb-4" + class="w-100 mb-5" @clickEvent="forwardButtonAction" />
@@ -95,7 +95,7 @@ import deductibleBox from '@/layouts/tpa-submit/deductible-box/deductible-box.vu import siteFooter from '@/iss-components/site-footer/site-footer.vue'; // Supporting files -import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; +import { fetchCmsContentForPage, processIfStatements, getStringWithCustomValues } from '@/helpers/cms-content-helper.js'; import { Form } from 'vee-validate'; import BaseFormMixin from '@/mixins/base-form-mixin.js'; import widgetFields from '@/constants/cms-widget-fields.js'; @@ -104,15 +104,6 @@ import { toTitleCase, toDisplayPhoneNumber, formatAddress, formatAmountInDollars const VERIFYING_COVERAGE = 'Verifying coverage'; -// TODO move functions to general location -function getStringWithCustomValues(str, customValueMap) { - let newString = str; - Object.entries(customValueMap).forEach((key, value) => { - newString = newString.replaceAll(`{custom:${key}}`, value); - }); - return newString; -} - export default { name: 'tpa-submit', components: { @@ -176,12 +167,17 @@ export default { return this.getCmsContent(this.widget.orderDetails, widgetFields.CONTENT_GROUP_WIDGET.HEADER_TEXT); }, orderDetailsBody() { - return this.getCmsContent(this.widget.orderDetails, widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT); + const orderDetailsBodyText = this.getCmsContent(this.widget.orderDetails, widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT); + return this.processIfStatements(orderDetailsBodyText, 'custom', this.getCustomValueFromString); + }, + isVerified() { + return useMainStore().order.payment.insuranceCoverage.isVerified; + }, + currentDeductible() { + return useMainStore().order.currentDeductible; }, deductibleBoxValue() { - const { isVerified } = useMainStore().order.payment.insuranceCoverage; - const { currentDeductible } = useMainStore().order; - return isVerified ? this.formatAmountInDollars(currentDeductible) : VERIFYING_COVERAGE; + return this.isVerified ? this.formatAmountInDollars(this.currentDeductible) : VERIFYING_COVERAGE; }, forwardButtonText() { return this.getCmsContent(this.widget.footer, widgetFields.FOOTER_WIDGET.FORWARD_BUTTON_TEXT); @@ -239,6 +235,19 @@ export default { navigate(scenario) { this.$router.navigate(scenario, this.$route); }, + getCustomValueFromString(str) { + switch (str) { + case 'deductibleAboveZero': + return this.isVerified && this.currentDeductible !== 0; + case 'zeroDeductible': + return this.isVerified && this.currentDeductible === 0; + case 'verifyingCoverage': + return !this.isVerified; + default: + return null; + } + }, + processIfStatements, getStringWithCustomValues, toDisplayPhoneNumber, toTitleCase, diff --git a/src/store/index.js b/src/store/index.js index 7d4c8c25..a019efb0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1324,7 +1324,9 @@ export const useMainStore = defineStore({ state: serviceLocationInfo.provider?.address?.state, zipCode: serviceLocationInfo.provider?.address?.zipCode, zipCodeCtu: serviceLocationInfo.provider?.address?.zipCodeCtu - } + }, + companyName: serviceLocationInfo.provider?.companyName, + phoneNumber: serviceLocationInfo.provider?.phoneNumber }; },