Merge pull request #1007 from Safelite/feature/kiener/INSR-6047
INSR-6047 | Provider-preference parity
This commit is contained in:
commit
1136e775ee
9 changed files with 178 additions and 375 deletions
|
|
@ -52,6 +52,7 @@ const errorMessages = Object.freeze({
|
|||
POLICYHOLDER_FIRST_NAME_REQUIRED: 'First name is required.',
|
||||
POLICYHOLDER_LAST_NAME_REQUIRED: 'Last name is required.',
|
||||
ACKNOWLEDGEMENT_REQUIRED: 'You must agree to the terms to continue',
|
||||
NO_SELECTION_REQUIRED: 'Please make a selection to continue',
|
||||
|
||||
YEAR_REQUIRED: 'Vehicle year is required.',
|
||||
MAKE_REQUIRED: 'Vehicle make is required.',
|
||||
|
|
|
|||
6
src/constants/provider-preference.js
Normal file
6
src/constants/provider-preference.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const PROVIDER_PREFERENCE_OPTIONS = Object.freeze({
|
||||
SAFELITE: 'SafeliteOption',
|
||||
TPA: 'TPAOption'
|
||||
});
|
||||
|
||||
export default PROVIDER_PREFERENCE_OPTIONS;
|
||||
|
|
@ -43,41 +43,37 @@ function setupMocks(mockApiResponses) {
|
|||
}
|
||||
|
||||
describe('provider-preference.vue', () => {
|
||||
test('Should navigate to safelite flow when safelite selected', () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
// Act
|
||||
wrapper.vm.selectedProvider = 'SafeliteOption';
|
||||
wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, 'provider-preference');
|
||||
});
|
||||
|
||||
test('Should navigate to tpa flow when TPAOption selected and TPA Flow Enabled', () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
// Act
|
||||
wrapper.vm.selectedProvider = 'TPAOption';
|
||||
useMainStore().issConfig.enableTPAFlow = true;
|
||||
wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED, 'provider-preference');
|
||||
});
|
||||
|
||||
test('Should navigate to tpa disabled route page when TPAOption selected and TPA Flow disabled', () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
// Act
|
||||
wrapper.vm.selectedProvider = 'TPAOption';
|
||||
useMainStore().issConfig.enableTPAFlow = false;
|
||||
wrapper.vm.forwardButtonAction();
|
||||
wrapper.vm.findAnotherShopClicked();
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED, 'provider-preference');
|
||||
});
|
||||
|
||||
test('Should navigate to safelite flow when navigateWithTPARecalAnswer is called with SafeliteOption', () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateWithTPARecalAnswer('SafeliteOption');
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, 'provider-preference');
|
||||
});
|
||||
|
||||
test('Should navigate to TPA flow when navigateWithTPARecalAnswer is called with TPAOption', () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks();
|
||||
|
||||
// Act
|
||||
wrapper.vm.navigateWithTPARecalAnswer('TPAOption');
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED, 'provider-preference');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,76 +15,70 @@
|
|||
id="sub-header"
|
||||
cmsWidgetName="SiteSubHeader"
|
||||
class="mb-0 mt-4 text-center" />
|
||||
<buttonQuestion
|
||||
ref="buttonQuestion"
|
||||
v-model="selectedProvider"
|
||||
class="provider-preference"
|
||||
questionText="Select an option:"
|
||||
:answers="prefAnswers"
|
||||
groupName="prefQuestions"
|
||||
buttonTypeString="providerPrefRadio"
|
||||
:validationRules="rules.optionRequired"
|
||||
isRequired />
|
||||
<div
|
||||
class="mt-4 mb-5"
|
||||
v-html="scheduleWithSafeliteText"></div>
|
||||
<buttonMain
|
||||
ref="buttonMain"
|
||||
class="full-width-button"
|
||||
variant="navigation"
|
||||
buttonText="Schedule now"
|
||||
@clickEvent="scheduleWithSafelite" />
|
||||
<div
|
||||
class="mt-5 mb-5"
|
||||
v-html="scheduleWithOtherText"></div>
|
||||
<textLink
|
||||
class="underlined-text"
|
||||
linkType="navigation"
|
||||
text="Find another shop"
|
||||
href="#"
|
||||
@clickEvent="findAnotherShopClicked" />
|
||||
<siteFooter
|
||||
:ref="SITE_FOOTER_REF_NAME"
|
||||
class="mt-5"
|
||||
class="mt-6"
|
||||
cmsWidgetName="SiteFooterWidget"
|
||||
:isForwardActionDisabled="isForwardActionDisabled"
|
||||
:isForwardButtonNavigationDisabled="isForwardNavigationDisabled"
|
||||
@backClicked="navigateBack"
|
||||
@forwardClicked="forwardButtonAction" />
|
||||
:isForwardButtonHidden="true"
|
||||
@backClicked="navigateBack" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<contentGroupModal
|
||||
:ref="RECAL_MODAL_REF_NAME"
|
||||
cssModalHeadlineClass="text-center"
|
||||
cmsWidgetName="RecalModal" />
|
||||
<steeringModal
|
||||
:ref="STEERING_MODAL_REF_NAME"
|
||||
cmsWidgetName="StateSteeringModal" />
|
||||
<shopPreferenceModal
|
||||
:ref="SHOP_PREFERENCE_MODAL_REF_NAME"
|
||||
cmsWidgetName="ShopPreferenceDrawer"
|
||||
:showSteeringLink="showSteeringLink"
|
||||
@openSteering="openStateSteeringModal" />
|
||||
<tpaRecalModal
|
||||
:ref="TPA_RECAL_MODAL_REF_NAME"
|
||||
cmsWidgetName="TPARecalModal"
|
||||
buttonCmsWidgetName="TPARecalQuestion"
|
||||
:ackError="ackError"
|
||||
@buttonClick="navigateWithTPAAck" />
|
||||
:noSelectionError="noSelectionError"
|
||||
@buttonClick="navigateWithTPARecalAnswer"/>
|
||||
</Form>
|
||||
</template>
|
||||
<script>
|
||||
// Import Supporting Files
|
||||
import {
|
||||
fetchCmsContentForPage,
|
||||
setupModalLink,
|
||||
setupModalLinks
|
||||
} from '@/helpers/cms-content-helper';
|
||||
import settleAllPromises from '@/helpers/layout-helper';
|
||||
import errorMessages from '@/constants/error-messages';
|
||||
import buttonQuestion from '@/digital-components/button-question/button-question.vue';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import baseFormMixin from '@/mixins/base-form-mixin';
|
||||
import PROVIDER_PREFERENCE_OPTIONS from '@/constants/provider-preference';
|
||||
|
||||
// Import Component
|
||||
import baseFormMixin from '@/mixins/base-form-mixin';
|
||||
import { Form } from 'vee-validate';
|
||||
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
||||
import siteSubHeader from '@/iss-components/site-sub-header/site-sub-header.vue';
|
||||
import steeringModal from '@/layouts/provider-preference/steering-modal/steering-modal.vue';
|
||||
import shopPreferenceModal from '@/layouts/provider-preference/shop-preference-modal/shop-preference-modal.vue';
|
||||
import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal.vue';
|
||||
import globalRules from '@/constants/global-rules';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import contentGroupModal from '@/iss-components/content-group-modal/content-group-modal.vue';
|
||||
import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||
import textLink from '@/ux-components/text-link/text-link.vue';
|
||||
import buttonMain from '@/ux-components/button-main/button-main.vue';
|
||||
|
||||
const options = { SAFELITE: 'SafeliteOption', TPA: 'TPAOption' };
|
||||
const RECAL_MODAL_REF_NAME = 'RecalModal';
|
||||
const STEERING_MODAL_REF_NAME = 'StateSteeringModal';
|
||||
const SHOP_PREFERENCE_MODAL_REF_NAME = 'ShopPreferenceDrawer';
|
||||
const TPA_RECAL_MODAL_REF_NAME = 'TPARecalModal';
|
||||
const SITE_FOOTER_REF_NAME = 'siteFooter';
|
||||
|
||||
|
|
@ -97,10 +91,10 @@ export default {
|
|||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
Form,
|
||||
buttonQuestion,
|
||||
buttonMain,
|
||||
steeringModal,
|
||||
shopPreferenceModal,
|
||||
tpaRecalModal,
|
||||
contentGroupModal
|
||||
textLink
|
||||
},
|
||||
mixins: [baseFormMixin],
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
|
|
@ -115,85 +109,37 @@ export default {
|
|||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
|
||||
vm.showSteeringLink = !!vm.$refs[STEERING_MODAL_REF_NAME].ModalBodyText;
|
||||
if (vm.showSteeringLink) {
|
||||
// open steering modal if it has body text, the state is defined in the CMS content and doesn't
|
||||
// populate if the state is not listed in the CMS content
|
||||
if (!!vm.$refs[STEERING_MODAL_REF_NAME].ModalBodyText) {
|
||||
vm.openStateSteeringModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedProvider: null,
|
||||
showSteeringLink: false,
|
||||
tpaAcknowledgement: false,
|
||||
rules: {
|
||||
optionRequired: globalRules.OPTION_REQUIRED
|
||||
},
|
||||
RECAL_MODAL_REF_NAME,
|
||||
providerPreferenceOptions: PROVIDER_PREFERENCE_OPTIONS,
|
||||
STEERING_MODAL_REF_NAME,
|
||||
SHOP_PREFERENCE_MODAL_REF_NAME,
|
||||
TPA_RECAL_MODAL_REF_NAME,
|
||||
SITE_FOOTER_REF_NAME
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isForwardActionDisabled() {
|
||||
return this.selectedProvider === null;
|
||||
},
|
||||
isForwardNavigationDisabled() {
|
||||
return this.selectedProvider === options.TPA && !this.tpaAcknowledgement;
|
||||
},
|
||||
prefAnswers() {
|
||||
const cmsAnswersContent = [
|
||||
{
|
||||
cmsWidgetName: options.SAFELITE
|
||||
},
|
||||
{
|
||||
cmsWidgetName: options.TPA
|
||||
}
|
||||
];
|
||||
// if cms content has not yet loaded, skip
|
||||
if (
|
||||
!this.getCmsContent(
|
||||
cmsAnswersContent[0].cmsWidgetName,
|
||||
'HeaderText'
|
||||
)
|
||||
|| this.getCmsContent(
|
||||
cmsAnswersContent[0].cmsWidgetName,
|
||||
'HeaderText'
|
||||
) === ''
|
||||
) {
|
||||
return {};
|
||||
}
|
||||
const modifiedAnswers = cmsAnswersContent.map((answer) => ({
|
||||
value: answer.cmsWidgetName,
|
||||
buttonLabel: this.getHeaderTextFromCms(answer.cmsWidgetName),
|
||||
buttonLabelSubCopy: this.getSubheaderTextFromCms(answer.cmsWidgetName),
|
||||
buttonBodyCopy: this.getBodyTextFromCms(answer.cmsWidgetName)
|
||||
}));
|
||||
return modifiedAnswers;
|
||||
},
|
||||
ackError() {
|
||||
return errorMessages.ACKNOWLEDGEMENT_REQUIRED;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
prefAnswers(newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
setupModalLink(this, RECAL_MODAL_REF_NAME);
|
||||
}
|
||||
},
|
||||
noSelectionError() {
|
||||
return errorMessages.NO_SELECTION_REQUIRED;
|
||||
},
|
||||
scheduleWithSafeliteText() {
|
||||
return this.getCmsContent('ScheduleWithSafeliteText', 'BodyText');
|
||||
},
|
||||
scheduleWithOtherText() {
|
||||
return this.getCmsContent('ScheduleWithOtherText', 'BodyText');
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
setupModalLinks(this);
|
||||
const pageData = this.mainStore.pageData(issPageValues.PROVIDER_PREFERENCE);
|
||||
this.selectedProvider = pageData?.selectedProvider
|
||||
? pageData.selectedProvider
|
||||
: null;
|
||||
this.tpaAcknowledgement = pageData?.tpaAcknowledgement
|
||||
? pageData.tpaAcknowledgement
|
||||
: false;
|
||||
},
|
||||
methods: {
|
||||
getHeaderTextFromCms(cmsWidgetName) {
|
||||
|
|
@ -213,50 +159,38 @@ export default {
|
|||
return true;
|
||||
},
|
||||
navigateForward(scenario) {
|
||||
showIssLoadingModal(true);
|
||||
this.$router.navigate(scenario, this.$route);
|
||||
},
|
||||
navigateWithTPAAck() {
|
||||
this.mainStore.saveProviderPreferenceData({
|
||||
selectedProvider: this.selectedProvider,
|
||||
tpaAcknowledgement: this.tpaAcknowledgement
|
||||
});
|
||||
showIssLoadingModal(true);
|
||||
this.navigateForward(this.navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED);
|
||||
navigateWithTPARecalAnswer(answer) {
|
||||
if (answer === this.providerPreferenceOptions.TPA) {
|
||||
this.scheduleWithTPA();
|
||||
} else {
|
||||
this.scheduleWithSafelite();
|
||||
}
|
||||
},
|
||||
forwardButtonAction() {
|
||||
if (this.selectedProvider) {
|
||||
let scenario = null;
|
||||
switch (this.selectedProvider) {
|
||||
case options.SAFELITE:
|
||||
this.mainStore.updateIsSafeliteProvider(true);
|
||||
scenario =
|
||||
this.navigationScenarios
|
||||
.CLICKED_FORWARD_WITH_SAFELITE;
|
||||
break;
|
||||
case options.TPA:
|
||||
this.mainStore.updateIsSafeliteProvider(false);
|
||||
if (this.mainStore.issConfig.enableTPAFlow) {
|
||||
if (this.mainStore.hasRecalibrationPart) {
|
||||
this.$refs[TPA_RECAL_MODAL_REF_NAME].openModal();
|
||||
return;
|
||||
}
|
||||
scenario =
|
||||
this.navigationScenarios
|
||||
.CLICKED_FORWARD_WITH_TPA_ENABLED;
|
||||
} else {
|
||||
this.mainStore.setBailout(bailoutMessage.TPANotEnabled());
|
||||
scenario =
|
||||
this.navigationScenarios
|
||||
.CLICKED_FORWARD_WITH_TPA_DISABLED;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
scheduleWithSafelite() {
|
||||
this.mainStore.updateIsSafeliteProvider(true);
|
||||
const scenario = this.navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE;
|
||||
this.navigateForward(scenario);
|
||||
},
|
||||
scheduleWithTPA() {
|
||||
this.mainStore.updateIsSafeliteProvider(false);
|
||||
const scenario = this.navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED;
|
||||
this.navigateForward(scenario);
|
||||
},
|
||||
findAnotherShopClicked() {
|
||||
if (this.mainStore.issConfig.enableTPAFlow) {
|
||||
if (this.mainStore.hasRecalibrationPart) {
|
||||
this.$refs[TPA_RECAL_MODAL_REF_NAME].openModal();
|
||||
return;
|
||||
} else {
|
||||
this.scheduleWithTPA();
|
||||
}
|
||||
} else {
|
||||
this.mainStore.setBailout(bailoutMessage.TPANotEnabled());
|
||||
const scenario = this.navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED;
|
||||
this.navigateForward(scenario);
|
||||
this.mainStore.saveProviderPreferenceData({
|
||||
selectedProvider: this.selectedProvider,
|
||||
tpaAcknowledgement: this.tpaAcknowledgement
|
||||
});
|
||||
}
|
||||
},
|
||||
openStateSteeringModal() {
|
||||
|
|
@ -279,12 +213,11 @@ export default {
|
|||
#sub-header span {
|
||||
color: $black;
|
||||
}
|
||||
.question-text {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
& > span {
|
||||
text-align: left;
|
||||
}
|
||||
.full-width-button {
|
||||
width: 100%;
|
||||
}
|
||||
.underlined-text {
|
||||
text-decoration: underline;
|
||||
}
|
||||
:deep(.safeliteLogo) {
|
||||
background-image: url(~@/assets/img/icons/logo.svg);
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
import { shallowMount } from '@vue/test-utils';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import shopPreferenceModal from '@/layouts/provider-preference/shop-preference-modal/shop-preference-modal.vue';
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||
|
||||
// Mock fetchCmsContentForPage
|
||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
fetchCmsContentForPage: jest.fn(),
|
||||
setupModalLinks: jest.fn()
|
||||
}));
|
||||
|
||||
/** @ignore */
|
||||
function setupMocks(propsData) {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
}
|
||||
});
|
||||
|
||||
mountOptions.propsData = propsData;
|
||||
|
||||
const wrapper = shallowMount(
|
||||
shopPreferenceModal,
|
||||
mountOptions
|
||||
);
|
||||
|
||||
const apiResponses = {};
|
||||
|
||||
settleAllPromises.mockImplementation(() => apiResponses);
|
||||
fetchCmsContentForPage.mockImplementation(() => { });
|
||||
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
describe('provider-preference.vue', () => {
|
||||
test('Should display state specific steering modal link when in state with steering language', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ showSteeringLink: true });
|
||||
|
||||
// Act
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.showSteeringLink).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Should not display state specific steering modal link when not in state with steering language', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({ showSteeringLink: false });
|
||||
|
||||
// Act
|
||||
|
||||
// Test
|
||||
expect(wrapper.vm.showSteeringLink).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
<template>
|
||||
<modal
|
||||
:ref="ModalName"
|
||||
:modalId="ModalName"
|
||||
:onModalClosedCallback="onModalClosed"
|
||||
:footerButtonText="ModalCloseButtonText"
|
||||
@footerButtonEvent="footerButtonClick">
|
||||
<h5 class="text-center mb-4">
|
||||
{{ ModalHeadline }}
|
||||
</h5>
|
||||
<div>
|
||||
<div
|
||||
class="mb-4"
|
||||
v-html="ModalBodyText"></div>
|
||||
<a
|
||||
v-if="showSteeringLink"
|
||||
class="modal-text"
|
||||
@click="openSteeringModal"
|
||||
v-html="ModalSubBodyText">
|
||||
</a>
|
||||
</div>
|
||||
</modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import modal from '@/digital-components/modal/modal.vue';
|
||||
import states from '@/constants/states';
|
||||
|
||||
export default {
|
||||
name: 'content-group-modal',
|
||||
components: {
|
||||
modal
|
||||
},
|
||||
props: {
|
||||
cmsWidgetName: String,
|
||||
showSteeringLink: Boolean
|
||||
},
|
||||
emits: ['openSteering'],
|
||||
data() {
|
||||
return {
|
||||
clickedSteeringLink: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
ModalName() {
|
||||
return this.cmsWidgetName;
|
||||
},
|
||||
ModalHeadline() {
|
||||
return this.getCmsContent(this.cmsWidgetName, 'HeaderText');
|
||||
},
|
||||
ModalSubheadertext() {
|
||||
return this.getCmsContent(this.cmsWidgetName, 'SubheaderText');
|
||||
},
|
||||
ModalBodyText() {
|
||||
return this.getCmsContent(this.cmsWidgetName, 'BodyText');
|
||||
},
|
||||
ModalSubBodyText() {
|
||||
const header = this.getCmsContent(this.cmsWidgetName, 'BodyText2');
|
||||
return header.replace('{custom:state}', states[this.mainStore.order.customer.address.state]);
|
||||
},
|
||||
ModalImage() {
|
||||
return this.getCmsContent(this.cmsWidgetName, 'Image');
|
||||
},
|
||||
ModalCloseButtonText() {
|
||||
return this.getCmsContent(this.cmsWidgetName, 'FooterText');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openModal() {
|
||||
this.$refs[this.ModalName].openModal();
|
||||
},
|
||||
onModalClosed() {
|
||||
if (this.clickedSteeringLink) {
|
||||
this.$emit('openSteering');
|
||||
this.clickedSteeringLink = false;
|
||||
}
|
||||
},
|
||||
footerButtonClick() {
|
||||
this.$refs[this.ModalName].closeModal();
|
||||
},
|
||||
openSteeringModal() {
|
||||
this.clickedSteeringLink = true;
|
||||
this.$refs[this.ModalName].closeModal();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.modal {
|
||||
&.modal-component {
|
||||
.modal-dialog {
|
||||
.modal-content {
|
||||
.modal-body {
|
||||
.modal-sub-body {
|
||||
color: $gray-600;
|
||||
}
|
||||
ul {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
p {
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -38,16 +38,26 @@ describe('tpa-Recal-Modal.vue', () => {
|
|||
test('should show error if not acknowledged', () => {
|
||||
const { wrapper } = setupMocks();
|
||||
wrapper.vm.acknowledged = false;
|
||||
wrapper.vm.tpaRecalAnswer = 'TPAOption';
|
||||
wrapper.vm.footerButtonClick();
|
||||
|
||||
expect(wrapper.vm.showError).toBeTruthy();
|
||||
expect(wrapper.vm.showAcknowledgementError).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should not show error if acknowledged', () => {
|
||||
const { wrapper } = setupMocks();
|
||||
wrapper.vm.acknowledged = true;
|
||||
wrapper.vm.tpaRecalAnswer = 'TPAOption';
|
||||
wrapper.vm.footerButtonClick();
|
||||
|
||||
expect(wrapper.vm.showError).toBeFalsy();
|
||||
expect(wrapper.vm.showAcknowledgementError).toBeFalsy();
|
||||
});
|
||||
test('should show error if no answer selected', () => {
|
||||
const { wrapper } = setupMocks();
|
||||
wrapper.vm.tpaRecalAnswer = '';
|
||||
wrapper.vm.tpaRecalAnswer = undefined;
|
||||
wrapper.vm.footerButtonClick();
|
||||
|
||||
expect(wrapper.vm.showNoSelectionError).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,11 +16,23 @@
|
|||
<tpaRecalToggle
|
||||
class="mb-5"
|
||||
cmsWidgetName="TPARecalModalToggle" />
|
||||
<buttonQuestion
|
||||
ref="tpaRecalQuestion"
|
||||
v-model="tpaRecalAnswer"
|
||||
class="radioQuestion safelite-or-tpa-question windshield-chip-count-question mb-4"
|
||||
:cmsWidgetName="buttonCmsWidgetName"
|
||||
:questionText="tpaRecalQuestionText"
|
||||
:answers="tpaRecalAnswersFromCms"
|
||||
groupName="tpaRecalQuestion"
|
||||
buttonID="tpaRecalQuestion"
|
||||
buttonTypeString="listButtonHorizontal"
|
||||
isRequired></buttonQuestion>
|
||||
<checkBox
|
||||
v-if="showAcknowledgementCheckbox"
|
||||
ref="tpaAcknowledgement"
|
||||
v-model="acknowledged"
|
||||
class="mb-2"
|
||||
:class="showError && ' has-error'"
|
||||
:class="showAcknowledgementError && ' has-error'"
|
||||
:validationRules="rules.optionRequired"
|
||||
checkboxName="tpaAcknowledgement"
|
||||
buttonID="tpaAcknowledgement"
|
||||
|
|
@ -29,9 +41,9 @@
|
|||
:screenReaderOnlyText="ModalSubBodyText"
|
||||
isRequired />
|
||||
<div
|
||||
v-if="showError"
|
||||
v-if="showAcknowledgementError || showNoSelectionError"
|
||||
class="row form-test-error mt-1">
|
||||
<p>{{ ackError }}</p>
|
||||
<p>{{ errorMessage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -42,24 +54,31 @@
|
|||
import modal from '@/digital-components/modal/modal.vue';
|
||||
import tpaRecalToggle from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-toggle/tpa-recal-toggle.vue';
|
||||
import checkBox from '@/ux-components/checkbox/checkbox.vue';
|
||||
import buttonQuestion from '@/digital-components/button-question/button-question.vue';
|
||||
import globalRules from '@/constants/global-rules';
|
||||
import PROVIDER_PREFERENCE_OPTIONS from '@/constants/provider-preference';
|
||||
|
||||
export default {
|
||||
name: 'content-group-modal',
|
||||
components: {
|
||||
modal,
|
||||
tpaRecalToggle,
|
||||
checkBox
|
||||
checkBox,
|
||||
buttonQuestion
|
||||
},
|
||||
props: {
|
||||
cmsWidgetName: String,
|
||||
ackError: String
|
||||
buttonCmsWidgetName: String,
|
||||
ackError: String,
|
||||
noSelectionError: String
|
||||
},
|
||||
emits: ['buttonClick'],
|
||||
data() {
|
||||
return {
|
||||
acknowledged: false,
|
||||
showError: false,
|
||||
showAcknowledgementError: false,
|
||||
showNoSelectionError: false,
|
||||
tpaRecalAnswer: '',
|
||||
rules: {
|
||||
optionRequired: globalRules.OPTION_REQUIRED
|
||||
}
|
||||
|
|
@ -81,13 +100,34 @@ export default {
|
|||
ModalCloseButtonText() {
|
||||
return this.getCmsContent(this.cmsWidgetName, 'FooterText');
|
||||
},
|
||||
tpaRecalQuestionText() {
|
||||
return this.getCmsContent(this.buttonCmsWidgetName, 'QuestionText');
|
||||
},
|
||||
tpaRecalAnswersFromCms() {
|
||||
return this.getCmsContent(this.buttonCmsWidgetName, 'Answers');
|
||||
},
|
||||
showAcknowledgementCheckbox() {
|
||||
return this.tpaRecalAnswer === PROVIDER_PREFERENCE_OPTIONS.TPA;
|
||||
},
|
||||
isButtonDisabled() {
|
||||
return !this.acknowledged;
|
||||
},
|
||||
errorMessage() {
|
||||
if (this.showNoSelectionError) {
|
||||
return this.noSelectionError;
|
||||
} else if (this.showAcknowledgementError) {
|
||||
return this.ackError;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
acknowledged() {
|
||||
this.showError = false;
|
||||
this.showAcknowledgementError = false;
|
||||
},
|
||||
tpaRecalAnswer() {
|
||||
this.showNoSelectionError = false;
|
||||
this.showAcknowledgementError = false;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -96,12 +136,15 @@ export default {
|
|||
},
|
||||
|
||||
footerButtonClick() {
|
||||
// check if acked, if not show error
|
||||
if (this.acknowledged) {
|
||||
if (this.tpaRecalAnswer && (!this.showAcknowledgementCheckbox || this.acknowledged )) {
|
||||
this.$refs[this.ModalName]?.closeModal();
|
||||
this.$emit('buttonClick');
|
||||
this.$emit('buttonClick', this.tpaRecalAnswer);
|
||||
} else if (!this.tpaRecalAnswer) {
|
||||
this.showNoSelectionError = true;
|
||||
this.showAcknowledgementError = false;
|
||||
} else {
|
||||
this.showError = true;
|
||||
this.showAcknowledgementError = true;
|
||||
this.showNoSelectionError = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -130,29 +173,16 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.form-check {
|
||||
.form-check-input {
|
||||
&:checked {
|
||||
+ label {
|
||||
p {
|
||||
font-weight: 400 !important;
|
||||
font-size: 1rem !important;
|
||||
color: $gray-600 !important;
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
.safelite-or-tpa-question {
|
||||
:deep(.question-text) {
|
||||
span {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
p {
|
||||
font-weight: 400 !important;
|
||||
font-size: 1rem !important;
|
||||
color: $gray-600 !important;
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.form-test-error {
|
||||
p {
|
||||
font-weight: 500;
|
||||
|
|
|
|||
|
|
@ -2393,9 +2393,6 @@ export const useMainStore = defineStore({
|
|||
|
||||
return retPricedLineItems;
|
||||
},
|
||||
saveProviderPreferenceData(data) {
|
||||
this.updatePageData({ page: issPageValues.PROVIDER_PREFERENCE, data });
|
||||
},
|
||||
addEventToBus(event) {
|
||||
this.applicationUser.eventBus.push(event);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue