diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index ef5459395..71c782856 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -33,6 +33,7 @@ const errorMessages = { MAKE_REQUIRED: "Please select your vehicle make", MODEL_REQUIRED: "Please select your vehicle model", STYLE_REQUIRED: "Please select your vehicle style", + PROMO_REQUIRED: "Please enter a promo code", }; export { errorMessages }; diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index a44ef3c07..afb13c0e1 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -221,15 +221,15 @@ export default { let cartItem = null; cartItem = { - name: promoLineItem.promoCode, + name: promoLineItem?.promoCode, // get from CMS? category: cartItemCategories.PROMOS, - cartItemType: promoLineItem.partType, + cartItemType: promoLineItem?.partType, isDisplayed: true, subTotal: - (promoLineItem.kitPrice ?? 0) + - (promoLineItem.laborAmount ?? 0) + - (promoLineItem.sellingPrice ?? 0), - salesTax: promoLineItem.salesTax, + (promoLineItem?.kitPrice ?? 0) + + (promoLineItem?.laborAmount ?? 0) + + (promoLineItem?.sellingPrice ?? 0), + salesTax: promoLineItem?.salesTax, lineItems: [], }; diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 98409e3e7..0d6f338bb 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -30,6 +30,13 @@ recyclingModalCmsWidgetName="RecycleModal" />
+
diff --git a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue new file mode 100644 index 000000000..91388396b --- /dev/null +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue @@ -0,0 +1,276 @@ + + + diff --git a/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.spec.js b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.spec.js new file mode 100644 index 000000000..97a4346ad --- /dev/null +++ b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.spec.js @@ -0,0 +1,40 @@ +import { shallowMount } from "@vue/test-utils"; +import promoQuestion from "./promo-question"; + +describe("promo-question.vue", () => { + it("Should get the modelValue", async () => { + // Arrange + const text = "test"; + const wrapper = shallowMount(promoQuestion, { + props: { + modelValue: text, + }, + attachTo: document.body, + }); + + // Act + const modelValueText = wrapper.vm.value; + wrapper.vm.value = "test also"; + + // Assert + expect(modelValueText).toEqual("test"); + }); + + it("Should emit to set value", async () => { + // Arrange + const text = "test"; + const wrapper = shallowMount(promoQuestion, { + props: { + modelValue: text, + }, + attachTo: document.body, + }); + + // Act + const modelValueText = wrapper.vm.value; + wrapper.vm.value = "test also"; + + // Assert + expect(wrapper.emitted("update:modelValue")).toEqual([["test also"]]); + }); +}); diff --git a/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue new file mode 100644 index 000000000..25744e652 --- /dev/null +++ b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue @@ -0,0 +1,45 @@ + + + diff --git a/src/store/index.js b/src/store/index.js index e8edb1ed2..4b4c4ca6d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2122,6 +2122,7 @@ export const actions = { }, // COMBINE THESE savePromos(context, promos) { + addGuidToLineItemsIfNotAlreadyThere(promos); context.commit(storeMutations.UPDATE_PROMOS, promos); }, saveInactivePromos(context, inactivePromos) { @@ -2805,7 +2806,7 @@ function renameGlassToReplaceAttributes(glassToReplace) { } function addGuidToLineItemsIfNotAlreadyThere(lineItems) { - lineItems.forEach((lineItem) => { + lineItems?.forEach((lineItem) => { if (!lineItem.id) { lineItem.id = crypto.randomUUID(); }