diff --git a/components/main-nav.tsx b/components/main-nav.tsx index e0f9cada..2c57f556 100644 --- a/components/main-nav.tsx +++ b/components/main-nav.tsx @@ -36,21 +36,6 @@ import { } from "@/components/ui/dropdown-menu"; import { format } from 'date-fns'; import { fr } from 'date-fns/locale'; -import dynamic from "next/dynamic"; - -// Dynamically import heavy components -const UserMenu = dynamic(() => import("./navbar/user-menu"), { - ssr: true, - loading: () =>
-}); - -const SidebarComponent = dynamic(() => import("./sidebar").then(mod => ({ default: mod.Sidebar })), { - ssr: false -}); - -const NavigationItems = dynamic(() => import("./navbar/navigation-items"), { - ssr: true -}); const requestNotificationPermission = async () => { try { @@ -235,42 +220,178 @@ export function MainNav() { return ( <> -
-
- - -
- +
+
+ {/* Left side */} +
+ + Neah Logo - Neah + + + + + + + TimeTracker + + + + Notes + + + + ALMA + + +
- -
- - + + {/* Right side */} +
+ {/* Date and Time with smaller text */} +
+ {formattedDate} + {formattedTime} +
+ + + + + + {status === "authenticated" && session?.user ? ( + + +
+ {getUserInitials()} +
+
+ + +
+ {getDisplayName()} + + +
+ + {statusConfig[userStatus].label} +
+
+ + handleStatusChange('online')} + > + + Online + + handleStatusChange('busy')} + > + + Busy + + handleStatusChange('away')} + > + + Away + + +
+
+
+ + {visibleMenuItems.map((item) => ( + window.location.href = item.href} + > + + {item.title} + + ))} + { + try { + // First sign out from NextAuth + await signOut({ + callbackUrl: '/signin', + redirect: false + }); + + // Then redirect to Keycloak logout with proper parameters + const keycloakLogoutUrl = new URL( + `${process.env.NEXT_PUBLIC_KEYCLOAK_ISSUER}/protocol/openid-connect/logout` + ); + + // Add required parameters + keycloakLogoutUrl.searchParams.append( + 'post_logout_redirect_uri', + window.location.origin + ); + keycloakLogoutUrl.searchParams.append( + 'id_token_hint', + session?.accessToken || '' + ); + + // Redirect to Keycloak logout + window.location.href = keycloakLogoutUrl.toString(); + } catch (error) { + console.error('Error during logout:', error); + // Fallback to simple redirect if something goes wrong + window.location.href = '/signin'; + } + }} + > + + Déconnexion + +
+
+ ) : ( +
+ signIn("keycloak", { callbackUrl: "/" })}> + Login + +
+ )}
-
- - {isSidebarOpen && ( - setIsSidebarOpen(false)} - /> - )} +
+ setIsSidebarOpen(false)} /> ); } diff --git a/components/navbar/navigation-items.tsx b/components/navbar/navigation-items.tsx deleted file mode 100644 index 68cfbacd..00000000 --- a/components/navbar/navigation-items.tsx +++ /dev/null @@ -1,78 +0,0 @@ -"use client"; - -import { - Calendar, - MessageSquare, - Bell, - Clock, - PenLine, - Telescope -} from "lucide-react"; -import Link from "next/link"; -import { Session } from "next-auth"; - -interface NavigationItemsProps { - session: Session | null; -} - -export default function NavigationItems({ session }: NavigationItemsProps) { - const isAuthenticated = !!session?.user; - - // Only show navigation items if user is authenticated - if (!isAuthenticated) { - return null; - } - - const navItems = [ - { - href: '/agenda', - icon: Calendar, - label: 'Calendar' - }, - { - href: '/messages', - icon: MessageSquare, - label: 'Messages' - }, - { - href: '/timetracker', - icon: Clock, - label: 'Time Tracker' - }, - { - href: '/notes', - icon: PenLine, - label: 'Notes' - }, - { - href: '/observatory', - icon: Telescope, - label: 'Observatory' - } - ]; - - return ( - <> -
- {navItems.map((item) => ( - - - - ))} -
- - - - - - ); -} \ No newline at end of file