CSR-2072 fix insurance search dropdown after API was updated and case mismatch caused issues.

This commit is contained in:
Bryan Mauger 2024-05-06 13:37:59 -04:00
parent 8a5624fd2d
commit 4d78134649

View file

@ -96,15 +96,28 @@ export default {
findMatches(request, response) {
const matches = [];
const term = request?.term?.toUpperCase();
const nonPriorityMatches = [];
this.searchableInsuranceCompanyList.forEach((company, index) => {
if (
company.accountName.indexOf(term) !== -1 ||
company.altTerms.indexOf(term) !== -1
company.accountName.toUpperCase().indexOf(term) !== -1 ||
company.altTerms.toUpperCase().indexOf(term) !== -1
) {
matches.push(company.accountName);
}
});
response(matches);
const priorityMatches = matches.filter((companyName, index) => {
if (companyName.toUpperCase().indexOf(term) === 0) {
return companyName;
} else {
nonPriorityMatches.push(companyName);
}
});
const prioritizedMatches = [...priorityMatches, ...nonPriorityMatches];
response(prioritizedMatches);
},
selectInsuranceCompany(parentAccountName) {
// this runs upon user selection within jQueryUI Autocomplete