diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 3bc5a3069..f738e707c 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -72,7 +72,7 @@ const endpoints = { url: "/parts/api/v1/parts/mobile-fee", method: "GET", }, - CashServicePackageDiscount: { + GetServicePackageDiscountPart: { url: "/parts/api/v1/parts/service-package-discount", method: "POST", }, diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 4ff481e64..bd772cafe 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -29,7 +29,7 @@ const storeActions = { GET_PART_FROM_CAPABILITY_QUESTION_ANSWER: "getPartFromCapabilityQuestionAnswer", GET_MOLDING_QUESTIONS: "getMoldingQuestions", GET_MOBILE_FEE_PART: "getMobileFeePart", - CASH_SERVICE_PACKAGE_DISCOUNT: "cashServicePackageDiscount", + GET_SERVICE_PACKAGE_DISCOUNT_PART: "getServicePackageDiscountPart", GET_SERVICEABILITY_DETAILS: "getServiceabilityDetails", GET_SHOP_TIME_SLOTS: "getShopTimeSlots", GET_MOBILE_TIME_SLOTS: "getMobileTimeSlots", diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index 74b856498..ca7037d4f 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -229,7 +229,7 @@ export default { const servicePackageDiscountLineItems = this.servicePackageDiscountCartItem; let subTotal = 0; - subTotal += servicePackageDiscountLineItems?.subTotal; + subTotal += servicePackageDiscountLineItems?.subTotal ?? 0; return subTotal; }, getVapsCartItemsForSelectedPackage(packageName) { @@ -272,7 +272,7 @@ export default { getLineItemAmount(amount, useVerifyingText, category) { if (useVerifyingText) return this.verifyingCoverageText; - return category == ("promos" && "servicePackageDiscount") + return category == "promos" || category == "servicePackageDiscount" ? "(" + this.currencyFormatter.format(amount * -1) + ")" : this.currencyFormatter.format(amount); }, @@ -825,11 +825,8 @@ export default { otherSupportingItemsCartItem() { let cartItem = null; - const servicePackageDiscountLineItem = this.supportingItems.find( - (lineItem) => lineItem.partType == partTypeStrings.SERVICE_PACKAGE_DISCOUNT - ); const otherSupportingItems = this.supportingItems.filter((item) => { - return item != servicePackageDiscountLineItem; + return item.partType != partTypeStrings.SERVICE_PACKAGE_DISCOUNT; }); // Don't include fees they are part of the package total let otherSupportingItemsLineItems = diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index a09b18bdc..21f1863d9 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -166,11 +166,12 @@ export default { if (isServicePackageDiscount) { const servicePackageDiscountPartResponse = await baseMixin.methods.dispatchStoreActionWithLogging( - storeActions.CASH_SERVICE_PACKAGE_DISCOUNT, + storeActions.GET_SERVICE_PACKAGE_DISCOUNT_PART, null, "quote" ); - servicePackageDiscountPart.push(servicePackageDiscountPartResponse.data); + if (servicePackageDiscountPartResponse.data) + servicePackageDiscountPart.push(servicePackageDiscountPartResponse.data); } const availableLineItems = [ resultMap.rainDefense, @@ -296,8 +297,8 @@ export default { vapsItemsSelectedAction(vapsItemsSelected) { this.lineItems.vaps = vapsItemsSelected; }, - servicePackageDiscountSelectedAction(servicePackageDiscountSelected) { - this.lineItems.supportingItems = servicePackageDiscountSelected; + servicePackageDiscountSelectedAction(supportingItemsSelected) { + this.lineItems.supportingItems = supportingItemsSelected; }, backButtonAction() { vehicleQuestionsMixin.methods.navigateBack(this); diff --git a/src/layouts/quote/service-package-question/service-package-question.vue b/src/layouts/quote/service-package-question/service-package-question.vue index c9e55ef3e..e77cdfb19 100644 --- a/src/layouts/quote/service-package-question/service-package-question.vue +++ b/src/layouts/quote/service-package-question/service-package-question.vue @@ -121,6 +121,7 @@ export default { buttonLabel: this.getHeaderTextFromCms(answer.SubWidgetName), buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.SubWidgetName), buttonBodyCopy: this.getBodyTextFromCms(answer.SubWidgetName), + //The package supports service-package-discount if it has the text value in CMS buttonAuxillaryCopy: this.getDiscountedPackagePriceString( answer.Name, this.isServicePackageDiscountOnOrder && answer.Text != "" diff --git a/src/store/index.js b/src/store/index.js index 90874f4d6..3ccfa4c01 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1422,15 +1422,15 @@ export const actions = { pageNameToLog: pageNameToLog, }); }, - cashServicePackageDiscount(context, { pageNameToLog }) { + getServicePackageDiscountPart(context, { pageNameToLog }) { const damage = context.getters.damage; const damageType = damage.isRepair ? "Repair" : "Replace"; const glassPieces = convertGlassPieceNamingForApi(damage.glassToReplace); return globalMethods .callHttpClient({ - method: endpoints.CashServicePackageDiscount.method, - endpoint: endpoints.CashServicePackageDiscount.url, + method: endpoints.GetServicePackageDiscountPart.method, + endpoint: endpoints.GetServicePackageDiscountPart.url, payload: { glassPieces: glassPieces, damageType: damageType,