'use client'; import { useState } from 'react'; import { FileText, ChevronDown, ChevronUp } from 'lucide-react'; import { Textarea } from '@/components/ui/textarea'; import { Button } from '@/components/ui/button'; import { useCortexStore } from '@/stores/cortex-store'; import { cn } from '@/lib/utils'; interface NoShowDocumentPrefill { documentId: string; content: string; title: string; originalContent?: string; rescriptWarning?: string; } interface NoShowDocumentBlockProps { prefill: NoShowDocumentPrefill; } export function NoShowDocumentBlock({ prefill }: NoShowDocumentBlockProps) { const [content, setContent] = useState(prefill.content ?? ''); const [showOriginal, setShowOriginal] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); const [isDone, setIsDone] = useState(false); const addChatMessage = useCortexStore((s) => s.addChatMessage); const setNoShowStep = useCortexStore((s) => s.setNoShowStep); const handleDispatch = async () => { setIsSubmitting(true); try { const res = await fetch('/api/cortex/noshow/dispatch', { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ documentId: prefill.documentId, finalContent: content, }), }); if (!res.ok) throw new Error('Dispatch mislukt'); setIsDone(true); setNoShowStep('done'); addChatMessage({ type: 'assistant', content: 'Brief is verzendklaar gemaakt. De no-show afhandeling is compleet.', }); } catch { addChatMessage({ type: 'error', content: 'Opslaan mislukt. Probeer het opnieuw.', }); } finally { setIsSubmitting(false); } }; return (
{/* Header */}

{prefill.title || 'Huisartsbrief'}

Aangepast door Cortex
{/* LLM waarschuwing bij fallback naar origineel */} {prefill.rescriptWarning && (
⚠️ {prefill.rescriptWarning}
)} {/* Bewerkbare tekstinhoud */}