From 1bdd0afec9208553ba4de88966df371e06591839 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 18:34:08 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/components/cases/time-tab.tsx | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/components/cases/time-tab.tsx b/src/components/cases/time-tab.tsx index 0046930..a3a9e6b 100644 --- a/src/components/cases/time-tab.tsx +++ b/src/components/cases/time-tab.tsx @@ -9,7 +9,7 @@ import { supabase } from "@/integrations/supabase/client"; import { useAuth } from "@/lib/auth"; import { Plus, Trash2, Loader2, FilePlus } from "lucide-react"; import { formatCurrency, formatDate } from "@/lib/format"; -import { roundToTenth } from "@/lib/timer"; +import { roundToSixth } from "@/lib/timer"; import { toast } from "sonner"; import { Select, @@ -41,11 +41,16 @@ export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { const [form, setForm] = useState({ work_date: new Date().toISOString().slice(0, 10), hours: "", + minutes: "", hourly_rate: caseRecord.default_hourly_rate?.toString() ?? "", description: "", billable: true, }); + // Compute total raw hours from hours + minutes inputs, then round UP to 1/6. + const rawHours = (parseFloat(form.hours || "0") || 0) + (parseFloat(form.minutes || "0") || 0) / 60; + const roundedHours = roundToSixth(rawHours); + const [fees, setFees] = useState([]); const [selectedFeeId, setSelectedFeeId] = useState(""); @@ -96,10 +101,9 @@ export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { const submit = async (e: React.FormEvent) => { e.preventDefault(); - const rawHours = parseFloat(form.hours); - const hours = roundToTenth(rawHours); + const hours = roundedHours; const rate = parseFloat(form.hourly_rate || "0"); - if (!hours || hours <= 0) { toast.error("Hours must be greater than 0"); return; } + if (!hours || hours <= 0) { toast.error("Time must be greater than 0"); return; } if (!form.description.trim()) { toast.error("Description required"); return; } if (!user?.id) { toast.error("Not signed in"); return; } setSubmitting(true); @@ -115,9 +119,9 @@ export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { setSubmitting(false); if (error) toast.error(error.message); else { - toast.success("Time entry added"); + toast.success(`Time entry added (${hours.toFixed(2)} hrs)`); setShowForm(false); - setForm({ ...form, hours: "", description: "" }); + setForm({ ...form, hours: "", minutes: "", description: "" }); load(); } }; @@ -191,14 +195,23 @@ export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { )} -
+
setForm({ ...form, work_date: e.target.value })} required />
- setForm({ ...form, hours: e.target.value })} required /> + setForm({ ...form, hours: e.target.value })} /> +
+
+ + setForm({ ...form, minutes: e.target.value })} /> + {rawHours > 0 && ( +

+ Billed as {roundedHours.toFixed(2)} hrs (1/6 hr) +

+ )}
@@ -210,11 +223,11 @@ export function CaseTimeTab({ caseRecord, onInvoice }: CaseTimeTabProps) { Billable
-
+