- state/authStore: session subscription (initialize + onAuthStateChange), profile + roles load, recovery flag, URL failure; services/localeSync: profiles.locale <-> localeStore - routes: /login, /signup, /forgot-password, /reset-password, /auth/callback; guards RequireAuth (next=) and RedirectIfSignedIn; /app (dashboard), /app/account behind the guard - shell: AppLayout (desktop sidebar, light top bar, mobile drawer), SidebarNav, UserBadge, SignOutButton - account: personal / professional / preferences / security sections, one save each, Zod validation with i18n keys - ui: Icon, FormField, Notice, ButtonLink (buttonClassName shared), PasswordField, OAuthButtons (config-driven) - Home header: Mon espace / Se connecter when Supabase is configured; local tool routes untouched - i18n: auth.*, shell.*, dashboard.*, account.*, home.space.* in fr + en
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { NavLink } from 'react-router-dom'
|
|
import Icon, { type IconName } from '@/components/ui/Icon'
|
|
import { useT } from '@/i18n/useT'
|
|
|
|
interface NavItem {
|
|
to: string
|
|
icon: IconName
|
|
labelKey: string
|
|
hintKey?: string
|
|
end?: boolean
|
|
}
|
|
|
|
export const NAV_ITEMS: readonly NavItem[] = [
|
|
{ to: '/app', icon: 'dashboard', labelKey: 'shell.nav.dashboard', end: true },
|
|
{ to: '/app/account', icon: 'user', labelKey: 'shell.nav.account' },
|
|
{
|
|
to: '/',
|
|
icon: 'tool',
|
|
labelKey: 'shell.nav.local_tool',
|
|
hintKey: 'shell.nav.local_tool_hint',
|
|
},
|
|
]
|
|
|
|
function linkClass(active: boolean): string {
|
|
return [
|
|
'relative flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm transition-colors min-h-11',
|
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]',
|
|
active
|
|
? 'bg-[var(--color-surface-strong)] text-[var(--color-ink)] font-medium before:absolute before:left-0 before:top-2 before:bottom-2 before:w-0.5 before:rounded-full before:bg-[var(--color-accent)]'
|
|
: 'text-[var(--color-ink-muted)] hover:bg-[var(--color-surface-strong)] hover:text-[var(--color-ink)]',
|
|
].join(' ')
|
|
}
|
|
|
|
/** The three destinations of the shell; `onNavigate` closes the mobile drawer. */
|
|
export default function SidebarNav({ onNavigate }: { onNavigate?: () => void }) {
|
|
const t = useT()
|
|
return (
|
|
<nav aria-label={t('shell.nav_label')} className="space-y-1">
|
|
{NAV_ITEMS.map((item) => (
|
|
<NavLink
|
|
key={item.to}
|
|
to={item.to}
|
|
end={item.end}
|
|
onClick={onNavigate}
|
|
className={({ isActive }) => linkClass(isActive)}
|
|
>
|
|
<Icon name={item.icon} size={20} className="shrink-0" />
|
|
<span className="flex min-w-0 flex-col leading-tight">
|
|
<span className="truncate">{t(item.labelKey)}</span>
|
|
{item.hintKey && (
|
|
<span className="truncate text-xs font-normal text-[var(--color-ink-muted)]">
|
|
{t(item.hintKey)}
|
|
</span>
|
|
)}
|
|
</span>
|
|
</NavLink>
|
|
))}
|
|
</nav>
|
|
)
|
|
}
|