diff --git a/src/routes/settings.import.tsx b/src/routes/settings.import.tsx index 507aa4f..fa14faa 100644 --- a/src/routes/settings.import.tsx +++ b/src/routes/settings.import.tsx @@ -516,6 +516,8 @@ interface ImportResult { function ImportPage() { const { user } = useAuth(); const [results, setResults] = useState>({}); + const [clientList, setClientList] = useState<{ id: string; name: string }[]>([]); + const [defaultClientId, setDefaultClientId] = useState(""); const ctx = useMemo(() => ({ userId: user?.id ?? "", clientByExt: new Map(), @@ -525,8 +527,18 @@ function ImportPage() { invoiceByExt: new Map(), clientByName: new Map(), caseByNumber: new Map(), + defaultClientId: null, }), [user?.id]); + useEffect(() => { + void supabase + .from("clients") + .select("id,name") + .is("archived_at", null) + .order("name") + .then(({ data }) => setClientList((data ?? []) as { id: string; name: string }[])); + }, []); + // Pre-load lookup caches from existing rows so subsequent imports can join. // Always reload (and paginate past Supabase's 1000-row default limit) so caches // pick up rows added since the page mounted (e.g., from a prior CSV import).