Refactoring.
This commit is contained in:
parent
abdda18b4a
commit
5a8c2f1cd3
1 changed files with 3 additions and 2 deletions
|
|
@ -150,12 +150,14 @@ const router = createRouter({
|
||||||
});
|
});
|
||||||
|
|
||||||
router.beforeEach(async (to, from) => {
|
router.beforeEach(async (to, from) => {
|
||||||
|
const store = useMainStore();
|
||||||
const fromQueryPage = from.query?.issPage;
|
const fromQueryPage = from.query?.issPage;
|
||||||
|
|
||||||
if (fromQueryPage === undefined) {
|
if (fromQueryPage === undefined) {
|
||||||
showIssLoadingModal(true);
|
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) {
|
if (callSaveSession) {
|
||||||
// Forcing a synchronous savesession call here to create the referral for the first time.
|
// 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.
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = useMainStore();
|
|
||||||
// Prevent navigating backwards if we enter a bailout that we are not allowed to go back on
|
// 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
|
if (store.isBailout && from.name === issPageValues.BAILOUT_PAGE && to.name !== 'root' && to.name !== issPageValues.CONTACT_CONFIRMATION
|
||||||
&& !canBailoutNavigateBack()) {
|
&& !canBailoutNavigateBack()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue