Check for windshield damage before adding section to block

This commit is contained in:
Chloe Herd 2023-06-15 09:36:21 -04:00
parent b5c5fa2a6c
commit 8451523a24

View file

@ -7,6 +7,7 @@
<script>
import reviewBlock from "@/layouts/review/review-block/review-block";
import { damageLocationsSelected } from "@/constants/damage-locations-selected.js";
export default {
name: "damage-review",
@ -24,13 +25,29 @@ export default {
},
computed: {
displayContent() {
return [
this.damage.isRepair
? `Windshield repair - ${this.damage.numberOfChips} chip${
this.damage.numberOfChips !== 1 ? "s" : ""
}`
: "Windshield crack",
];
let linesToDisplay = [];
if (this.hasWindshieldDamage) {
linesToDisplay.push(this.windshieldString);
}
return linesToDisplay;
},
hasWindshieldDamage() {
return (
this.damage.isRepair ||
this.damage.glassToReplace?.some(
(glass) => glass.glassLocation === damageLocationsSelected.WINDSHIELD
)
);
},
windshieldString() {
if (this.damage.isRepair) {
return `Windshield repair - ${this.damage.numberOfChips} chip${
this.damage.numberOfChips !== 1 ? "s" : ""
}`;
} else {
return "Windshield crack";
}
},
},
components: {