SSR-586 PR Changes
Moved from store to pageData Added bailoutMessage const update setBailout method to accept currentPage or to/from types
This commit is contained in:
parent
6dba70c156
commit
04c375a341
14 changed files with 213 additions and 123 deletions
50
src/constants/bailoutMessage.js
Normal file
50
src/constants/bailoutMessage.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import bailoutCode from '@/constants/bailoutCode';
|
||||
|
||||
function getItemData(data) {
|
||||
if (data === undefined || data == null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (typeof data === 'string') {
|
||||
return data;
|
||||
}
|
||||
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
const bailoutMessage = Object.freeze({
|
||||
unknown: (error) => ({
|
||||
code: bailoutCode.Unknown,
|
||||
message: `An unknown bailout occurred: ${getItemData(error)}`
|
||||
}),
|
||||
saveSessionError: (error) => ({
|
||||
code: bailoutCode.SaveSessionError,
|
||||
message: `An error occurred during save session: ${getItemData(error)}`
|
||||
}),
|
||||
vehicleNotFound: (vin) => ({
|
||||
code: bailoutCode.VehicleNotFound,
|
||||
message: `Failed to find vehicle in system with vin: ${vin}`
|
||||
}),
|
||||
vehicleLookupError: (vin, error) => ({
|
||||
code: bailoutCode.VehicleLookupError,
|
||||
message: `An error occurred looking up Vin: ${vin}. Error: ${getItemData(error)}`
|
||||
}),
|
||||
coverageStatementInvalidState: () => ({
|
||||
code: bailoutCode.CoverageStatementInvalidState,
|
||||
message: 'Coverage Statement has entered an invalid state'
|
||||
}),
|
||||
doNotSeeMyShop: () => ({
|
||||
code: bailoutCode.DoNotSeeMyShop,
|
||||
message: 'User does not see their shop.'
|
||||
}),
|
||||
pricingResponseError: (lineItems, error) => ({
|
||||
code: bailoutCode.PricingResponseError,
|
||||
message: `An error occurred in getPriceOrderItems. Line Items: ${getItemData(lineItems)} Error: ${getItemData(error)}`
|
||||
}),
|
||||
TPANotEnabled: () => ({
|
||||
code: bailoutCode.TPANotEnabled,
|
||||
message: 'User selected TPA when TPA is not enabled for this client'
|
||||
})
|
||||
});
|
||||
|
||||
export default bailoutMessage;
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
import { useMainStore } from '@/store';
|
||||
import BailoutCode from '@/constants/bailoutCode';
|
||||
import issPageValues from "@/router/router-constants/issPage-values";
|
||||
|
||||
function canBailoutNavigateBack() {
|
||||
const code = useMainStore().order.bailout.bailoutCode;
|
||||
const code = useMainStore().pageData(issPageValues.BAILOUT_PAGE)?.bailoutCode;
|
||||
if (code == null) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -11,7 +12,7 @@ function canBailoutNavigateBack() {
|
|||
case BailoutCode.VehicleNotFound:
|
||||
case BailoutCode.DoNotSeeMyShop:
|
||||
case BailoutCode.TPANotEnabled:
|
||||
return false;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
exports[`Bailout page returns the initial data 1`] = `
|
||||
Object {
|
||||
"bailoutCode": null,
|
||||
"bailout": Object {
|
||||
"bailoutCode": 0,
|
||||
},
|
||||
"bailoutPageModel": Object {
|
||||
"email": "alexander.hamilton45@gmail.com",
|
||||
"firstName": "Alexander",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import routerParams from '@/router/router-constants/router-params';
|
|||
import { useMainStore } from '@/store';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import BailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
|
||||
// Mock fetchCmsContentForPage
|
||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
|
|
@ -29,7 +29,16 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
|||
|
||||
const testingPinia = createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
main: {
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.Unknown
|
||||
}
|
||||
}
|
||||
},
|
||||
...mainInitialState
|
||||
}
|
||||
}
|
||||
});
|
||||
useMainStore(testingPinia);
|
||||
|
|
@ -150,9 +159,11 @@ describe('Bailout page', () => {
|
|||
test('returns noTpa widget name when bailout code is BailoutCode.TPANotEnabled', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.TPANotEnabled
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.TPANotEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -166,12 +177,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(name).toBe(expected);
|
||||
});
|
||||
test('returns notSeeingPreferredShop widget name when bailout code is BailoutCode.DoNotSeeMyShop', () => {
|
||||
test('returns notSeeingPreferredShop widget name when bailout code is bailoutCode.DoNotSeeMyShop', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.DoNotSeeMyShop
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.DoNotSeeMyShop
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -185,12 +198,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(name).toBe(expected);
|
||||
});
|
||||
test('returns default widget name when BailoutCode does not match any other content bailout codes', () => {
|
||||
test('returns default widget name when bailoutCode does not match any other content bailout codes', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.Unknown
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -206,12 +221,14 @@ describe('Bailout page', () => {
|
|||
});
|
||||
});
|
||||
describe('subHeaderContentProperty', () => {
|
||||
test('returns "SubHeaderText" when BailoutCode does not match any other content bailout codes', () => {
|
||||
test('returns "SubHeaderText" when bailoutCode does not match any other content bailout codes', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.Unknown
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -225,12 +242,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(name).toBe(expected);
|
||||
});
|
||||
test('returns "HeaderText" when BailoutCode is BailoutCode.TPANotEnabled', () => {
|
||||
test('returns "HeaderText" when bailoutCode is bailoutCode.TPANotEnabled', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.TPANotEnabled
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.TPANotEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -244,12 +263,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(name).toBe(expected);
|
||||
});
|
||||
test('returns "HeaderText" when BailoutCode is BailoutCode.DoNotSeeMyShop', () => {
|
||||
test('returns "HeaderText" when bailoutCode is bailoutCode.DoNotSeeMyShop', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.DoNotSeeMyShop
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.DoNotSeeMyShop
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -265,12 +286,14 @@ describe('Bailout page', () => {
|
|||
});
|
||||
});
|
||||
describe('subContentProperty', () => {
|
||||
test('returns "SecondaryText" when BailoutCode does not match any other content bailout codes', () => {
|
||||
test('returns "SecondaryText" when bailoutCode does not match any other content bailout codes', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.Unknown
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -284,12 +307,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(name).toBe(expected);
|
||||
});
|
||||
test('returns "BodyText" when BailoutCode is BailoutCode.TPANotEnabled', () => {
|
||||
test('returns "BodyText" when bailoutCode is bailoutCode.TPANotEnabled', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.TPANotEnabled
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.TPANotEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -303,12 +328,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(name).toBe(expected);
|
||||
});
|
||||
test('returns "BodyText" when BailoutCode is BailoutCode.DoNotSeeMyShop', () => {
|
||||
test('returns "BodyText" when bailoutCode is bailoutCode.DoNotSeeMyShop', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.DoNotSeeMyShop
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.DoNotSeeMyShop
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -324,12 +351,14 @@ describe('Bailout page', () => {
|
|||
});
|
||||
});
|
||||
describe('stripRteStyle', () => {
|
||||
test('returns false when BailoutCode does not match any other content bailout codes', () => {
|
||||
test('returns false when bailoutCode does not match any other content bailout codes', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.Unknown
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -343,12 +372,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(flag).toBe(expected);
|
||||
});
|
||||
test('returns true when BailoutCode is BailoutCode.TPANotEnabled', () => {
|
||||
test('returns true when bailoutCode is bailoutCode.TPANotEnabled', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.TPANotEnabled
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.TPANotEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -362,12 +393,14 @@ describe('Bailout page', () => {
|
|||
// Assert
|
||||
expect(flag).toBe(expected);
|
||||
});
|
||||
test('returns true when when BailoutCode is BailoutCode.DoNotSeeMyShop', () => {
|
||||
test('returns true when when bailoutCode is bailoutCode.DoNotSeeMyShop', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
bailout: {
|
||||
bailoutCode: BailoutCode.DoNotSeeMyShop
|
||||
applicationUser: {
|
||||
pageData: {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.DoNotSeeMyShop
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ import widgetFields from '@/constants/cms-widget-fields.js';
|
|||
import routerParams from '@/router/router-constants/router-params';
|
||||
import canNavigateBackFromBailout from '@/helpers/bailout-helper';
|
||||
import BailoutCode from '@/constants/bailoutCode';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
|
||||
export default {
|
||||
name: 'bailout-page',
|
||||
|
|
@ -115,7 +116,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
bailoutPageModel: this.getBailoutPageModelFromStore(),
|
||||
bailoutCode: this.mainStore.order.bailout.bailoutCode,
|
||||
bailout: this.mainStore.pageData(issPageValues.BAILOUT_PAGE),
|
||||
widget: {
|
||||
defaultSiteHeader: 'SiteSubHeaderWidget',
|
||||
noTpa: 'ContentGroupNoTPAWidget',
|
||||
|
|
@ -131,7 +132,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
subHeaderCmsWidgetName() {
|
||||
switch (this.bailoutCode) {
|
||||
switch (this.bailout.bailoutCode) {
|
||||
case BailoutCode.TPANotEnabled:
|
||||
return this.widget.noTpa;
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ export default {
|
|||
}
|
||||
},
|
||||
subHeaderContentProperty() {
|
||||
switch (this.bailoutCode) {
|
||||
switch (this.bailout.bailoutCode) {
|
||||
case BailoutCode.TPANotEnabled:
|
||||
case BailoutCode.DoNotSeeMyShop:
|
||||
return widgetFields.CONTENT_GROUP_WIDGET.HEADER_TEXT;
|
||||
|
|
@ -153,7 +154,7 @@ export default {
|
|||
}
|
||||
},
|
||||
subContentProperty() {
|
||||
switch (this.bailoutCode) {
|
||||
switch (this.bailout.bailoutCode) {
|
||||
case BailoutCode.TPANotEnabled:
|
||||
case BailoutCode.DoNotSeeMyShop:
|
||||
return widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT;
|
||||
|
|
@ -163,7 +164,7 @@ export default {
|
|||
}
|
||||
},
|
||||
stripRteStyle() {
|
||||
switch (this.bailoutCode) {
|
||||
switch (this.bailout.bailoutCode) {
|
||||
case BailoutCode.TPANotEnabled:
|
||||
case BailoutCode.DoNotSeeMyShop:
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ import navigationScenarios from '@/router/router-constants/navigation-scenarios.
|
|||
import routerParams from '@/router/router-constants/router-params';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
|
||||
export default {
|
||||
name: 'coverage-statement',
|
||||
|
|
@ -171,27 +172,29 @@ export default {
|
|||
...(clonedGlassParts ?? [])
|
||||
];
|
||||
|
||||
let hasBailedOut = false;
|
||||
let pricingResults = [];
|
||||
if (useMainStore().order.policy.policyLookupSuccessful && useMainStore().order.vehicle.policyVehicleId >= 0) {
|
||||
await useMainStore().getFinalDeductible();
|
||||
pricingResults = await useMainStore().getPriceOrderItems(availableLineItems)
|
||||
.catch((err) => {
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.PricingResponseError, 'An error occurred in getPriceOrderItems.'
|
||||
+ `</ br> ${availableLineItems.join(', ')}`
|
||||
+ `</ br> ${err.data}`);
|
||||
useMainStore().setBailout(to, bailoutMessage.pricingResponseError(availableLineItems.map((li) => li.partNumber), { code: err.code, message: err.message, data: err.data }));
|
||||
hasBailedOut = true;
|
||||
next(`/?issPage=${issPageValues.BAILOUT_PAGE}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.setSupportingItems(resultMap.supportingItems);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.$refs.loadingModal.showModal();
|
||||
vm.initializeComponent(availableLineItems);
|
||||
});
|
||||
if (!hasBailedOut) {
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.setSupportingItems(resultMap.supportingItems);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.$refs.loadingModal.showModal();
|
||||
vm.initializeComponent(availableLineItems);
|
||||
});
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
const mainStore = useMainStore();
|
||||
|
|
@ -387,7 +390,7 @@ export default {
|
|||
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
|
||||
);
|
||||
} else {
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.TPANotEnabled, 'User selected TPA when TPA is not enabled for this client');
|
||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.TPANotEnabled());
|
||||
this.$router.navigate(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED,
|
||||
this.$route,
|
||||
|
|
@ -396,7 +399,7 @@ export default {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.CoverageStatementInvalidState, 'Coverage Statement has entered an invalid state');
|
||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.coverageStatementInvalidState());
|
||||
this.$router.navigate(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_INVALID_STATE,
|
||||
this.$route,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import { getRandomString, getRandomInt } from '@/helpers/data-generation';
|
|||
import endorsementOptions from '@/constants/endorsement-options';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import vehicleSelectionOptions from '@/constants/vehicle-selection-options';
|
||||
import bailoutCode from "@/constants/bailoutCode";
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
|
||||
// Mock fetchCmsContentForPage
|
||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
|
|
@ -75,7 +77,7 @@ function setupMocks() {
|
|||
}
|
||||
|
||||
beforeEach(() => {
|
||||
useMainStore().order.bailout.bailoutCode = null;
|
||||
useMainStore().applicationUser.pageData[issPageValues.BAILOUT_PAGE] = null;
|
||||
});
|
||||
|
||||
describe('policy-vehicles.vue', () => {
|
||||
|
|
@ -259,11 +261,16 @@ describe('policy-vehicles.vue', () => {
|
|||
});
|
||||
|
||||
// Act
|
||||
wrapper.vm.mainStore.order.bailout.bailoutCode = bailoutCode.VehicleLookupError;
|
||||
wrapper.vm.mainStore.applicationUser.pageData[issPageValues.BAILOUT_PAGE] = {
|
||||
'bailout-page': {
|
||||
bailoutCode: bailoutCode.VehicleLookupError
|
||||
}
|
||||
};
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.mainStore.setBailout).toHaveBeenCalledWith(wrapper.vm.$router, bailoutCode.VehicleLookupError, `An error occurred looking up Vin: ${vin}. Error: ${lookupReturnValue.data}`);
|
||||
// eslint-disable-next-line max-len
|
||||
expect(wrapper.vm.mainStore.setBailout).toHaveBeenCalledWith(wrapper.vm.$router.currentRoute, bailoutMessage.vehicleLookupError(vin, lookupReturnValue.data));
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
||||
undefined,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import endorsementOptions from '@/constants/endorsement-options.js';
|
|||
import globalRules from '@/constants/global-rules.js';
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
|
||||
export default {
|
||||
name: 'policy-vehicles',
|
||||
|
|
@ -201,7 +202,7 @@ export default {
|
|||
return this.navigateForward();
|
||||
}
|
||||
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.VehicleLookupError, `An error occurred looking up Vin: ${vehicle.vin}. Error: ${vehicleLookupResponse.data}`);
|
||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.vehicleLookupError(vehicle.vin, vehicleLookupResponse.data));
|
||||
return this.navigateForward();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ import shopPreferenceModal from '@/layouts/provider-preference/shop-preference-m
|
|||
import tpaRecalModal from '@/layouts/provider-preference/tpa-recal-modal/tpa-recal-modal.vue';
|
||||
import globalRules from '@/constants/global-rules';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from "@/constants/bailoutMessage";
|
||||
|
||||
const options = { SAFELITE: 'SafeliteOption', TPA: 'TPAOption' };
|
||||
|
||||
|
|
@ -195,7 +196,7 @@ export default {
|
|||
}
|
||||
scenario = this.navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED;
|
||||
} else {
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.TPANotEnabled, 'User selected TPA when TPA is not enabled for this client');
|
||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.TPANotEnabled());
|
||||
scenario = this.navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,8 @@ import allGlassPartsAndItemsHavePrices from '@/layouts/service-packages/service-
|
|||
import globalRules from '@/constants/global-rules';
|
||||
import servicePackageQuestion from '@/layouts/service-packages/service-package-question/service-package-question.vue';
|
||||
import issPageValues from '@/router/router-constants/issPage-values';
|
||||
import bailoutCode from "@/constants/bailoutCode";
|
||||
import bailoutMessage from "@/constants/bailoutMessage";
|
||||
|
||||
const store = useMainStore();
|
||||
|
||||
|
|
@ -119,29 +121,23 @@ export default {
|
|||
...clonedGlassParts
|
||||
];
|
||||
|
||||
let hasBailedOut = false;
|
||||
const pricingResults = await store.getPriceOrderItems(availableLineItems)
|
||||
.catch((err) => {
|
||||
const errorPageData = {
|
||||
errorData: err.data,
|
||||
functionLocation: 'beforeRouteEnter',
|
||||
functionName: 'getPriceOrderItems',
|
||||
functionParameters: {
|
||||
availableLineItems
|
||||
},
|
||||
routeFrom: from,
|
||||
routeTo: to
|
||||
};
|
||||
useMainStore().updatePageData({ page: issPageValues.BAILOUT_PAGE, data: errorPageData });
|
||||
useMainStore().setBailout(to, bailoutMessage.pricingResponseError(availableLineItems.map((li) => li.partNumber), { code: err.code, message: err.message, data: err.data }));
|
||||
hasBailedOut = true;
|
||||
next(`/?issPage=${issPageValues.BAILOUT_PAGE}`);
|
||||
});
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.pricedGlassParts = clonedGlassParts;
|
||||
vm.supportingItems = resultMap.supportingItems;
|
||||
vm.availableLineItems = pricingResults;
|
||||
});
|
||||
if (!hasBailedOut) {
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.pricedGlassParts = clonedGlassParts;
|
||||
vm.supportingItems = resultMap.supportingItems;
|
||||
vm.availableLineItems = pricingResults;
|
||||
});
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ import { shallowRef } from 'vue';
|
|||
import routerParams from '@/router/router-constants/router-params';
|
||||
import { toTitleCase, toDisplayPhoneNumber } from '@/helpers/text-helper.js';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from "@/constants/bailoutMessage";
|
||||
|
||||
const radiusFilterPairs = [
|
||||
{ radius: 15, filter: '15 miles' },
|
||||
|
|
@ -326,7 +327,7 @@ export default {
|
|||
return getTpaProvidersResult?.data?.shopProviders ?? [];
|
||||
},
|
||||
doNotSeeMyShopLinkClick() {
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.DoNotSeeMyShop, 'User does not see their shop.');
|
||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.doNotSeeMyShop());
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.CLICKED_DO_NOT_SEE_MY_SHOP_LINK,
|
||||
this.$route
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ import vinLocationInformation from '@/layouts/vin-lookup/vin-location-informatio
|
|||
import vinLookupAlerts from '@/layouts/vin-lookup/vin-lookup-alerts/vin-lookup-alerts.vue';
|
||||
import vinQuestion from '@/layouts/vin-lookup/vin-question/vin-question.vue';
|
||||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import bailoutMessage from "@/constants/bailoutMessage";
|
||||
|
||||
export default {
|
||||
name: 'vin-lookup',
|
||||
|
|
@ -178,7 +179,7 @@ export default {
|
|||
|
||||
if (vehicleLookupResponse.error) {
|
||||
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND;
|
||||
this.mainStore.setBailout(this.$router, bailoutCode.VehicleNotFound, `Failed to find vehicle in system with vin: ${this.vin}`);
|
||||
this.mainStore.setBailout(this.$router.currentRoute, bailoutMessage.vehicleNotFound(this.vin));
|
||||
this.resetVehicleFromLookup();
|
||||
this.$refs.siteFooter.removeLoader();
|
||||
// Temp solution to turn on 'disabled' style on the Continue button
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import bailoutCode from '@/constants/bailoutCode';
|
|||
import IssPageValues from '@/router/router-constants/issPage-values';
|
||||
import navigationScenarios from './router-constants/navigation-scenarios';
|
||||
import canBailoutNavigateBack from "@/helpers/bailout-helper";
|
||||
import bailoutMessage from "@/constants/bailoutMessage";
|
||||
|
||||
const routes = [
|
||||
{
|
||||
|
|
@ -130,7 +131,7 @@ router.beforeEach(async (to, from) => {
|
|||
|
||||
const store = useMainStore();
|
||||
// Prevent navigating backwards if we enter a bailout that we are not allowed to go back on
|
||||
if (store.isBailout && from.name === IssPageValues.BAILOUT_PAGE && to.name !== IssPageValues.CONTACT_CONFIRMATION
|
||||
if (store.isBailout && from.name === IssPageValues.BAILOUT_PAGE && to.name !== 'root' && to.name !== IssPageValues.CONTACT_CONFIRMATION
|
||||
&& !canBailoutNavigateBack()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -153,7 +154,7 @@ router.afterEach(async (to, from) => {
|
|||
const saveSessionSynchronous = !!from.params[routerParams.SAVE_SESSION_SYNCHRONOUS];
|
||||
await saveSession({ shouldAwaitSaveSessionQueue: saveSessionSynchronous }).catch((error) => {
|
||||
if (from.name === issPageValues.WELCOME_PAGE) {
|
||||
store.setBailout(router, bailoutCode.SaveSessionError, error.data);
|
||||
store.setBailout(router, bailoutMessage.saveSessionError(error.data));
|
||||
router.navigate(
|
||||
navigationScenarios.SAVE_SESSION_FAILED,
|
||||
{ query: { issPage: issPageValues.WELCOME_PAGE } }
|
||||
|
|
|
|||
|
|
@ -163,13 +163,6 @@ const getDefaultState = () => ({
|
|||
jobMaxMinutes: null,
|
||||
jobMinMinutes: null
|
||||
},
|
||||
bailout: {
|
||||
page: null,
|
||||
url: null,
|
||||
bailoutCode: null,
|
||||
errorMessage: null,
|
||||
submit: false
|
||||
},
|
||||
referralNumber: null,
|
||||
referralDate: null,
|
||||
referralCorrelationId: '00000000-0000-0000-0000-000000000000',
|
||||
|
|
@ -228,7 +221,7 @@ export const useMainStore = defineStore({
|
|||
|| state.order.serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP,
|
||||
isDropOffAppointment: (state) => state.order.serviceLocation.appointmentType === AppointmentTypeStrings.DROP_OFF,
|
||||
isClaimRegistrationRequired: (state) => state.issConfig.isClaimRegistrationRequired,
|
||||
isBailout: (state) => state.order.bailout.bailoutCode !== null,
|
||||
isBailout: (state) => state.applicationUser.pageData[issPageValues.BAILOUT_PAGE] != null,
|
||||
eventBusItem: (state) => (eventCategory, eventSubCategory) => {
|
||||
const matchedEvent = state.applicationUser.eventBus.find(({ category, subCategory }) => category === eventCategory && subCategory === eventSubCategory);
|
||||
return matchedEvent?.eventValue;
|
||||
|
|
@ -1156,12 +1149,6 @@ export const useMainStore = defineStore({
|
|||
jobMaxMinutes: schedule.jobMaxMinutes,
|
||||
jobMinMinutes: schedule.jobMinMinutes
|
||||
},
|
||||
bailout: this.order.bailout.submit ? {
|
||||
page: this.order.bailout.page,
|
||||
url: this.order.bailout.url,
|
||||
bailoutCode: this.order.bailout.bailoutCode,
|
||||
errorMessage: this.order.bailout.errorMessage
|
||||
} : null,
|
||||
referralDate: this.order.referralDate,
|
||||
referralNumber: this.order.referralNumber?.toString(),
|
||||
referralCorrelationId: this.order.referralCorrelationId,
|
||||
|
|
@ -1419,11 +1406,10 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
resetBailout() {
|
||||
this.order.bailout.url = null;
|
||||
this.order.bailout.page = null;
|
||||
this.order.bailout.bailoutCode = null;
|
||||
this.order.bailout.errorMessage = null;
|
||||
this.order.bailout.submit = false;
|
||||
this.updatePageData({
|
||||
page: issPageValues.BAILOUT_PAGE,
|
||||
data: null
|
||||
});
|
||||
},
|
||||
|
||||
updateSupportingItems(partsData) {
|
||||
|
|
@ -2069,11 +2055,17 @@ export const useMainStore = defineStore({
|
|||
this.updateRegistration(registrationInfo);
|
||||
},
|
||||
|
||||
setBailout(router, code, errorMessage) {
|
||||
this.order.bailout.url = window.location.href;
|
||||
this.order.bailout.page = router.currentRoute.value.name;
|
||||
this.order.bailout.bailoutCode = code;
|
||||
this.order.bailout.errorMessage = errorMessage;
|
||||
setBailout(currentRoute, bailoutData) {
|
||||
this.updatePageData({
|
||||
page: issPageValues.BAILOUT_PAGE,
|
||||
data: {
|
||||
url: window.location.href,
|
||||
page: currentRoute.value?.name ?? currentRoute.name,
|
||||
bailoutCode: bailoutData.code,
|
||||
errorMessage: bailoutData.message,
|
||||
submit: false
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setBailoutContactInfo(contact) {
|
||||
|
|
@ -2081,7 +2073,7 @@ export const useMainStore = defineStore({
|
|||
this.order.customer.lastName = contact.lastName;
|
||||
this.order.customer.phoneNumber = contact.phoneNumber;
|
||||
this.order.customer.emailAddress = contact.email;
|
||||
this.order.bailout.submit = true;
|
||||
this.pageData(issPageValues.BAILOUT_PAGE).submit = true;
|
||||
},
|
||||
|
||||
resetRegistrationAndDependencies() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue