Skip to content

Commit

Permalink
fix: while last opened tab is loaded instead of rerouting just update…
Browse files Browse the repository at this point in the history
… the route with hash
  • Loading branch information
shariquerik committed Sep 28, 2024
1 parent 9e156ef commit 2f58da9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion frontend/src/composables/useActiveTabManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function useActiveTabManager(tabs, storageKey) {

let lastVisitedTab = getActiveTabFromLocalStorage()
if (lastVisitedTab) {
setActiveTabInUrl(lastVisitedTab)
return getTabIndex(lastVisitedTab)
}

Expand Down
8 changes: 7 additions & 1 deletion frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})
Expand Down

0 comments on commit 2f58da9

Please sign in to comment.