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,25 +20,18 @@ export function endorsementsForSelectedVehicle(vehicle) {
|
|||
return [];
|
||||
}
|
||||
export function endorsementCodesForSelectedVehicle(vehicle) {
|
||||
if (vehicle?.endorsements?.length === 1) {
|
||||
switch (true) {
|
||||
case vehicle.endorsements.includes(endorsementOptions.EDUCATOR):
|
||||
return endorsementCodes_LibertyMutual.EDUCATOR;
|
||||
case vehicle.endorsements.includes(endorsementOptions.PARKING_GUARD):
|
||||
return endorsementCodes_LibertyMutual.PARKING_GUARD;
|
||||
}
|
||||
if (!Array.isArray(vehicle?.endorsements) || vehicle.endorsements.length === 0) {
|
||||
return '';
|
||||
}
|
||||
else if (vehicle?.endorsements?.length > 1) {
|
||||
let codes = [];
|
||||
if (vehicle.endorsements.includes(endorsementOptions.EDUCATOR)) {
|
||||
codes.push(endorsementCodes_LibertyMutual.EDUCATOR);
|
||||
}
|
||||
if (vehicle.endorsements.includes(endorsementOptions.PARKING_GUARD)) {
|
||||
codes.push(endorsementCodes_LibertyMutual.PARKING_GUARD);
|
||||
}
|
||||
return codes.join(',');
|
||||
|
||||
let codes = [];
|
||||
if (vehicle.endorsements.includes(endorsementOptions.EDUCATOR)) {
|
||||
codes.push(endorsementCodes_LibertyMutual.EDUCATOR);
|
||||
}
|
||||
return "";
|
||||
if (vehicle.endorsements.includes(endorsementOptions.PARKING_GUARD)) {
|
||||
codes.push(endorsementCodes_LibertyMutual.PARKING_GUARD);
|
||||
}
|
||||
return codes.join(',');
|
||||
}
|
||||
export function repairWaivedForSelectedVehicle(vehicle) {
|
||||
return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false;
|
||||
|
|
|
|||
|
|
@ -111,8 +111,6 @@ export const getDefaultState = () => ({
|
|||
endorsements: [],
|
||||
endorsementQuestionAnswers: [],
|
||||
cvrgEndorsementCode: null,
|
||||
educatorEndorsementAnswer: null,
|
||||
parkingGuardEndorsementAnswer: null,
|
||||
status: null,
|
||||
policyData: null
|
||||
},
|
||||
|
|
@ -1475,8 +1473,7 @@ export const useMainStore = defineStore({
|
|||
noCoverage: this.isNoComp,
|
||||
isItac: this.isITAC,
|
||||
cvrgEndorsementCode: policy.cvrgEndorsementCode ?? endorsementCodesForSelectedVehicle(vehicle),
|
||||
educatorEndorsement: policy.educatorEndorsementAnswer,
|
||||
parkingGuardEndorsement: policy.parkingGuardEndorsementAnswer
|
||||
endorsementQuestionAnswers: policy.endorsementQuestionAnswers
|
||||
},
|
||||
customer: {
|
||||
address: {
|
||||
|
|
@ -2121,8 +2118,6 @@ export const useMainStore = defineStore({
|
|||
this.order.policy.endorsements = [];
|
||||
this.order.policy.endorsementQuestionAnswers = [];
|
||||
this.order.policy.cvrgEndorsementCode = null;
|
||||
this.order.policy.educatorEndorsementAnswer = null;
|
||||
this.order.policy.parkingGuardEndorsementAnswer = null;
|
||||
this.order.policy.policyData = null;
|
||||
this.order.policy.deductible.repair = null;
|
||||
this.order.policy.deductible.replace = null;
|
||||
|
|
@ -2306,8 +2301,6 @@ export const useMainStore = defineStore({
|
|||
if (answersArray !== null) {
|
||||
const educatorEndorsement = answersArray.find((endorsement) => endorsement.endorsementName === endorsementOptions.EDUCATOR);
|
||||
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