Merge pull request #767 from Safelite/defect/digital/SSR-1377

SSR-1377 Prevent back navigation on TPA submit
This commit is contained in:
Josh Dassinger 2024-06-25 12:55:53 -05:00 committed by GitHub
commit 56a882bec2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 48 additions and 15 deletions

View file

@ -0,0 +1,6 @@
const submitType = Object.freeze({
SAFELITE: 0,
TPA: 1
});
export default submitType;

View file

@ -54,7 +54,8 @@ export default {
}, },
methods: { methods: {
getUnmatchedVehicleIcon() { getUnmatchedVehicleIcon() {
switch (this.mainStore.order.vehicle.category) { const category = this.mainStore.submittedOrder?.vehicle.category ?? this.mainStore.order.vehicle.category;
switch (category) {
case this.vehicleCategories.CAR: case this.vehicleCategories.CAR:
return this.carUnmatchedVehicleIcon; return this.carUnmatchedVehicleIcon;
case this.vehicleCategories.SUV: case this.vehicleCategories.SUV:

View file

@ -105,6 +105,7 @@ import {
import { toTitleCase } from '@/helpers/text-helper.js'; import { toTitleCase } from '@/helpers/text-helper.js';
import { AppointmentTypeStrings } from '@/constants/schedule-constants'; import { AppointmentTypeStrings } from '@/constants/schedule-constants';
import applicationConfig from '@/constants/application-config'; import applicationConfig from '@/constants/application-config';
import submitType from '@/constants/submit-type';
export default { export default {
name: 'order-confirmation', name: 'order-confirmation',
@ -119,7 +120,7 @@ export default {
}, },
mixins: [BaseFormMixin], mixins: [BaseFormMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
useMainStore().createSubmittedOrder(); useMainStore().createSubmittedOrder(submitType.SAFELITE);
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);

View file

@ -15,6 +15,7 @@ import getQueryStringParameter from '@/helpers/querystring-helper.js';
import { paymentMethods } from '@/constants/payment-method-constants.js'; import { paymentMethods } from '@/constants/payment-method-constants.js';
import { submitWorkOrder } from '@/helpers/order-helper.js'; import { submitWorkOrder } from '@/helpers/order-helper.js';
import showIssLoadingModal from '@/helpers/loading-modal-helper'; import showIssLoadingModal from '@/helpers/loading-modal-helper';
import submitType from '@/constants/submit-type';
export default { export default {
name: 'payment-return', name: 'payment-return',
@ -133,7 +134,7 @@ export default {
} }
showIssLoadingModal(false); showIssLoadingModal(false);
useMainStore().createSubmittedOrder(); useMainStore().createSubmittedOrder(submitType.SAFELITE);
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.PAY_IN_ADVANCE_SUCCESS, this.navigationScenarios.PAY_IN_ADVANCE_SUCCESS,
this.$route this.$route

View file

@ -3,7 +3,7 @@ import tpaConfirmation from '@/layouts/tpa-confirmation/tpa-confirmation.vue';
// Supporting Files // Supporting Files
import { getEnumName, getMountOptions } from '@/helpers/unit-test-helper.js'; 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 settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
@ -53,7 +53,14 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
main: mainInitialState 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(); methodToRun();
mountOptions.global.plugins = [testingPinia]; mountOptions.global.plugins = [testingPinia];

View file

@ -133,7 +133,8 @@ export default {
}, },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
return { mainStore }; const { submittedOrder } = mainStore;
return { mainStore, submittedOrder };
}, },
computed: { computed: {
tpaConfirmationHeaderText() { tpaConfirmationHeaderText() {
@ -193,16 +194,16 @@ export default {
: VERIFYING_COVERAGE; : VERIFYING_COVERAGE;
}, },
currentDeductible() { currentDeductible() {
return useMainStore().order.currentDeductible; return this.submittedOrder.currentDeductible;
}, },
preferredShopName() { preferredShopName() {
return toTitleCase(useMainStore().order.serviceLocation.provider.companyName); return toTitleCase(this.submittedOrder.serviceLocation.provider.companyName);
}, },
preferredShopPhoneNumber() { preferredShopPhoneNumber() {
return this.toDisplayPhoneNumber(useMainStore().order.serviceLocation.provider.phoneNumber); return this.toDisplayPhoneNumber(this.submittedOrder.serviceLocation.provider.phoneNumber);
}, },
isVerified() { isVerified() {
return useMainStore().isVerified; return this.submittedOrder.isVerified;
}, },
carrierName() { carrierName() {
return this.mainStore.issConfig.clientName; return this.mainStore.issConfig.clientName;
@ -211,7 +212,7 @@ export default {
return this.mainStore.issConfig.successReturnURL; return this.mainStore.issConfig.successReturnURL;
}, },
carrierPhoneNumber() { carrierPhoneNumber() {
return this.toDisplayPhoneNumber(useMainStore().order.carrierPhoneNumber); return this.toDisplayPhoneNumber(this.submittedOrder.carrierPhoneNumber);
} }
}, },
mounted() { mounted() {

View file

@ -137,6 +137,7 @@ import {
import damageLocationsSelected from '@/constants/damage-locations-selected.js'; import damageLocationsSelected from '@/constants/damage-locations-selected.js';
import { submitWorkOrder } from '@/helpers/order-helper.js'; import { submitWorkOrder } from '@/helpers/order-helper.js';
import bailoutMessage from '@/constants/bailoutMessage'; import bailoutMessage from '@/constants/bailoutMessage';
import submitType from '@/constants/submit-type';
const VERIFYING_COVERAGE = 'Verifying coverage'; const VERIFYING_COVERAGE = 'Verifying coverage';
@ -357,6 +358,7 @@ export default {
pageNameToLog: 'tpa-submit', pageNameToLog: 'tpa-submit',
submitAfterSave: true submitAfterSave: true
}).then(() => { }).then(() => {
useMainStore().createSubmittedOrder(submitType.TPA);
this.navigate(this.navigationScenarios.CLICKED_FORWARD); this.navigate(this.navigationScenarios.CLICKED_FORWARD);
}).catch((submitError) => { }).catch((submitError) => {
useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data)); useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data));

View file

@ -19,6 +19,7 @@ import routerParams from '@/router/router-constants/router-params';
import canBailoutNavigateBack from '@/helpers/bailout-helper'; import canBailoutNavigateBack from '@/helpers/bailout-helper';
import bailoutMessage from '@/constants/bailoutMessage'; import bailoutMessage from '@/constants/bailoutMessage';
import navigationScenarios from './router-constants/navigation-scenarios'; import navigationScenarios from './router-constants/navigation-scenarios';
import submitType from '@/constants/submit-type';
const routes = [ const routes = [
{ {
@ -49,7 +50,7 @@ const routes = [
// Intercept all navigation if a submitted order exists in storage // Intercept all navigation if a submitted order exists in storage
if (useMainStore().hasSubmittedOrder()) { if (useMainStore().hasSubmittedOrder()) {
if (to.query.issPage !== issPageValues.ENTRY_PAGE) { 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) { async function GoToConfirmationPage(next, order) {
const nextPageName = issPageValues.ORDER_CONFIRMATION; const nextPageName = getConfirmationPageFromOrder(order);
router.addRoute({ router.addRoute({
path: '/', path: '/',
name: nextPageName, name: nextPageName,
@ -379,6 +380,17 @@ async function GoToOrderConfirmationPage(next) {
}); });
} }
function getConfirmationPageFromOrder(order) {
switch (order.submitType) {
case submitType.SAFELITE:
return issPageValues.ORDER_CONFIRMATION;
case submitType.TPA:
return issPageValues.TPA_CONFIRMATION;
default:
return issPageValues.ORDER_CONFIRMATION;
}
}
async function GoToStartOn404(next, msgCopy = null, msgHeadline = null) { async function GoToStartOn404(next, msgCopy = null, msgHeadline = null) {
const errorPageName = issPageValues.WELCOME_PAGE; const errorPageName = issPageValues.WELCOME_PAGE;
router.addRoute({ router.addRoute({

View file

@ -2566,7 +2566,7 @@ export const useMainStore = defineStore({
return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null; return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null;
}, },
createSubmittedOrder() { createSubmittedOrder(submitType) {
if (this.hasSubmittedOrder()) { if (this.hasSubmittedOrder()) {
return; return;
} }
@ -2575,6 +2575,8 @@ export const useMainStore = defineStore({
const { issConfig } = this; const { issConfig } = this;
submittedOrder.isUnverified = this.isUnverified; submittedOrder.isUnverified = this.isUnverified;
submittedOrder.isVerified = this.isVerified;
submittedOrder.submitType = submitType;
// set to local storage // set to local storage
window.sessionStorage.setItem(webStorageConstants.SUBMITTED_ORDER, JSON.stringify(submittedOrder)); window.sessionStorage.setItem(webStorageConstants.SUBMITTED_ORDER, JSON.stringify(submittedOrder));