# HG changeset patch
# User Arnaud Vergnet <arnaud.vergnet@logilab.fr>
# Date 1712239716 -7200
#      Thu Apr 04 16:08:36 2024 +0200
# Node ID 809ff43d836d5d56adae698b14a02422cb460f1c
# Parent  5334b804219a6ffbaddd201531d897887abc8d2b
feat(frontend): add env variable for app title

diff --git a/frontend/.env.development b/frontend/.env.development
--- a/frontend/.env.development
+++ b/frontend/.env.development
@@ -1,1 +1,2 @@
-RODOLF_API_URL="http://localhost:8080/api"
\ No newline at end of file
+RODOLF_API_URL="http://localhost:8080/api"
+RODOLF_APP_TITLE="Rodolf Dev"
\ No newline at end of file
diff --git a/frontend/.env.production b/frontend/.env.production
--- a/frontend/.env.production
+++ b/frontend/.env.production
@@ -1,1 +1,2 @@
-RODOLF_API_URL="https://rodolf-api.k.intra.logilab.fr/api"
\ No newline at end of file
+RODOLF_API_URL="https://rodolf-api.k.intra.logilab.fr/api"
+RODOLF_APP_TITLE="Rodolf"
\ No newline at end of file
diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx
--- a/frontend/src/app/layout.tsx
+++ b/frontend/src/app/layout.tsx
@@ -3,8 +3,7 @@
 import { AppRouterCacheProvider } from "@mui/material-nextjs/v14-appRouter";
 
 export const metadata: Metadata = {
-  title: "Rodolf",
-  description: "Bonjour",
+  title: process.env.RODOLF_APP_TITLE ?? "Rodolf",
 };
 
 // See https://mui.com/material-ui/guides/nextjs/
@@ -14,6 +13,7 @@
   children: React.ReactNode;
 }) {
   const API_ENDPOINT = process.env.RODOLF_API_URL;
+  const APP_TITLE = process.env.RODOLF_APP_TITLE;
 
   if (!API_ENDPOINT) {
     throw new Error("No api endpoint configured");
@@ -23,7 +23,9 @@
     <html lang="en">
       <body style={{ margin: 0 }}>
         <AppRouterCacheProvider>
-          <BaseLayout endpoint={API_ENDPOINT}>{children}</BaseLayout>
+          <BaseLayout endpoint={API_ENDPOINT} title={APP_TITLE ?? "Rodolf"}>
+            {children}
+          </BaseLayout>
         </AppRouterCacheProvider>
       </body>
     </html>
diff --git a/frontend/src/components/BaseLayout.tsx b/frontend/src/components/BaseLayout.tsx
--- a/frontend/src/components/BaseLayout.tsx
+++ b/frontend/src/components/BaseLayout.tsx
@@ -9,7 +9,8 @@
 export default function BaseLayout({
   children,
   endpoint,
-}: PropsWithChildren<{ endpoint: string }>) {
+  title,
+}: PropsWithChildren<{ endpoint: string; title: string }>) {
   return (
     <ClientProvider endpoint={endpoint}>
       <CustomThemeProvider>
@@ -19,7 +20,7 @@
           sx={{ minHeight: "100vh", display: "flex" }}
         >
           <Stack flex={1}>
-            <Header />
+            <Header title={title} />
             <Box paddingTop={1} paddingBottom={1} flex={1}>
               {children}
             </Box>
diff --git a/frontend/src/components/Header.tsx b/frontend/src/components/Header.tsx
--- a/frontend/src/components/Header.tsx
+++ b/frontend/src/components/Header.tsx
@@ -17,7 +17,11 @@
 import { usePathname } from "next/navigation";
 import { useApiLogout } from "@/api/cubicweb";
 
-export function Header() {
+type HeaderProps = {
+  title: string;
+};
+
+export function Header({ title }: HeaderProps) {
   const pathname = usePathname();
   const loggedIn = pathname !== "/login";
   const logout = useApiLogout();
@@ -66,7 +70,7 @@
                 display: { xs: "none", sm: "none", md: "block" },
               }}
             >
-              Rodolf
+              {title}
             </Typography>
           </Stack>
         </Link>