Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-18 01:12:01 +00:00
co-authored by renee-png
parent 6b38292218
commit 361cd2c108
+28
View File
@@ -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<string>("ELEVENTH");
const [county, setCounty] = useState<string>("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 ?? [];