From 361cd2c10806d71cb6407e06ab01ea2aec852820 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 01:12:01 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/documents.pleading.new.tsx | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/routes/documents.pleading.new.tsx b/src/routes/documents.pleading.new.tsx index 9221fc9..4cbda98 100644 --- a/src/routes/documents.pleading.new.tsx +++ b/src/routes/documents.pleading.new.tsx @@ -30,6 +30,7 @@ export const Route = createFileRoute("/documents/pleading/new")({ function PleadingNewPage() { const { user } = useAuth(); const navigate = useNavigate(); + const { from } = Route.useSearch(); const [courtType, setCourtType] = useState<"CIRCUIT" | "COUNTY">("CIRCUIT"); const [circuit, setCircuit] = useState("ELEVENTH"); const [county, setCounty] = useState("Miami-Dade"); @@ -45,6 +46,33 @@ function PleadingNewPage() { const [docName, setDocName] = useState("Pleading"); const [saving, setSaving] = useState(false); + useEffect(() => { + if (!from) return; + (async () => { + const { data, error } = await supabase + .from("generated_documents") + .select("name, payload") + .eq("id", from) + .maybeSingle(); + if (error || !data) return; + const p = (data.payload || {}) as any; + if (p.courtType) setCourtType(p.courtType); + if (p.circuit) setCircuit(p.circuit); + if (p.county) setCounty(p.county); + if (typeof p.plaintiffs === "string") setPlaintiffs(p.plaintiffs); + if (typeof p.defendants === "string") setDefendants(p.defendants); + if (typeof p.caseNumber === "string") setCaseNumber(p.caseNumber); + if (typeof p.title === "string") setTitle(p.title); + if (typeof p.bodyHtml === "string") setBodyHtml(p.bodyHtml); + if (Array.isArray(p.footnotes)) setFootnotes(p.footnotes); + if (typeof p.footerLeft === "string") setFooterLeft(p.footerLeft); + if (typeof p.footerCenter === "string") setFooterCenter(p.footerCenter); + if (typeof p.footerRight === "string") setFooterRight(p.footerRight); + setDocName(`${data.name} (copy)`); + toast.success("Loaded saved pleading"); + })(); + }, [from]); + const counties = useMemo(() => { const c = FL_CIRCUITS.find((x) => x.value === circuit); return c?.counties ?? [];