feat(app): identity screens and /app shell — auth store, login/signup/reset flows, dashboard, account
- 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
This commit is contained in:
1 parent
0f7292f9b3
commit
c517ea267b
46 files changed
+2798
-11
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { useState } from 'react'
|
||||
import { Link, Outlet, useLocation } from 'react-router-dom'
|
||||
import Brand from '@/components/brand/Brand'
|
||||
import LanguageSwitcher from '@/components/brand/LanguageSwitcher'
|
||||
import Icon from '@/components/ui/Icon'
|
||||
import MobileDrawer from './MobileDrawer'
|
||||
import SidebarNav, { NAV_ITEMS } from './SidebarNav'
|
||||
import SignOutButton from './SignOutButton'
|
||||
import UserBadge from './UserBadge'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
/** Title of the current /app page for the top bar, from the nav table. */
|
||||
function pageTitleKey(pathname: string): string {
|
||||
const match = NAV_ITEMS.find((item) =>
|
||||
item.end ? item.to === pathname : pathname.startsWith(item.to) && item.to !== '/',
|
||||
)
|
||||
return match?.labelKey ?? 'shell.nav.dashboard'
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticated shell: fixed sidebar on large screens, light top bar with a
|
||||
* drawer button below. The page content scrolls on its own.
|
||||
*/
|
||||
export default function AppLayout() {
|
||||
const t = useT()
|
||||
const location = useLocation()
|
||||
const [drawerOpen, setDrawerOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<div className="flex min-h-dvh bg-[var(--color-bg)]">
|
||||
<aside className="hidden lg:flex lg:w-64 lg:shrink-0 lg:flex-col border-r border-[var(--color-border)] bg-[var(--color-surface)]">
|
||||
<div className="px-5 py-5">
|
||||
<Link to="/app" aria-label={t('shell.nav.dashboard')} className="inline-block">
|
||||
<Brand size="md" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="flex-1 px-3">
|
||||
<SidebarNav />
|
||||
</div>
|
||||
<div className="space-y-3 border-t border-[var(--color-border)] px-4 py-4">
|
||||
<UserBadge />
|
||||
<SignOutButton className="w-full" />
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<header className="sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-[var(--color-border)] bg-[var(--color-surface)]/95 px-3 backdrop-blur-sm sm:px-6 pt-[env(safe-area-inset-top)]">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setDrawerOpen(true)}
|
||||
aria-label={t('shell.open_menu')}
|
||||
aria-expanded={drawerOpen}
|
||||
className="grid h-11 w-11 place-items-center rounded-lg text-[var(--color-ink)] hover:bg-[var(--color-surface-strong)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)] lg:hidden"
|
||||
>
|
||||
<Icon name="menu" />
|
||||
</button>
|
||||
<Link to="/app" className="lg:hidden" aria-label={t('shell.nav.dashboard')}>
|
||||
<Brand size="sm" />
|
||||
</Link>
|
||||
<h1 className="hidden lg:block text-sm font-medium text-[var(--color-ink-muted)]">
|
||||
{t(pageTitleKey(location.pathname))}
|
||||
</h1>
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
<LanguageSwitcher />
|
||||
</div>
|
||||
</header>
|
||||
<main className="flex-1 px-4 py-6 sm:px-8 sm:py-8">
|
||||
<div className="mx-auto w-full max-w-4xl">
|
||||
<Outlet />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<MobileDrawer open={drawerOpen} onClose={() => setDrawerOpen(false)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user