packages/supabase assets module: closed AssetFailure kinds, begin / quarantine upload (upsert off) / confirm / remove, own-row state read with an explicit column list, download under the SELECT policy. App: client transport (magic byte sniff, never SVG, createImageBitmap, canvas 1024 px, JPEG 0.9, 5 MiB cap), AvatarSection (preview, save, 1 s polling up to 30 s, rejection and failure messages per closed code, removal with confirmation, in-flight row resumed at mount), auth store blob URL revoked on change and sign-out, AvatarCircle in UserBadge and the top bar link to Mon compte (D3), FR/EN strings, fake client extended, 27 new tests (app 300).
91 lines
3.9 KiB
TypeScript
91 lines
3.9 KiB
TypeScript
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, { AvatarCircle } from './UserBadge'
|
|
import { useAuthStore } from '@/state/authStore'
|
|
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)
|
|
const profile = useAuthStore((s) => s.profile)
|
|
const user = useAuthStore((s) => s.user)
|
|
const displayName = profile?.display_name ?? user?.email ?? ''
|
|
|
|
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 sm:gap-3">
|
|
<LanguageSwitcher />
|
|
<Link
|
|
to="/app/account"
|
|
aria-label={t('shell.nav.account')}
|
|
data-testid="topbar-account"
|
|
className="flex min-h-11 items-center gap-2 rounded-full pr-1 pl-1 text-sm text-[var(--color-ink)] hover:bg-[var(--color-surface-strong)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)] sm:pr-3"
|
|
>
|
|
<AvatarCircle size="sm" />
|
|
<span className="hidden max-w-[12rem] truncate sm:inline">{displayName}</span>
|
|
</Link>
|
|
</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>
|
|
)
|
|
}
|