"use client"; import React, { useState } from "react"; export default function NoteForm({ projectId }) { const [note, setNote] = useState(""); const [status, setStatus] = useState(null); async function handleSubmit(e) { e.preventDefault(); const res = await fetch("/api/notes", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ project_id: projectId, note }), }); if (res.ok) { setNote(""); setStatus("Note added"); window.location.reload(); } else { setStatus("Failed to save note"); } } return (
); }