This commit is contained in:
Michaela Brydon 2024-03-04 13:28:39 -05:00
parent 5ac9970d65
commit 090188ed64
2 changed files with 98 additions and 100 deletions

View file

@ -38,7 +38,7 @@
{{ formattedDeductible }} {{ formattedDeductible }}
</div> </div>
<div <div
v-if="displayQuote" v-if="isQuoteDisplayed"
class="d-flex justify-content-center cost mb-0"> class="d-flex justify-content-center cost mb-0">
{{ formattedServicePrice }} {{ formattedServicePrice }}
</div> </div>
@ -53,8 +53,8 @@
ref="verifiedITACAlert" ref="verifiedITACAlert"
class="mb-5" class="mb-5"
cmsWidgetName="VerifiedITACAlert" cmsWidgetName="VerifiedITACAlert"
:manualHeadline="verifiedITACAlertHeader" :manualHeadline="verifiedItacAlertHeader"
:manualCopy="verifiedITACAlertBody" :manualCopy="verifiedItacAlertBody"
alertClass="alert-success" alertClass="alert-success"
:isDismissible="false"> :isDismissible="false">
</alert> </alert>
@ -67,18 +67,18 @@
v-html="nextStepsBody"> v-html="nextStepsBody">
</div> </div>
<buttonQuestion <buttonQuestion
v-if="displayQuote" v-if="isQuoteDisplayed"
v-model="selectedProvider" v-model="selectedProvider"
cmsWidgetName="ServiceProviderQuestion" cmsWidgetName="ServiceProviderQuestion"
:questionText="questionText" :questionText="serviceProviderQuestionText"
:answers="answersFromCms" :answers="serviceProviderQuestionAnswers"
groupName="ServiceProviderQuestionOption" groupName="ServiceProviderQuestionOption"
buttonTypeString="listButton" buttonTypeString="listButton"
isRequired isRequired
:validationRules="rules.selectionRequired"> :validationRules="rules.selectionRequired">
</buttonQuestion> </buttonQuestion>
<text-block <text-block
v-if="displayQuote" v-if="isQuoteDisplayed"
cmsWidgetName="DisclaimerWidget" cmsWidgetName="DisclaimerWidget"
typeStyle="caption" /> typeStyle="caption" />
</div> </div>
@ -88,7 +88,7 @@
cmsWidgetName="SiteFooterWidget" cmsWidgetName="SiteFooterWidget"
:isForwardActionDisabled="!meta.valid" :isForwardActionDisabled="!meta.valid"
@backClicked="navigateBackByVehicleQuestions" @backClicked="navigateBackByVehicleQuestions"
@forwardClicked="forwardButtonAction" /> @forwardClicked="navigateForward" />
</div> </div>
</div> </div>
</div> </div>
@ -129,6 +129,9 @@ import navigationScenarios from '@/router/router-constants/navigation-scenarios.
import routerParams from '@/router/router-constants/router-params'; import routerParams from '@/router/router-constants/router-params';
import issPageValues from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import bailoutMessage from '@/constants/bailoutMessage'; import bailoutMessage from '@/constants/bailoutMessage';
import widgetFields from '@/constants/cms-widget-fields.js';
const SAFELITE_PROVIDER = 'Safelite';
export default { export default {
name: 'coverage-statement', name: 'coverage-statement',
@ -163,8 +166,8 @@ export default {
]; ];
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
const clonedGlassParts = useMainStore().order.lineItems.glassParts const clonedGlassParts = useMainStore().lineItems.glassParts
? JSON.parse(JSON.stringify(useMainStore().order.lineItems.glassParts)) ? JSON.parse(JSON.stringify(useMainStore().lineItems.glassParts))
: []; : [];
const availableLineItems = [ const availableLineItems = [
...(resultMap.supportingItems ?? []), ...(resultMap.supportingItems ?? []),
@ -173,7 +176,7 @@ export default {
let hasBailedOut = false; let hasBailedOut = false;
let pricingResults = []; let pricingResults = [];
if (useMainStore().order.policy.policyLookupSuccessful && useMainStore().order.vehicle.policyVehicleId >= 0) { if (useMainStore().policy.policyLookupSuccessful && useMainStore().vehicle.policyVehicleId >= 0) {
await useMainStore().getFinalDeductible(); await useMainStore().getFinalDeductible();
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems) pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
.catch((err) => { .catch((err) => {
@ -196,9 +199,9 @@ export default {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.setSupportingItems(resultMap.supportingItems); vm.setSupportingItems(resultMap.supportingItems);
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
vm.availableLineItems = pricingResults; vm.setAvailableLineItems(pricingResults);
vm.$refs.loadingModal.showModal(); vm.$refs.loadingModal.showModal();
vm.initializeComponent(availableLineItems); vm.initializeComponent();
if (!vm.unverified) { if (!vm.unverified) {
useMainStore().disableKeyFields(); useMainStore().disableKeyFields();
} }
@ -206,7 +209,14 @@ export default {
} }
}, },
data() { data() {
const { isRepair } = useMainStore().damage;
const { policyLookupSuccessful, noCoverage } = useMainStore().policy;
const { currentDeductible } = useMainStore().order.currentDeductible;
return { return {
isRepair,
policyLookupSuccessful,
deductibleValue: currentDeductible,
isNoComp: noCoverage ?? false,
availableLineItems: [], availableLineItems: [],
selectedProvider: '', selectedProvider: '',
deductibleText: 'Your deductible is', deductibleText: 'Your deductible is',
@ -219,83 +229,84 @@ export default {
rules: { rules: {
selectionRequired: globalRules.OPTION_REQUIRED selectionRequired: globalRules.OPTION_REQUIRED
}, },
supportingItems: null supportingItems: null,
widget: {
subheader: 'SiteSubHeaderWidget',
verifiedItacAlert: 'VerifiedITACAlert',
explanatoryText: 'ExplanatoryTextWidget',
nextStep: 'NextStepsWidget',
serviceProviderQuestion: 'ServiceProviderQuestion'
}
}; };
}, },
computed: { computed: {
verifiedITACAlertHeader() { coverageStatementSubHeader() {
return this.getCmsContent( return this.getTextFromCmsWithCustomIfStatements(
'VerifiedITACAlert', this.widget.subheader,
'HeadlineText' widgetFields.SUB_HEADER_WIDGET.SUB_HEADER_TEXT
); );
}, },
verifiedITACAlertBody() { verifiedItacAlertHeader() {
return this.getCmsContent( return this.getCmsContent(
'VerifiedITACAlert', this.widget.verifiedItacAlert,
'BodyText' widgetFields.ALERT_WIDGET.HEADLINE_TEXT
);
},
verifiedItacAlertBody() {
return this.getCmsContent(
this.widget.verifiedItacAlert,
widgetFields.ALERT_WIDGET.BODY_TEXT
)?.replaceAll('{custom:costSavings}', this.costSavings); )?.replaceAll('{custom:costSavings}', this.costSavings);
}, },
coverageStatementSubHeader() {
return this.getSubheaderTextFromCms('SiteSubHeaderWidget');
},
secondaryText() { secondaryText() {
return this.getSecondaryTextFromCms('SiteSubHeaderWidget'); return this.getTextFromCmsWithCustomIfStatements(
this.widget.subheader,
widgetFields.CONTENT_GROUP_WIDGET.SECONDARY_TEXT
);
}, },
explanatoryText() { explanatoryText() {
return this.getExplantoryTextFromCms('ExplanatoryTextWidget'); return this.getTextFromCmsWithCustomIfStatements(
this.widget.explanatoryText,
widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT
);
}, },
nextStepsHeader() { nextStepsHeader() {
return this.getHeaderTextFromCms('NextStepsWidget'); return this.getTextFromCmsWithCustomIfStatements(
this.widget.nextStep,
widgetFields.CONTENT_GROUP_WIDGET.HEADER_TEXT
);
}, },
nextStepsBody() { nextStepsBody() {
return this.getBodyTextFromCms('NextStepsWidget')?.replaceAll('{custom:damage}', this.damageText); return this.getTextFromCmsWithCustomIfStatements(
}, this.widget.nextStep,
continueWithSchedulingBodyText() { widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT
return this.getCmsContent('continueWithSchedulingCopy', 'BodyText'); )?.replaceAll('{custom:damage}', this.damageText);
},
unverifiedADASNextStepsBodyText() {
return this.getCmsContent('UnverifiedADASNextStepsWidget', 'BodyText')?.replaceAll('{custom:damage}', this.damageText);
},
unverifiedNonADASNextStepsBodyText() {
return this.getCmsContent('UnverifiedNonADASNextStepsWidget', 'BodyText')?.replaceAll('{custom:damage}', this.damageText);
},
unverifiedNonADASRepairBodyText() {
return this.getCmsContent('UnverifiedNonADASRepairWidget', 'BodyText');
}, },
damageText() { damageText() {
const damageString = getDamageString(); const damageString = getDamageString();
return damageString === 'match' ? '' : damageString; return damageString === 'match' ? '' : damageString;
}, },
vehicleDeductible() {
const deductible = useMainStore().order.currentDeductible;
return deductible;
},
formattedDeductible() { formattedDeductible() {
return this.getDeductibleString(this.vehicleDeductible); return this.getDeductibleString(this.deductibleValue);
},
isDeductibleZero() {
return this.vehicleDeductible === 0;
},
policyLookupSuccessful() {
return useMainStore().order.policy.policyLookupSuccessful;
}, },
registerClaimSuccessful() { registerClaimSuccessful() {
return useMainStore().payment.insuranceCoverage.isVerified; return useMainStore().payment.insuranceCoverage.isVerified;
}, },
verifiedNoComp() { verifiedNoComp() {
return this.policyLookupSuccessful ? useMainStore().order.policy.noCoverage : false; return this.policyLookupSuccessful && this.isNoComp;
}, },
verifiedITAC() { verifiedITAC() {
return this.policyLookupSuccessful return this.policyLookupSuccessful
&& !this.verifiedNoComp && !this.isNoComp
&& this.vehicleDeductible > this.totalServicePrice; && this.deductibleValue > this.totalServicePrice;
}, },
// TODO maybe tweak
coveredAndServicePriceAboveOrEqualDeductible() { coveredAndServicePriceAboveOrEqualDeductible() {
return !this.verifiedNoComp && this.totalServicePrice >= this.vehicleDeductible; return !this.verifiedNoComp && this.totalServicePrice >= this.deductibleValue;
}, },
verifiedDeductible() { verifiedDeductible() {
return useMainStore().isClaimRegistrationRequired return useMainStore().isClaimRegistrationRequired
? this.registerClaimSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible && this.vehicleDeductible !== null ? this.registerClaimSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible && this.deductibleValue !== null
: this.policyLookupSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible; : this.policyLookupSuccessful && this.coveredAndServicePriceAboveOrEqualDeductible;
}, },
unverified() { unverified() {
@ -305,9 +316,7 @@ export default {
const parts = useMainStore().order.lineItems.glassParts; const parts = useMainStore().order.lineItems.glassParts;
return parts !== null && !!parts.find((part) => part.requiresRecalibration); return parts !== null && !!parts.find((part) => part.requiresRecalibration);
}, },
isRepair() { // TODO replace with better method
return useMainStore().order.damage.isRepair;
},
totalServicePrice() { totalServicePrice() {
let total = 0; let total = 0;
this.availableLineItems.forEach((lineItem) => { this.availableLineItems.forEach((lineItem) => {
@ -319,27 +328,30 @@ export default {
return this.getServicePriceString(this.totalServicePrice); return this.getServicePriceString(this.totalServicePrice);
}, },
costSavings() { costSavings() {
const savings = this.getITACCostSavings(this.vehicleDeductible, this.totalServicePrice); const savings = this.getITACCostSavings(this.deductibleValue, this.totalServicePrice);
const formattedSavings = parseFloat(savings).toFixed(2); const formattedSavings = parseFloat(savings).toFixed(2);
return `$${formattedSavings}`; return `$${formattedSavings}`;
}, },
questionText() { serviceProviderQuestionText() {
return this.getCmsContent('ServiceProviderQuestion', 'QuestionText'); return this.getCmsContent(
this.widget.serviceProviderQuestion,
widgetFields.INPUT_QUESTION_WIDGET.QUESTION_TEXT
);
}, },
answersFromCms() { serviceProviderQuestionAnswers() {
return this.getCmsContent('ServiceProviderQuestion', 'Answers'); return this.getCmsContent(
this.widget.serviceProviderQuestion,
widgetFields.INPUT_QUESTION_WIDGET.ANSWERS
);
}, },
displayQuote() { isQuoteDisplayed() {
return this.verifiedITAC || this.verifiedNoComp; return this.verifiedITAC || this.verifiedNoComp;
} }
}, },
watch: { watch: {
selectedProvider() { selectedProvider() {
if (this.selectedProvider === 'Safelite') { const buttonText = this.selectedProvider === SAFELITE_PROVIDER ? 'Continue with Safelite' : 'Safelite';
this.$refs.siteFooter.updateButtonText('Continue with Safelite'); this.$refs.siteFooter.updateButtonText(buttonText);
} else {
this.$refs.siteFooter.updateButtonText('Continue');
}
}, },
nextStepsBody(newValue, oldValue) { nextStepsBody(newValue, oldValue) {
if (newValue !== oldValue) { if (newValue !== oldValue) {
@ -366,9 +378,6 @@ export default {
} }
this.$refs.loadingModal.hideModal(); this.$refs.loadingModal.hideModal();
}, },
async forwardButtonAction() {
return this.navigateForward();
},
async navigateForward() { async navigateForward() {
if (this.unverified || this.verifiedDeductible) { if (this.unverified || this.verifiedDeductible) {
useMainStore().saveSupportingItems(this.supportingItems); useMainStore().saveSupportingItems(this.supportingItems);
@ -379,8 +388,8 @@ export default {
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true } { [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
); );
} else if (this.verifiedITAC || this.verifiedNoComp) { } else if (this.verifiedITAC || this.verifiedNoComp) {
useMainStore().updateIsSafeliteProvider(this.selectedProvider === 'Safelite'); useMainStore().updateIsSafeliteProvider(this.selectedProvider === SAFELITE_PROVIDER);
if (this.selectedProvider === 'Safelite') { if (this.selectedProvider === SAFELITE_PROVIDER) {
useMainStore().saveSupportingItems(this.supportingItems); useMainStore().saveSupportingItems(this.supportingItems);
this.$router.navigate( this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
@ -407,25 +416,9 @@ export default {
); );
} }
}, },
getHeaderTextFromCms(cmsWidgetName) { getTextFromCmsWithCustomIfStatements(widgetName, widgetField) {
const header = this.getCmsContent(cmsWidgetName, 'HeaderText'); const rawText = this.getCmsContent(widgetName, widgetField);
return processIfStatements(header, 'custom', this.getCustomValueFromString); return processIfStatements(rawText, 'custom', this.getCustomValueFromString);
},
getSubheaderTextFromCms(cmsWidgetName) {
const subHeader = this.getCmsContent(cmsWidgetName, 'SubHeaderText');
return processIfStatements(subHeader, 'custom', this.getCustomValueFromString);
},
getBodyTextFromCms(cmsWidgetName) {
const bodyText = this.getCmsContent(cmsWidgetName, 'BodyText');
return processIfStatements(bodyText, 'custom', this.getCustomValueFromString);
},
getSecondaryTextFromCms(cmsWidgetName) {
const secondaryText = this.getCmsContent(cmsWidgetName, 'SecondaryText');
return processIfStatements(secondaryText, 'custom', this.getCustomValueFromString);
},
getExplantoryTextFromCms(cmsWidgetName) {
const explanatoryText = this.getCmsContent(cmsWidgetName, 'BodyText');
return processIfStatements(explanatoryText, 'custom', this.getCustomValueFromString);
}, },
getCustomValueFromString(str) { getCustomValueFromString(str) {
switch (str) { switch (str) {
@ -444,20 +437,23 @@ export default {
case 'nonADASRepair': case 'nonADASRepair':
return this.isRepair; return this.isRepair;
case 'deductibleOverZero': case 'deductibleOverZero':
return this.verifiedDeductible && !this.isDeductibleZero; // TODO what if deductible is negative? return this.verifiedDeductible && this.deductibleValue !== 0; // TODO what if deductible is negative?
case 'isDeductibleZero': case 'isDeductibleZero':
return this.verifiedDeductible && this.isDeductibleZero; return this.verifiedDeductible && this.deductibleValue === 0;
default: default:
return null; return null;
} }
}, },
// TODO move to common location
getTotalLineItemPrice(lineItem) { getTotalLineItemPrice(lineItem) {
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice; return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
}, },
// TODO use price formatter
getDeductibleString(deductible) { getDeductibleString(deductible) {
const formattedDeductibleFloat = parseFloat(deductible).toFixed(2); const formattedDeductibleFloat = parseFloat(deductible).toFixed(2);
return `$${formattedDeductibleFloat}`; return `$${formattedDeductibleFloat}`;
}, },
// TODO use price formatter
getServicePriceString(price) { getServicePriceString(price) {
const formattedPriceFloat = parseFloat(price).toFixed(2); const formattedPriceFloat = parseFloat(price).toFixed(2);
return `$${formattedPriceFloat}`; return `$${formattedPriceFloat}`;
@ -467,6 +463,9 @@ export default {
}, },
setSupportingItems(newSupportingItems) { setSupportingItems(newSupportingItems) {
this.supportingItems = newSupportingItems; this.supportingItems = newSupportingItems;
},
setAvailableLineItems(newAvailableLineItems) {
this.availableLineItems = newAvailableLineItems;
} }
} }
}; };

View file

@ -947,10 +947,9 @@ export const useMainStore = defineStore({
}, },
async getSupportingItems() { async getSupportingItems() {
const glassPartsArray = this.order.lineItems.glassParts ?? []; const glassPartsArray = this.lineItems.glassParts ?? [];
const { carId } = this.order.vehicle; const { carId } = this.vehicle;
const { isRepair } = this.order.damage; const { isRepair, numberOfChips } = this.damage;
const { numberOfChips } = this.order.damage;
return globalMethods return globalMethods
.callHttpClient({ .callHttpClient({