From aa56de71c01bf1217270844917bbbbb9244fa0d2 Mon Sep 17 00:00:00 2001 From: makearmy Date: Sun, 28 Sep 2025 07:41:15 -0400 Subject: [PATCH] api endpoint fix for me --- app/components/forms/SettingsSubmit.tsx | 838 ++++++++---------------- 1 file changed, 278 insertions(+), 560 deletions(-) diff --git a/app/components/forms/SettingsSubmit.tsx b/app/components/forms/SettingsSubmit.tsx index 0a40c14c..8d74b1c2 100644 --- a/app/components/forms/SettingsSubmit.tsx +++ b/app/components/forms/SettingsSubmit.tsx @@ -28,7 +28,6 @@ function useOptions(path: string) { .then((r) => r.json()) .then((j) => { if (!alive) return; - // Normalize to {id, label} no matter what the API returns const raw = (j?.data ?? j) as any[]; const normalized: Opt[] = Array.isArray(raw) ? raw @@ -40,26 +39,17 @@ function useOptions(path: string) { : []; setOpts(normalized); }) - .finally(() => { - if (alive) setLoading(false); - }); - return () => { - alive = false; - }; + .finally(() => alive && setLoading(false)); + return () => { + alive = false; + }; }, [path, q]); return { opts, loading, setQ }; } function FilterableSelect({ - label, - name, - register, - options, - loading, - onQuery, - placeholder = "—", - required = false, + label, name, register, options, loading, onQuery, placeholder = "—", required = false, }: { label: string; name: string; @@ -71,9 +61,7 @@ function FilterableSelect({ required?: boolean; }) { const [filter, setFilter] = useState(""); - useEffect(() => { - onQuery?.(filter); - }, [filter, onQuery]); + useEffect(() => { onQuery?.(filter); }, [filter, onQuery]); const filtered = useMemo(() => { if (!filter) return options; @@ -93,21 +81,18 @@ function FilterableSelect({ onChange={(e) => setFilter(e.target.value)} /> ); } -function BoolBox({ label, name, register }: { label: string; name: string; register: UseFormRegister }) { +function BoolBox({ label, name, register }:{ + label: string; name: string; register: UseFormRegister; +}) { return (