Merge branch 'develop' into feature/csr-1984

This commit is contained in:
Chloe Herd 2024-03-12 12:20:17 -04:00
commit dd160a43fa
3 changed files with 120 additions and 55 deletions

View file

@ -28,7 +28,7 @@ const applicationConfig = {
YAHOO_CALENDAR: "https://calendar.yahoo.com/?v=60", YAHOO_CALENDAR: "https://calendar.yahoo.com/?v=60",
OUTLOOK_CALENDAR: OUTLOOK_CALENDAR:
"https://outlook.office.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent", "https://outlook.office.com/calendar/deeplink/compose?path=/calendar/action/compose&rru=addevent",
FRONTEND_LOGGER_URL: process.env.VUE_APP_CONSUMER_CF_DISTRO + "/analytics/api/v1/logging", FRONTEND_LOGGER_PATH: "/analytics/api/v1/logging",
}; };
export { applicationConfig }; export { applicationConfig };

View file

@ -42,12 +42,29 @@ export class Logger {
// If running locally or in the Dev environment show the log entries in the console. // If running locally or in the Dev environment show the log entries in the console.
if ( if (
applicationConfig.CURRENT_ENVIRONMENT === "Localhost" || applicationConfig.CURRENT_ENVIRONMENT === "Localhost" ||
applicationConfig.CURRENT_ENVIRONMENT === "Dev" applicationConfig.CURRENT_ENVIRONMENT === "Dev" ||
applicationConfig.CURRENT_ENVIRONMENT === "SysTest"
) { ) {
console.log(logEntry); switch (endpoint) {
case loggingEndpointMethods.LOG_INFORMATION:
console.info(logEntry);
break;
case loggingEndpointMethods.LOG_WARNING:
console.warn(logEntry);
break;
case loggingEndpointMethods.LOG_ERROR:
console.error(logEntry);
break;
case loggingEndpointMethods.LOG_CRITICAL:
console.error(logEntry);
break;
default:
console.log(logEntry);
}
} }
const url = applicationConfig.FRONTEND_LOGGER_URL; const url =
applicationConfig.CONSUMER_CF_DISTRO + applicationConfig.FRONTEND_LOGGER_PATH;
const headers = { const headers = {
[headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings), [headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings),
}; };

View file

@ -41,33 +41,31 @@ import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
import { settleAllPromises } from "@/helpers/layout-helper"; import { settleAllPromises } from "@/helpers/layout-helper";
import { storeActions } from "@/constants/store-actions"; import { storeActions } from "@/constants/store-actions";
import { errorMessages } from "@/constants/error-messages";
import { required, regex } from "@/helpers/validation-rules";
import { Form, defineRule } from "vee-validate"; import { Form, defineRule } from "vee-validate";
import baseMixin from "@/mixins/base-mixin.js"; import baseMixin from "@/mixins/base-mixin.js";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import store from "@/store"; import store from "@/store";
import vinPagesMixin from "@/mixins/vin-pages-mixin";
import $ from "jquery"; import $ from "jquery";
// DEFINE VALIDATION RULES // MAPPNG
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); const termMapping = [
defineRule("zip-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.SERVICE_ZIP_FORMAT)); {
defineRule("email-address-required", required(errorMessages.EMAIL_ADDRESS_REQUIRED)); term: "1ST",
defineRule( altTerm: "FIRST",
"email-address-format", },
regex( {
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9-]+)\.([a-zA-Z]{2,})$/, term: "FIRST",
errorMessages.EMAIL_ADDRESS_FORMAT altTerm: "1ST",
) },
); {
defineRule("vin-required", required(errorMessages.VIN_REQUIRED)); term: "AAA",
defineRule("vin-format", regex(/^[a-hA-Hj-nJ-NpPr-zR-Z0-9]{17}$/, errorMessages.VIN_FORMAT)); altTerm: "American",
},
];
export default { export default {
name: "insurance-company", name: "insurance-company",
mixins: [vinPagesMixin],
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);
@ -90,69 +88,117 @@ export default {
]; ];
const resultMap = await settleAllPromises(promiseResultMap); 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;
}
);
// 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; vm.originalList = resultMap.insuranceCompanyList;
vm.searchableInsuranceCompanyList = searchableInsuranceCompanyList;
}); });
}, },
data() { data() {
return { return {
insuranceCompanyList: [], searchableInsuranceCompanyList: [],
originalList: [],
}; };
}, },
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;
}, },
handleAutocompleteSelect(value) { findMatches(request, response) {
this.selectedQuery = value; const matches = [];
const term = request?.term?.toUpperCase();
this.originalList.forEach((company, index) => {
if (
company.accountName.indexOf(term) !== -1 ||
company.altTerms.indexOf(term) !== -1
) {
matches.push(company.accountName);
}
});
response(matches);
}, },
backButtonAction() { backButtonAction() {
// Go back to Quote page // Go back to Quote page
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
}, },
forwardButtonAction() { forwardButtonAction() {
this.dispatchStoreAction(
this.storeActions.SAVE_PARENT_ACCOUNT_NUMBER,
this.selectedParentAccount,
false
);
navigateToHeritageFunnel({ navigateToHeritageFunnel({
shouldSaveSession: true, shouldSaveSession: true,
pageNameToLog: "insurance-company", pageNameToLog: "insurance-company",
loadingModal: this.$refs.loadingModal, loadingModal: this.$refs.loadingModal,
}); });
}, },
}, selectParentAccountNumber(parentAccountName) {
mounted() { if (!this.insuranceCompanyList) {
const select = this.handleAutocompleteSelect; console.error("No insurance companies found");
return;
}
$("#autocomplete").autocomplete({ var selectedItem = this.insuranceCompanyList.filter((item) => {
source: this.insuranceCompanyListTags, return item.accountName === parentAccountName;
position: { });
my: "left top+6",
}, if (selectedItem) {
minLength: 0, // Necessary to display menu when clearing input this.selectedParentAccount = selectedItem[0].parentAccountNumber;
// Bold matching letters as you type in the input } else {
search: function (event, ui) { console.error("Error locating " + parentAccountName);
setTimeout(() => {
let w = $(this).autocomplete("widget").find("div"),
re = new RegExp("(" + this.value + ")", "i");
w.html((i, html) => html.replace(re, "<span>$1</span>"));
}, 5);
},
});
},
watch: {
selectedQuery(newValue, oldValue) {
if (oldValue.length > 0 && newValue.length === 0) {
$("#autocomplete").autocomplete("search", "");
} }
}, },
}, },
mounted() {
const select = this.selectParentAccountNumber;
setTimeout(() => {
$("#autocomplete").autocomplete({
source: this.findMatches,
position: {
my: "left top+6",
},
minLength: 0, // Necessary to display menu when clearing input
// Bold matching letters as you type in the input
search: function (event, ui) {
setTimeout(() => {
let w = $(this).autocomplete("widget").find("div");
let regExpString = "(" + this.value + ")";
let re = new RegExp(regExpString, "i");
w.html((i, html) =>
html.replace(re, "<span style='font-weight: bold;'>$1</span>")
);
}, 5);
},
select: function (event, ui) {
select(ui.item.value);
},
});
}, 0);
},
components: { components: {
funnelHeader, funnelHeader,
navbar, navbar,
@ -173,6 +219,8 @@ ul {
background: $white; background: $white;
border: 1px solid $gray; border: 1px solid $gray;
border-radius: 0.25rem; border-radius: 0.25rem;
height: 50%;
overflow: auto;
li { li {
&:hover, &:hover,
.ui-state-active { .ui-state-active {