WIP add insurance company endpoint list.
This commit is contained in:
parent
1fca56a56c
commit
ef6310880c
4 changed files with 51 additions and 23 deletions
|
|
@ -164,6 +164,10 @@ const endpoints = {
|
||||||
url: "/experiments/api/v1/experiments/run",
|
url: "/experiments/api/v1/experiments/run",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
},
|
},
|
||||||
|
GetInsuranceCompanyList: {
|
||||||
|
url: "/account/api/v1/account/insurance-companies",
|
||||||
|
method: "GET",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export { endpoints };
|
export { endpoints };
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ const storeActions = {
|
||||||
GET_SIGNATURE: "getSignature",
|
GET_SIGNATURE: "getSignature",
|
||||||
VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA: "validateOrderPromoAndSaveServerData",
|
VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA: "validateOrderPromoAndSaveServerData",
|
||||||
REVALIDATE_ORDER_PROMOS_AND_SAVE_SERVER_DATA: "revalidateOrderPromosAndSaveServerData",
|
REVALIDATE_ORDER_PROMOS_AND_SAVE_SERVER_DATA: "revalidateOrderPromosAndSaveServerData",
|
||||||
|
GET_INSURANCE_COMPANY_LIST: "getInsuranceCompanyList",
|
||||||
|
|
||||||
// DEPENDENCY MUTATIONS
|
// DEPENDENCY MUTATIONS
|
||||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ import { required, regex } from "@/helpers/validation-rules";
|
||||||
import { Form, defineRule } from "vee-validate";
|
import { Form, defineRule } from "vee-validate";
|
||||||
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { routerParams } from "@/router/router-constants/router-params";
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||||
|
|
@ -76,6 +77,11 @@ export default {
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
const insuranceCompanyListPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.GET_INSURANCE_COMPANY_LIST,
|
||||||
|
{},
|
||||||
|
"insurance-lookup"
|
||||||
|
);
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
|
@ -83,15 +89,31 @@ export default {
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "insuranceCompanyList",
|
||||||
|
promise: insuranceCompanyListPromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
vm.insuranceCompanyList = resultMap.insuranceCompanyList;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
insuranceCompanyList: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
insuranceCompanyListTags() {
|
||||||
|
return this.insuranceCompanyList.map(item => {
|
||||||
|
return item.accountName;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return store.getters.vehicle.carId !== null;
|
return store.getters.vehicle.carId !== null;
|
||||||
|
|
@ -110,34 +132,13 @@ export default {
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const select = this.handleAutocompleteSelect;
|
const select = this.handleAutocompleteSelect;
|
||||||
// Temporary list of insurance companies for testing
|
|
||||||
var tags = [
|
|
||||||
"21st Century Insurance",
|
|
||||||
"Farmers Insurance",
|
|
||||||
"Grange Insurance",
|
|
||||||
"Liberty Mutual Insurance",
|
|
||||||
"State Auto Insurance",
|
|
||||||
"State Farm Insurance",
|
|
||||||
"Travelers Insurance",
|
|
||||||
"AAA",
|
|
||||||
"AAA Ohio",
|
|
||||||
"AAA Indiana",
|
|
||||||
"AAA Florida",
|
|
||||||
"American Autombile Insurance Co",
|
|
||||||
"American Automobile Association",
|
|
||||||
"American Insurance",
|
|
||||||
];
|
|
||||||
tags.sort(); //Sort list alphabetically
|
|
||||||
|
|
||||||
$("#autocomplete").autocomplete({
|
$("#autocomplete").autocomplete({
|
||||||
source: tags,
|
source: this.insuranceCompanyListTags,
|
||||||
position: {
|
position: {
|
||||||
my: "left top+6",
|
my: "left top+6",
|
||||||
},
|
},
|
||||||
minLength: 0, // Necessary to display menu when clearing input
|
minLength: 0, // Necessary to display menu when clearing input
|
||||||
select: function (event, ui) {
|
|
||||||
select(ui.item.value);
|
|
||||||
},
|
|
||||||
// Bold matching letters as you type in the input
|
// Bold matching letters as you type in the input
|
||||||
search: function (event, ui) {
|
search: function (event, ui) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
||||||
|
|
@ -2421,6 +2421,28 @@ export const actions = {
|
||||||
|
|
||||||
return revalidateResponse?.data;
|
return revalidateResponse?.data;
|
||||||
},
|
},
|
||||||
|
// List all insurance companies
|
||||||
|
async getInsuranceCompanyList(context, { pageNameToLog }) {
|
||||||
|
const insuranceCompanyList = await globalMethods.callHttpClient({
|
||||||
|
method: endpoints.GetInsuranceCompanyList.method,
|
||||||
|
endpoint: endpoints.GetInsuranceCompanyList.url,
|
||||||
|
payload: {},
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
|
});
|
||||||
|
console.log(insuranceCompanyList);
|
||||||
|
return insuranceCompanyList.data.sort((a, b) => {
|
||||||
|
const nameA = a.accountName.toUpperCase();
|
||||||
|
const nameB = b.accountName.toUpperCase();
|
||||||
|
if (nameA < nameB) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (nameA > nameB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// Misc order actions
|
// Misc order actions
|
||||||
saveSchedule(context, scheduleInfo) {
|
saveSchedule(context, scheduleInfo) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue