Refactoring.

This commit is contained in:
Jeremy-Z 2026-07-01 14:09:36 -04:00
parent abdda18b4a
commit 5a8c2f1cd3

View file

@ -150,12 +150,14 @@ const router = createRouter({
});
router.beforeEach(async (to, from) => {
const store = useMainStore();
const fromQueryPage = from.query?.issPage;
if (fromQueryPage === undefined) {
showIssLoadingModal(true);
}
const callSaveSession = !useMainStore().order?.referralNumber && (to.name === issPageValues.VEHICLE_SELECTION || to.name === issPageValues.POLICY_VEHICLES);
const callSaveSession = !store.order?.referralNumber && (to.name === issPageValues.VEHICLE_SELECTION || to.name === issPageValues.POLICY_VEHICLES);
if (callSaveSession) {
// Forcing a synchronous savesession call here to create the referral for the first time.
// AfterEach does not support synchronous calls that block navigation. Which is why this is in the beforeEach method.
@ -188,7 +190,6 @@ router.beforeEach(async (to, from) => {
return false;
}
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 !== 'root' && to.name !== issPageValues.CONTACT_CONFIRMATION
&& !canBailoutNavigateBack()) {