Merge pull request #270 from Safelite/feature/Digital/SSR-316

SSR-316 and SSR-289.
This commit is contained in:
DavidAtSafelite 2023-04-26 09:13:16 -04:00 committed by GitHub
commit ed4f274c57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 79 deletions

View file

@ -21,7 +21,7 @@ export default {
url: cfDistroUrl + endpoint, url: cfDistroUrl + endpoint,
data: payloadAndAnalyticsData, data: payloadAndAnalyticsData,
crossDomain: true, crossDomain: true,
responseType: {}, responseType: 'json',
headers: headers, headers: headers,
}) })
.then((response) => { .then((response) => {

View file

@ -24,6 +24,7 @@
}; };
export default { export default {
name: 'servicePackageQuestion', name: 'servicePackageQuestion',
emits: ['vapsItemsSelected'],
props: { props: {
cmsWidgetName: String, cmsWidgetName: String,
groupName: String, groupName: String,
@ -34,16 +35,10 @@
data() { data() {
return { return {
servicePackageRadio: servicePackageRadio, servicePackageRadio: servicePackageRadio,
selectedPackageName: null selectedPackageName: packageNames.TIER_ONE
}; };
}, },
watch: { watch: {
availableLineItems() {
const store = useMainStore();
if (this.allGlassPartsAndSupportingItemsHavePrices(store.order.lineItems)) {
this.selectDefaultPackage();
}
},
selectedPackageName(newValue) { selectedPackageName(newValue) {
const VapsProductsInSelectedPackage = this.getVapsLineItemsForSelectedPackage(newValue); const VapsProductsInSelectedPackage = this.getVapsLineItemsForSelectedPackage(newValue);
this.$emit('vapsItemsSelected', VapsProductsInSelectedPackage); this.$emit('vapsItemsSelected', VapsProductsInSelectedPackage);
@ -51,10 +46,14 @@
}, },
computed: { computed: {
nullSafeAvailableLineItems() { nullSafeAvailableLineItems() {
if (this.availableLineItems?.lineItems) {
return this.availableLineItems.lineItems;
}
return this.availableLineItems ?? []; return this.availableLineItems ?? [];
}, },
servicePackageAnswers() { servicePackageAnswers() {
if (!this.cmsWidgetName) return {}; if (!this.cmsWidgetName) return [];
const cmsAnswersContent = [ const cmsAnswersContent = [
{ {
Name: 'TierOne', Name: 'TierOne',
@ -84,6 +83,9 @@
)); ));
return modifiedAnswers; return modifiedAnswers;
}, },
isRecalibrationOnOrder() {
return this.lineItemsContainsPartType(partTypeStrings.RECALIBRATION);
},
frontWipersApplicableForTierTwo() { frontWipersApplicableForTierTwo() {
const store = useMainStore(); const store = useMainStore();
const frontWipersAreAvailable = this.lineItemsContainsPartType( const frontWipersAreAvailable = this.lineItemsContainsPartType(
@ -205,50 +207,6 @@
}); });
return vapsPrice; return vapsPrice;
}, },
selectDefaultPackage() {
const store = useMainStore();
const vapsFromStore = store.lineItems.vaps;
let lowestTierForPackage = packageNames.TIER_ONE;
if (vapsFromStore?.length > 0) {
vapsFromStore.every((vapsItem) => {
let lowestTierForThisItem = this.getLowestTierForThisItem(vapsItem);
if (lowestTierForThisItem === packageNames.TIER_THREE) {
lowestTierForPackage = packageNames.TIER_THREE;
return false;
} else if (lowestTierForThisItem === packageNames.TIER_TWO) {
lowestTierForPackage = packageNames.TIER_TWO;
return true;
} else {
return true;
}
});
}
this.selectedPackageName = lowestTierForPackage;
},
allGlassPartsAndSupportingItemsHavePrices(lineItems) {
if (lineItems?.glassParts) {
for (let i = 0; i < lineItems.glassParts.length; i++) {
if (this.priceIsNullOrZero(lineItems.glassParts[i])) {
return false;
}
}
}
if (lineItems?.supportingItems) {
for (let i = 0; i < lineItems.supportingItems.length; i++) {
if (this.priceIsNullOrZero(lineItems.supportingItems[i])) {
return false;
}
}
}
return true;
},
priceIsNullOrZero(lineItem) {
return (
(lineItem.kitPrice == null || lineItem.kitPrice == 0) &&
(lineItem.laborAmount == null || lineItem.laborAmount == 0) &&
(lineItem.sellingPrice == null || lineItem.sellingPrice == 0)
);
},
getLowestTierForThisItem(vapsItem) { getLowestTierForThisItem(vapsItem) {
let lowestTierForThisItem = null; let lowestTierForThisItem = null;
switch (vapsItem.partType) { switch (vapsItem.partType) {
@ -345,7 +303,7 @@
return !!glassLocationMatches.length; return !!glassLocationMatches.length;
}, },
getTotalLineItemPrice(lineItem) { getTotalLineItemPrice(lineItem) {
return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice return lineItem.kitPrice + lineItem.laborAmount + lineItem.sellingPrice;
} }
}, },
components: { components: {

View file

@ -1,5 +1,5 @@
<template> <template>
<baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange" v-model="selectedValue"> <baseInputButton v-bind="$props" v-model="selectedValue">
<div class="package-label mb-4" <div class="package-label mb-4"
:class="[this.buttonLabelSubCopy ? 'has-subheader' : '']" :class="[this.buttonLabelSubCopy ? 'has-subheader' : '']"
for="testradio"> for="testradio">
@ -26,12 +26,7 @@
<textLink linkType="text" <textLink linkType="text"
:text="getRouterLinkDisplayTextFromCopy(copy)" :text="getRouterLinkDisplayTextFromCopy(copy)"
href="#!" href="#!"
@click-event=" @click-event="textLinkEmit(copy)"
$emit('buttonEvent', {
eventName: 'openModal',
args: getRouterLinkRouteFromCopy(copy),
})
"
:data-bs-target="'#' + getRouterLinkRouteFromCopy(copy)" :data-bs-target="'#' + getRouterLinkRouteFromCopy(copy)"
aria-label="Modal window" /> aria-label="Modal window" />
</span> </span>
@ -61,6 +56,7 @@ import {
} from '@/helpers/cms-content-helper'; } from '@/helpers/cms-content-helper';
export default { export default {
name: 'servicePackageRadio', name: 'servicePackageRadio',
emits:['link-event'],
mixins: [inputButtonWrapperMixin], mixins: [inputButtonWrapperMixin],
components: { components: {
baseInputButton, baseInputButton,
@ -85,8 +81,13 @@ export default {
.split('- ') //At some point we'll want a better delimiter .split('- ') //At some point we'll want a better delimiter
.filter((lineItem) => lineItem); .filter((lineItem) => lineItem);
} }
},
textLinkEmit(copy) {
this.$parent.$emit('link-event', {
args: getRouterLinkRouteFromCopy(copy)
});
} }
}, }
}; };
</script> </script>

View file

@ -12,7 +12,7 @@
groupName="ServicePackageQuestion" groupName="ServicePackageQuestion"
:availableLineItems="availableLineItems" :availableLineItems="availableLineItems"
@vapsItemsSelected="vapsItemsSelectedAction" @vapsItemsSelected="vapsItemsSelectedAction"
v-on="{ 'buttonEvent.openModal': openModalAction }" v-on:link-event="openModalAction"
validationRules="option-required" validationRules="option-required"
isRequired /> isRequired />
<textBlock cmsWidgetName="PriceDisclaimerWidget" <textBlock cmsWidgetName="PriceDisclaimerWidget"
@ -35,7 +35,7 @@
<script> <script>
// Components // Components
import baseFormMixin from '@/mixins/base-form-mixin'; import baseFormMixin from '@/mixins/base-form-mixin';
import siteHeader from '@/iss-components/site-header/site-header'; import siteHeader from '@/iss-components/site-header/site-header';
import siteFooter from '@/iss-components/site-footer/site-footer'; import siteFooter from '@/iss-components/site-footer/site-footer';
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header'; import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header';
@ -52,12 +52,12 @@
defineRule('option-required', required(errorMessages.OPTION_REQUIRED)); defineRule('option-required', required(errorMessages.OPTION_REQUIRED));
const store = useMainStore();
export default { export default {
name: 'service-packages', name: 'service-packages',
mixins: [baseFormMixin], mixins: [baseFormMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
const store = useMainStore();
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
@ -106,18 +106,17 @@
}, },
data() { data() {
return { return {
selectedVaps: null, selectedVaps: [],
availableLineItems: null, availableLineItems: [],
supportingItems: null, supportingItems: [],
pricedGlassParts: null pricedGlassParts: []
}; };
}, },
methods: { methods: {
openModalAction(modalName) { openModalAction(modalName) {
this.$refs[modalName].openModal(); this.$refs[modalName.args].openModal();
}, },
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
const store = useMainStore();
return ( return (
store.order.serviceLocation.zipCode && store.order.serviceLocation.zipCode &&
store.order.serviceLocation.zipCodeCtu && store.order.serviceLocation.zipCodeCtu &&
@ -134,8 +133,48 @@
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
forwardButtonAction() { forwardButtonAction() {
//TODO: save items if (!this.allGlassPartsAndItemsHavePrices()) {
console.error('One or more items have no price assigned!');
}
if (this.pricedGlassParts.length > 0) {
store.saveGlassParts(this.pricedGlassParts);
}
store.saveSupportingItems(this.supportingItems);
store.saveVaps(this.selectedVaps);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route);
},
allGlassPartsAndItemsHavePrices() {
if (this.pricedGlassParts) {
for (let i = 0; i < this.pricedGlassParts.length; i++) {
if (this.priceIsNullOrZero(this.pricedGlassParts[i])) {
return false;
}
}
}
if (this.supportingItems) {
for (let i = 0; i < this.supportingItems.length; i++) {
if (this.priceIsNullOrZero(this.supportingItems[i])) {
return false;
}
}
}
if (this.selectedVaps) {
for (let i = 0; i < this.selectedVaps.length; i++) {
if (this.priceIsNullOrZero(this.selectedVaps[i])) {
return false;
}
}
}
return true;
},
priceIsNullOrZero(lineItem) {
return (
(lineItem.kitPrice == null || lineItem.kitPrice == 0) &&
(lineItem.laborAmount == null || lineItem.laborAmount == 0) &&
(lineItem.sellingPrice == null || lineItem.sellingPrice == 0)
);
} }
}, },
components: { components: {

View file

@ -483,11 +483,11 @@ const routingTable = function(store) {
maps: [ maps: [
{ {
scenario: navigationScenarios.CLICKED_BACK, scenario: navigationScenarios.CLICKED_BACK,
destinationIssPageValue: issPageValues.PROVIDER_PREFERENCE destinationIssPageValue: issPageValues.SERVICE_LOCATION
}, },
{ {
scenario: navigationScenarios.CLICKED_FORWARD, scenario: navigationScenarios.CLICKED_FORWARD,
destinationIssPageValue: issPageValues.SERVICE_LOCATION destinationIssPageValue: issPageValues.REVIEW_PAGE
} }
] ]
}, },

View file

@ -497,8 +497,8 @@ export const useMainStore = defineStore({
///WARNING ///WARNING
///TODO: this is temp test code until serviceLocation is complete. ///TODO: this is temp test code until serviceLocation is complete.
/// and ctu is available. Also, EON may need to be implemented. /// and ctu is available. Also, EON may need to be implemented.
zipCodeToUse = "44902" zipCodeToUse = "44902";
ctuToUse = "01820" ctuToUse = "01820";
let queryString = let queryString =
`ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}` + `ParentAccountNumber=${applicationConfig.CASH_PARENT_ACCOUNT_NUMBER}` +
`&CTU=${ctuToUse}` + `&CTU=${ctuToUse}` +
@ -905,7 +905,15 @@ export const useMainStore = defineStore({
// Save new values // Save new values
this.updateCapabilityQuestionAnswers(capabilityQuestionAnswersArray); this.updateCapabilityQuestionAnswers(capabilityQuestionAnswersArray);
}, },
saveGlassParts(glassParts) {
this.order.lineItems.glassParts = glassParts;
},
saveSupportingItems(supportingItems) {
this.order.lineItems.supportingItems = supportingItems;
},
saveVaps(vaps) {
this.order.lineItems.vaps = vaps;
},
addEventToBus (event) { addEventToBus (event) {
this.applicationUser.eventBus.push(event); this.applicationUser.eventBus.push(event);
}, },
@ -1178,7 +1186,7 @@ export const useMainStore = defineStore({
resetPartsAndDependencies() { resetPartsAndDependencies() {
this.resetGlassPartsState(); this.resetGlassPartsState();
this.updateSupportingItems(null); this.updateSupportingItems(null);
}, }
}, },
persist: true persist: true
}); });