diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index baa219aa1..e7cb38953 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -27,6 +27,7 @@ const storeActions = { GET_RAIN_DEFENSE: "getRainDefense", GET_SUPPORTING_ITEMS: "getSupportingItems", GET_CAPABILITY_QUESTIONS: "getCapabilityQuestions", + SUBMIT_DONATION_PART_TO_SV2: "submitDonationPartToSV2", GET_PART_FROM_CAPABILITY_QUESTION_ANSWER: "getPartFromCapabilityQuestionAnswer", GET_MOLDING_QUESTIONS: "getMoldingQuestions", GET_MOBILE_FEE_PART: "getMobileFeePart", diff --git a/src/experiment-components/donation-block.vue b/src/experiment-components/donation-block.vue index 30fca4fd1..c90e6af14 100644 --- a/src/experiment-components/donation-block.vue +++ b/src/experiment-components/donation-block.vue @@ -54,7 +54,7 @@
+ v-html="DonationAddButtonCopy">
@@ -108,7 +108,7 @@ export default { DonationBodySubText() { return this.getCmsContent(this.cmsWidgetName, "BodyText2"); }, - DonationAddButtonWidget() { + DonationAddButtonCopy() { return this.getCmsContent("DonationAddButtonWidget", "Text"); }, DonationThanksAlertWidget() { @@ -126,6 +126,7 @@ export default { }, set: function (newValue) { this.$emit("update:modelValue", newValue); + this.$emit("DonationAddedEvent"); }, }, }, diff --git a/src/layouts/confirmation/confirmation.vue b/src/layouts/confirmation/confirmation.vue index 1a6a4d99e..f6810f726 100644 --- a/src/layouts/confirmation/confirmation.vue +++ b/src/layouts/confirmation/confirmation.vue @@ -71,7 +71,8 @@ v-model="donationAmount" :donationValues="donationValues" :showDonationSuccess="showDonationSuccess" - :showDonationError="showDonationError" /> + :showDonationError="showDonationError" + @DonationAddedEvent="addDonationToOrder" />
@@ -522,61 +523,28 @@ export default { forwardButtonAction() { window.location.assign(location.protocol + "//" + location.host); }, - async addDonation(amount, plateTemp) { - // try to call API to add donation to order - - // TEMP DUMMY CALL TO SIMULATE SUCCESS OR ERROR FROM API CALL - const donationResponse = this.createMockedResponse(amount); + async addDonationToOrder() { + const donationResponse = await baseMixin.methods.dispatchStoreActionWithLogging( + storeActions.SUBMIT_DONATION_PART_TO_SV2, + { + donationAmount: parseInt(this.donationAmount), + submittedOrder: this.submittedOrder, + }, + false + ); + console.log(donationResponse); if (donationResponse?.wasSuccessful) { this.showDonationSuccess = true; this.showDonationError = false; - const donationResponse = await baseMixin.methods.dispatchStoreAction( + await baseMixin.methods.dispatchStoreAction( storeActions.ADD_DONATION_TO_SUBMITTED_ORDER, - amount, + parseInt(this.donationAmount), false ); } else { this.showDonationError = true; this.showDonationSuccess = false; - const donationResponse = await baseMixin.methods.dispatchStoreAction( - storeActions.ADD_DONATION_TO_SUBMITTED_ORDER, - 0, - false - ); - } - }, - //mocked response. should be removed once integrate with actual api call. - createMockedResponse(amount) { - let result; - - switch (amount) { - case 1: - result = { wasSuccessful: true, wasLocked: false }; - break; - case 3: - result = { wasSuccessful: false, wasLocked: true }; - break; - case 5: - result = { wasSuccessful: false, wasLocked: false }; - break; - default: - result = { wasSuccessful: null, wasLocked: null }; // Default case if amount doesn't match - } - - return result; - }, - }, - watch: { - donationAmount(newValue) { - newValue = parseInt(newValue); - - // this.addDonation(newValue); - // TODO - when backend code is final, then remove the below and restore the line above - if (newValue === 5) { - this.addDonation(newValue, "FAILING_PLATE"); // throws error - } else { - this.addDonation(newValue, "2fast"); // should give successful response } }, }, diff --git a/src/store/index.js b/src/store/index.js index bdf6c48a7..13c12cd94 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1892,6 +1892,99 @@ export const actions = { pageNameToLog: pageNameToLog, }); }, + submitDonationPartToSV2( + context, + { payload: { donationAmount, submittedOrder }, pageNameToLog } + ) { + donationAmount = parseInt(donationAmount); + /* Request contract + { + "donationAmount": 5, + "savedSessionId": "96b1a16e-410a-4d08-8421-fe36e82b2275", + "paymentInfo": { + "parentAccountNumber": 167132, + "billToAccountNumber": 87291, + "providerNumber": "005819", + "carId": "CR00069266", + "make": "Acura", + "model": "MDX", + "year": 2020, + "eon": "S1820397", + "zipCode": "43015", + "state": "OH", + "referralNumber": "1821895", + "referralDate": "2025-03-20T16:27:38.93", + "referralSequenceNumber": "1821895", + "serviceZipCode": "43015", + "isReplacement": true, + "deductible": 0, + "coverageStatus": null, + "coverageSubStatus": null, + "serverData": "ZtCNOF1tCLQBAx2NRKHE/n/fqD8zUxRfYtDuTu7uUiPpeg7i6TmwXwggssX5KsXVQbeft+PN+vXYfBFJytLVYgbafNDR0JH3izVTIOh7KGTeB6YaPuCJmodF4SfgVVDHD9LEmEH9wNzM9j3pFjgfXehOFH11SH9dNwTkXIbsGzAeu64DRyJsDdpamM/BPOxlJj60S/R8vnUM8mjyM7B9a63NskFI6BCVIh5mxDE4cSMUgb4zFtwvDgTPxJSwXqKShtoY6ryB8n5UPNkG/Z5tjVuJ7/8RV7WrURM7PN7xLfp6pVEeipWyeFnVEK33G9JOuB6yH75jPO6vMCYRNi0p0pg6laasFDy3hmfuy2W/N0qtcJLVa5N0bUMFFuPQusyEeqsEZ/zx1Srlvsk7i0DF8pTyBcm3JTF5BOWm60wg3ntEOqfRuQqzFc5updILwLAIp39CwJG/fs5Mj3HCDcUKwYlK70fAARtJwFu7wI0vqW5bUSUvJkvm1JRPlyWJ8JNY4Oq1apYqhZS9bps5ofgiOYJbBhPEboEnVukoTkQiYjgbMtBwVGKGL2nNEd77osoEg1KXhEQS+0KD3PoUu/bZkGub6FNGE6iKeFPt9gDSs+S21s22rVSaZkgaoC6SkufPpN6aV78Jx69nMIDd4go4pj2IJX4kS1pD1NEOSWjN4bgVKAtV6/bxBvhNJwnqUE+mE8eAmULsezub4LMhPqA58y/ZlO44jt/qkAw9nuVDRPBve+TdJTotID5dIqJJd6/vkDoHTVaSrbkCBbdG6d9By8AEbKuVrQS/+VurUnYEd2TGahPbOyRdNlud8RB4+4af0ZRFmiKkr6ppa5IbHbTIZ2qtyeOSbIOkv8O7xK/GL6e6Iaaz0wDHaQZC4Ea8FczjpFOlQgixfYcYJBb/W2db+uRvZ3lftVyJ/d082CGbYplOa+aTxymVcQSjBRbXzs6GZ2ytDqRYcRe94F9x/XSVj7g+mih7VS+YH0eOEp0ViTuWP8B1dVnOV5yTkdMbr8n9Q82G4v5brtQdiMDMY3HS6mxPb1IiKiqFX6Jgju8sIMxkJFZQ3iIkAJuOqUYkG1ZW7s4uI6hT46bRqzYaQA18CFu56qaMblOBFuxlJIsYsnMePh2xAH89oay5Kc88xwT2T/4+dzYQ0CqhQ4MTBB7nXelav2rMCjaLQ/V/a5r1TnLr2n0GbvODQeNl97qzi5lDYKlnuF8nOfOqZNOsPSsrsk3UZJJYZwNxDZaweHIeeg5P2ZW5agswPx/U5DkU1MzE1VAQ+DQAenaE2SLo4dSPBHMmt2gLpgu0LaCuzTR2IL/EM+Tpdn/Pcv1E7lPJIycIIwO7QGJcVkwCx8CJ/WCo6xDMq+9zjSVbqAaL5MzySZCeFCMyZxvEk7qXig6rflB3K3Jay4qSFjBxBXhOEuT6zKXyhR41IXRtZRmtPkscypFEUXvR5nJV7AQUIbljGEcikOLmSiCEnl8dI2Ny9xCHLOro8UXqVUy8dHGmTRGTE/mS1JNZ3y4XaZSyHcABVWbZcR3KIXVxd6rtUA/pBvWpbq8nH3WWlJGqkoxUVEridtXqcBuzTKg3/i6vLs0/pHGwdM38XizKcIxykvJrur3vEQ==" + } + } + */ + + /* Uncomment and use when endpoint integration is finalized + return globalMethods.callHttpClient({ + method: endpoints.AddDonationPart.method, + endpoint: endpoints.AddDonationPart.url, + payload: { + donationAmount: donationAmount, + savedSessionId: "96b1a16e-410a-4d08-8421-fe36e82b2275", + paymentInfo: { + parentAccountNumber: submittedSessionData.parentAccountNumber, + billToAccountNumber: submittedSessionData.billToAccountNumber, + providerNumber: submittedSessionData.providerNumber, + carId: "CR00069266", + make: "Acura", + model: "MDX", + year: 2020, + eon: "S1820397", + zipCode: "43015", + state: "OH", + referralNumber: "1821895", + referralDate: "2025-03-20T16:27:38.93", + referralSequenceNumber: "1821895", + serviceZipCode: "43015", + isReplacement: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iMDMY3HS6mxPb1IiKiqFX6Jgju8sIMxkJFZQ3iIkAJuOqUYkG1ZW7s4uI6hT46bRqzYaQA18CFu56qaMblOBFuxlJIsYsnMePh2xAH89oay5Kc88xwT2T/4+dzYQ0CqhQ4MTBB7nXelav2rMCjaLQ/V/a5r1TnLr2n0GbvODQeNl97qzi5lDYKlnuF8nOfOqZNOsPSsrsk3UZJJYZwNxDZaweHIeeg5P2ZW5agswPx/U5DkU1MzE1VAQ+DQAenaE2SLo4dSPBHMmt2gLpgu0LaCuzTR2IL/EM+Tpdn/Pcv1E7lPJIycIIwO7QGJcVkwCx8CJ/WCo6xDMq+9zjSVbqAaL5MzySZCeFCMyZxvEk7qXig6rflB3K3Jay4qSFjBxBXhOEuT6zKXyhR41IXRtZRmtPkscypFEUXvR5nJV7AQUIbljGEcikOLmSiCEnl8dI2Ny9xCHLOro8UXqVUy8dHGmTRGTE/mS1JNZ3y4XaZSyHcABVWbZcR3KIXVxd6rtUA/pBvWpbq8nH3WWlJGqkoxUVEridtXqcBuzTKg3/i6vLs0/pHGwdM38XizKcIxykvJrur3vEQ==" + } + }, + logApiCall: true, + pageNameToLog: pageNameToLog, + }); + */ + + /* Response contract + { + "wasSuccessful": true, + "wasLocked": true + } + */ + let result; + + + + switch (donationAmount) { + case 1: + result = { wasSuccessful: true, wasLocked: false }; + break; + case 3: + result = { wasSuccessful: false, wasLocked: true }; + break; + case 5: + result = { wasSuccessful: false, wasLocked: false }; + break; + default: + result = { wasSuccessful: null, wasLocked: null }; // Default case if amount doesn't match + } + + return result; + }, getPartFromCapabilityQuestionAnswer(context, { payload, pageNameToLog }) { const glassLocation = payload;