1
0
forked from test/crm

fix: while last opened tab is loaded instead of rerouting just update the route with hash

This commit is contained in:
Shariq Ansari 2024-09-28 19:44:39 +05:30
parent 9e156efe9b
commit 2f58da93a6
2 changed files with 7 additions and 2 deletions

View File

@ -46,7 +46,6 @@ export function useActiveTabManager(tabs, storageKey) {
let lastVisitedTab = getActiveTabFromLocalStorage()
if (lastVisitedTab) {
setActiveTabInUrl(lastVisitedTab)
return getTabIndex(lastVisitedTab)
}

View File

@ -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()
}
})