refactor method, reuse existing array for answers
This commit is contained in:
parent
696cbaaaf5
commit
f262b05df1
2 changed files with 11 additions and 25 deletions
|
|
@ -20,15 +20,10 @@ export function endorsementsForSelectedVehicle(vehicle) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
export function endorsementCodesForSelectedVehicle(vehicle) {
|
export function endorsementCodesForSelectedVehicle(vehicle) {
|
||||||
if (vehicle?.endorsements?.length === 1) {
|
if (!Array.isArray(vehicle?.endorsements) || vehicle.endorsements.length === 0) {
|
||||||
switch (true) {
|
return '';
|
||||||
case vehicle.endorsements.includes(endorsementOptions.EDUCATOR):
|
|
||||||
return endorsementCodes_LibertyMutual.EDUCATOR;
|
|
||||||
case vehicle.endorsements.includes(endorsementOptions.PARKING_GUARD):
|
|
||||||
return endorsementCodes_LibertyMutual.PARKING_GUARD;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (vehicle?.endorsements?.length > 1) {
|
|
||||||
let codes = [];
|
let codes = [];
|
||||||
if (vehicle.endorsements.includes(endorsementOptions.EDUCATOR)) {
|
if (vehicle.endorsements.includes(endorsementOptions.EDUCATOR)) {
|
||||||
codes.push(endorsementCodes_LibertyMutual.EDUCATOR);
|
codes.push(endorsementCodes_LibertyMutual.EDUCATOR);
|
||||||
|
|
@ -37,8 +32,6 @@ export function endorsementCodesForSelectedVehicle(vehicle) {
|
||||||
codes.push(endorsementCodes_LibertyMutual.PARKING_GUARD);
|
codes.push(endorsementCodes_LibertyMutual.PARKING_GUARD);
|
||||||
}
|
}
|
||||||
return codes.join(',');
|
return codes.join(',');
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
export function repairWaivedForSelectedVehicle(vehicle) {
|
export function repairWaivedForSelectedVehicle(vehicle) {
|
||||||
return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
|
return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,6 @@ export const getDefaultState = () => ({
|
||||||
endorsements: [],
|
endorsements: [],
|
||||||
endorsementQuestionAnswers: [],
|
endorsementQuestionAnswers: [],
|
||||||
cvrgEndorsementCode: null,
|
cvrgEndorsementCode: null,
|
||||||
educatorEndorsementAnswer: null,
|
|
||||||
parkingGuardEndorsementAnswer: null,
|
|
||||||
status: null,
|
status: null,
|
||||||
policyData: null
|
policyData: null
|
||||||
},
|
},
|
||||||
|
|
@ -1475,8 +1473,7 @@ export const useMainStore = defineStore({
|
||||||
noCoverage: this.isNoComp,
|
noCoverage: this.isNoComp,
|
||||||
isItac: this.isITAC,
|
isItac: this.isITAC,
|
||||||
cvrgEndorsementCode: policy.cvrgEndorsementCode ?? endorsementCodesForSelectedVehicle(vehicle),
|
cvrgEndorsementCode: policy.cvrgEndorsementCode ?? endorsementCodesForSelectedVehicle(vehicle),
|
||||||
educatorEndorsement: policy.educatorEndorsementAnswer,
|
endorsementQuestionAnswers: policy.endorsementQuestionAnswers
|
||||||
parkingGuardEndorsement: policy.parkingGuardEndorsementAnswer
|
|
||||||
},
|
},
|
||||||
customer: {
|
customer: {
|
||||||
address: {
|
address: {
|
||||||
|
|
@ -2121,8 +2118,6 @@ export const useMainStore = defineStore({
|
||||||
this.order.policy.endorsements = [];
|
this.order.policy.endorsements = [];
|
||||||
this.order.policy.endorsementQuestionAnswers = [];
|
this.order.policy.endorsementQuestionAnswers = [];
|
||||||
this.order.policy.cvrgEndorsementCode = null;
|
this.order.policy.cvrgEndorsementCode = null;
|
||||||
this.order.policy.educatorEndorsementAnswer = null;
|
|
||||||
this.order.policy.parkingGuardEndorsementAnswer = null;
|
|
||||||
this.order.policy.policyData = null;
|
this.order.policy.policyData = null;
|
||||||
this.order.policy.deductible.repair = null;
|
this.order.policy.deductible.repair = null;
|
||||||
this.order.policy.deductible.replace = null;
|
this.order.policy.deductible.replace = null;
|
||||||
|
|
@ -2306,8 +2301,6 @@ export const useMainStore = defineStore({
|
||||||
if (answersArray !== null) {
|
if (answersArray !== null) {
|
||||||
const educatorEndorsement = answersArray.find((endorsement) => endorsement.endorsementName === endorsementOptions.EDUCATOR);
|
const educatorEndorsement = answersArray.find((endorsement) => endorsement.endorsementName === endorsementOptions.EDUCATOR);
|
||||||
const parkingGuardEndorsement = answersArray.find((endorsement) => endorsement.endorsementName === endorsementOptions.PARKING_GUARD);
|
const parkingGuardEndorsement = answersArray.find((endorsement) => endorsement.endorsementName === endorsementOptions.PARKING_GUARD);
|
||||||
this.order.policy.educatorEndorsementAnswer = educatorEndorsement ? educatorEndorsement.selectedAnswer : null;
|
|
||||||
this.order.policy.parkingGuardEndorsementAnswer = parkingGuardEndorsement ? parkingGuardEndorsement.selectedAnswer : null;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue