'use client';
import { useActionState } from 'react';
import { createNote } from '@/app/actions/notes';
import type { NoteState } from '@/lib/notes-schema';
export function NoteForm({ workspaceId, requestId }: { workspaceId: string; requestId: string }) {
  const [state, action, pending] = useActionState<NoteState, FormData>(createNote, {});
  return <form action={action} className="grid gap-3 max-w-xl">
    <input type="hidden" name="org_id" value={workspaceId} />
    <input type="hidden" name="request_id" value={requestId} />
    <label htmlFor="note-body">New workspace note</label>
    <textarea id="note-body" name="body" required minLength={1} maxLength={2000} className="rounded-md border p-3" />
    <button type="submit" disabled={pending} className="rounded-md border px-4 py-2">{pending ? 'Saving…' : 'Save note'}</button>
    <p role="status" aria-live="polite">{state.error || state.success}</p>
  </form>;
}
