Facturas de cliente
This commit is contained in:
parent
18c37692ea
commit
a946aa129a
@ -22,6 +22,12 @@ interface ItemsEditorProps {
|
||||
|
||||
const createEmptyItem = () => defaultCustomerInvoiceItemFormData;
|
||||
|
||||
function getSelectAllState(totalRows: number, selectedCount: number): boolean | 'indeterminate' {
|
||||
if (totalRows === 0 || selectedCount === 0) return false;
|
||||
if (selectedCount === totalRows) return true;
|
||||
return 'indeterminate';
|
||||
}
|
||||
|
||||
export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEditorProps) => {
|
||||
const { t } = useTranslation();
|
||||
const form = useFormContext();
|
||||
@ -86,13 +92,24 @@ export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEdi
|
||||
</colgroup>
|
||||
<TableHeader className="text-sm bg-muted backdrop-blur supports-[backdrop-filter]:bg-muted/60 ">
|
||||
<TableRow>
|
||||
<TableHead><div className='h-5'>
|
||||
<Checkbox
|
||||
aria-label={t("common.select_row")}
|
||||
className='block h-5 w-5 leading-none align-middle'
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</div></TableHead>
|
||||
<TableHead>
|
||||
<div className='h-5'>
|
||||
<Checkbox
|
||||
aria-label={t("common.select_all")}
|
||||
className='block h-5 w-5 leading-none align-middle'
|
||||
disabled={readOnly}
|
||||
checked={getSelectAllState(tableNav.fa.fields.length, selection.size)}
|
||||
onCheckedChange={(next) => {
|
||||
const shouldSelectAll = next !== false;
|
||||
if (shouldSelectAll) {
|
||||
setSelection(new Set(tableNav.fa.fields.map((_, i) => i)));
|
||||
} else {
|
||||
resetSelection();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</TableHead>
|
||||
<TableHead>#</TableHead>
|
||||
<TableHead>{t("form_fields.item.description.label")}</TableHead>
|
||||
<TableHead className="text-right">{t("form_fields.item.quantity.label")}</TableHead>
|
||||
@ -121,8 +138,7 @@ export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEdi
|
||||
checked={selection.has(rowIndex)}
|
||||
onCheckedChange={() => toggleSel(rowIndex)}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
</div>
|
||||
/> </div>
|
||||
</TableCell>
|
||||
|
||||
{/* # */}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user