From 731b60aeffa1a5f8dfa71e30783bad86a866dced 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:00:36 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/cases/status-tab.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/cases/status-tab.tsx b/src/components/cases/status-tab.tsx index e171365..d5bd569 100644 --- a/src/components/cases/status-tab.tsx +++ b/src/components/cases/status-tab.tsx @@ -23,12 +23,19 @@ export function CaseStatusTab({ caseId }: { caseId: string }) { const [form, setForm] = useState({ title: nowLocal(), body: "" }); const load = async () => { - const { data } = await supabase + const { data, error } = await supabase .from("status_updates") - .select("*, user:profiles!status_updates_created_by_fkey(full_name, email)") + .select("*") .eq("case_id", caseId) .order("created_at", { ascending: false }); - setItems(data ?? []); + if (error) { toast.error("Could not load updates", { description: error.message }); return; } + const ids = Array.from(new Set((data ?? []).map((d: any) => d.created_by).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])); + } + setItems((data ?? []).map((d: any) => ({ ...d, user: d.created_by ? profileMap[d.created_by] : null }))); }; useEffect(() => { load(); }, [caseId]);