Updates for calculating highest fully completed package tier
Misc linting updates as well - service-package component all linting
This commit is contained in:
parent
f57fc69e51
commit
7849694667
2 changed files with 23 additions and 53 deletions
|
|
@ -19,6 +19,7 @@ import partTypeStrings from '@/constants/part-type-strings';
|
|||
import { useMainStore } from '@/store';
|
||||
import allGlassPartsAndItemsHavePrices from '@/layouts/service-packages/service-package-helper/service-package-helper';
|
||||
import { getPriceOfLineItem } from '@/helpers/price-calculator';
|
||||
import { getHighestFullySatisfiedTier } from '@/helpers/service-package-helper.js';
|
||||
|
||||
const glassLocations = damageLocationsSelected;
|
||||
|
||||
|
|
@ -40,7 +41,10 @@ export default {
|
|||
groupName: String,
|
||||
validationRules: String,
|
||||
isRequired: Boolean,
|
||||
availableLineItems: []
|
||||
availableLineItems: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
emits: ['vapsItemsSelected'],
|
||||
data() {
|
||||
|
|
@ -212,51 +216,15 @@ export default {
|
|||
return vapsPrice;
|
||||
},
|
||||
selectDefaultPackage() {
|
||||
const vapsFromStore = store.order.lineItems.vaps;
|
||||
let lowestTierForPackage = packageNames.TIER_ONE;
|
||||
if (vapsFromStore?.length > 0) {
|
||||
vapsFromStore.every((vapsItem) => {
|
||||
const lowestTierForThisItem = this.getLowestTierForThisItem(vapsItem);
|
||||
if (lowestTierForThisItem === packageNames.TIER_THREE) {
|
||||
lowestTierForPackage = packageNames.TIER_THREE;
|
||||
return false;
|
||||
} if (lowestTierForThisItem === packageNames.TIER_TWO) {
|
||||
lowestTierForPackage = packageNames.TIER_TWO;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
this.selectedPackageName = lowestTierForPackage;
|
||||
},
|
||||
|
||||
getLowestTierForThisItem(vapsItem) {
|
||||
let lowestTierForThisItem = null;
|
||||
switch (vapsItem.partType) {
|
||||
case partTypeStrings.FRONT_WIPER:
|
||||
if (this.frontWipersApplicableForTierThree) {
|
||||
lowestTierForThisItem = packageNames.TIER_THREE;
|
||||
}
|
||||
if (this.frontWipersApplicableForTierTwo) {
|
||||
lowestTierForThisItem = packageNames.TIER_TWO;
|
||||
}
|
||||
break;
|
||||
case partTypeStrings.REAR_WIPER:
|
||||
if (this.rearWiperApplicableForTierThree) {
|
||||
lowestTierForThisItem = packageNames.TIER_THREE;
|
||||
}
|
||||
if (this.rearWiperApplicableForTierTwo) {
|
||||
lowestTierForThisItem = packageNames.TIER_TWO;
|
||||
}
|
||||
break;
|
||||
case partTypeStrings.RAIN_DEFENSE:
|
||||
if (this.rainDefenseApplicableForTierThree) {
|
||||
lowestTierForThisItem = packageNames.TIER_THREE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return lowestTierForThisItem;
|
||||
const { glassToReplace, isRepair } = store.order.damage;
|
||||
const { vaps } = store.order.lineItems;
|
||||
const defaultTier = getHighestFullySatisfiedTier(
|
||||
glassToReplace ?? [],
|
||||
this.availableLineItems,
|
||||
isRepair,
|
||||
vaps ?? []
|
||||
);
|
||||
this.selectedPackageName = defaultTier;
|
||||
},
|
||||
getVapsLineItemsForSelectedPackage(packageName) {
|
||||
const vapsLineItemsForSelectedPackage = [];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
ref="theForm"
|
||||
v-slot="{ meta }"
|
||||
@submit="onSubmit"
|
||||
@invalid-submit="onInvalidSubmit">
|
||||
@invalidSubmit="onInvalidSubmit">
|
||||
<div class="container-fluid fade-on-route-transition service-packages">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6 px-0 px-md-2">
|
||||
|
|
@ -50,8 +50,8 @@
|
|||
ref="RearWiperModal"
|
||||
cmsWidgetName="RearWiperModal" />
|
||||
<contentGroupModal
|
||||
ref="RecalModal"
|
||||
cmsWidgetName="RecalModal" />
|
||||
ref="RecalModal"
|
||||
cmsWidgetName="RecalModal" />
|
||||
</div>
|
||||
</Form>
|
||||
</template>
|
||||
|
|
@ -72,7 +72,6 @@ import allGlassPartsAndItemsHavePrices from '@/layouts/service-packages/service-
|
|||
import globalRules from '@/constants/global-rules';
|
||||
import servicePackageQuestion from '@/layouts/service-packages/service-package-question/service-package-question.vue';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
|
||||
const store = useMainStore();
|
||||
|
|
@ -143,9 +142,7 @@ export default {
|
|||
if (!hasBailedOut) {
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.pricedGlassParts = clonedGlassParts;
|
||||
vm.supportingItems = resultMap.supportingItems;
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.setData(clonedGlassParts, resultMap.supportingItems, pricingResults);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -185,6 +182,11 @@ export default {
|
|||
&& store.order.lineItems.glassParts.length > 0))
|
||||
);
|
||||
},
|
||||
setData(clonedGlassParts, supportingItems, pricingResults) {
|
||||
this.pricedGlassParts = clonedGlassParts;
|
||||
this.supportingItems = supportingItems;
|
||||
this.availableLineItems = pricingResults;
|
||||
},
|
||||
vapsItemsSelectedAction(vapsItemsSelected) {
|
||||
this.selectedVaps = vapsItemsSelected;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue