From 2f58da93a635844f68adbbfe203f62269f5eb4c2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 19:44:39 +0530 Subject: [PATCH] fix: while last opened tab is loaded instead of rerouting just update the route with hash --- frontend/src/composables/useActiveTabManager.js | 1 - frontend/src/router.js | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/composables/useActiveTabManager.js b/frontend/src/composables/useActiveTabManager.js index 5b9cd484..4fffdedf 100644 --- a/frontend/src/composables/useActiveTabManager.js +++ b/frontend/src/composables/useActiveTabManager.js @@ -46,7 +46,6 @@ export function useActiveTabManager(tabs, storageKey) { let lastVisitedTab = getActiveTabFromLocalStorage() if (lastVisitedTab) { - setActiveTabInUrl(lastVisitedTab) return getTabIndex(lastVisitedTab) } diff --git a/frontend/src/router.js b/frontend/src/router.js index 9490d4f0..2cb37387 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -145,10 +145,16 @@ router.beforeEach(async (to, from, next) => { if (to.name === 'Home' && isLoggedIn) { next({ name: 'Leads' }) } else if (!isLoggedIn) { - window.location.href = "/login?redirect-to=/crm"; + window.location.href = '/login?redirect-to=/crm' } else if (to.matched.length === 0) { next({ name: 'Invalid Page' }) } else { + if (['Deal', 'Lead'].includes(to.name) && !to.hash) { + let storageKey = to.name === 'Deal' ? 'lastDealTab' : 'lastLeadTab' + const activeTab = localStorage.getItem(storageKey) || 'activity' + const hash = '#' + activeTab + next({ ...to, hash }) + } next() } })