diff --git a/app/(marketing)/documentatie/layout.tsx b/app/(marketing)/documentatie/layout.tsx index 4be4ada..5b3f748 100644 --- a/app/(marketing)/documentatie/layout.tsx +++ b/app/(marketing)/documentatie/layout.tsx @@ -6,7 +6,7 @@ import type { ReactNode } from 'react' import { getAllReleases, getCategoryMetadata } from '@/lib/mdx/documentatie' -import ReleaseSidebar from './components/release-sidebar-wrapper' +import { ReleaseSidebar } from './components/release-sidebar' interface ReleasesLayoutProps { children: ReactNode diff --git a/app/epd/clients/[id]/page.tsx b/app/epd/clients/[id]/page.tsx index b922cc0..1a4497f 100644 --- a/app/epd/clients/[id]/page.tsx +++ b/app/epd/clients/[id]/page.tsx @@ -10,7 +10,7 @@ interface ClientDetailPageProps { * Wanneer een gebruiker direct naar /epd/clients/[id] navigeert, * wordt deze automatisch doorgestuurd naar het dashboard. */ -export default async function ClientDetailPage({ +export default async function ClientRedirect({ params, }: ClientDetailPageProps) { const { id } = await params; diff --git a/app/epd/components/epd-header.tsx b/app/epd/components/epd-header.tsx index c976305..5c2bc0a 100644 --- a/app/epd/components/epd-header.tsx +++ b/app/epd/components/epd-header.tsx @@ -1,26 +1,54 @@ "use client"; -import React from 'react'; +import React, { useState, useEffect } from 'react'; import { Search, ChevronDown } from 'lucide-react'; import { usePathname } from 'next/navigation'; +import { getClient } from '../clients/actions'; interface EPDHeaderProps { className?: string; } +interface ClientData { + id: string; + first_name: string; + last_name: string; + birth_date: string; +} + export function EPDHeader({ className = "" }: EPDHeaderProps) { const pathname = usePathname(); + const [selectedClient, setSelectedClient] = useState(null); + const [isLoading, setIsLoading] = useState(false); // Context detection: Level 2 if URL contains /clients/[id] const isClientContext = pathname.match(/\/epd\/clients\/[^\/]+/); const clientId = isClientContext ? pathname.split('/')[3] : null; - // TODO: Fetch actual client data based on clientId - // For now, hardcoded demo data - const selectedClient = clientId ? { - name: "Bas Jansen", - id: "CL0002", - birthDate: "20-11-1992" - } : null; + useEffect(() => { + async function fetchClient() { + if (!clientId) { + setSelectedClient(null); + return; + } + + // Don't re-fetch if we already have the correct client + if (selectedClient?.id === clientId) return; + + setIsLoading(true); + try { + const client = await getClient(clientId); + if (client) { + setSelectedClient(client); + } + } catch (error) { + console.error('Failed to fetch client for header:', error); + } finally { + setIsLoading(false); + } + } + + fetchClient(); + }, [clientId, selectedClient?.id]); return (
@@ -31,17 +59,23 @@ export function EPDHeader({ className = "" }: EPDHeaderProps) { {/* Center: Client Selector (only in Level 2) */}
- {selectedClient && ( + {(selectedClient || isLoading) && clientId && ( )}