From 982f17fb820e4f5b065b677fe5722a4af3c9b595 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 02:09:53 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/cases/time-tab.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/cases/time-tab.tsx b/src/components/cases/time-tab.tsx index 320ef5e..37cc90a 100644 --- a/src/components/cases/time-tab.tsx +++ b/src/components/cases/time-tab.tsx @@ -17,7 +17,7 @@ interface CaseTimeTabProps { onInvoice?: () => void; } -export function CaseTimeTab({ caseRecord }: { caseRecord: any }) { +export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { const { user } = useAuth(); const [entries, setEntries] = useState([]); const [showForm, setShowForm] = useState(false); @@ -32,12 +32,19 @@ export function CaseTimeTab({ caseRecord }: { caseRecord: any }) { }); const load = async () => { - const { data } = await supabase + const { data, error } = await supabase .from("time_entries") - .select("*, user:profiles!time_entries_user_id_fkey(full_name, email)") + .select("*") .eq("case_id", caseRecord.id) .order("work_date", { ascending: false }); - setEntries(data ?? []); + if (error) { toast.error("Could not load time entries", { description: error.message }); return; } + const ids = Array.from(new Set((data ?? []).map((d: any) => d.user_id).filter(Boolean))); + let profileMap: Record = {}; + if (ids.length) { + const { data: profs } = await supabase.from("profiles").select("id, full_name, email").in("id", ids); + profileMap = Object.fromEntries((profs ?? []).map((p: any) => [p.id, p])); + } + setEntries((data ?? []).map((d: any) => ({ ...d, user: d.user_id ? profileMap[d.user_id] : null }))); }; useEffect(() => { load(); }, [caseRecord.id]);