updates to store methods, API calls

This commit is contained in:
Katie Kroell 2023-10-11 15:56:39 -04:00
parent b322eb23b4
commit 12b2ebd88a

View file

@ -76,6 +76,7 @@ const getDefaultState = () => ({
},
isITAC: null,
vehicles: [],
endorsements: [],
endorsementQuestionAnswers: null
},
customer: {
@ -494,94 +495,35 @@ export const useMainStore = defineStore({
});
});
},
getFinalDeductible() {
return global.callHttpClient({
method: endpoints.FinalDeductible.method,
endpoint: endpoints.FinalDeductible.url,
payload:
{
correlationId: this.order.referralCorrelationId,
referralNumber: this.order.referralNumber,
async getFinalDeductible() {
try {
const endorsementAnswersToSend = [];
if (this.order.policy.endorsementQuestionAnswers[0].selectedAnswer.includes('Yes')) {
endorsementAnswersToSend.push(this.order.policy.endorsementQuestionAnswers[0].endorsement);
}
const response = await globalMethods.callHttpClient({
method: endpoints.FinalDeductible.method,
endpoint: endpoints.FinalDeductible.url,
payload: {
accountNumber: this.issConfig.parentAccountNumber?.toString() ?? '',
sourceSystem: null,
additionalInfo: {},
fakeType: null,
responseType: null,
vin: this.order.vehicle.vin,
fleetNumber: null,
lossLocation: null,
vehicleNotFound: null,
driverNotFound: null,
isRepair: this.order.damage.isRepair,
isOEMRequested: null,
currentDeductible: this.order.currentDeductible,
noCoverage: this.order.policy.noCoverage,
endorsements: this.order.policy.endorsementQuestionAnswers, // FIX
endorsements: endorsementAnswersToSend, // FIX
policy: {
policyEffectiveDate: null,
expirationDate: null,
type: null,
lineOfBusiness: null,
policyNumber: this.order.policy.policyNumber,
status: this.order.policy.status,
source: null,
policyState: this.order.vehicle.registration.state, // check on this
insureds: [{
firstName: this.order.customer.firstName,
middleName: null,
lastName: this.order.customer.lastName,
businessName: null,
address: this.order.customer.address.streetAddress,
state: this.order.customer.address.state,
zipCode: this.order.customer.address.zipCode,
zipCodePlus4: null,
phones: [{
phoneNumber: this.order.customer.phoneNumber?.replaceAll(nonNumberCharRegex, ''),
type: null
}],
email: this.order.customer.emailAddress,
driverLicenseState: this.order.vehicle.registration.state, // check on this
relationToInsured: null,
roles: [{
role: null
}],
companyCode: null,
customerId: null,
isExcluded: null,
notes: []
}],
vehicles: [{
id: null,
vehicleYear: this.order.vehicle.year?.toString() ?? '',
vehicleMake: this.order.vehicle.make,
vehicleModel: this.order.vehicle.model,
vehicleStyle: this.order.vehicle.style,
licensePlate: this.order.vehicle.registration.licensePlate,
vin: this.order.vehicle.vin,
driver: null,
owner: null,
noCoverage: this.order.policy.noCoverage,
coverages: [{
code: null,
deductible: this.order.currentDeductible,
individualLimit: null,
occurrenceLimit: null,
dayLimit: null
}],
fleetNumber: null,
fleetUnitNumber: null,
endorsements: this.order.policy.endorsementQuestionAnswers, // FIX
oemRequired: null,
additionalFields: {},
notes: []
}],
agent: {},
taxExempt: null,
additionalFields: {},
notes: []
status: 'Active',
policyState: this.order.vehicle.registration.state // check on this
}
}
});
});
this.updateDeductible(response.data);
return response;
} catch (responseError) {
return {
error: {
status: responseError.status
}
};
}
},
getDuplicateReferrals() {
return new Promise((resolve, reject) => {
@ -1259,6 +1201,7 @@ export const useMainStore = defineStore({
: coverageStatuses.PENDING;
this.order.policy.deductible.replace = vehicle.deductible;
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible;
this.order.policy.endorsements = vehicle?.endorsements;
// TODO logic should be more complicated later on
this.order.originalDeductible = parseFloat(vehicle.deductible);
@ -1449,6 +1392,11 @@ export const useMainStore = defineStore({
updatePolicyITACFlag(isITAC) {
this.order.policy.isITAC = isITAC;
},
updateDeductible(finalDeductible) {
this.order.currentDeductible = finalDeductible;
},
savePartQuestionAnswers(partQuestionAnswersArray) {
// if part question answers have changed, reset subsequent question answers
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.partQuestionAnswers, 'result');