fix(activities): favorites tab shows login toast instead of navigating when logged out
Tapping Favorites used to drop the user onto an empty page that *then* fired the auth-prompt toast on mount — the navigation was wasted motion. Mirror the Create tab pattern: onClick checks auth first, fires the same toast (with Log in action) when unauthed, and only router-pushes when authed. `path` is kept on the tab so the active-highlight still works when the user is actually on /activities/favorites after logging in (BottomNav highlights via tab.path && isActive(tab.path)). The mount-time toast on ActivitiesFavoritesPage stays as a defensive fallback for direct URL access.
This commit is contained in:
parent
f92d4090dd
commit
aee29f1ad5
1 changed files with 21 additions and 1 deletions
|
|
@ -54,7 +54,27 @@ const tabs = computed<BottomTab[]>(() => [
|
||||||
disabled: !isAuthenticated.value,
|
disabled: !isAuthenticated.value,
|
||||||
},
|
},
|
||||||
{ name: t('activities.nav.map'), icon: Map, path: '/activities/map' },
|
{ name: t('activities.nav.map'), icon: Map, path: '/activities/map' },
|
||||||
{ name: t('activities.nav.favorites'), icon: Heart, path: '/activities/favorites' },
|
{
|
||||||
|
name: t('activities.nav.favorites'),
|
||||||
|
icon: Heart,
|
||||||
|
// path kept so the tab stays active-highlighted while the user is
|
||||||
|
// on /activities/favorites; onClick wins for the actual tap so we
|
||||||
|
// can gate on auth (mirrors the Create tab pattern above).
|
||||||
|
path: '/activities/favorites',
|
||||||
|
onClick: () => {
|
||||||
|
if (!isAuthenticated.value) {
|
||||||
|
toast.info(t('activities.favorites.loginPrompt'), {
|
||||||
|
action: {
|
||||||
|
label: t('activities.favorites.logIn'),
|
||||||
|
onClick: () => router.push('/login'),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
router.push('/activities/favorites')
|
||||||
|
},
|
||||||
|
disabled: !isAuthenticated.value,
|
||||||
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
// Feed tab is active for the bare /activities route AND all sub-paths that
|
// Feed tab is active for the bare /activities route AND all sub-paths that
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue