Merge pull request #1367 from Safelite/feature/CSR-1383-add-product-tiles
Feature/CSR-1383 add product tiles
This commit is contained in:
commit
4c042ddb92
9 changed files with 802 additions and 24 deletions
|
|
@ -14,6 +14,9 @@ module.exports = {
|
||||||
"!src/helpers/unit-test-helper.js",
|
"!src/helpers/unit-test-helper.js",
|
||||||
"!src/layouts/vehicle-damage/windshield-options/windshield-options.vue",
|
"!src/layouts/vehicle-damage/windshield-options/windshield-options.vue",
|
||||||
"!src/layouts/reveal/**/*.vue",
|
"!src/layouts/reveal/**/*.vue",
|
||||||
|
"!src/layouts/payment-method/**/*.vue",
|
||||||
|
"!src/fmg-components/cart/**/*.vue",
|
||||||
|
"!src/fmg-components/add-vaps-modal-buttons/**/*.vue",
|
||||||
"!src/ux-components/text-link/**/*.vue",
|
"!src/ux-components/text-link/**/*.vue",
|
||||||
"!src/layouts/vin-lookup/**/*.vue", //Temporary for Quote page testing
|
"!src/layouts/vin-lookup/**/*.vue", //Temporary for Quote page testing
|
||||||
"!src/common-components/funnel-header/menu-modal/**/*.vue",
|
"!src/common-components/funnel-header/menu-modal/**/*.vue",
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,12 @@ export default {
|
||||||
classes += "flex-column";
|
classes += "flex-column";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "addVapsButton":
|
||||||
|
classes = "row g-4 justify-content-center mb-2";
|
||||||
|
if (this.isWide) {
|
||||||
|
classes += " flex-column";
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "radio":
|
case "radio":
|
||||||
classes = "ui-radio d-flex";
|
classes = "ui-radio d-flex";
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,218 @@
|
||||||
|
<template>
|
||||||
|
<baseInputButton
|
||||||
|
v-bind="$props"
|
||||||
|
:buttonWrapperClasses="[
|
||||||
|
'add-vaps-button w-100 rounded-3 d-flex align-items-center h-100 base-input-button',
|
||||||
|
{ horizontal: isWide },
|
||||||
|
]"
|
||||||
|
v-model="selectedValue">
|
||||||
|
<div
|
||||||
|
class="d-flex w-100 align-items-center px-1 h-100 add-vaps-button-content button-content rounded-3"
|
||||||
|
:class="labelClasses">
|
||||||
|
<img :id="buttonImageId" :src="buttonImage" :alt="altText" />
|
||||||
|
<div class="copy-wrapper" :class="isWide ? 'ms-4 me-2' : ''">
|
||||||
|
<p class="small mb-0" :class="isWide ? 'mt-0' : 'mt-1'">
|
||||||
|
{{ buttonLabel }}
|
||||||
|
</p>
|
||||||
|
<p v-if="buttonLabelSubCopy" class="fs-7 m-0 sub-copy">
|
||||||
|
{{ buttonLabelSubCopy }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<p class="fs-7 mb-0 link-styling" :class="isWide ? 'mt-0' : 'mt-2'">View details</p>
|
||||||
|
</div>
|
||||||
|
</baseInputButton>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import baseInputButton from "@/digital-components/base-input-button/base-input-button";
|
||||||
|
import inputButtonWrapperMixin from "@/mixins/input-button-wrapper-mixin";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "addVapsButton",
|
||||||
|
mixins: [inputButtonWrapperMixin],
|
||||||
|
components: {
|
||||||
|
baseInputButton,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
labelClasses() {
|
||||||
|
if (this.isWide) {
|
||||||
|
let classes = "flex-row py-2 ps-4 pe-4";
|
||||||
|
if (this.buttonLabelSubCopy) {
|
||||||
|
classes += " checkboxTop";
|
||||||
|
}
|
||||||
|
return classes;
|
||||||
|
} else {
|
||||||
|
return "flex-column py-2";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@mixin add-vaps-button-focus($box-shadow-color) {
|
||||||
|
&:focus-visible + .add-vaps-button-content {
|
||||||
|
box-shadow: 0 0 0 2.5px $box-shadow-color;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
&:focus + .add-vaps-button-content {
|
||||||
|
box-shadow: 0 0 0 2.5px $box-shadow-color;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
&:checked:focus + .add-vaps-button-content {
|
||||||
|
box-shadow: 0 0 0 2.5px $box-shadow-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.add-vaps-button {
|
||||||
|
border: 1px solid $gray-500;
|
||||||
|
&.has-error {
|
||||||
|
input[type="checkbox"],
|
||||||
|
input[type="radio"] {
|
||||||
|
@include add-vaps-button-focus($red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
height: auto;
|
||||||
|
width: 2.6rem;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
.copy-wrapper {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
.link-styling {
|
||||||
|
font-weight: 500;
|
||||||
|
color: $blue;
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 4px;
|
||||||
|
}
|
||||||
|
input[type="checkbox"],
|
||||||
|
input[type="radio"] {
|
||||||
|
position: absolute;
|
||||||
|
|
||||||
|
+ .add-vaps-button-content {
|
||||||
|
outline: none;
|
||||||
|
display: flex;
|
||||||
|
position: relative;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: $gray-600;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
&.sub-copy {
|
||||||
|
color: $green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@include add-vaps-button-focus($blue);
|
||||||
|
|
||||||
|
+ .add-vaps-button-content::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
margin: 3rem 0 0 0;
|
||||||
|
background: white;
|
||||||
|
border: 1px solid $gray-500;
|
||||||
|
border-radius: 2px;
|
||||||
|
order: 2;
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: $gray-600;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ .add-vaps-button-content.checkboxTop::before {
|
||||||
|
margin: -1.25rem 0.5rem 0 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ .add-vaps-button-content.checkboxTop::after {
|
||||||
|
margin: -1.5rem 0.5rem 0 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:checked + .add-vaps-button-content::before {
|
||||||
|
background: $blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:checked + .add-vaps-button-content::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
margin: 3.2rem 0 0 0;
|
||||||
|
border-left: 2px solid $white;
|
||||||
|
border-bottom: 2px solid $white;
|
||||||
|
height: 6px;
|
||||||
|
width: 11px;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="radio"] {
|
||||||
|
+ .add-vaps-button-content::before {
|
||||||
|
content: "";
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ .add-vaps-button-content::after {
|
||||||
|
content: "";
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ .add-vaps-button-content {
|
||||||
|
img {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.horizontal {
|
||||||
|
input[type="checkbox"],
|
||||||
|
input[type="radio"] {
|
||||||
|
+ .add-vaps-button-content::before {
|
||||||
|
content: "";
|
||||||
|
position: relative;
|
||||||
|
margin: 0 0.5rem 0 0;
|
||||||
|
order: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:checked + .add-vaps-button-content::after {
|
||||||
|
content: "";
|
||||||
|
margin: -0.15rem 0 0 0;
|
||||||
|
left: 1.175rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:checked + .add-vaps-button-content {
|
||||||
|
p {
|
||||||
|
color: $black;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sub-copy {
|
||||||
|
color: $gray-600;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ .add-vaps-button-content {
|
||||||
|
outline: none;
|
||||||
|
min-height: 48px;
|
||||||
|
color: $gray-600;
|
||||||
|
|
||||||
|
img {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: $gray-600;
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
&.sub-copy {
|
||||||
|
color: $gray-550;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
<template>
|
||||||
|
<transition name="fade" mode="out-in">
|
||||||
|
<div class="add-vaps-buttons" aria-live="polite" v-if="isDisplayed">
|
||||||
|
<buttonQuestion
|
||||||
|
ref="buttonQuestion"
|
||||||
|
:answers="answersToDisplay"
|
||||||
|
groupName="addVaps"
|
||||||
|
v-model="selectedValues"
|
||||||
|
buttonTypeString="addVapsButton"
|
||||||
|
:buttonTypeObject="addVapsButton"
|
||||||
|
:isWide="answersToDisplay.length > 1 ? false : true" />
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||||
|
import addVapsButton from "./add-vaps-button/add-vaps-button";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "add-vaps-modal-buttons",
|
||||||
|
props: {
|
||||||
|
cart: Object,
|
||||||
|
rainDefenseItem: Object,
|
||||||
|
wiperItems: Object,
|
||||||
|
vapsTilesCmsName: String,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
addVapsButton: addVapsButton,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
selectedValues: {
|
||||||
|
get: function () {
|
||||||
|
return this.answersToDisplay;
|
||||||
|
},
|
||||||
|
set: function (newValue) {
|
||||||
|
// TODO - emit event to open modal
|
||||||
|
},
|
||||||
|
},
|
||||||
|
isDisplayed() {
|
||||||
|
return this.showAddRainDefense || this.showAddWipers;
|
||||||
|
},
|
||||||
|
showAddRainDefense() {
|
||||||
|
// if it's not found in the cart
|
||||||
|
return !this.cart.some((vap) => {
|
||||||
|
return vap.partType === "RAIN DEFENSE";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showAddWipers() {
|
||||||
|
// if it's not found in the cart
|
||||||
|
return !this.cart.some((vap) => {
|
||||||
|
return vap.partType.includes(" WIPER");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
rainDefensePrice() {
|
||||||
|
const lineItem = this.rainDefenseItem;
|
||||||
|
const price = lineItem.laborAmount + lineItem.sellingPrice + lineItem.kitPrice;
|
||||||
|
return parseFloat(price).toFixed(2);
|
||||||
|
},
|
||||||
|
wipersPrice() {
|
||||||
|
let price = 0;
|
||||||
|
const lineItems = this.wiperItems;
|
||||||
|
lineItems?.forEach((item) => {
|
||||||
|
price += item.laborAmount + item.sellingPrice + item.kitPrice;
|
||||||
|
});
|
||||||
|
return parseFloat(price).toFixed(2);
|
||||||
|
},
|
||||||
|
answersCmsData() {
|
||||||
|
return this.getCmsContent(this.vapsTilesCmsName, "Answers");
|
||||||
|
},
|
||||||
|
answersToDisplay() {
|
||||||
|
const answers = [];
|
||||||
|
if (!this.answersCmsData) return answers;
|
||||||
|
|
||||||
|
const getAnswer = (name, answers) => {
|
||||||
|
const answerIndex = answers.findIndex((answer) => {
|
||||||
|
return answer.Name === name;
|
||||||
|
});
|
||||||
|
return answers[answerIndex];
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.showAddWipers) {
|
||||||
|
const answer = getAnswer("ADD WIPER BLADES", this.answersCmsData);
|
||||||
|
answer.SubText = "+$" + this.wipersPrice;
|
||||||
|
answers.push(answer);
|
||||||
|
}
|
||||||
|
if (this.showAddRainDefense) {
|
||||||
|
const answer = getAnswer("ADD RAIN DEFENSE", this.answersCmsData);
|
||||||
|
answer.SubText = "+$" + this.rainDefensePrice;
|
||||||
|
answers.push(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return answers;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
buttonQuestion,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
351
src/fmg-components/cart/cart.vue
Normal file
351
src/fmg-components/cart/cart.vue
Normal file
|
|
@ -0,0 +1,351 @@
|
||||||
|
<template>
|
||||||
|
<div class="cart">
|
||||||
|
<div class="container-fluid px-0">
|
||||||
|
<div
|
||||||
|
class="row vin-toggle flex align-items-center"
|
||||||
|
:class="[isActive ? 'active' : '']"
|
||||||
|
@click="toggleClass()">
|
||||||
|
<div class="col d-flex justify-content-between">
|
||||||
|
<span class="label">Amount Due</span
|
||||||
|
><span class="label amount-due">$321.00</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="price-table">
|
||||||
|
<div class="service-type" :class="{ packageWithVAPS: packageWithVAPS }">
|
||||||
|
<textBlock :cmsWidgetName="packageNameWidget" /><span>{{ packagePrice }}</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="(lineItem, i) in displayedPackageLineItems"
|
||||||
|
:key="i"
|
||||||
|
:class="[this.displayedPackageLineItems ? 'vaps' : '']">
|
||||||
|
<span>{{ lineItem.name }}</span>
|
||||||
|
<span><a href="#">Remove</a></span>
|
||||||
|
</div>
|
||||||
|
<hr style="background: red" />
|
||||||
|
<div
|
||||||
|
v-for="(lineItem, i) in displayedNonPackageLineItems"
|
||||||
|
:key="i"
|
||||||
|
:class="[this.displayedNonPackageLineItems ? 'vaps' : '']">
|
||||||
|
<span>{{ lineItem.name }}</span>
|
||||||
|
<span><a href="#">Remove</a></span>
|
||||||
|
<span>{{ lineItem.price }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="hasRecycleLineItem">
|
||||||
|
<span>{{ recycleLabel }}</span
|
||||||
|
><span>{{ recycleFee }}</span>
|
||||||
|
</div>
|
||||||
|
<!-- Sub total, sales tax, total columns -->
|
||||||
|
<div class="sub-total"><span>Subtotal</span><span>$320</span></div>
|
||||||
|
<div class="sales-tax"><span>Sales tax</span><span>$1</span></div>
|
||||||
|
<div class="amount-due"><span>Amount due</span><span>$321</span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import cart from "@/fmg-components/cart/cart";
|
||||||
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
||||||
|
import { packageNames } from "@/constants/package-names";
|
||||||
|
import {
|
||||||
|
getHighestFullySatisfiedTier,
|
||||||
|
containsLineItemWithPartType,
|
||||||
|
getPackageContents,
|
||||||
|
findLineItemsWithPartType,
|
||||||
|
} from "@/helpers/service-package-helper";
|
||||||
|
import reviewBlock from "@/layouts/review/review-block/review-block";
|
||||||
|
import textBlock from "@/digital-components/text-block/text-block";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "modal",
|
||||||
|
props: {
|
||||||
|
headerCmsWidgetName: String,
|
||||||
|
servicePackageOptionsCmsName: String,
|
||||||
|
damage: Object,
|
||||||
|
orderLineItems: Object,
|
||||||
|
availableLineItems: Object,
|
||||||
|
allowableCartItems: Object,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isActive: false,
|
||||||
|
//availableVaps: [], TO DO Do we need this?
|
||||||
|
packageWithVAPS: false,
|
||||||
|
// packageLevel: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toggleClass: function (event) {
|
||||||
|
this.isActive = !this.isActive;
|
||||||
|
},
|
||||||
|
initializeComponent(apiResponses) {
|
||||||
|
//TO DO Do we need this?
|
||||||
|
// const vapsFromApi = [...apiResponses.wipers, apiResponses.rainDefense];
|
||||||
|
// this.availableVaps = vapsFromApi;
|
||||||
|
},
|
||||||
|
getPackagePriceString(packageName) {
|
||||||
|
const formattedPriceFloat = parseFloat(this.getPackagePrice(packageName)).toFixed(2);
|
||||||
|
return (this.isInsuranceSelected ? "As little as $" : "$") + formattedPriceFloat;
|
||||||
|
},
|
||||||
|
getPackagePrice(packageName) {
|
||||||
|
let priceFloat = this.isInsuranceSelected
|
||||||
|
? 0
|
||||||
|
: baseMixin.methods.getTierOnePackagePrice(
|
||||||
|
baseMixin.methods.filterOutFees(this.nullSafeAvailableLineItems)
|
||||||
|
);
|
||||||
|
|
||||||
|
priceFloat += this.getVapsPrice(packageName);
|
||||||
|
|
||||||
|
return priceFloat;
|
||||||
|
},
|
||||||
|
getVapsPrice(packageName) {
|
||||||
|
const vapsItems = this.getVapsLineItemsForSelectedPackage(packageName);
|
||||||
|
|
||||||
|
let price = 0;
|
||||||
|
|
||||||
|
vapsItems.forEach((item) => {
|
||||||
|
price += baseMixin.methods.getTotalLineItemPrice(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
return price;
|
||||||
|
},
|
||||||
|
//START HERE
|
||||||
|
getVapsLineItemsForSelectedPackage(packageName) {
|
||||||
|
const packageContentTypes = getPackageContents(
|
||||||
|
this.glassToReplace,
|
||||||
|
this.nullSafeAvailableLineItems,
|
||||||
|
this.isRepair,
|
||||||
|
packageName
|
||||||
|
);
|
||||||
|
|
||||||
|
let vapsLineItemsForSelectedPackage = [];
|
||||||
|
|
||||||
|
packageContentTypes.forEach((vapType) => {
|
||||||
|
vapsLineItemsForSelectedPackage.push(
|
||||||
|
...findLineItemsWithPartType(vapType, this.nullSafeAvailableLineItems)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
// console.log("VapsLineItems:", vapsLineItemsForSelectedPackage);
|
||||||
|
return vapsLineItemsForSelectedPackage;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
packageNameWidget() {
|
||||||
|
const servicePackageNames = this.getCmsContent(
|
||||||
|
this.servicePackageOptionsCmsName,
|
||||||
|
"Answers"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!servicePackageNames) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentPackage = servicePackageNames.find(
|
||||||
|
(entry) => entry.Name === this.packageLevel
|
||||||
|
);
|
||||||
|
|
||||||
|
return currentPackage.SubWidgetName;
|
||||||
|
},
|
||||||
|
packageLevel() {
|
||||||
|
const tier = getHighestFullySatisfiedTier(
|
||||||
|
this.glassToReplace,
|
||||||
|
this.availableLineItems,
|
||||||
|
this.isRepair,
|
||||||
|
this.vaps
|
||||||
|
);
|
||||||
|
return tier;
|
||||||
|
},
|
||||||
|
packagePrice() {
|
||||||
|
let packagePriceString;
|
||||||
|
if (this.packageLevel.length > 0) {
|
||||||
|
packagePriceString = this.getPackagePriceString(this.packageLevel);
|
||||||
|
}
|
||||||
|
return packagePriceString;
|
||||||
|
// return (packagePriceString.length > 0) ? packagePriceString : "Test String";
|
||||||
|
},
|
||||||
|
displayedPackageLineItems() {
|
||||||
|
const displayedPackageLineItems = [];
|
||||||
|
const packageLineItems = this.getVapsLineItemsForSelectedPackage(this.packageLevel);
|
||||||
|
//TO DO Could we get the same list from this.orderLineItems?
|
||||||
|
packageLineItems?.forEach((item) => {
|
||||||
|
let price = item.sellingPrice + item.kitPrice + item.laborAmount;
|
||||||
|
const packageLineItem = {
|
||||||
|
name: item.partType,
|
||||||
|
price: "$" + parseFloat(price).toFixed(2),
|
||||||
|
partType: item.partType,
|
||||||
|
isRemovable: item.isRemovable,
|
||||||
|
};
|
||||||
|
displayedPackageLineItems.push(packageLineItem);
|
||||||
|
});
|
||||||
|
// console.log("What displayedPackageLineItems is", packageLineItems);
|
||||||
|
return displayedPackageLineItems;
|
||||||
|
},
|
||||||
|
displayedNonPackageLineItems() {
|
||||||
|
const displayedNonPackageLineItems = [];
|
||||||
|
const possibleLineItems = [...this.vaps, ...this.supportingItems];
|
||||||
|
possibleLineItems?.forEach((item) => {
|
||||||
|
let price = item.sellingPrice + item.kitPrice + item.laborAmount;
|
||||||
|
const isAllowed = this.allowableLineItems?.findIndex((lineItem) => {
|
||||||
|
return lineItem.partType === item.partType;
|
||||||
|
});
|
||||||
|
const indexFound = this.displayedPackageLineItems?.findIndex((packageLineItem) => {
|
||||||
|
return packageLineItem.partType === item.partType;
|
||||||
|
});
|
||||||
|
const isInPackage = this.displayedPackageLineItems?.findIndex((packageLineItem) => {
|
||||||
|
return packageLineItem.partType === item.partType;
|
||||||
|
});
|
||||||
|
if (isInPackage === -1 && isAllowed > -1) {
|
||||||
|
const nonPackageLineItem = {
|
||||||
|
name: item.partType,
|
||||||
|
price: "$" + parseFloat(price).toFixed(2),
|
||||||
|
partType: item.partType,
|
||||||
|
isRemovable: item.isRemovable,
|
||||||
|
};
|
||||||
|
displayedNonPackageLineItems.push(nonPackageLineItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return displayedNonPackageLineItems;
|
||||||
|
},
|
||||||
|
glassToReplace() {
|
||||||
|
if (!this.damage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.damage.glassToReplace;
|
||||||
|
},
|
||||||
|
isRepair() {
|
||||||
|
if (!this.damage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.damage.isRepair;
|
||||||
|
},
|
||||||
|
vaps() {
|
||||||
|
const vaps = this.orderLineItems?.vaps;
|
||||||
|
return vaps?.length > 0 ? vaps : [];
|
||||||
|
},
|
||||||
|
supportingItems() {
|
||||||
|
const supportingItems = this.orderLineItems?.supportingItems;
|
||||||
|
return supportingItems?.length > 0 ? supportingItems : [];
|
||||||
|
},
|
||||||
|
recycleLabel() {
|
||||||
|
return "Recycling";
|
||||||
|
},
|
||||||
|
recycleFee() {
|
||||||
|
return "$35.00";
|
||||||
|
},
|
||||||
|
hasRecycleLineItem() {
|
||||||
|
//TO DO
|
||||||
|
// if (this.lineItems.supportingItems[0].partNumber === "RECYCLE FEE") {
|
||||||
|
// return true;
|
||||||
|
// } else {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
nullSafeAvailableLineItems() {
|
||||||
|
return this.availableLineItems ?? [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
textBlock,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.cart {
|
||||||
|
h5 {
|
||||||
|
border-bottom: 1px solid $gray-500;
|
||||||
|
color: $black;
|
||||||
|
}
|
||||||
|
.border-bottom {
|
||||||
|
color: $gray;
|
||||||
|
}
|
||||||
|
.label {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.amount-due {
|
||||||
|
color: $green;
|
||||||
|
}
|
||||||
|
.price-table {
|
||||||
|
max-height: 0;
|
||||||
|
transition: all 350ms ease-in;
|
||||||
|
overflow: hidden;
|
||||||
|
div {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0.5rem 1.5rem;
|
||||||
|
&:nth-child(odd) {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
&:nth-last-child(-n + 3) {
|
||||||
|
background-color: #e3f2ea;
|
||||||
|
}
|
||||||
|
&:last-child {
|
||||||
|
background-color: #0c7e47;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vaps {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
padding-left: 2.5rem;
|
||||||
|
align-items: center;
|
||||||
|
span {
|
||||||
|
display: flex;
|
||||||
|
width: 33.33333%;
|
||||||
|
&:nth-child(2) {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
&:last-child {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.package-type,
|
||||||
|
.service-type {
|
||||||
|
//background-color: #f5f5f5;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.sub-total,
|
||||||
|
.sales-tax,
|
||||||
|
.amount-due {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.sub-total {
|
||||||
|
border-top: 1px solid #0c7e47;
|
||||||
|
}
|
||||||
|
.service-type {
|
||||||
|
// background-color: #f5f5f5;
|
||||||
|
.text-block {
|
||||||
|
background: transparent;
|
||||||
|
margin-top: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vin-toggle {
|
||||||
|
&:after {
|
||||||
|
content: "";
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 8.9' xml:space='preserve'%3e%3cpath d='M8 8.9c-.2 0-.5-.1-.6-.3L.3 1.5C.1 1.4 0 1.1 0 .9 0 .7.1.4.3.3.4.1.7 0 .9 0c.2 0 .5.1.6.3L8 6.7 14.5.2c.1-.1.4-.2.6-.2.2 0 .5.1.6.3s.3.4.3.6c0 .2-.1.5-.3.6L8.6 8.6c-.1.2-.4.3-.6.3z' fill='%231474a2'/%3e%3c/svg%3e");
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-position: right center;
|
||||||
|
width: 16px;
|
||||||
|
height: 9px;
|
||||||
|
display: inline-flex;
|
||||||
|
position: relative;
|
||||||
|
right: 0.75rem;
|
||||||
|
margin: 1rem 0 1rem 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
&.active:after {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
&.active + .price-table {
|
||||||
|
max-height: 650px;
|
||||||
|
transition: all 350ms ease-in;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -11,7 +11,6 @@ export function findLineItemsWithPartType(typeToFind, itemsToSearch) {
|
||||||
const partTypeMatches = itemsToSearch?.filter(
|
const partTypeMatches = itemsToSearch?.filter(
|
||||||
(lineItem) => lineItem.partType.toUpperCase() === typeToFind.toUpperCase()
|
(lineItem) => lineItem.partType.toUpperCase() === typeToFind.toUpperCase()
|
||||||
);
|
);
|
||||||
|
|
||||||
return partTypeMatches;
|
return partTypeMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import customerDetails from "@/layouts/payment-method/payment-method.vue";
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
import store from "@/store";
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
|
@ -41,15 +42,22 @@ describe("payment-method.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks() {
|
function setupMocks() {
|
||||||
|
store.getters = {
|
||||||
|
damage: {},
|
||||||
|
lineItems: [],
|
||||||
|
};
|
||||||
|
|
||||||
const wrapper = shallowMount(
|
const wrapper = shallowMount(
|
||||||
customerDetails,
|
customerDetails,
|
||||||
getMountOptions({
|
getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn(),
|
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(),
|
||||||
navigateWithSaving: jest.fn(),
|
navigateWithSaving: jest.fn(),
|
||||||
navigateWithoutSaving: jest.fn(),
|
navigateWithoutSaving: jest.fn(),
|
||||||
},
|
},
|
||||||
|
store: {
|
||||||
|
getters: store.getters,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,39 @@
|
||||||
<template>
|
<template>
|
||||||
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
||||||
<div class="page-container-grouped-styles">
|
<loadingModal ref="loadingModal" />
|
||||||
<loadingModal ref="loadingModal" />
|
<div class="container-fluid page-container-grouped-styles">
|
||||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
<div class="row">
|
||||||
<funnelSubHeader class="mb-5" cmsWidgetName="FunnelSubHeaderWidget" leftAlignHeader />
|
<div class="col">
|
||||||
<hr class="mt-0" />
|
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||||
<div class="fade-on-route-transition sub-container make-tall">
|
</div>
|
||||||
<navbar
|
</div>
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
<div class="row justify-content-md-center">
|
||||||
:isForwardActionDisabled="!meta.valid"
|
<div class="col-md-6 col-xl-4">
|
||||||
:isBackButtonHidden="shouldHideBackButton"
|
<vehicleBanner
|
||||||
@back-clicked="backButtonAction"
|
cmsWidgetName="VehicleBannerWidget"
|
||||||
@ForwardClicked="forwardButtonAction" />
|
:displayGenericVehicleImage="false" />
|
||||||
|
|
||||||
|
<funnelSubHeader class="mb-5" cmsWidgetName="FunnelSubHeaderWidget" />
|
||||||
|
|
||||||
|
<cart
|
||||||
|
:damage="damageInfo"
|
||||||
|
:orderLineItems="orderLineItems"
|
||||||
|
:availableLineItems="cartItems"
|
||||||
|
servicePackageOptionsCmsName="ServicePackageTitle" />
|
||||||
|
|
||||||
|
<add-vaps-modal-buttons
|
||||||
|
:cart="cartItems"
|
||||||
|
:wiperItems="availableWipers"
|
||||||
|
:rainDefenseItem="availableRainDefense"
|
||||||
|
vapsTilesCmsName="VapsProductTiles" />
|
||||||
|
|
||||||
|
<navbar
|
||||||
|
cmsWidgetName="FunnelFooterWidget"
|
||||||
|
:isForwardActionDisabled="!meta.valid"
|
||||||
|
:isBackButtonHidden="shouldHideBackButton"
|
||||||
|
@back-clicked="backButtonAction"
|
||||||
|
@ForwardClicked="forwardButtonAction" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
@ -22,43 +44,104 @@
|
||||||
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
||||||
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
||||||
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
||||||
|
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
||||||
|
import cart from "@/fmg-components/cart/cart";
|
||||||
|
import addVapsModalButtons from "@/fmg-components/add-vaps-modal-buttons/add-vaps-modal-buttons";
|
||||||
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
|
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
|
import { storeActions } from "@/constants/store-actions";
|
||||||
// Validation
|
import store from "@/store";
|
||||||
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { Form } from "vee-validate";
|
import { Form } from "vee-validate";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "payment-method",
|
name: "paymentMethod",
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
// TODO: Data fetching Promise declarations
|
const wipersPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.GET_WIPERS,
|
||||||
|
null,
|
||||||
|
"payment-method"
|
||||||
|
);
|
||||||
|
const rainDefensePromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.GET_RAIN_DEFENSE,
|
||||||
|
null,
|
||||||
|
"payment-method"
|
||||||
|
);
|
||||||
|
const supportingItemsPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.GET_SUPPORTING_ITEMS,
|
||||||
|
null,
|
||||||
|
"payment-method"
|
||||||
|
);
|
||||||
|
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "wipers",
|
||||||
|
promise: wipersPromise,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "rainDefense",
|
||||||
|
promise: rainDefensePromise,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "supportingItems",
|
||||||
|
promise: supportingItemsPromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
const clonedGlassParts = store.getters.order.lineItems.glassParts
|
||||||
|
? JSON.parse(JSON.stringify(store.getters.order.lineItems.glassParts))
|
||||||
|
: [];
|
||||||
|
const availableLineItems = [
|
||||||
|
resultMap.rainDefense,
|
||||||
|
...resultMap.supportingItems,
|
||||||
|
...resultMap.wipers,
|
||||||
|
...clonedGlassParts,
|
||||||
|
];
|
||||||
|
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||||
|
{
|
||||||
|
availableLineItems: availableLineItems,
|
||||||
|
},
|
||||||
|
"payment-method",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
vm.pricedGlassParts = clonedGlassParts;
|
||||||
|
vm.supportingItems = resultMap.supportingItems;
|
||||||
|
vm.availableLineItems = pricingResults;
|
||||||
|
vm.availableWipers = resultMap.wipers;
|
||||||
|
vm.availableRainDefense = resultMap.rainDefense;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {
|
||||||
|
cartItems: [],
|
||||||
|
availableWipers: null,
|
||||||
|
availableRainDefense: null,
|
||||||
|
availableLineItems: null,
|
||||||
|
supportingItems: null,
|
||||||
|
pricedGlassParts: null,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
// TODO
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
vapsItemsSelectedAction(vapsItemsSelected) {
|
||||||
|
this.cartItems = vapsItemsSelected;
|
||||||
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
|
|
@ -71,13 +154,22 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
damageInfo() {
|
||||||
|
return this.$store.getters.damage;
|
||||||
|
},
|
||||||
|
orderLineItems() {
|
||||||
|
return this.$store.getters.lineItems;
|
||||||
|
},
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
funnelHeader,
|
funnelHeader,
|
||||||
navbar,
|
navbar,
|
||||||
funnelSubHeader,
|
funnelSubHeader,
|
||||||
Form,
|
Form,
|
||||||
|
loadingModal,
|
||||||
|
cart,
|
||||||
|
addVapsModalButtons,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss"></style>
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,6 @@ export default {
|
||||||
resultMap.supportingItems,
|
resultMap.supportingItems,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue