diff --git a/src/routes/documents.pleading.new.tsx b/src/routes/documents.pleading.new.tsx
index 1156e11..8daf654 100644
--- a/src/routes/documents.pleading.new.tsx
+++ b/src/routes/documents.pleading.new.tsx
@@ -12,11 +12,12 @@ import {
} from "@/components/ui/select";
import { FL_CIRCUITS } from "@/lib/florida";
import { Packer } from "docx";
-import { buildPleadingDoc, downloadPleading } from "@/lib/docx-pleading";
+import { buildPleadingDoc, downloadPleading, type PleadingFootnote } from "@/lib/docx-pleading";
+import { RichTextEditor } from "@/components/documents/rich-text-editor";
import { supabase } from "@/integrations/supabase/client";
import { useAuth } from "@/lib/auth";
import { toast } from "sonner";
-import { Download, Save, Loader2 } from "lucide-react";
+import { Download, Save, Loader2, Plus, Trash2 } from "lucide-react";
export const Route = createFileRoute("/documents/pleading/new")({
component: PleadingNewPage,
@@ -32,7 +33,8 @@ function PleadingNewPage() {
const [defendants, setDefendants] = useState("");
const [caseNumber, setCaseNumber] = useState("");
const [title, setTitle] = useState("");
- const [body, setBody] = useState("");
+ const [bodyHtml, setBodyHtml] = useState("
");
+ const [footnotes, setFootnotes] = useState([]);
const [docName, setDocName] = useState("Pleading");
const [saving, setSaving] = useState(false);
@@ -41,7 +43,6 @@ function PleadingNewPage() {
return c?.counties ?? [];
}, [circuit]);
- // Reset county when circuit changes if current county isn't valid
const handleCircuitChange = (v: string) => {
setCircuit(v);
const c = FL_CIRCUITS.find((x) => x.value === v);
@@ -51,7 +52,7 @@ function PleadingNewPage() {
const input = {
courtType, circuit, county,
plaintiffs, defendants, caseNumber,
- title, body,
+ title, bodyHtml, footnotes,
};
const headerLine1 = `IN THE ${courtType} COURT OF THE ${circuit} JUDICIAL CIRCUIT,`;
@@ -75,7 +76,7 @@ function PleadingNewPage() {
const { error: insErr } = await supabase.from("generated_documents").insert({
name: docName || "Pleading",
kind: "pleading",
- payload: input,
+ payload: input as any,
storage_path: path,
created_by: user?.id,
});
@@ -89,6 +90,17 @@ function PleadingNewPage() {
}
};
+ const addFootnote = () => {
+ const nextId = (footnotes[footnotes.length - 1]?.id ?? 0) + 1;
+ setFootnotes([...footnotes, { id: nextId, text: "" }]);
+ };
+ const updateFootnote = (id: number, text: string) =>
+ setFootnotes(footnotes.map((f) => (f.id === id ? { ...f, text } : f)));
+ const removeFootnote = (id: number) => {
+ const remaining = footnotes.filter((f) => f.id !== id).map((f, i) => ({ ...f, id: i + 1 }));
+ setFootnotes(remaining);
+ };
+
return (
@@ -106,8 +118,8 @@ function PleadingNewPage() {
}
/>
+ {/* Top row: settings + caption preview */}
- {/* Form */}
@@ -161,29 +173,25 @@ function PleadingNewPage() {
-
-
- setCaseNumber(e.target.value)} placeholder="e.g. 2025-CA-001234" />
-
-
-
-
- setTitle(e.target.value)} placeholder="e.g. COMPLAINT FOR DAMAGES" />
-
-
-