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/helpers/promotions-helper.js b/src/helpers/promotions-helper.js index d18a4aa17..996ca1aa6 100644 --- a/src/helpers/promotions-helper.js +++ b/src/helpers/promotions-helper.js @@ -16,7 +16,7 @@ export const addableVapsPromoPartNumbers = [ promoPartNumberStrings.WIPER_DISCOUNT_PART_NUMBER, ]; -const promoErrorCodes = { +export const promoErrorCodes = { UNKNOWN: "Unknown", PROMO_NOT_YET_IN_USE: "PromoNotYetInUse", PROMO_USAGE_COUNT_EXCEEDED: "PromoUsageCountExceeded", diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 98409e3e7..5dc83bbe0 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -2,8 +2,8 @@
-
-
+
+
@@ -30,6 +30,12 @@ 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..db04dfb00 --- /dev/null +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue @@ -0,0 +1,268 @@ + + + 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/layouts/payment-pia-return/payment-pia-return.vue b/src/layouts/payment-pia-return/payment-pia-return.vue index 54e49c620..8088cbb06 100644 --- a/src/layouts/payment-pia-return/payment-pia-return.vue +++ b/src/layouts/payment-pia-return/payment-pia-return.vue @@ -131,6 +131,7 @@ export default { } this.$refs.loadingModal.isModalVisible = false; + await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_ORDER); this.$router.navigateWithoutSaving(this.navigationScenarios.PIA_SUCCESS, this.$route); }, forwardButtonAction() { diff --git a/src/router/index.js b/src/router/index.js index cec3ff193..f7ff73a94 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -169,7 +169,16 @@ router.beforeEach(async (to, from, next) => { showFmgLoadingModal(true); } - next(); + const toQueryPage = to.query?.fmgPage; + const notToPIAReturn = toQueryPage != "payment-pia-return"; + const isInIframe = window !== window.top; + + if (isInIframe && notToPIAReturn) { + const newUrl = `${window.top.location.origin}${to.href}`; + window.top.location.href = newUrl; + } else { + next(); + } }); router.afterEach(async (to, from) => { 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(); }