diff --git a/src/constants/insurance.js b/src/constants/insurance.js index 2b0cacc53..651be751c 100644 --- a/src/constants/insurance.js +++ b/src/constants/insurance.js @@ -82,9 +82,6 @@ export function coverageTypeEnum(strCoverageType) { export const parentAccountNumbers = { CONNECT: "560636", }; -export const NON_MANAGED_SHOW_CLAIM_NUMBER_PARENTS = [ - { name: "KentuckyFarmBureau", value: "223499" }, -]; export const PARENT_ACCOUNT_NUMBERS = { STATE_FARM: "711310", diff --git a/src/constants/state-options.js b/src/constants/state-options.js index 19eb348d5..e803b6440 100644 --- a/src/constants/state-options.js +++ b/src/constants/state-options.js @@ -52,3 +52,80 @@ const stateOptions = { WY: "Wyoming", }; export { stateOptions }; + +const stateOptionsInternational = { + AL: "Alabama", + AK: "Alaska", + AZ: "Arizona", + AR: "Arkansas", + CA: "California", + CO: "Colorado", + CT: "Connecticut", + DE: "Delaware", + DC: "District Of Columbia", + FL: "Florida", + GA: "Georgia", + GU: "Guam", + HI: "Hawaii", + ID: "Idaho", + IL: "Illinois", + IN: "Indiana", + IA: "Iowa", + KS: "Kansas", + KY: "Kentucky", + LA: "Louisiana", + ME: "Maine", + MD: "Maryland", + MA: "Massachusetts", + MI: "Michigan", + MN: "Minnesota", + MS: "Mississippi", + MO: "Missouri", + MT: "Montana", + NE: "Nebraska", + NV: "Nevada", + NH: "New Hampshire", + NJ: "New Jersey", + NM: "New Mexico", + NY: "New York", + NC: "North Carolina", + ND: "North Dakota", + OH: "Ohio", + OK: "Oklahoma", + OR: "Oregon", + PA: "Pennsylvania", + PR: "Puerto Rico", + RI: "Rhode Island", + SC: "South Carolina", + SD: "South Dakota", + TN: "Tennessee", + TX: "Texas", + UT: "Utah", + VT: "Vermont", + VA: "Virginia", + WA: "Washington", + WV: "West Virginia", + WI: "Wisconsin", + WY: "Wyoming", + AB: "Alberta", + BC: "British Columbia", + MB: "Manitoba", + NB: "New Brunswick", + NS: "Nova Scotia", + ON: "Ontario", + PE: "Prince Edward Island", + QC: "Quebec", + SK: "Saskatchewan", + YT: "Yukon", + CN: "Canada", + AE: "Military Address - AE", + AP: "Military Address - AP", + AA: "Military Address - AA", + AS: "American Samoa - AS", + MH: "Marshall Islands - MH", + MP: "Mariana Islands - MP", + NL: "Newfoundland and Labrador", + PW: "Palau", + VI: "Virgin Islands", +}; +export { stateOptionsInternational }; diff --git a/src/digital-components/date-picker-popup/date-picker-popup.vue b/src/digital-components/date-picker-popup/date-picker-popup.vue index 087e68765..851e7c486 100644 --- a/src/digital-components/date-picker-popup/date-picker-popup.vue +++ b/src/digital-components/date-picker-popup/date-picker-popup.vue @@ -82,7 +82,7 @@ export default { // Format used for the v-model value emitted to parent modelType: { type: String, - default: "MM/dd/yyyy", + default: "yyyy-MM-dd", }, enableTimePicker: { type: Boolean, diff --git a/src/helpers/cms-content-helper.js b/src/helpers/cms-content-helper.js index e5e189908..f16edc3ca 100644 --- a/src/helpers/cms-content-helper.js +++ b/src/helpers/cms-content-helper.js @@ -35,7 +35,9 @@ export function fetchCmsContentForPage(fmgPage) { // Client-specific config pages are optional. When one doesn't exist // the CMS returns a 404 - treat that as "no overrides" instead of an // error so callers receive an empty config object. - const isClientConfigPage = typeof fmgPage === "string" && fmgPage.startsWith("client_"); + const isClientConfigPage = + typeof fmgPage === "string" && + (fmgPage.startsWith("client_") || fmgPage.startsWith("unmanaged_")); const status = error?.status ?? error?.response?.status; const isNotFound = status == 404; diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index f3269bcd9..a3c93f0ea 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -113,17 +113,21 @@ export default { const pageName = to.name; const cmsContentPromise = fetchCmsContentForPage(pageName); const clientConfigPageName = `client_${store.getters.order.payment.parentAccountNumber}`; - const clientConfigPromise = fetchCmsContentForPage(clientConfigPageName); const promiseResultMap = [ { resultKey: "cmsContent", promise: cmsContentPromise, }, - { - resultKey: "clientConfig", - promise: clientConfigPromise, - }, ]; + + // Only fetch the client-specific config when this is a claim & coverage order. + if (store.getters.order?.payment?.isClaimAndCoverage) { + promiseResultMap.push({ + resultKey: "clientConfig", + promise: fetchCmsContentForPage(clientConfigPageName), + }); + } + const resultMap = await settleAllPromises(promiseResultMap); next((vm) => { vm.setCmsContent(resultMap.cmsContent); diff --git a/src/layouts/insurance-details/insurance-details.vue b/src/layouts/insurance-details/insurance-details.vue index d4a686fa1..72978f784 100644 --- a/src/layouts/insurance-details/insurance-details.vue +++ b/src/layouts/insurance-details/insurance-details.vue @@ -37,7 +37,7 @@ placeholderText="MM/DD/YYYY" validationRules="date-of-loss-required" format="MM/dd/yyyy" - modelType="MM/dd/yyyy" + modelType="yyyy-MM-dd" :enableTimePicker="false" :clearable="false" :textInput="true" @@ -146,14 +146,11 @@ import { errorMessages } from "@/constants/error-messages"; import { required } from "@/helpers/validation-rules"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; -import { stateOptions } from "@/constants/state-options"; +import { stateOptionsInternational } from "@/constants/state-options"; import { regex } from "@/helpers/validation-rules"; -import { - NON_MANAGED_SHOW_CLAIM_NUMBER_PARENTS, - coverageStatus, - coverageStatusEnum, -} from "@/constants/insurance"; +import { coverageStatus, coverageStatusEnum } from "@/constants/insurance"; import saveProgressModalQuestion from "@/fmg-components/save-progress-modal-question/save-progress-modal-question"; +import { debugLog } from "@/helpers/debug-log-helper"; // DEFINE VALIDATION RULES defineRule( @@ -174,6 +171,7 @@ export default { mixins: [], data() { return { + clientConfig: {}, insuranceCompanyName: this.getInsuranceCompanyNameFromStore(), policyNumber: this.getPolicyNumberFromStore(), dateOfLoss: this.getDateOfLossFromStore(), @@ -202,11 +200,17 @@ export default { async beforeRouteEnter(to, from, next) { const pageName = to.name; const cmsContentPromise = fetchCmsContentForPage(pageName); + const clientConfigPageName = `unmanaged_${store.getters.order.payment.parentAccountNumber}`; + const clientConfigPromise = fetchCmsContentForPage(clientConfigPageName); const promiseResultMap = [ { resultKey: "cmsContent", promise: cmsContentPromise, }, + { + resultKey: "clientConfig", + promise: clientConfigPromise, + }, ]; const resultMap = await settleAllPromises(promiseResultMap); const emailFromStore = store.getters.order.customer.emailAddress; @@ -214,6 +218,14 @@ export default { next((vm) => { vm.setCmsContent(resultMap.cmsContent); vm.showSaveProgressModal = showSaveProgressModal; + vm.clientConfig = resultMap.clientConfig ?? {}; + // The load-session API can return damageCause in a different case than + // the CMS answer values. Reconcile it so the dropdown pre-selects. + vm.damageCause = vm.matchDamageCauseToOption(vm.damageCause); + debugLog( + `insurance-details clientConfig::${clientConfigPageName}`, + JSON.stringify(vm.clientConfig) + ); }); }, @@ -221,16 +233,21 @@ export default { today() { return new Date(); }, + parsedClientConfig() { + const raw = this.clientConfig?.ConfigWidget?.Text; + if (!raw) return {}; + try { + return JSON.parse(raw); + } catch (err) { + console.warn("Failed to parse clientConfig.ConfigWidget.Text", err); + return {}; + } + }, displayClaimNumber() { - const order = store.getters.order; - - const parent = NON_MANAGED_SHOW_CLAIM_NUMBER_PARENTS.find( - (item) => item.value === order.payment?.parentAccountNumber?.toString() - ); - return !!parent; + return this.parsedClientConfig?.displayClaimNumberField ?? false; }, stateOptions() { - return stateOptions; + return stateOptionsInternational; }, damageCauseQuestionText() { return this.getCmsContent("DamageTypesWidget", "QuestionText"); @@ -239,6 +256,9 @@ export default { const options = {}; const answers = this.getCmsContent("DamageTypesWidget", "Answers"); + if (!Array.isArray(answers)) { + return options; + } for (const answer of answers) { options[answer.Name] = answer.Text; } @@ -259,23 +279,36 @@ export default { getDamageCauseFromStore() { return store.getters.order.damage.damageCause ?? ""; }, + // Maps a stored damageCause to the matching dropdown option value using a + // case-insensitive comparison (load-session can return it uppercased). + // Returns the canonical option value, or the original value if no match. + matchDamageCauseToOption(value) { + if (!value) { + return value; + } + const optionValues = Object.values(this.damageTypesOptions ?? {}); + const match = optionValues.find( + (option) => option?.toLowerCase() === value.toLowerCase() + ); + return match ?? value; + }, getStreetAddressFromStore() { - return store.getters.order.policy.policyAddress.streetAddress ?? ""; + return store.getters.order.customer.address.streetAddress ?? ""; }, getStreetAddress2FromStore() { - return store.getters.order.policy.policyAddress.streetAddress2 ?? ""; + return store.getters.order.customer.address.streetAddress2 ?? ""; }, getCityFromStore() { - return store.getters.order.policy.policyAddress.city ?? ""; + return store.getters.order.customer.address.city ?? ""; }, getPolicyStateFromStore() { - return store.getters.order.policy.policyAddress.state ?? ""; + return store.getters.order.customer.address.state ?? ""; }, getPolicyZipFromStore() { - return store.getters.order.policy.policyAddress.zipCode ?? ""; + return store.getters.order.customer.address.zipCode ?? ""; }, getClaimNumberFromStore() { - return store.getters.order.policy.claimNumber ?? ""; + return store.getters.order.payment.insuranceCoverage.claimNumber ?? ""; }, backButtonAction() { this.$router.navigateWithoutSaving( diff --git a/src/layouts/policy-info/policy-info.vue b/src/layouts/policy-info/policy-info.vue index 300429a34..ac03c43bd 100644 --- a/src/layouts/policy-info/policy-info.vue +++ b/src/layouts/policy-info/policy-info.vue @@ -37,7 +37,7 @@ placeholderText="MM/DD/YYYY" validationRules="date-of-birth-required" format="MM/dd/yyyy" - modelType="MM/dd/yyyy" + modelType="yyyy-MM-dd" :enableTimePicker="false" :textInput="true" :maxDate="today" @@ -100,7 +100,7 @@ placeholderText="MM/DD/YYYY" validationRules="date-of-loss-required" format="MM/dd/yyyy" - modelType="MM/dd/yyyy" + modelType="yyyy-MM-dd" :enableTimePicker="false" :textInput="true" :maxDate="today" @@ -314,6 +314,9 @@ export default { const options = {}; const answers = this.getCmsContent("DamageTypesWidget", "Answers"); + if (!Array.isArray(answers)) { + return options; + } for (const answer of answers) { options[answer.Name] = answer.Text; } @@ -411,6 +414,9 @@ export default { next((vm) => { vm.setCmsContent(resultMap.cmsContent); vm.clientConfig = resultMap.clientConfig ?? {}; + // The load-session API can return damageCause in a different case than + // the CMS answer values. Reconcile it so the dropdown pre-selects. + vm.damageCause = vm.matchDamageCauseToOption(vm.damageCause); debugLog( `policy-infoclientConfig::${clientConfigPageName}`, JSON.stringify(vm.clientConfig) @@ -437,6 +443,19 @@ export default { getDamageCauseFromStore() { return store.getters.order.damage.damageCause; }, + // Maps a stored damageCause to the matching dropdown option value using a + // case-insensitive comparison (load-session can return it uppercased). + // Returns the canonical option value, or the original value if no match. + matchDamageCauseToOption(value) { + if (!value) { + return value; + } + const optionValues = Object.values(this.damageTypesOptions ?? {}); + const match = optionValues.find( + (option) => option?.toLowerCase() === value.toLowerCase() + ); + return match ?? value; + }, getPolicyStateFromStore() { return store.getters.order.policy.state; }, diff --git a/src/layouts/verify-details/verify-details.vue b/src/layouts/verify-details/verify-details.vue index 5fcf78049..a7e5daa23 100644 --- a/src/layouts/verify-details/verify-details.vue +++ b/src/layouts/verify-details/verify-details.vue @@ -31,7 +31,7 @@ placeholderText="MM/DD/YYYY" validationRules="date-of-birth-required" format="MM/dd/yyyy" - modelType="MM/dd/yyyy" + modelType="yyyy-MM-dd" :enableTimePicker="false" :textInputOnly="true" :maxDate="today" @@ -55,7 +55,7 @@ placeholderText="MM/DD/YYYY" validationRules="date-of-loss-required" format="MM/dd/yyyy" - modelType="MM/dd/yyyy" + modelType="yyyy-MM-dd" :enableTimePicker="false" :textInput="true" :maxDate="today" diff --git a/src/store/index.js b/src/store/index.js index a6d32044f..2d30a94c5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -114,6 +114,13 @@ const getDefaultState = () => { phoneNumber: null, isSmsOptIn: null, waitListRequested: null, + address: { + streetAddress: null, + streetAddress2: null, + city: null, + state: null, + zipCode: null, + }, }, damage: { isRepair: null, @@ -141,6 +148,7 @@ const getDefaultState = () => { coverageSubStatus: null, coverageType: null, coverageVerificationType: null, + claimNumber: null, }, parentAccountNumber: 0, accountName: null, @@ -171,20 +179,12 @@ const getDefaultState = () => { currentDeductible: 0, originalDeductible: 0, policyNumber: null, - claimNumber: null, isItac: false, additionalAuthFlag: null, isNoComp: false, insuranceCompanyName: null, phoneNumber: null, phoneExtension: null, - policyAddress: { - streetAddress: null, - streetAddress2: null, - city: null, - state: null, - zipCode: null, - }, dateOfBirth: null, lossTime: null, lossLocation: null, @@ -363,22 +363,22 @@ export const mutations = { state.order.policy.phoneExtension = phoneExtension; }, updateStreetAddress(state, streetAddress) { - state.order.policy.policyAddress.streetAddress = streetAddress; + state.order.customer.address.streetAddress = streetAddress; }, updateStreetAddress2(state, streetAddress2) { - state.order.policy.policyAddress.streetAddress2 = streetAddress2; + state.order.customer.address.streetAddress2 = streetAddress2; }, updateCity(state, city) { - state.order.policy.policyAddress.city = city; + state.order.customer.address.city = city; }, updateState(state, stateValue) { - state.order.policy.policyAddress.state = stateValue; + state.order.customer.address.state = stateValue; }, updateZipCode(state, zipCode) { - state.order.policy.policyAddress.zipCode = zipCode; + state.order.customer.address.zipCode = zipCode; }, updateClaimNumber(state, claimNumber) { - state.order.policy.claimNumber = claimNumber; + state.order.payment.insuranceCoverage.claimNumber = claimNumber; }, updateIsClaimAndCoverage(state, isClaimAndCoverage) { state.order.payment.isClaimAndCoverage = isClaimAndCoverage; @@ -405,13 +405,13 @@ export const mutations = { }; state.order.policy.policyNumber = null; - state.order.policy.claimNumber = null; + state.order.payment.insuranceCoverage.claimNumber = null; state.order.policy.insuranceCompanyName = null; - state.order.policy.policyAddress.streetAddress = null; - state.order.policy.policyAddress.streetAddress2 = null; - state.order.policy.policyAddress.city = null; - state.order.policy.policyAddress.state = null; - state.order.policy.policyAddress.zipCode = null; + state.order.customer.address.streetAddress = null; + state.order.customer.address.streetAddress2 = null; + state.order.customer.address.city = null; + state.order.customer.address.state = null; + state.order.customer.address.zipCode = null; state.order.damage.dateOfLoss = null; state.order.damage.damageCause = null; }, @@ -565,12 +565,12 @@ export const mutations = { updateInsuranceDetails(state, insuranceDetails) { if (insuranceDetails) { state.order.policy.policyNumber = insuranceDetails.policyNumber; - state.order.policy.policyAddress.streetAddress = insuranceDetails.streetAddress; - state.order.policy.policyAddress.streetAddress2 = insuranceDetails.streetAddress2; - state.order.policy.policyAddress.city = insuranceDetails.city; - state.order.policy.policyAddress.state = insuranceDetails.state; - state.order.policy.policyAddress.zipCode = insuranceDetails.zipCode; - state.order.policy.claimNumber = insuranceDetails.claimNumber; + state.order.customer.address.streetAddress = insuranceDetails.streetAddress; + state.order.customer.address.streetAddress2 = insuranceDetails.streetAddress2; + state.order.customer.address.city = insuranceDetails.city; + state.order.customer.address.state = insuranceDetails.state; + state.order.customer.address.zipCode = insuranceDetails.zipCode; + state.order.payment.insuranceCoverage.claimNumber = insuranceDetails.claimNumber; state.order.policy.phoneNumber = insuranceDetails.phoneNumber; state.order.policy.phoneExtension = insuranceDetails.phoneExtension; state.order.policy.morePolicyQuestions = insuranceDetails.morePolicyQuestions; @@ -587,7 +587,6 @@ export const mutations = { state.order.payment.insuranceCoverage.coverageSubStatus = insuranceDetails.coverageSubStatus; } - console.log("::::" + state.order.payment.insuranceCoverage.coverageStatus); }, updateDamageDetails(state, damageDetails) { if (damageDetails) { @@ -958,6 +957,16 @@ export const mutations = { state.order.customer.phoneNumber = sessionInformation.order.customer.homePhone; state.order.customer.isSmsOptIn = sessionInformation.order.customer.isSmsOptIn; + if (sessionInformation.order.customer.address) { + state.order.customer.address = Object.assign(state.order.customer.address, { + streetAddress: sessionInformation.order.customer.address.streetAddress, + streetAddress2: sessionInformation.order.customer.address.streetAddress2, + city: sessionInformation.order.customer.address.city, + state: sessionInformation.order.customer.address.state, + zipCode: sessionInformation.order.customer.address.zipCode, + }); + } + state.applicationUser.experiments = sessionInformation.applicationUser.experiments; state.applicationUser.crmCustomerId = sessionInformation.applicationUser.crmCustomerId; state.applicationUser.pageData = sessionInformation.applicationUser.pageData; @@ -985,20 +994,10 @@ export const mutations = { ? true : false; state.order.policy.policyNumber = sessionInformation.order.policy?.policyNumber; - state.order.policy.claimNumber = sessionInformation.order.policy?.claimNumber; + state.order.payment.insuranceCoverage.claimNumber = sessionInformation.order.insuranceCoverage?.claimNumber; state.order.policy.insuranceCompanyName = sessionInformation.order.policy?.insuranceCompanyName; - if (!state.order.policy.policyAddress) { - state.order.policy.policyAddress = {}; - } - const sessionPolicyAddress = sessionInformation.order.policy?.address; - state.order.policy.policyAddress.streetAddress = sessionPolicyAddress?.streetAddress; - state.order.policy.policyAddress.streetAddress2 = sessionPolicyAddress?.streetAddress2; - state.order.policy.policyAddress.city = sessionPolicyAddress?.city; - state.order.policy.policyAddress.state = sessionPolicyAddress?.state; - state.order.policy.policyAddress.zipCode = sessionPolicyAddress?.zipCode; - state.order.policy.isNoComp = coverageTypeValue(sessionInformation?.order.insuranceCoverage.coverageType) === coverageType.NOCOMP @@ -2668,6 +2667,13 @@ export const actions = { lastName: order.customer.lastName, isSmsOptIn: order.customer.isSmsOptIn, phoneNumber: order.customer.phoneNumber, + address: { + streetAddress: order.customer.address.streetAddress, + streetAddress2: order.customer.address.streetAddress2, + city: order.customer.address.city, + state: order.customer.address.state, + zipCode: order.customer.address.zipCode, + }, }, damage: { numberOfChips: damage.numberOfChips, @@ -2695,6 +2701,7 @@ export const actions = { coverageVerificationType: order.payment.insuranceCoverage.coverageVerificationType, coverageSubStatus: order.payment.insuranceCoverage.coverageSubStatus, + claimNumber: order.payment.insuranceCoverage.claimNumber, }, isInsurance: order.payment.isInsurance, parentAccountNumber: order.payment.parentAccountNumber, @@ -2730,15 +2737,7 @@ export const actions = { isNoComp: order.policy?.isNoComp, currentDeductible: order.policy?.currentDeductible, originalDeductible: order.policy?.originalDeductible, - policyAddress: { - streetAddress: order.policy?.policyAddress?.streetAddress, - streetAddress2: order.policy?.policyAddress?.streetAddress2, - city: order.policy?.policyAddress?.city, - state: order.policy?.policyAddress?.state, - zipCode: order.policy?.policyAddress?.zipCode, - }, policyNumber: order.policy?.policyNumber, - claimNumber: order.policy?.claimNumber, }, serviceLocation: { streetAddress: order.serviceLocation.address,