'use client' import { useState } from 'react' interface Props { capaId: string initialNotes: string | null } export function CapaOwnerNotesForm({ capaId, initialNotes }: Props) { const [notes, setNotes] = useState(initialNotes ?? '') const [saving, setSaving] = useState(false) const [saved, setSaved] = useState(false) const [error, setError] = useState(null) async function handleSave() { setSaving(true) setSaved(false) setError(null) const res = await fetch(`/api/capa/${capaId}`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ owner_notes: notes }), }) setSaving(false) if (!res.ok) { setError('Failed to save. Please try again.') return } setSaved(true) setTimeout(() => setSaved(false), 2000) } return (