Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-17 02:00:36 +00:00
co-authored by renee-png
parent 5c36d0f6b5
commit 731b60aeff
+10 -3
View File
@@ -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<string, any> = {};
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]);