Made the requested updates

X-Lovable-Edit-ID: edt-28180972-114c-4d2c-b413-71555ec510e4
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-05-14 23:15:53 +00:00
co-authored by renee-png
+16 -3
View File
@@ -193,14 +193,15 @@ function InvoiceDetail() {
load();
};
const addManualItem = async (caseId: string | null) => {
const addManualItem = async (caseId: string | null, kind: "manual" | "expense" = "manual") => {
setSavingItem(true);
const sort_order = items.length ? Math.max(...items.map((i) => i.sort_order)) + 1 : 0;
const { error } = await supabase.from("invoice_line_items").insert({
invoice_id: invoiceId,
case_id: caseId,
kind: "manual",
kind,
description: "New line",
work_date: new Date().toISOString().slice(0, 10),
quantity: 1,
rate: 0,
amount: 0,
@@ -439,7 +440,19 @@ function InvoiceDetail() {
</tr>
{sub.items.map((it) => (
<tr key={it.id} className={`border-t ${!sub.billable ? "text-muted-foreground" : ""}`}>
<td className="px-3 py-2 text-xs">{it.work_date ? formatDate(it.work_date) : "—"}</td>
<td className="px-3 py-2 text-xs">
{canModify ? (
<Input
type="date"
className="h-8 text-xs"
defaultValue={it.work_date ?? ""}
onBlur={(e) =>
e.target.value !== (it.work_date ?? "") &&
updateItem(it.id, { work_date: e.target.value || null })
}
/>
) : it.work_date ? formatDate(it.work_date) : "—"}
</td>
<td className="px-3 py-2 align-top">
{canModify ? (
<Input className="h-8" defaultValue={it.description}