From 5c3731528f8868cc7711b6c6bb0b237e70b26eb8 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:11:21 +0000 Subject: [PATCH 1/5] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- .../quick-add/quick-add-call-log.tsx | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/components/quick-add/quick-add-call-log.tsx b/src/components/quick-add/quick-add-call-log.tsx index 66c5521..8eccc5b 100644 --- a/src/components/quick-add/quick-add-call-log.tsx +++ b/src/components/quick-add/quick-add-call-log.tsx @@ -63,25 +63,54 @@ export function QuickAddCallLog() { useEffect(() => { if (!open) return; (async () => { - const [{ data: cs }, { data: ks }, { data: ct }] = await Promise.all([ + const [{ data: cs }, { data: ks }] = await Promise.all([ supabase.from("clients").select("id, name").is("archived_at", null).order("name"), supabase .from("cases") .select("id, case_number, title, client_id") .is("archived_at", null) .order("case_number", { ascending: false }), - supabase - .from("contacts") - .select("id, name, phone") - .is("archived_at", null) - .order("name"), ]); setClients(cs ?? []); setCases((ks ?? []) as CaseOpt[]); - setContacts((ct ?? []) as ContactOpt[]); })(); }, [open]); + // Server-side contact search (debounced). No preloaded list — every keystroke queries the DB. + const [contactQuery, setContactQuery] = useState(""); + const [contactResults, setContactResults] = useState([]); + const [contactSearching, setContactSearching] = useState(false); + const [selectedContact, setSelectedContact] = useState(null); + const [contactPopoverOpen, setContactPopoverOpen] = useState(false); + + useEffect(() => { + if (!open) return; + const term = contactQuery.trim(); + setContactSearching(true); + let cancelled = false; + const handle = setTimeout(async () => { + let q = supabase + .from("contacts") + .select("id, name, phone") + .is("archived_at", null) + .order("name") + .limit(25); + if (term) { + const esc = term.replace(/[%,]/g, " "); + q = q.or(`name.ilike.%${esc}%,phone.ilike.%${esc}%,email.ilike.%${esc}%,company.ilike.%${esc}%`); + } + const { data } = await q; + if (!cancelled) { + setContactResults((data ?? []) as ContactOpt[]); + setContactSearching(false); + } + }, 200); + return () => { + cancelled = true; + clearTimeout(handle); + }; + }, [open, contactQuery]); + const filteredCases = useMemo( () => (clientId ? cases.filter((k) => k.client_id === clientId) : cases), [cases, clientId], From e1a2941f02fb1f1632e2c5bb58aa45788c98bd5b Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:11:34 +0000 Subject: [PATCH 2/5] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/quick-add/quick-add-call-log.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/quick-add/quick-add-call-log.tsx b/src/components/quick-add/quick-add-call-log.tsx index 8eccc5b..2833068 100644 --- a/src/components/quick-add/quick-add-call-log.tsx +++ b/src/components/quick-add/quick-add-call-log.tsx @@ -48,7 +48,6 @@ export function QuickAddCallLog() { const [clients, setClients] = useState([]); const [cases, setCases] = useState([]); - const [contacts, setContacts] = useState([]); const [clientId, setClientId] = useState(""); const [caseId, setCaseId] = useState(""); From 332712a952fb020802d4d06d3875d981c22fd853 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:11:48 +0000 Subject: [PATCH 3/5] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/quick-add/quick-add-call-log.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/quick-add/quick-add-call-log.tsx b/src/components/quick-add/quick-add-call-log.tsx index 2833068..709e414 100644 --- a/src/components/quick-add/quick-add-call-log.tsx +++ b/src/components/quick-add/quick-add-call-log.tsx @@ -119,6 +119,9 @@ export function QuickAddCallLog() { setClientId(""); setCaseId(""); setContactId(""); + setSelectedContact(null); + setContactQuery(""); + setContactResults([]); setCallerName(""); setCallerPhone(""); setDirection("outbound"); From 8d5451829f920002e9cfbd0787a20ec4dfce635e Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:12:05 +0000 Subject: [PATCH 4/5] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- .../quick-add/quick-add-call-log.tsx | 97 ++++++++++++++----- 1 file changed, 75 insertions(+), 22 deletions(-) diff --git a/src/components/quick-add/quick-add-call-log.tsx b/src/components/quick-add/quick-add-call-log.tsx index 709e414..7a9df58 100644 --- a/src/components/quick-add/quick-add-call-log.tsx +++ b/src/components/quick-add/quick-add-call-log.tsx @@ -249,28 +249,81 @@ export function QuickAddCallLog() {
- { - setContactId(id); - const c = contacts.find((x) => x.id === id); - if (c) { - if (!callerName) setCallerName(c.name); - if (!callerPhone && c.phone) setCallerPhone(c.phone); - } - }} - placeholder="Select contact or enter manually below" - searchPlaceholder="Search contacts…" - emptyText="No contacts found." - options={[ - { value: "", label: "— None —", keywords: "none" }, - ...contacts.map((c) => ({ - value: c.id, - label: c.phone ? `${c.name} (${c.phone})` : c.name, - keywords: `${c.name} ${c.phone ?? ""}`, - })), - ]} - /> + + + + + +
+ setContactQuery(e.target.value)} + placeholder="Type to search all contacts…" + className="h-8 text-sm" + /> +
+
+ {selectedContact && ( + + )} + {contactSearching ? ( +

Searching…

+ ) : contactResults.length === 0 ? ( +

+ {contactQuery.trim() ? "No matching contacts." : "Start typing to search."} +

+ ) : ( +
    + {contactResults.map((c) => ( +
  • + +
  • + ))} +
+ )} +
+
+
From e43efdec7186284d9a13e527e59436f6ccf79356 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:12:12 +0000 Subject: [PATCH 5/5] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/quick-add/quick-add-call-log.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/quick-add/quick-add-call-log.tsx b/src/components/quick-add/quick-add-call-log.tsx index 7a9df58..4ff5098 100644 --- a/src/components/quick-add/quick-add-call-log.tsx +++ b/src/components/quick-add/quick-add-call-log.tsx @@ -22,7 +22,8 @@ import { SelectValue, } from "@/components/ui/select"; import { SearchableSelect } from "@/components/ui/searchable-select"; -import { Phone, Loader2 } from "lucide-react"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Phone, Loader2, Search } from "lucide-react"; import { toast } from "sonner"; interface ClientOpt {