185 lines
7 KiB
Vue
185 lines
7 KiB
Vue
<template>
|
|
<Form
|
|
ref="theForm"
|
|
v-slot="{ meta }"
|
|
@submit="onSubmit"
|
|
@invalidSubmit="onInvalidSubmit">
|
|
<div class="page-container-grouped-styles">
|
|
<siteHeader
|
|
ref="siteHeader"
|
|
cmsWidgetName="SiteHeaderWidget" />
|
|
<div class="main-content-container">
|
|
<siteSubHeader
|
|
ref="siteSubHeader"
|
|
:cmsWidgetName="subHeaderCmsWidgetName"
|
|
:contentProperty="subHeaderContentProperty"
|
|
:stripRteStyle="stripRteStyle"
|
|
:subContentProperty="subContentProperty"
|
|
class="sub-header-content"
|
|
justification="left" />
|
|
<textboxQuestion
|
|
ref="firstName"
|
|
v-model="bailoutPageModel.firstName"
|
|
inputId="firstNameField"
|
|
cmsWidgetName="FirstNameQuestion"
|
|
isRequired
|
|
disableAutoFill
|
|
:validationRules="rules.firstName" />
|
|
<textboxQuestion
|
|
ref="lastName"
|
|
v-model="bailoutPageModel.lastName"
|
|
inputId="lastNameField"
|
|
cmsWidgetName="LastNameQuestion"
|
|
isRequired
|
|
disableAutoFill
|
|
:validationRules="rules.lastName" />
|
|
<textboxQuestion
|
|
ref="phoneNumber"
|
|
v-model="bailoutPageModel.phoneNumber"
|
|
inputId="phoneNumberField"
|
|
cmsWidgetName="PhoneNumberQuestion"
|
|
isRequired
|
|
mask="###-###-####"
|
|
disableAutoFill
|
|
:validationRules="rules.phoneNumber" />
|
|
<textboxQuestion
|
|
ref="emailAddress"
|
|
v-model="bailoutPageModel.email"
|
|
inputId="emailAddressField"
|
|
cmsWidgetName="EmailAddressQuestion"
|
|
isRequired
|
|
disableAutoFill
|
|
:validationRules="rules.email" />
|
|
<siteFooter
|
|
ref="siteFooter"
|
|
class="footer-content-container"
|
|
cmsWidgetName="SiteFooterWidget"
|
|
:isForwardActionDisabled="!meta.valid"
|
|
@backClicked="backButtonAction"
|
|
@ForwardClicked="forwardButtonAction" />
|
|
</div>
|
|
</div>
|
|
</Form>
|
|
</template>
|
|
<script>
|
|
// Components
|
|
import { Form } from 'vee-validate';
|
|
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
|
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
|
|
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
|
import textboxQuestion from '@/digital-components/textbox-question/textbox-question.vue';
|
|
// Supporting files
|
|
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
|
import globalRules from '@/constants/global-rules';
|
|
import settleAllPromises from '@/helpers/layout-helper';
|
|
import { useMainStore } from '@/store';
|
|
import widgetFields from '@/constants/cms-widget-fields.js';
|
|
import routerParams from '@/router/router-constants/router-params';
|
|
|
|
export default {
|
|
name: 'bailout-page',
|
|
components: {
|
|
siteHeader,
|
|
siteSubHeader,
|
|
siteFooter,
|
|
textboxQuestion,
|
|
// eslint-disable-next-line vue/no-reserved-component-names
|
|
Form
|
|
},
|
|
mixins: [BaseFormMixin],
|
|
async beforeRouteEnter(to, from, next) {
|
|
// Call APIs
|
|
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
|
// Settle promises and get results
|
|
const promiseResultMap = [
|
|
{
|
|
resultKey: 'cmsContent',
|
|
promise: cmsContentPromise
|
|
}
|
|
];
|
|
// use resultMap to populate layout content.
|
|
const resultMap = await settleAllPromises(promiseResultMap);
|
|
|
|
const pageData = useMainStore().pageData(to.query.issPage);
|
|
next((vm) => {
|
|
vm.setCmsContent(resultMap.cmsContent);
|
|
vm.setNotSeeingPreferShop(pageData[routerParams.NOT_SEEING_PREFERRED_SHOP]);
|
|
});
|
|
},
|
|
data() {
|
|
return {
|
|
notSeeingPreferredShop: false,
|
|
bailoutPageModel: this.getBailoutPageModelFromStore(),
|
|
widget: {
|
|
defaultSiteHeader: 'SiteSubHeaderWidget',
|
|
noTpa: 'ContentGroupNoTPAWidget',
|
|
notSeeingPreferredShop: 'ContentGroupNotSeeingPreferredShop'
|
|
},
|
|
rules: {
|
|
firstName: globalRules.FIRST_NAME_REQUIRED,
|
|
lastName: globalRules.LAST_NAME_REQUIRED,
|
|
phoneNumber: `${globalRules.PHONE_NUMBER_REQUIRED}|${globalRules.PHONE_NUMBER_FORMAT}`,
|
|
email: `${globalRules.EMAIL_ADDRESS_REQUIRED}|${globalRules.EMAIL_ADDRESS_FORMAT}`
|
|
}
|
|
};
|
|
},
|
|
computed: {
|
|
subHeaderCmsWidgetName() {
|
|
if (!this.isTpaEnabled) {
|
|
return this.widget.noTpa;
|
|
}
|
|
if (this.notSeeingPreferredShop) {
|
|
return this.widget.notSeeingPreferredShop;
|
|
}
|
|
return this.widget.defaultSiteHeader;
|
|
},
|
|
subHeaderContentProperty() {
|
|
return !this.isTpaEnabled || this.notSeeingPreferredShop
|
|
? widgetFields.CONTENT_GROUP_WIDGET.HEADER_TEXT
|
|
: widgetFields.SUB_HEADER_WIDGET.SUB_HEADER_TEXT;
|
|
},
|
|
subContentProperty() {
|
|
return !this.isTpaEnabled || this.notSeeingPreferredShop
|
|
? widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT
|
|
: widgetFields.SUB_HEADER_WIDGET.SECONDARY_TEXT;
|
|
},
|
|
stripRteStyle() {
|
|
return !this.isTpaEnabled || this.notSeeingPreferredShop;
|
|
},
|
|
isTpaEnabled() {
|
|
return useMainStore().issConfig.enableTPAFlow;
|
|
}
|
|
},
|
|
methods: {
|
|
backButtonAction() {
|
|
// route to move backwards
|
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK_PREVIOUS, this.$route);
|
|
},
|
|
forwardButtonAction() {
|
|
this.$router.navigate(
|
|
this.navigationScenarios.CLICKED_FORWARD,
|
|
this.$route,
|
|
{},
|
|
{},
|
|
this.bailoutPageModel
|
|
);
|
|
},
|
|
getBailoutPageModelFromStore() {
|
|
return {
|
|
firstName: useMainStore().order.customer.firstName,
|
|
lastName: useMainStore().order.customer.lastName,
|
|
phoneNumber: useMainStore().order.customer.phoneNumber,
|
|
email: useMainStore().order.customer.emailAddress
|
|
};
|
|
},
|
|
setNotSeeingPreferShop(value) {
|
|
this.notSeeingPreferredShop = value ?? false;
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import '@/styles/bailout-common.scss';
|
|
</style>
|