220 lines
7.9 KiB
Vue
220 lines
7.9 KiB
Vue
<template>
|
|
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
|
<funnelHeader
|
|
cmsWidgetName="FunnelHeaderWidget"
|
|
ref="funnelHeader"
|
|
:overrideImageSrc="clientLogoImageSrc" />
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-12 col-md-10 col-lg-8 col-xl-7">
|
|
<funnelSubHeader
|
|
cmsWidgetName="FunnelSubHeaderWidget"
|
|
class="siteSubHeader pb-4"
|
|
:alignLeft="true" />
|
|
|
|
<textboxQuestion
|
|
isRequired
|
|
class="mb-4"
|
|
cmsWidgetName="PolicyNumberWidget"
|
|
v-model="policyNumber"
|
|
inputId="policyNumber"
|
|
validationRules="policy-number-required" />
|
|
|
|
<datePickerPopup
|
|
v-if="displayDateOfBirth"
|
|
isRequired
|
|
class="mb-4"
|
|
cmsWidgetName="DateOfBirthWidget"
|
|
v-model="dateOfBirth"
|
|
customInputId="dateOfBirth"
|
|
placeholderText="MM/DD/YYYY"
|
|
validationRules="date-of-birth-required"
|
|
format="MM/dd/yyyy"
|
|
modelType="yyyy-MM-dd"
|
|
:enableTimePicker="false"
|
|
:textInputOnly="true"
|
|
:maxDate="today"
|
|
:preventMinMaxNavigation="true" />
|
|
|
|
<textboxQuestion
|
|
isRequired
|
|
class="mb-4"
|
|
cmsWidgetName="ZipWidget"
|
|
v-model="policyZip"
|
|
inputId="policyZip"
|
|
maxLength="5"
|
|
validationRules="zip-code-required|zip-code-format" />
|
|
|
|
<datePickerPopup
|
|
isRequired
|
|
class="mb-4"
|
|
cmsWidgetName="DateOfLossWidget"
|
|
v-model="dateOfLoss"
|
|
customInputId="dateOfLoss"
|
|
placeholderText="MM/DD/YYYY"
|
|
validationRules="date-of-loss-required"
|
|
format="MM/dd/yyyy"
|
|
modelType="yyyy-MM-dd"
|
|
:enableTimePicker="false"
|
|
:textInput="true"
|
|
:maxDate="today"
|
|
:preventMinMaxNavigation="true" />
|
|
|
|
<insuranceNavBar
|
|
cmsWidgetName="FunnelFooterWidget"
|
|
ref="navbar"
|
|
:isForwardActionDisabled="!meta.valid"
|
|
@cancel-clicked="cancelButtonAction"
|
|
@back-clicked="backButtonAction"
|
|
@ForwardClicked="forwardButtonAction" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Form>
|
|
</template>
|
|
|
|
<script>
|
|
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
|
import insuranceNavBar from "@/fmg-components/insurance-nav-bar/insurance-nav-bar";
|
|
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
|
import datePickerPopup from "@/digital-components/date-picker-popup/date-picker-popup";
|
|
import textboxQuestion from "@/digital-components/textbox-question/textbox-question";
|
|
import { Form, defineRule } from "vee-validate";
|
|
import { required } from "@/helpers/validation-rules";
|
|
import { errorMessages } from "@/constants/error-messages";
|
|
import { regex } from "@/helpers/validation-rules";
|
|
|
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
|
import { debugLog } from "@/helpers/debug-log-helper";
|
|
import store from "@/store";
|
|
|
|
// DEFINE VALIDATION RULES
|
|
defineRule("policy-number-required", required(errorMessages.POLICY_NUMBER_REQUIRED));
|
|
defineRule("zip-code-required", required(errorMessages.ZIP_REQUIRED));
|
|
defineRule("zip-code-format", regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.ZIP_FORMAT));
|
|
defineRule("date-of-loss-required", required(errorMessages.DATE_OF_LOSS_REQUIRED));
|
|
defineRule("date-of-birth-required", required(errorMessages.DATE_OF_BIRTH_REQUIRED));
|
|
|
|
export default {
|
|
name: "verify-details",
|
|
mixins: [],
|
|
data() {
|
|
return {
|
|
clientConfig: {},
|
|
policyNumber: this.getPolicyNumberFromStore(),
|
|
policyZip: this.getPolicyZipFromStore(),
|
|
dateOfLoss: this.getDateOfLossFromStore(),
|
|
dateOfBirth: this.getDateOfBirthFromStore(),
|
|
};
|
|
},
|
|
components: {
|
|
Form,
|
|
funnelHeader,
|
|
insuranceNavBar,
|
|
funnelSubHeader,
|
|
datePickerPopup,
|
|
textboxQuestion,
|
|
},
|
|
// Ensure CMS content is fetched during route navigation without depending on `to`/`from`
|
|
async beforeRouteEnter(to, from, next) {
|
|
const clientConfigPageName = `client_${store.getters.order.payment.parentAccountNumber}`;
|
|
const clientConfigPromise = fetchCmsContentForPage(clientConfigPageName);
|
|
|
|
const pageName = to.name;
|
|
const cmsContentPromise = fetchCmsContentForPage(pageName);
|
|
const promiseResultMap = [
|
|
{
|
|
resultKey: "cmsContent",
|
|
promise: cmsContentPromise,
|
|
},
|
|
{
|
|
resultKey: "clientConfig",
|
|
promise: clientConfigPromise,
|
|
},
|
|
];
|
|
const resultMap = await settleAllPromises(promiseResultMap);
|
|
next((vm) => {
|
|
vm.setCmsContent(resultMap.cmsContent);
|
|
vm.clientConfig = resultMap.clientConfig ?? {};
|
|
debugLog(
|
|
`verify-details clientConfig::${clientConfigPageName}`,
|
|
JSON.stringify(vm.clientConfig)
|
|
);
|
|
});
|
|
},
|
|
|
|
computed: {
|
|
clientLogoImageSrc() {
|
|
return this.clientConfig?.ClientLogoWidget?.Image || "";
|
|
},
|
|
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 {};
|
|
}
|
|
},
|
|
displayDateOfBirth() {
|
|
return this.parsedClientConfig.displayDateOfBirth ?? false;
|
|
},
|
|
},
|
|
|
|
methods: {
|
|
getPolicyNumberFromStore() {
|
|
return store.getters.order.policy.policyNumber;
|
|
},
|
|
getPolicyZipFromStore() {
|
|
return store.getters.order.policy.zipCode;
|
|
},
|
|
getDateOfLossFromStore() {
|
|
return store.getters.order.damage.dateOfLoss;
|
|
},
|
|
getDateOfBirthFromStore() {
|
|
return store.getters.order.policy.dateOfBirth;
|
|
},
|
|
cancelButtonAction() {
|
|
this.$router.navigateWithoutSaving(
|
|
this.navigationScenarios.CLICKED_CANCEL_VERIFICATION,
|
|
this.pageName
|
|
);
|
|
},
|
|
backButtonAction() {
|
|
this.$router.navigateWithoutSaving(
|
|
this.navigationScenarios.CLICKED_BACK,
|
|
this.pageName
|
|
);
|
|
},
|
|
async forwardButtonAction() {
|
|
this.$router.navigateWithSaving(
|
|
this.navigationScenarios.CLICKED_FORWARD,
|
|
this.pageName
|
|
);
|
|
},
|
|
arePagePrerequisitesValid() {
|
|
return true;
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.cc-page-title {
|
|
font-size: 20px !important;
|
|
line-height: 1.325;
|
|
font-weight: 300;
|
|
color: $black;
|
|
}
|
|
.cc-page-instructions {
|
|
font-size: 16px !important;
|
|
font-weight: 400;
|
|
color: $gray-600;
|
|
line-height: 1.625;
|
|
}
|
|
</style>
|