updates to store methods, API calls
This commit is contained in:
parent
b322eb23b4
commit
12b2ebd88a
1 changed files with 30 additions and 82 deletions
|
|
@ -76,6 +76,7 @@ const getDefaultState = () => ({
|
||||||
},
|
},
|
||||||
isITAC: null,
|
isITAC: null,
|
||||||
vehicles: [],
|
vehicles: [],
|
||||||
|
endorsements: [],
|
||||||
endorsementQuestionAnswers: null
|
endorsementQuestionAnswers: null
|
||||||
},
|
},
|
||||||
customer: {
|
customer: {
|
||||||
|
|
@ -494,94 +495,35 @@ export const useMainStore = defineStore({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getFinalDeductible() {
|
async getFinalDeductible() {
|
||||||
return global.callHttpClient({
|
try {
|
||||||
method: endpoints.FinalDeductible.method,
|
const endorsementAnswersToSend = [];
|
||||||
endpoint: endpoints.FinalDeductible.url,
|
if (this.order.policy.endorsementQuestionAnswers[0].selectedAnswer.includes('Yes')) {
|
||||||
payload:
|
endorsementAnswersToSend.push(this.order.policy.endorsementQuestionAnswers[0].endorsement);
|
||||||
{
|
}
|
||||||
correlationId: this.order.referralCorrelationId,
|
const response = await globalMethods.callHttpClient({
|
||||||
referralNumber: this.order.referralNumber,
|
method: endpoints.FinalDeductible.method,
|
||||||
|
endpoint: endpoints.FinalDeductible.url,
|
||||||
|
payload: {
|
||||||
accountNumber: this.issConfig.parentAccountNumber?.toString() ?? '',
|
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,
|
currentDeductible: this.order.currentDeductible,
|
||||||
noCoverage: this.order.policy.noCoverage,
|
noCoverage: this.order.policy.noCoverage,
|
||||||
endorsements: this.order.policy.endorsementQuestionAnswers, // FIX
|
endorsements: endorsementAnswersToSend, // FIX
|
||||||
policy: {
|
policy: {
|
||||||
policyEffectiveDate: null,
|
status: 'Active',
|
||||||
expirationDate: null,
|
policyState: this.order.vehicle.registration.state // check on this
|
||||||
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: []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.updateDeductible(response.data);
|
||||||
|
return response;
|
||||||
|
} catch (responseError) {
|
||||||
|
return {
|
||||||
|
error: {
|
||||||
|
status: responseError.status
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getDuplicateReferrals() {
|
getDuplicateReferrals() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
@ -1259,6 +1201,7 @@ export const useMainStore = defineStore({
|
||||||
: coverageStatuses.PENDING;
|
: coverageStatuses.PENDING;
|
||||||
this.order.policy.deductible.replace = vehicle.deductible;
|
this.order.policy.deductible.replace = vehicle.deductible;
|
||||||
this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : 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
|
// TODO logic should be more complicated later on
|
||||||
this.order.originalDeductible = parseFloat(vehicle.deductible);
|
this.order.originalDeductible = parseFloat(vehicle.deductible);
|
||||||
|
|
@ -1449,6 +1392,11 @@ export const useMainStore = defineStore({
|
||||||
updatePolicyITACFlag(isITAC) {
|
updatePolicyITACFlag(isITAC) {
|
||||||
this.order.policy.isITAC = isITAC;
|
this.order.policy.isITAC = isITAC;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateDeductible(finalDeductible) {
|
||||||
|
this.order.currentDeductible = finalDeductible;
|
||||||
|
},
|
||||||
|
|
||||||
savePartQuestionAnswers(partQuestionAnswersArray) {
|
savePartQuestionAnswers(partQuestionAnswersArray) {
|
||||||
// if part question answers have changed, reset subsequent question answers
|
// if part question answers have changed, reset subsequent question answers
|
||||||
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.partQuestionAnswers, 'result');
|
const sortedPreviousResultsArray = sortArrayOfObjectsByPropertyValue(this.order.damage.partQuestionAnswers, 'result');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue