From 7875f21b4d3817a0f7f94ab14d51e6b978006533 Mon Sep 17 00:00:00 2001 From: Louis Mazin Date: Mon, 21 Sep 2026 14:18:14 +0200 Subject: [PATCH] nice --- backend/users/apps.py | 10 ++- frontend/src/components/NavBar.jsx | 125 ++++++++++++++++++++++++----- 2 files changed, 112 insertions(+), 23 deletions(-) diff --git a/backend/users/apps.py b/backend/users/apps.py index 4b14488..6aa7f3c 100644 --- a/backend/users/apps.py +++ b/backend/users/apps.py @@ -13,11 +13,16 @@ class UsersConfig(AppConfig): # Only run when the server is actually starting if 'runserver' in sys.argv: try: - # Import here to avoid issues during Django startup from .models import User from decouple import config from django.db import transaction - + + # Don't create/synchronize the configured admin if another + # superuser already exists. + if User.objects.filter(is_superuser=True).exists(): + print('A superuser already exists; no admin user was created.') + return + username = config('ADMIN_USERNAME', default='').strip() password = config('ADMIN_PASSWORD', default='') first_name = config('ADMIN_FIRST_NAME', default='').strip() @@ -50,6 +55,7 @@ class UsersConfig(AppConfig): action = 'created' if created else 'synchronized' print(f'Admin user "{username}" {action}.') + except Exception as e: # Don't fail the entire Django startup if there's an error print(f'Error creating admin user: {e}') diff --git a/frontend/src/components/NavBar.jsx b/frontend/src/components/NavBar.jsx index c42c0b7..29846a9 100644 --- a/frontend/src/components/NavBar.jsx +++ b/frontend/src/components/NavBar.jsx @@ -8,7 +8,6 @@ import { SidebarFooter, SidebarGroup, SidebarGroupContent, - SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, @@ -86,6 +85,82 @@ const NavBar = () => { }, ]; + /* + * Hauteur d'une ligne de navigation. + * + * Le SidebarMenuButton natif fait 32px. + * On lui donne une ligne de 48px et on le centre. + * + * Le header de groupe fait lui aussi 32px. + * En mode plié, il est remplacé visuellement par + * une séparation, mais conserve exactement ses 32px. + */ + const menuItemClass = 'h-12 min-h-12 flex items-center'; + + const buttonClass = ` + w-full + h-8 + min-h-8 + group-data-[collapsible=icon]:size-8! + group-data-[collapsible=icon]:p-2! + `; + + const linkClass = ` + flex + h-full + w-full + items-center + gap-2 + text-base + `; + + /* + * Header de groupe : + * + * Déplié : + * [ Navigation ] 32px + * + * Plié : + * [ ---------------------- ] 32px + * + * Même hauteur dans les deux cas. + */ + const GroupHeader = ({ children }) => ( +
+ {/* Nom du groupe */} + + {children} + + + {/* Séparation en mode plié */} +
+
+ ); + return ( { onMouseLeave={handleMouseLeave} > {/* Logo / nom de la boulangerie */} - + - + { - {/* Navigation */} - - + {/* Navigation */} + + Navigation - + @@ -139,15 +219,18 @@ const NavBar = () => { const Icon = item.icon; return ( - + @@ -166,22 +249,22 @@ const NavBar = () => { {/* Administration */} {user.is_admin && ( - - + + Administration - + - + @@ -201,16 +284,16 @@ const NavBar = () => { {/* Déconnexion */} - +