SSR-1377 Prevent back navigation on TPA submit
This commit is contained in:
parent
8be7d75be4
commit
67133af6fc
9 changed files with 50 additions and 15 deletions
6
src/constants/submit-type.js
Normal file
6
src/constants/submit-type.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
const submitType = Object.freeze({
|
||||
REFERRAL: 0,
|
||||
TPA: 1
|
||||
});
|
||||
|
||||
export default submitType;
|
||||
|
|
@ -54,7 +54,10 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
getUnmatchedVehicleIcon() {
|
||||
switch (this.mainStore.order.vehicle.category) {
|
||||
const category = this.mainStore.hasSubmittedOrder()
|
||||
? this.mainStore.submittedOrder.vehicle.category
|
||||
: this.mainStore.order.vehicle.category;
|
||||
switch (category) {
|
||||
case this.vehicleCategories.CAR:
|
||||
return this.carUnmatchedVehicleIcon;
|
||||
case this.vehicleCategories.SUV:
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ import {
|
|||
import { toTitleCase } from '@/helpers/text-helper.js';
|
||||
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
||||
import applicationConfig from '@/constants/application-config';
|
||||
import submitType from '@/constants/submit-type';
|
||||
|
||||
export default {
|
||||
name: 'order-confirmation',
|
||||
|
|
@ -119,7 +120,7 @@ export default {
|
|||
},
|
||||
mixins: [BaseFormMixin],
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
useMainStore().createSubmittedOrder();
|
||||
useMainStore().createSubmittedOrder(submitType.REFERRAL);
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import getQueryStringParameter from '@/helpers/querystring-helper.js';
|
|||
import { paymentMethods } from '@/constants/payment-method-constants.js';
|
||||
import { submitWorkOrder } from '@/helpers/order-helper.js';
|
||||
import showIssLoadingModal from '@/helpers/loading-modal-helper';
|
||||
import submitType from '@/constants/submit-type';
|
||||
|
||||
export default {
|
||||
name: 'payment-return',
|
||||
|
|
@ -133,7 +134,7 @@ export default {
|
|||
}
|
||||
|
||||
showIssLoadingModal(false);
|
||||
useMainStore().createSubmittedOrder();
|
||||
useMainStore().createSubmittedOrder(submitType.REFERRAL);
|
||||
this.$router.navigate(
|
||||
this.navigationScenarios.PAY_IN_ADVANCE_SUCCESS,
|
||||
this.$route
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import tpaConfirmation from '@/layouts/tpa-confirmation/tpa-confirmation.vue';
|
|||
|
||||
// Supporting Files
|
||||
import { getEnumName, getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { useMainStore } from '@/store/index.js';
|
||||
import { getDefaultState, useMainStore } from '@/store/index.js';
|
||||
import settleAllPromises from '@/helpers/layout-helper.js';
|
||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||
import { mount } from '@vue/test-utils';
|
||||
|
|
@ -53,7 +53,14 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
|||
main: mainInitialState
|
||||
}
|
||||
});
|
||||
useMainStore(testingPinia);
|
||||
const store = useMainStore(testingPinia);
|
||||
store.submittedOrder = {
|
||||
...JSON.parse(JSON.stringify(store.order)),
|
||||
isVerified: store.isVerified,
|
||||
isUnverified: store.isUnverified
|
||||
};
|
||||
store.order = getDefaultState().order;
|
||||
store.hasSubmittedOrder = jest.fn().mockReturnValue(true);
|
||||
methodToRun();
|
||||
|
||||
mountOptions.global.plugins = [testingPinia];
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ export default {
|
|||
},
|
||||
setup() {
|
||||
const mainStore = useMainStore();
|
||||
return { mainStore };
|
||||
const { submittedOrder } = mainStore;
|
||||
return { mainStore, submittedOrder };
|
||||
},
|
||||
computed: {
|
||||
tpaConfirmationHeaderText() {
|
||||
|
|
@ -193,16 +194,16 @@ export default {
|
|||
: VERIFYING_COVERAGE;
|
||||
},
|
||||
currentDeductible() {
|
||||
return useMainStore().order.currentDeductible;
|
||||
return this.submittedOrder.currentDeductible;
|
||||
},
|
||||
preferredShopName() {
|
||||
return toTitleCase(useMainStore().order.serviceLocation.provider.companyName);
|
||||
return toTitleCase(this.submittedOrder.serviceLocation.provider.companyName);
|
||||
},
|
||||
preferredShopPhoneNumber() {
|
||||
return this.toDisplayPhoneNumber(useMainStore().order.serviceLocation.provider.phoneNumber);
|
||||
return this.toDisplayPhoneNumber(this.submittedOrder.serviceLocation.provider.phoneNumber);
|
||||
},
|
||||
isVerified() {
|
||||
return useMainStore().isVerified;
|
||||
return this.submittedOrder.isVerified;
|
||||
},
|
||||
carrierName() {
|
||||
return this.mainStore.issConfig.clientName;
|
||||
|
|
@ -211,7 +212,7 @@ export default {
|
|||
return this.mainStore.issConfig.successReturnURL;
|
||||
},
|
||||
carrierPhoneNumber() {
|
||||
return this.toDisplayPhoneNumber(useMainStore().order.carrierPhoneNumber);
|
||||
return this.toDisplayPhoneNumber(this.submittedOrder.carrierPhoneNumber);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ import {
|
|||
import damageLocationsSelected from '@/constants/damage-locations-selected.js';
|
||||
import { submitWorkOrder } from '@/helpers/order-helper.js';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import submitType from '@/constants/submit-type';
|
||||
|
||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||
|
||||
|
|
@ -357,6 +358,7 @@ export default {
|
|||
pageNameToLog: 'tpa-submit',
|
||||
submitAfterSave: true
|
||||
}).then(() => {
|
||||
useMainStore().createSubmittedOrder(submitType.TPA);
|
||||
this.navigate(this.navigationScenarios.CLICKED_FORWARD);
|
||||
}).catch((submitError) => {
|
||||
useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data));
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import routerParams from '@/router/router-constants/router-params';
|
|||
import canBailoutNavigateBack from '@/helpers/bailout-helper';
|
||||
import bailoutMessage from '@/constants/bailoutMessage';
|
||||
import navigationScenarios from './router-constants/navigation-scenarios';
|
||||
import submitType from '@/constants/submit-type';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
|
|
@ -49,7 +50,7 @@ const routes = [
|
|||
// Intercept all navigation if a submitted order exists in storage
|
||||
if (useMainStore().hasSubmittedOrder()) {
|
||||
if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
|
||||
return await GoToOrderConfirmationPage(next);
|
||||
return await GoToConfirmationPage(next, useMainStore().submittedOrder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,8 +366,8 @@ async function GoToAccessIsDenied(next) {
|
|||
});
|
||||
}
|
||||
|
||||
async function GoToOrderConfirmationPage(next) {
|
||||
const nextPageName = issPageValues.ORDER_CONFIRMATION;
|
||||
async function GoToConfirmationPage(next, order) {
|
||||
const nextPageName = getConfirmationPageFromOrder(order);
|
||||
router.addRoute({
|
||||
path: '/',
|
||||
name: nextPageName,
|
||||
|
|
@ -379,6 +380,17 @@ async function GoToOrderConfirmationPage(next) {
|
|||
});
|
||||
}
|
||||
|
||||
function getConfirmationPageFromOrder(order) {
|
||||
switch (order.submitType) {
|
||||
case submitType.REFERRAL:
|
||||
return issPageValues.ORDER_CONFIRMATION;
|
||||
case submitType.TPA:
|
||||
return issPageValues.TPA_CONFIRMATION;
|
||||
default:
|
||||
return issPageValues.ORDER_CONFIRMATION;
|
||||
}
|
||||
}
|
||||
|
||||
async function GoToStartOn404(next, msgCopy = null, msgHeadline = null) {
|
||||
const errorPageName = issPageValues.WELCOME_PAGE;
|
||||
router.addRoute({
|
||||
|
|
|
|||
|
|
@ -2566,7 +2566,7 @@ export const useMainStore = defineStore({
|
|||
return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null;
|
||||
},
|
||||
|
||||
createSubmittedOrder() {
|
||||
createSubmittedOrder(submitType) {
|
||||
if (this.hasSubmittedOrder()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -2575,6 +2575,8 @@ export const useMainStore = defineStore({
|
|||
const { issConfig } = this;
|
||||
|
||||
submittedOrder.isUnverified = this.isUnverified;
|
||||
submittedOrder.isVerified = this.isVerified;
|
||||
submittedOrder.submitType = submitType;
|
||||
|
||||
// set to local storage
|
||||
window.sessionStorage.setItem(webStorageConstants.SUBMITTED_ORDER, JSON.stringify(submittedOrder));
|
||||
|
|
|
|||
Loading…
Reference in a new issue