CSR-1891: use term mapping to update co list
This commit is contained in:
parent
0403ad22d8
commit
7057f6bf52
1 changed files with 36 additions and 86 deletions
|
|
@ -41,35 +41,24 @@ import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
|||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
import {
|
||||
getDamageString,
|
||||
getIsWindshieldOnly,
|
||||
isGlassAvailableForCarId,
|
||||
} from "@/helpers/damage-helper";
|
||||
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";
|
||||
import $ from "jquery";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
|
||||
defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT));
|
||||
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED));
|
||||
defineRule(
|
||||
"email-address-format",
|
||||
regex(
|
||||
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9-]+)\.([a-zA-Z]{2,})$/,
|
||||
errorMessages.EMAIL_ADDRESS_FORMAT
|
||||
)
|
||||
);
|
||||
defineRule("vin-required", required(errorMessages.VIN_REQUIRED));
|
||||
defineRule("vin-format", regex(/^[a-hA-Hj-nJ-NpPr-zR-Z0-9]{17}$/, errorMessages.VIN_FORMAT));
|
||||
// MAPPNG
|
||||
const termMapping = [
|
||||
{
|
||||
term: "1ST",
|
||||
altTerm: "FIRST",
|
||||
},
|
||||
{
|
||||
term: "AAA",
|
||||
altTerm: "American"
|
||||
}
|
||||
];
|
||||
|
||||
export default {
|
||||
name: "insurance-company",
|
||||
|
|
@ -96,73 +85,36 @@ export default {
|
|||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
const searchableInsuranceCompanyList = resultMap.insuranceCompanyList.map(( insuranceCompany ) => {
|
||||
|
||||
insuranceCompany.altTerms = "";
|
||||
|
||||
termMapping.forEach((matchingTerm) => {
|
||||
if (insuranceCompany.accountName.toUpperCase().includes(matchingTerm.term.toUpperCase())) {
|
||||
insuranceCompany.altTerms = insuranceCompany.altTerms + matchingTerm.altTerm?.toUpperCase() + " ";
|
||||
}
|
||||
});
|
||||
|
||||
return insuranceCompany;
|
||||
|
||||
});
|
||||
|
||||
console.log("searchableInsuranceCompanyList: ", searchableInsuranceCompanyList);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.insuranceCompanyList = resultMap.insuranceCompanyList;
|
||||
vm.originalList = resultMap.insuranceCompanyList;
|
||||
vm.searchableInsuranceCompanyList = searchableInsuranceCompanyList;
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
insuranceCompanyList: [],
|
||||
searchableInsuranceCompanyList: [],
|
||||
originalList: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
insuranceCompanyListTags() {
|
||||
// return this.insuranceCompanyList.map((item) => {
|
||||
// return item.accountName;
|
||||
// });
|
||||
|
||||
const termMap = [
|
||||
{
|
||||
term: "1st",
|
||||
altTerm: "FIRST",
|
||||
}
|
||||
];
|
||||
|
||||
const doTest = (testTerm) => {
|
||||
return termMap.find((matchingTerm) => {
|
||||
if (testTerm.includes(matchingTerm.term)) return matchingTerm.altTerm;
|
||||
return;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
return this.insuranceCompanyList.map((item) => {
|
||||
// return item.accountName;
|
||||
return {
|
||||
label: item.accountName,
|
||||
altTerms: doTest(item.accountName) ? doTest(item.accountName) : "",
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// return [
|
||||
// {
|
||||
// "label": "1ST INSURANCE",
|
||||
// "altTerms": "FIRST"
|
||||
// },
|
||||
// {
|
||||
// "label": "AAA INSURANCE",
|
||||
// "altTerms": "AMERICAN AUTOMOTIVE AUTOMOBILE ASSOCIATION TRIPLE"
|
||||
// },
|
||||
// {
|
||||
// "label": "AMERICAN ROADS INSURANCE",
|
||||
// "altTerms": ""
|
||||
// },
|
||||
// {
|
||||
// "label": "DONT USE US INSURANCE",
|
||||
// "altTerms": ""
|
||||
// },
|
||||
// {
|
||||
// "label": "FIRST PIONEER INSURANCE",
|
||||
// "altTerms": "1ST"
|
||||
// },
|
||||
// ];
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
return store.getters.vehicle.carId !== null;
|
||||
|
|
@ -170,13 +122,11 @@ export default {
|
|||
findMatches(request, response) {
|
||||
const matches = [];
|
||||
const term = request?.term?.toUpperCase();
|
||||
console.log(this.insuranceCompanyListTags);
|
||||
this.insuranceCompanyListTags.forEach((tag, index) => {
|
||||
if (tag.label.indexOf(term) !== -1 || tag.altTerms.indexOf(term) !== -1) {
|
||||
matches.push(tag);
|
||||
this.originalList.forEach((company, index) => {
|
||||
if (company.accountName.indexOf(term) !== -1 || company.altTerms.indexOf(term) !== -1) {
|
||||
matches.push(company.accountName);
|
||||
}
|
||||
});
|
||||
|
||||
response(matches);
|
||||
},
|
||||
backButtonAction() {
|
||||
|
|
@ -207,7 +157,7 @@ export default {
|
|||
}, 5);
|
||||
},
|
||||
});
|
||||
}, 5);
|
||||
}, 0);
|
||||
},
|
||||
components: {
|
||||
funnelHeader,
|
||||
|
|
|
|||
Loading…
Reference in a new issue