This commit is contained in:
2026-04-23 14:38:41 +03:00
parent f17dd1486c
commit c0f78c6e18
90 changed files with 10819 additions and 1583 deletions
@@ -22,6 +22,7 @@ type PartItem = {
title: string
quantity: number
rate: number
discount_amount?: number
description?: string
}
@@ -34,6 +35,7 @@ export type PartsSelectorFieldProps<
name: TName & (TValues[TName] extends PartsItemsFieldConstraint ? TName : never)
label?: string
triggerLabel?: string
showDiscount?: boolean
}
export function PartsSelectorField<
@@ -43,6 +45,7 @@ export function PartsSelectorField<
name,
label = "Parts",
triggerLabel = "Add Parts",
showDiscount = false,
}: PartsSelectorFieldProps<TValues, TName>) {
return (
<RhfResourceField<TValues, TName, PartsClient>
@@ -81,6 +84,7 @@ export function PartsSelectorField<
<TableHead>Part</TableHead>
<TableHead className="w-24">Qty</TableHead>
<TableHead className="w-28">Rate</TableHead>
{showDiscount && <TableHead className="w-28">Discount</TableHead>}
<TableHead>Description</TableHead>
<TableHead className="w-12" />
</TableRow>
@@ -112,6 +116,20 @@ export function PartsSelectorField<
className="h-8 w-24"
/>
</TableCell>
{showDiscount && (
<TableCell>
<Input
type="number"
min={0}
step={0.01}
value={item.discount_amount ?? 0}
onChange={(e) =>
update(index, { ...item, discount_amount: Number(e.target.value) || 0 } as any)
}
className="h-8 w-24"
/>
</TableCell>
)}
<TableCell>
<Input
value={item.description ?? ""}