'use client' // IdeaTimeline — chronologische merge van IdeaLog + ClaudeQuestion entries. // Server-component zou ook kunnen, maar we mounten dit binnen de client-side // detail-layout dus client is simpler (geen rsc-boundary doorbreken). // // Iconen + kleur per log-type voor snelle herkenning. import { ClipboardList, FileText, HelpCircle, Lightbulb, RefreshCw, StickyNote, Wrench, } from 'lucide-react' import type { IdeaLogType } from '@prisma/client' export interface TimelineLog { id: string type: string content: string metadata: unknown created_at: string } export interface TimelineQuestion { id: string question: string options: string[] | null status: 'open' | 'answered' | 'cancelled' | 'expired' answer: string | null created_at: string expires_at: string } interface Props { logs: TimelineLog[] questions: TimelineQuestion[] } const LOG_ICON: Record = { DECISION: , NOTE: , GRILL_RESULT: , PLAN_RESULT: , STATUS_CHANGE: , JOB_EVENT: , } const LOG_LABEL: Record = { DECISION: 'Beslissing', NOTE: 'Notitie', GRILL_RESULT: 'Grill-resultaat', PLAN_RESULT: 'Plan-resultaat', STATUS_CHANGE: 'Status', JOB_EVENT: 'Job-event', } const QUESTION_STATUS_LABEL: Record = { open: 'Open', answered: 'Beantwoord', cancelled: 'Geannuleerd', expired: 'Verlopen', } export function IdeaTimeline({ logs, questions }: Props) { const merged = [ ...logs.map((l) => ({ kind: 'log' as const, created_at: l.created_at, data: l, })), ...questions.map((q) => ({ kind: 'question' as const, created_at: q.created_at, data: q, })), ].sort((a, b) => (a.created_at < b.created_at ? 1 : -1)) if (merged.length === 0) { return (

Nog geen activiteit op dit idee.

) } return (
    {merged.map((entry, i) => { const time = new Date(entry.created_at).toLocaleString() if (entry.kind === 'log') { const type = entry.data.type as IdeaLogType return (
  1. {LOG_ICON[type] ?? }
    {LOG_LABEL[type] ?? type} ·

    {entry.data.content}

    {entry.data.metadata != null && typeof entry.data.metadata === 'object' && Object.keys(entry.data.metadata as object).length > 0 ? (
    metadata
                          {JSON.stringify(entry.data.metadata, null, 2)}
                        
    ) : null}
  2. ) } const q = entry.data return (
  3. Vraag · {QUESTION_STATUS_LABEL[q.status]} ·

    {q.question}

    {q.options && q.options.length > 0 ? (
      {q.options.map((o, ii) => (
    • {o}
    • ))}
    ) : null} {q.answer ? (

    Antwoord {q.answer}

    ) : null}
  4. ) })}
) }