diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index e09a4c78b..2fc0c88eb 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -111,6 +111,7 @@ const storeActions = { SAVE_PAYPAL_TOKEN: "savePaypalToken", SAVE_NEXTGEN_SETTLED_AMOUNT: "saveNextGenSettledAmount", SAVE_IS_RECAL_ACK_OPT_IN: "saveIsRecalAckOptIn", + SAVE_IS_OEM_GLASS_SELECTED: "saveIsOemGlassSelected", SAVE_IS_MSR_FEE_APPLICABLE: "saveIsMSRFeeApplicable", CREATE_SUBMITTED_STATE: "createSubmittedState", diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 2112c789c..5167581e0 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -69,6 +69,7 @@ const storeMutations = { LOCK_TOKEN: "updateLockToken", UPDATE_SETTLED_TENDER_AMOUNT: "updateSettledTenderAmount", UPDATE_IS_RECAL_ACK_OPT_IN: "updateIsRecalAckOptIn", + UPDATE_IS_OEM_GLASS_SELECTED: "updateIsOemGlassSelected", UPDATE_IS_MSR_FEE_APPLICABLE: "updateIsMSRFeeApplicable", UPDATE_CASH_PRICE_SUBTOTAL: "updateCashPriceSubTotal", diff --git a/src/layouts/quote/oem-glass-question/oem-glass-question.vue b/src/layouts/quote/oem-glass-question/oem-glass-question.vue new file mode 100644 index 000000000..b591587c6 --- /dev/null +++ b/src/layouts/quote/oem-glass-question/oem-glass-question.vue @@ -0,0 +1,139 @@ + + + + + diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js index 5d9f3bacb..60dd548ad 100644 --- a/src/layouts/quote/quote.spec.js +++ b/src/layouts/quote/quote.spec.js @@ -118,6 +118,9 @@ jest.mock("@/mixins/experiment-mixin.js", () => ({ if (settingName === mockExperimentSettings.DISPLAY_AFTERPAY_BREAKOUT_DISPLAY) { return false; } + if (settingName === mockExperimentSettings.OFFER_OEM) { + return false; + } return "test"; }, }, diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index b08e9ed72..05102d3a5 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -86,6 +86,11 @@ isInsuranceSelected ? isInsuranceContinueButtonText : '' " /> + + 0 + ? oemGlassPieceParts[0].parts + : null; + const isOemGlassSelected = store.getters.order.damage?.installOemGlass ?? false; + + let alternateGlassPartsForOem; + if (oemGlassParts) alternateGlassPartsForOem = oemGlassParts; + const quotePageDiscountPartsInfo = getAvailableQuotePageDiscounts(); const quotePageDiscountParts = quotePageDiscountPartsInfo.map((partInfo) => ({ @@ -403,6 +421,9 @@ export default { vm.holdParentAccountNumber = holdParentAccountNumber; vm.holdBillToAccountNumber = holdBillToAccountNumber; vm.skipToInsurance = shouldSkipToInsurance; + vm.offerOem = offerOem; + vm.alternateGlassPartsForOem = alternateGlassPartsForOem; // oemParts + vm.isOemGlassSelected = isOemGlassSelected; if (revalidatePromoResponse) { const revalidateAlerts = buildToastMessagesFromRevalidateOrValidatePromoResponse( @@ -570,6 +591,8 @@ export default { availableLineItems: null, lineItems: [], addableVaps: [], + offerOem: null, + alternateGlassPartsForOem: null, servicePackage: null, holdParentAccountNumber: null, holdBillToAccountNumber: null, @@ -579,6 +602,7 @@ export default { packageNumber: null, skipToInsurance: null, servicePackageSelected: null, + isOemGlassSelected: false, }; }, async mounted() { @@ -743,6 +767,20 @@ export default { this.lineItems.supportingItems = this.filterOutFees(this.lineItems.supportingItems); } + if ( + this.lineItems.glassParts && + this.alternateGlassPartsForOem && + this.alternateGlassPartsForOem.length > 0 + ) { + let isOEMGlassOnOrder = this.isOEMGlassOnOrder(this.lineItems.glassParts); + if ( + (this.isOemGlassSelected && !isOEMGlassOnOrder) || + (!this.isOemGlassSelected && isOEMGlassOnOrder) + ) { + this.swapOEMGlassPartsOnOrder(); + } + } + if (this.lineItems.glassParts?.length > 0) { this.dispatchStoreAction( this.storeActions.SAVE_GLASS_PARTS_SUPPRESSING_STATE_RESETTING, @@ -775,6 +813,11 @@ export default { }, false ); + this.dispatchStoreAction( + this.storeActions.SAVE_IS_OEM_GLASS_SELECTED, + this.isOemGlassSelected, + false + ); await savePageData( this.pageName, @@ -893,6 +936,25 @@ export default { const alert = createPromoSuccessAlert(lineItems.promos[0].promoCode); this.$refs.funnelHeader.pushGlobalAlert(alert, alert.shouldAutoFade); }, + isOEMGlassOnOrder(glassParts) { + if (glassParts && glassParts.length > 0) { + return glassParts.some((part) => part.partNumber.endsWith("OEM")); + } + return false; + }, + swapOEMGlassPartsOnOrder() { + const windshieldString = "WINDSHIELD"; + this.lineItems.glassParts.forEach((part, index) => { + if (part.partType === windshieldString) { + let altPartToUse = this.alternateGlassPartsForOem.find( + (altPart) => altPart.partType === windshieldString + ); + if (altPartToUse) { + this.lineItems.glassParts[index] = altPartToUse; + } + } + }); + }, }, components: { funnelHeader, @@ -909,6 +971,7 @@ export default { recalDisclaimer, saveProgressModalQuestion, saveProgressPopupQuestion, + oemGlassQuestion, }, }; diff --git a/src/store/index.js b/src/store/index.js index 6802ddb13..8faf39f73 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -122,6 +122,7 @@ const getDefaultState = () => { capabilityQuestionAnswers: null, dateOfLoss: null, damageCause: null, + installOemGlass: null, }, lineItems: { glassParts: null, @@ -342,6 +343,9 @@ export const mutations = { updateIsRecalAckOptIn(state, isRecalAckOptIn) { state.order.isRecalAckOptIn = isRecalAckOptIn; }, + updateIsOemGlassSelected(state, isOemGlassSelected) { + state.order.damage.installOemGlass = isOemGlassSelected; + }, updateIsMSRFeeApplicable(state, isMSRFeeApplicable) { state.order.isMSRFeeApplicable = isMSRFeeApplicable; }, @@ -712,6 +716,8 @@ export const mutations = { state.order.damage.capabilityQuestionAnswers = sessionInformation.order.damage.capabilityQuestionAnswers; + state.order.damage.installOemGlass = sessionInformation.order.damage.installOemGlass; + state.order.lineItems.glassParts = sessionInformation.order.lineItems.glassParts; state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems; state.order.lineItems.vaps = sessionInformation.order.lineItems.vaps ?? []; @@ -1853,8 +1859,7 @@ export const actions = { const serviceType = order.serviceLocation?.appointmentType; const referralSeqNumber = order.referralSequenceNumber; const parentAccountNumber = applicationConfig.CASH_PARENT_ACCOUNT_NUMBER; - const oemEndorsementFlag = false; // Need to update from the store when available - + const oemEndorsementFlag = order.damage.installOemGlass || false; // create a new array to avoid mutating state const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray); const resultsArrayForPayload = convertResultsForApi(resultsArray); @@ -2453,6 +2458,7 @@ export const actions = { partQuestionAnswers: order.damage.partQuestionAnswers, moldingQuestionAnswers: order.damage.moldingQuestionAnswers, capabilityQuestionAnswers: order.damage.capabilityQuestionAnswers, + installOemGlass: order.damage.installOemGlass, }, lineItems: { glassParts: lineItems.glassParts, @@ -2959,6 +2965,10 @@ export const actions = { context.commit(storeMutations.UPDATE_IS_RECAL_ACK_OPT_IN, isRecalAckOptIn); }, + saveIsOemGlassSelected(context, isOemGlassSelected) { + context.commit(storeMutations.UPDATE_IS_OEM_GLASS_SELECTED, isOemGlassSelected); + }, + saveIsMSRFeeApplicable(context, isMSRFeeApplicable) { context.commit(storeMutations.UPDATE_IS_MSR_FEE_APPLICABLE, isMSRFeeApplicable); },