Adding mocked response for the api call to display error and success message.
This commit is contained in:
hiteshkumar87 2025-03-26 19:52:00 +05:30
parent ab750a4b30
commit 3e551bc7a0

View file

@ -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) {