refactoring

This commit is contained in:
Katie Kroell 2023-10-17 15:56:56 -04:00
parent e23645eb02
commit 5c86c0546c

View file

@ -77,7 +77,7 @@ const getDefaultState = () => ({
isITAC: null,
vehicles: [],
endorsements: [],
endorsementQuestionAnswers: null,
endorsementQuestionAnswers: [],
status: null
},
customer: {
@ -497,11 +497,13 @@ export const useMainStore = defineStore({
});
},
getFinalDeductible() {
const endorsementAnswersToSend = [];
const endorsementAnswersForPayload = [];
const endorsementAnswers = this.order.policy.endorsementQuestionAnswers;
if (endorsementAnswers && endorsementAnswers[0].selectedAnswer?.includes('Yes')) {
endorsementAnswersToSend.push(this.order.policy.endorsementQuestionAnswers[0].endorsement);
if (endorsementAnswers && endorsementAnswers[0]?.selectedAnswer?.includes('Yes')) {
endorsementAnswersForPayload.push(this.order.policy.endorsementQuestionAnswers[0].endorsement);
return endorsementAnswersForPayload;
}
return new Promise((resolve, reject) => {
globalMethods.callHttpClient({
method: endpoints.FinalDeductible.method,
@ -510,52 +512,19 @@ export const useMainStore = defineStore({
accountNumber: this.issConfig.parentAccountNumber?.toString() ?? '',
currentDeductible: this.order.currentDeductible,
noCoverage: this.order.policy.noCoverage,
endorsements: endorsementAnswersToSend,
endorsements: endorsementAnswersForPayload,
policy: {
status: 'Active',
// status: this.order.policy.status,
status: 'Active', // change to this.order.policy.status after changing back end request
policyState: this.order.vehicle.registration.state
}
}
}).then((r) => {
this.updateDeductible(r.data);
return resolve(r);
}).catch((error) => {
this.updateDeductible(this.order.originalDeductible);
return reject(error);
});
}).catch((error) => reject(error));
});
},
// getFinalDeductible() {
// try {
// const endorsementAnswersToSend = [];
// if (this.order.policy.endorsementQuestionAnswers[0].selectedAnswer.includes('Yes')) {
// endorsementAnswersToSend.push(this.order.policy.endorsementQuestionAnswers[0].endorsement);
// }
// const response = globalMethods.callHttpClient({
// method: endpoints.FinalDeductible.method,
// endpoint: endpoints.FinalDeductible.url,
// payload: {
// accountNumber: this.issConfig.parentAccountNumber?.toString() ?? '',
// currentDeductible: this.order.currentDeductible,
// noCoverage: this.order.policy.noCoverage,
// endorsements: endorsementAnswersToSend,
// policy: {
// status: this.order.policy.status,
// policyState: this.order.vehicle.registration.state
// }
// }
// });
// this.updateDeductible(response.data);
// return response;
// } catch (responseError) {
// return {
// error: {
// status: responseError.status
// }
// };
// }
// },
getDuplicateReferrals() {
return new Promise((resolve, reject) => {
globalMethods.callHttpClient({