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",
|
||||
method: "POST",
|
||||
},
|
||||
GetInsuranceCompanyList: {
|
||||
url: "/account/api/v1/account/insurance-companies",
|
||||
method: "GET",
|
||||
},
|
||||
};
|
||||
|
||||
export { endpoints };
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ const storeActions = {
|
|||
GET_SIGNATURE: "getSignature",
|
||||
VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA: "validateOrderPromoAndSaveServerData",
|
||||
REVALIDATE_ORDER_PROMOS_AND_SAVE_SERVER_DATA: "revalidateOrderPromosAndSaveServerData",
|
||||
GET_INSURANCE_COMPANY_LIST: "getInsuranceCompanyList",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import { required, regex } from "@/helpers/validation-rules";
|
|||
import { Form, defineRule } from "vee-validate";
|
||||
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||
import { routerParams } from "@/router/router-constants/router-params";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
|
||||
import store from "@/store";
|
||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||
|
|
@ -76,6 +77,11 @@ export default {
|
|||
async beforeRouteEnter(to, from, next) {
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||
const insuranceCompanyListPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_INSURANCE_COMPANY_LIST,
|
||||
{},
|
||||
"insurance-lookup"
|
||||
);
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
|
|
@ -83,15 +89,31 @@ export default {
|
|||
resultKey: "cmsContent",
|
||||
promise: cmsContentPromise,
|
||||
},
|
||||
{
|
||||
resultKey: "insuranceCompanyList",
|
||||
promise: insuranceCompanyListPromise,
|
||||
},
|
||||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.insuranceCompanyList = resultMap.insuranceCompanyList;
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
insuranceCompanyList: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
insuranceCompanyListTags() {
|
||||
return this.insuranceCompanyList.map(item => {
|
||||
return item.accountName;
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
return store.getters.vehicle.carId !== null;
|
||||
|
|
@ -110,34 +132,13 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
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({
|
||||
source: tags,
|
||||
source: this.insuranceCompanyListTags,
|
||||
position: {
|
||||
my: "left top+6",
|
||||
},
|
||||
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
|
||||
search: function (event, ui) {
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
|
|
@ -2421,6 +2421,28 @@ export const actions = {
|
|||
|
||||
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
|
||||
saveSchedule(context, scheduleInfo) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue