From 3e551bc7a095ae7565c0767f9bdd421ad02ca527 Mon Sep 17 00:00:00 2001 From: hiteshkumar87 Date: Wed, 26 Mar 2025 19:52:00 +0530 Subject: [PATCH] CASH-134 Adding mocked response for the api call to display error and success message. --- src/layouts/confirmation/confirmation.vue | 32 ++++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/layouts/confirmation/confirmation.vue b/src/layouts/confirmation/confirmation.vue index 8c4d6cf1a..1a6a4d99e 100644 --- a/src/layouts/confirmation/confirmation.vue +++ b/src/layouts/confirmation/confirmation.vue @@ -526,17 +526,9 @@ export default { // try to call API to add donation to order // TEMP DUMMY CALL TO SIMULATE SUCCESS OR ERROR FROM API CALL - // TO BE REPLACED BY REAL CALL LATER - const donationResponse = await this.dispatchStoreActionWithLogging( - storeActions.LOOKUP_VIN_BY_PLATE, - { licensePlate: plateTemp, licenseState: "OH" }, - "test", - false - ).catch((error) => { - return error; - }); + const donationResponse = this.createMockedResponse(amount); - if (donationResponse?.status == "200") { + if (donationResponse?.wasSuccessful) { this.showDonationSuccess = true; this.showDonationError = false; const donationResponse = await baseMixin.methods.dispatchStoreAction( @@ -554,6 +546,26 @@ export default { ); } }, + //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) {