refactor store access

This commit is contained in:
Katie Kroell 2023-07-20 11:27:41 -04:00
parent 3376fbb9d5
commit 3961534838

View file

@ -114,8 +114,6 @@ import { errorMessages } from "@/constants/error-messages";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule("selection-required", required(errorMessages.OPTION_REQUIRED)); defineRule("selection-required", required(errorMessages.OPTION_REQUIRED));
const store = useMainStore();
export default { export default {
name: 'coverage-statement', name: 'coverage-statement',
mixins: [baseFormMixin, vehicleQuestionsMixin], mixins: [baseFormMixin, vehicleQuestionsMixin],
@ -123,7 +121,7 @@ export default {
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
const supportingItemsPromise = await store.getSupportingItems(); const supportingItemsPromise = await useMainStore().getSupportingItems();
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
@ -147,15 +145,15 @@ export default {
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
const clonedGlassParts = store.order.lineItems.glassParts const clonedGlassParts = useMainStore().order.lineItems.glassParts
? JSON.parse(JSON.stringify(store.order.lineItems.glassParts)) ? JSON.parse(JSON.stringify(useMainStore().order.lineItems.glassParts))
: []; : [];
const availableLineItems = [ const availableLineItems = [
...resultMap.supportingItems, ...resultMap.supportingItems,
...clonedGlassParts, ...clonedGlassParts,
]; ];
const pricingResults = await store.getPriceOrderItems(availableLineItems); const pricingResults = await useMainStore().getPriceOrderItems(availableLineItems);
// 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) => {
@ -181,7 +179,7 @@ export default {
}, },
data() { data() {
return { return {
isVerified: store.order.payment.insuranceCoverage.isVerified, isVerified: useMainStore().order.payment.insuranceCoverage.isVerified,
supportingItems: [], supportingItems: [],
pricedGlassParts: [], pricedGlassParts: [],
availableLineItems: [], availableLineItems: [],
@ -189,6 +187,10 @@ export default {
deductibleText: "Your deductible is:", deductibleText: "Your deductible is:",
} }
}, },
setup() {
const mainStore = useMainStore();
return { mainStore };
},
computed: { computed: {
verifiedITACAlertHeader() { verifiedITACAlertHeader() {
return this.getCmsContent( return this.getCmsContent(
@ -240,12 +242,12 @@ export default {
}, },
vehicleDeductible() { vehicleDeductible() {
if (this.coverageVerified) { if (this.coverageVerified) {
if (store.order.damage.isRepair) { if (this.mainStore.order.damage.isRepair) {
const repairDeductible = store.order.policy.deductible.repair const repairDeductible = this.mainStore.order.policy.deductible.repair
return repairDeductible; return repairDeductible;
} }
else { else {
const replaceDeductible = store.order.policy.deductible.replace; const replaceDeductible = this.mainStore.order.policy.deductible.replace;
return replaceDeductible; return replaceDeductible;
} }
} }
@ -271,7 +273,7 @@ export default {
}, },
verifiedNoComp() { verifiedNoComp() {
if (this.coverageVerified) { if (this.coverageVerified) {
return store.order.policy.noCoverage; return this.mainStore.order.policy.noCoverage;
} }
}, },
verifiedITAC() { verifiedITAC() {
@ -289,8 +291,8 @@ export default {
} }
}, },
ADASReplace() { ADASReplace() {
if (!store.order.damage.isRepair) { if (!this.mainStore.order.damage.isRepair) {
let parts = store.order.lineItems.glassParts; let parts = this.mainStore.order.lineItems.glassParts;
if (parts != null && parts.filter(part => part.requiresRecalibration).length > 0) { if (parts != null && parts.filter(part => part.requiresRecalibration).length > 0) {
return true; return true;
@ -298,12 +300,12 @@ export default {
} }
}, },
nonADASReplace() { nonADASReplace() {
if (!store.order.damage.isRepair) { if (!this.mainStore.order.damage.isRepair) {
return !this.ADASReplace; return !this.ADASReplace;
} }
}, },
nonADASRepair() { nonADASRepair() {
if (store.order.damage.isRepair) { if (this.mainStore.order.damage.isRepair) {
return true; return true;
} }
}, },
@ -359,7 +361,7 @@ export default {
this.$route this.$route
) )
} }
else if (store.issConfig.enableTPAFlow){ else if (this.mainStore.issConfig.enableTPAFlow){
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_THIRD_PARTY, this.navigationScenarios.CLICKED_FORWARD_WITH_THIRD_PARTY,
this.$route this.$route