From 28629222ea6850c493517cc4d586ea90229ea11a 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:41 +0000 Subject: [PATCH 1/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/cases/time-tab.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/cases/time-tab.tsx b/src/components/cases/time-tab.tsx index eb855e7..320ef5e 100644 --- a/src/components/cases/time-tab.tsx +++ b/src/components/cases/time-tab.tsx @@ -7,11 +7,16 @@ import { Textarea } from "@/components/ui/textarea"; import { Checkbox } from "@/components/ui/checkbox"; import { supabase } from "@/integrations/supabase/client"; import { useAuth } from "@/lib/auth"; -import { Plus, Trash2, Loader2 } from "lucide-react"; +import { Plus, Trash2, Loader2, FilePlus } from "lucide-react"; import { formatCurrency, formatDate } from "@/lib/format"; import { roundToTenth } from "@/lib/timer"; import { toast } from "sonner"; +interface CaseTimeTabProps { + caseRecord: any; + onInvoice?: () => void; +} + export function CaseTimeTab({ caseRecord }: { caseRecord: any }) { const { user } = useAuth(); const [entries, setEntries] = useState([]); 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 2/4] 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]); From 357ba9ef3d33840e1fd5fd18e2bb0348a0480b96 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:10:02 +0000 Subject: [PATCH 3/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/cases/time-tab.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/cases/time-tab.tsx b/src/components/cases/time-tab.tsx index 37cc90a..83693d6 100644 --- a/src/components/cases/time-tab.tsx +++ b/src/components/cases/time-tab.tsx @@ -113,9 +113,16 @@ export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { - +
+ {totals.unbilled > 0 && onInvoice && ( + + )} + +
{showForm && ( From 60336af2d7f3be4754d7253da568cc16c6fcb413 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:10:20 +0000 Subject: [PATCH 4/4] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/cases.$caseId.tsx | 51 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/routes/cases.$caseId.tsx b/src/routes/cases.$caseId.tsx index a04a1a7..fff7e58 100644 --- a/src/routes/cases.$caseId.tsx +++ b/src/routes/cases.$caseId.tsx @@ -137,28 +137,7 @@ function CaseDetail() { )} - - - Litigation - Status log - Documents - Time - Expenses - Invoices - {(data.client?.client_type === "hoa" || data.client?.client_type === "condo") && ( - Collections - )} - - - - - - - - {(data.client?.client_type === "hoa" || data.client?.client_type === "condo") && ( - - )} - +
@@ -170,6 +149,34 @@ function CaseDetail() { ); } +function CaseTabs({ data, caseId, canManage, load }: { data: any; caseId: string; canManage: boolean; load: () => void }) { + const [tab, setTab] = useState("litigation"); + return ( + + + Litigation + Status log + Documents + Time + Expenses + Invoices + {(data.client?.client_type === "hoa" || data.client?.client_type === "condo") && ( + Collections + )} + + + + + setTab("invoices")} /> + + + {(data.client?.client_type === "hoa" || data.client?.client_type === "condo") && ( + + )} + + ); +} + function SmallStat({ label, value }: { label: string; value: string }) { return (