CASH-133
CASH-133 successfully added a donation to cart on confirmation using mock api call
This commit is contained in:
parent
93f96bdadf
commit
383eb001df
5 changed files with 57 additions and 8 deletions
|
|
@ -11,6 +11,7 @@ const cartItemTypes = {
|
|||
EARLY_BIRD: "EARLY BIRD",
|
||||
SUPPLIES_REPAIR: "SUPPLIES-REPAIR",
|
||||
SERVICE_PACKAGE_DISCOUNT: "SERVICE PACKAGE DISCOUNT",
|
||||
DONATION: "DONATION",
|
||||
};
|
||||
|
||||
export { cartItemTypes };
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ const partTypeStrings = {
|
|||
REPAIR_FEE: "REPAIR FEE",
|
||||
EARLY_BIRD: "EARLY BIRD",
|
||||
SERVICE_PACKAGE_DISCOUNT: "SERVICE PACKAGE DISCOUNT",
|
||||
DONATION: "DONATION",
|
||||
};
|
||||
|
||||
export { partTypeStrings };
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ export default {
|
|||
isNoComp: Boolean,
|
||||
isExpandedOnLoad: Boolean,
|
||||
isMSRFeeApplicable: Boolean,
|
||||
donationAmount: Number,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -403,7 +404,9 @@ export default {
|
|||
}
|
||||
return [
|
||||
...(this.lineItems.glassParts ?? []),
|
||||
...(this.lineItems.supportingItems ?? []),
|
||||
...(this.lineItems.supportingItems.filter(
|
||||
(item) => item.partType !== partTypeStrings.DONATION
|
||||
) ?? []),
|
||||
...(this.availableVaps ?? []),
|
||||
];
|
||||
},
|
||||
|
|
@ -466,6 +469,10 @@ export default {
|
|||
});
|
||||
}
|
||||
|
||||
if (this.donationCartItem) {
|
||||
cartItems.push(this.donationCartItem);
|
||||
}
|
||||
|
||||
return cartItems;
|
||||
},
|
||||
},
|
||||
|
|
@ -1064,6 +1071,43 @@ export default {
|
|||
|
||||
return promoCartItems;
|
||||
},
|
||||
showDonationCartItem() {
|
||||
if (this.donationAmount !== 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
donationCartItemName() {
|
||||
return this.getCmsContent("DonationCartTextWidget", "Text");
|
||||
},
|
||||
donationCartItem() {
|
||||
if (!this.lineItems || !this.lineItems.supportingItems) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const donationLineItem = this.lineItems.supportingItems.find(
|
||||
(item) => item.partType === partTypeStrings.DONATION
|
||||
);
|
||||
|
||||
if (donationLineItem && donationLineItem.sellingPrice > 0) {
|
||||
return {
|
||||
name: this.donationCartItemName,
|
||||
category: cartItemCategories.SUPPORTING_ITEMS,
|
||||
cartItemType: cartItemTypes.DONATION,
|
||||
isDisplayed: true,
|
||||
isRemovable: false,
|
||||
subTotal: donationLineItem.sellingPrice,
|
||||
salesTax: 0,
|
||||
lineItems: [],
|
||||
isCoveredByInsurance: cartItemTypesCoveredByInsurance.includes(
|
||||
cartItemTypes.DONATION
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
removeLinkText() {
|
||||
return this.getCmsContent("RemoveCartItemTextWidget", "Text");
|
||||
},
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@
|
|||
:isExpandedOnLoad="false"
|
||||
:isItac="isItac"
|
||||
:isNoComp="isNoComp"
|
||||
:isMSRFeeApplicable="isMSRFeeApplicable" />
|
||||
:isMSRFeeApplicable="isMSRFeeApplicable"
|
||||
:donationAmount="donationAmount"
|
||||
@update-donation-amount="updateDonationAmount" />
|
||||
|
||||
<div class="mt-3" v-if="DisplayFosterLove">
|
||||
<donationBlock
|
||||
|
|
@ -532,7 +534,6 @@ export default {
|
|||
},
|
||||
false
|
||||
);
|
||||
console.log(donationResponse);
|
||||
|
||||
if (donationResponse?.wasSuccessful) {
|
||||
this.showDonationSuccess = true;
|
||||
|
|
@ -542,9 +543,11 @@ export default {
|
|||
parseInt(this.donationAmount),
|
||||
false
|
||||
);
|
||||
this.lineItems = deepClone(this.getSubmittedOrder().lineItems);
|
||||
} else {
|
||||
this.showDonationError = true;
|
||||
this.showDonationSuccess = false;
|
||||
this.donationAmount = 0;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3298,16 +3298,16 @@ export const actions = {
|
|||
"running addDonationToSubmittedOrder()... adding donation to supportingItems in session storage "
|
||||
);
|
||||
submittedOrder.lineItems.supportingItems.push({
|
||||
partNumber: "DONATION",
|
||||
description: null,
|
||||
partType: "DONATION",
|
||||
partNumber: `DONATION_${donationAmount}`,
|
||||
description: `DONATION $${donationAmount}`,
|
||||
partType: partTypeStrings.DONATION,
|
||||
isInsurable: false,
|
||||
isChildPart: false,
|
||||
laborAmount: 0,
|
||||
sellingPrice: donationAmount,
|
||||
kitPrice: 0,
|
||||
salesTax: null,
|
||||
id: "donation-" + donationAmount,
|
||||
salesTax: 0,
|
||||
id: `donation-${donationAmount}`,
|
||||
});
|
||||
} else {
|
||||
// filter out all donations
|
||||
|
|
|
|||
Loading…
Reference in a new issue