refactor cart to use submittedOrder values on order-confirmation page
This commit is contained in:
parent
5e3fe33414
commit
4c6cd78e62
1 changed files with 38 additions and 125 deletions
|
|
@ -59,7 +59,7 @@
|
|||
<div class="py-1 d-flex justify-content-between align-items-center">
|
||||
<span>{{ item?.name ?? '' }}</span>
|
||||
<textLink
|
||||
v-if="!readOnly || !showAsPaid"
|
||||
v-if="!readOnly"
|
||||
linkType="text"
|
||||
text="Remove"
|
||||
href="javascript:void(0)"
|
||||
|
|
@ -196,36 +196,20 @@ export default {
|
|||
computed: {
|
||||
deductible() {
|
||||
// Note: added as computed so it can be used in the template.
|
||||
if (this.submittedOrder) {
|
||||
return this.submittedOrder.currentDeductible;
|
||||
}
|
||||
return useMainStore().order.currentDeductible;
|
||||
return this.submittedOrder ? this.submittedOrder.currentDeductible : useMainStore().order.currentDeductible;
|
||||
},
|
||||
showDeductibleCartItem() {
|
||||
if (this.submittedOrder) {
|
||||
return this.submittedOrder.policy.noCoverage === false && this.submittedOrder.policy.isITAC === false;
|
||||
}
|
||||
return !useMainStore().isNoComp && !useMainStore().isITAC;
|
||||
return !this.isNoComp && !this.isITAC;
|
||||
},
|
||||
lineItems() {
|
||||
return this.submittedOrder ? this.submittedOrder.lineItems : useMainStore().lineItems;
|
||||
},
|
||||
recycleFeeLineItem() {
|
||||
if (this.submittedOrder) {
|
||||
return this.submittedOrder.lineItems.supportingItems
|
||||
?.find((lineItem) => lineItem.partNumber === partNumberStrings.RECYCLE_FEE);
|
||||
}
|
||||
return useMainStore().lineItems.supportingItems
|
||||
return this.lineItems.supportingItems
|
||||
?.find((lineItem) => lineItem.partNumber === partNumberStrings.RECYCLE_FEE);
|
||||
},
|
||||
baseServiceLineItems() {
|
||||
if (this.submittedOrder) {
|
||||
const { supportingItems, glassParts, otherParts } = this.submittedOrder.lineItems;
|
||||
const parts = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
...(otherParts ?? [])
|
||||
];
|
||||
return parts.filter((part) => part !== this.recycleFeeLineItem);
|
||||
}
|
||||
const { supportingItems, glassParts, otherParts } = useMainStore().lineItems;
|
||||
const { supportingItems, glassParts, otherParts } = this.lineItems;
|
||||
const parts = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
|
|
@ -236,29 +220,21 @@ export default {
|
|||
baseServicePrice() {
|
||||
return getPriceOfLineItems(this.baseServiceLineItems) ?? 0;
|
||||
},
|
||||
isVerified() {
|
||||
return this.submittedOrder ? this.submittedOrder.payment.isVerified : useMainStore().isVerifiedCoverageStatus;
|
||||
},
|
||||
isUnverified() {
|
||||
if (this.submittedOrder) {
|
||||
return this.submittedOrder.policy.noCoverage === false && this.submittedOrder.policy.isITAC === false
|
||||
&& (this.submittedOrder.currentDeductible == null || this.submittedOrder.payment.isVerified === false);
|
||||
} return !useMainStore().isNoComp && !useMainStore().isITAC
|
||||
&& (this.deductible == null || !useMainStore().isVerifiedCoverageStatus);
|
||||
return !this.isNoComp && !this.isITAC
|
||||
&& (this.deductible == null || this.isUnverified);
|
||||
},
|
||||
isITAC() {
|
||||
return this.submittedOrder ? this.submittedOrder.policy.isITAC : useMainStore().isITAC;
|
||||
},
|
||||
isNoComp() {
|
||||
return this.submittedOrder ? this.submittedOrder.policy.noCoverage : useMainStore().isNoComp;
|
||||
},
|
||||
subTotal() {
|
||||
if (this.submittedOrder) {
|
||||
const { supportingItems, glassParts, otherParts, vaps, mobileFee } = this.submittedOrder.lineItems;
|
||||
const allLineItems = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
...(otherParts ?? []),
|
||||
...(vaps ?? []),
|
||||
mobileFee
|
||||
];
|
||||
return this.submittedOrder.policy.noCoverage === false && this.submittedOrder.policy.isITAC === false
|
||||
? this.deductible + getPriceOfLineItems([...this.feeLineItems, ...(vaps ?? [])])
|
||||
: getPriceOfLineItems(allLineItems);
|
||||
}
|
||||
|
||||
const { supportingItems, glassParts, otherParts, vaps, mobileFee } = useMainStore().lineItems;
|
||||
const { supportingItems, glassParts, otherParts, vaps, mobileFee } = this.lineItems;
|
||||
const allLineItems = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
|
|
@ -266,23 +242,12 @@ export default {
|
|||
...(vaps ?? []),
|
||||
mobileFee
|
||||
];
|
||||
return !useMainStore().isNoComp && !useMainStore().isITAC
|
||||
return !this.isNoComp && !this.isITAC
|
||||
? this.deductible + getPriceOfLineItems([...this.feeLineItems, ...(vaps ?? [])])
|
||||
: getPriceOfLineItems(allLineItems);
|
||||
},
|
||||
feeLineItems() {
|
||||
if (this.submittedOrder) {
|
||||
const { mobileFee } = this.submittedOrder.lineItems;
|
||||
const result = [];
|
||||
if (mobileFee) {
|
||||
result.push(mobileFee);
|
||||
}
|
||||
if (this.recycleFeeLineItem) {
|
||||
result.push(this.recycleFeeLineItem);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const { mobileFee } = useMainStore().lineItems;
|
||||
const { mobileFee } = this.lineItems;
|
||||
const result = [];
|
||||
if (mobileFee) {
|
||||
result.push(mobileFee);
|
||||
|
|
@ -299,21 +264,8 @@ export default {
|
|||
|
||||
let result = 0;
|
||||
|
||||
if (this.submittedOrder) {
|
||||
if (this.submittedOrder.payment.insuranceCoverage.isVerified) {
|
||||
if (this.submittedOrder.policy.isITAC || this.submittedOrder.policy.noCoverage) {
|
||||
result += sumTax(this.baseServiceLineItems);
|
||||
} else {
|
||||
// deductible-case need to show tax for Recycle Fee
|
||||
result += this.recycleFeeLineItem?.salesTax ?? 0;
|
||||
}
|
||||
}
|
||||
result += sumTax(this.submittedOrder.lineItems.vaps ?? []);
|
||||
|
||||
return result;
|
||||
}
|
||||
if (useMainStore().payment.insuranceCoverage.isVerified) {
|
||||
if (useMainStore().isITAC || useMainStore().isNoComp) {
|
||||
if (this.isVerified) {
|
||||
if (this.isITAC || this.isNoComp) {
|
||||
result += sumTax(this.baseServiceLineItems);
|
||||
} else {
|
||||
// deductible-case need to show tax for Recycle Fee
|
||||
|
|
@ -321,7 +273,7 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
result += sumTax(useMainStore().lineItems.vaps ?? []);
|
||||
result += sumTax(this.lineItems.vaps ?? []);
|
||||
|
||||
return result;
|
||||
},
|
||||
|
|
@ -331,20 +283,7 @@ export default {
|
|||
: this.subTotal + this.salesTax;
|
||||
},
|
||||
availableLineItems() {
|
||||
if (this.submittedOrder) {
|
||||
const { supportingItems, glassParts, otherParts, mobileFee } = this.submittedOrder.lineItems;
|
||||
const result = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
...(otherParts ?? []),
|
||||
...(this.availableVaps ?? [])
|
||||
];
|
||||
if (mobileFee) {
|
||||
result.push(mobileFee);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const { supportingItems, glassParts, otherParts, mobileFee } = useMainStore().lineItems;
|
||||
const { supportingItems, glassParts, otherParts, mobileFee } = this.lineItems;
|
||||
const result = [
|
||||
...(supportingItems ?? []),
|
||||
...(glassParts ?? []),
|
||||
|
|
@ -356,19 +295,12 @@ export default {
|
|||
}
|
||||
return result;
|
||||
},
|
||||
vehicleDamage() {
|
||||
return this.submittedOrder ? this.submittedOrder.damage : useMainStore().damage;
|
||||
},
|
||||
servicePackageTier() {
|
||||
if (this.submittedOrder) {
|
||||
const { glassToReplace, isRepair } = this.submittedOrder.damage;
|
||||
const { vaps } = this.submittedOrder.lineItems;
|
||||
return getHighestFullySatisfiedTier(
|
||||
glassToReplace ?? [],
|
||||
this.availableLineItems,
|
||||
isRepair,
|
||||
vaps ?? []
|
||||
);
|
||||
}
|
||||
const { glassToReplace, isRepair } = useMainStore().damage;
|
||||
const { vaps } = useMainStore().lineItems;
|
||||
const { glassToReplace, isRepair } = this.vehicleDamage;
|
||||
const { vaps } = this.lineItems;
|
||||
return getHighestFullySatisfiedTier(
|
||||
glassToReplace ?? [],
|
||||
this.availableLineItems,
|
||||
|
|
@ -377,7 +309,7 @@ export default {
|
|||
);
|
||||
},
|
||||
partTypesInServicePackage() {
|
||||
const { glassToReplace, isRepair } = useMainStore().damage;
|
||||
const { glassToReplace, isRepair } = this.vehicleDamage;
|
||||
return getPackageContents(
|
||||
glassToReplace ?? [],
|
||||
this.availableLineItems,
|
||||
|
|
@ -399,7 +331,7 @@ export default {
|
|||
return items;
|
||||
},
|
||||
nonServicePackageCartItems() {
|
||||
const vapPartTypesInOrder = Array.from(new Set(useMainStore().lineItems.vaps?.map((vap) => vap.partType) ?? []));
|
||||
const vapPartTypesInOrder = Array.from(new Set(this.lineItems.vaps?.map((vap) => vap.partType) ?? []));
|
||||
const vapPartTypesInOrderButNotPackage = vapPartTypesInOrder
|
||||
.filter((partType) => !this.partTypesInServicePackage.includes(partType))
|
||||
?? [];
|
||||
|
|
@ -455,16 +387,10 @@ export default {
|
|||
return this.getCmsContent(this.widget.salesTax, widgetFields.TEXT_BLOCK_WIDGET.TEXT);
|
||||
},
|
||||
servicePackageNames() {
|
||||
const test = this.getCmsContent(
|
||||
return this.getCmsContent(
|
||||
this.widget.servicePackage,
|
||||
widgetFields.INPUT_QUESTION_WIDGET.ANSWERS
|
||||
);
|
||||
console.log(test);
|
||||
return test;
|
||||
// return this.getCmsContent(
|
||||
// this.widget.servicePackage,
|
||||
// widgetFields.INPUT_QUESTION_WIDGET.ANSWERS
|
||||
// );
|
||||
},
|
||||
servicePackageLabelWidget() {
|
||||
if (!this.servicePackageNames) {
|
||||
|
|
@ -486,7 +412,7 @@ export default {
|
|||
: null;
|
||||
},
|
||||
mobileFeeCartItem() {
|
||||
const mobileFeeLineItem = useMainStore().lineItems.mobileFee;
|
||||
const mobileFeeLineItem = this.lineItems.mobileFee;
|
||||
return mobileFeeLineItem
|
||||
? this.getCartItem(
|
||||
this.getCmsContent(this.widget.mobileFee, widgetFields.TEXT_BLOCK_WIDGET.TEXT),
|
||||
|
|
@ -505,16 +431,9 @@ export default {
|
|||
this.isExpanded = !this.isExpanded;
|
||||
},
|
||||
getDisplayed(amount) {
|
||||
if (this.submittedOrder) {
|
||||
return this.isUnverified
|
||||
&& this.submittedOrder.policy.noCoverage === false
|
||||
&& this.submittedOrder.policy.isITAC === false
|
||||
? VERIFYING_COVERAGE
|
||||
: formatAmountInDollars(amount);
|
||||
}
|
||||
return this.isUnverified
|
||||
&& !useMainStore().isNoComp
|
||||
&& !useMainStore().isITAC
|
||||
&& !this.isNoComp
|
||||
&& !this.isITAC
|
||||
? VERIFYING_COVERAGE
|
||||
: formatAmountInDollars(amount);
|
||||
},
|
||||
|
|
@ -537,14 +456,8 @@ export default {
|
|||
return cartItem;
|
||||
},
|
||||
getCartItemForVapsPart(partType) {
|
||||
if (this.submittedOrder) {
|
||||
const label = this.getCmsContentForVapsType(partType);
|
||||
const lineItems = this.submittedOrder.lineItems.vaps
|
||||
?.filter((vapsLineItem) => vapsLineItem.partType === partType) ?? [];
|
||||
return this.getCartItem(label, lineItems, cartItemType.VAP, partType);
|
||||
}
|
||||
const label = this.getCmsContentForVapsType(partType);
|
||||
const lineItems = useMainStore().lineItems.vaps
|
||||
const lineItems = this.lineItems.vaps
|
||||
?.filter((vapsLineItem) => vapsLineItem.partType === partType) ?? [];
|
||||
return this.getCartItem(label, lineItems, cartItemType.VAP, partType);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue