diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c4ceb59..c1dc63c 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3,6 +3,7 @@ import { Spinner } from "./ui/index.js"; import { useSession } from "./lib/session.js"; import { AppShell } from "./components/AppShell.js"; import { AuthLayout } from "./components/AuthLayout.js"; +import { DocumentTitle } from "./components/DocumentTitle.js"; import { Login } from "./pages/Login.js"; import { ForgotPassword } from "./pages/ForgotPassword.js"; import { ResetPassword } from "./pages/ResetPassword.js"; @@ -42,39 +43,42 @@ const RequireAdmin = () => { }; export const App = () => ( - - }> - } /> - } /> - } /> - } /> - - - }> + <> + + }> - } /> + } /> + } /> + } /> + } /> - }> - }> - } /> - } /> - } /> - } /> - } /> - } /> + }> + }> + } /> - }> + }> }> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + }> + }> + } /> + } /> + } /> + - - } /> - + } /> + + ); diff --git a/frontend/src/components/DocumentTitle.tsx b/frontend/src/components/DocumentTitle.tsx new file mode 100644 index 0000000..3c3e91a --- /dev/null +++ b/frontend/src/components/DocumentTitle.tsx @@ -0,0 +1,46 @@ +import { useEffect } from "react"; +import { useLocation } from "react-router-dom"; +import { useI18n } from "../lib/i18n.js"; + +const BRAND = "CoHaiSe Cloud"; + +/** + * Clef i18n (chaine source) par section. Le titre de l'onglet devient + * «
| CoHaiSe Cloud », dans la langue courante. Les chemins sont + * compares en prefixe afin de couvrir les eventuels sous-chemins. + */ +const SECTIONS: Array<[string, string]> = [ + ["/files", "Fichiers"], + ["/favorites", "Favoris"], + ["/search", "Recherche"], + ["/gallery", "Galerie"], + ["/trash", "Corbeille"], + ["/profile", "Mon compte"], + ["/admin/comptes", "Comptes"], + ["/admin/stockage", "Stockage"], + ["/admin/audit", "Journal"], + ["/login", "Connexion"], + ["/forgot-password", "Mot de passe oublié"], + ["/reset-password", "Réinitialisation"], + ["/confirm-email", "Confirmation"], + ["/change-password", "Changement requis"], +]; + +const sectionFor = (pathname: string): string | undefined => { + const found = SECTIONS.find( + ([path]) => pathname === path || pathname.startsWith(`${path}/`), + ); + return found?.[1]; +}; + +export const DocumentTitle = () => { + const { pathname } = useLocation(); + const { t } = useI18n(); + + useEffect(() => { + const section = sectionFor(pathname); + document.title = section ? `${t(section)} | ${BRAND}` : BRAND; + }, [pathname, t]); + + return null; +};