Adding policyLookupSuccessful to store

This commit is contained in:
brydon1 2023-07-21 09:39:33 -04:00
parent 3376fbb9d5
commit e21cd97c7b

View file

@ -53,6 +53,7 @@ const getDefaultState = () =>
damageState: null,
damageCity: null,
isDamageGlassOnly: null,
policyLookupSuccessful: null,
noCoverage: null,
deductible: {
repair: null, // numerical value; how much customer owes on deductible in repair case
@ -349,6 +350,7 @@ export const useMainStore = defineStore({
getCoveragePolicyInfo({ accountNumber, policyNumber, dateOfLoss, zipCode }) {
// TODO: replace place holder correlationId with the real thing
const placeHolderCorrelationId = '00000000-0000-0000-0000-000000000000';
const { policy } = this.order;
try {
const response = globalMethods.callHttpClient({
method: endpoints.CoveragePolicyInfo.method,
@ -360,9 +362,14 @@ export const useMainStore = defineStore({
zipCode,
correlationId: placeHolderCorrelationId
}
}).then((r) => {
const responsePolicy = response.policies?.[0];
policy.policyLookupSuccessful = !!responsePolicy;
return r;
});
return response;
} catch (responseError) {
policy.policyLookupSuccessful = false;
return {
error: {
status: responseError.status