I would like to disabled some checkbox created by a custom BulkActionsButton. This is a simple list:
function CourseList(props): ReactElement {
return (
<List
{...props}
bulkActionButtons={<BulkActionButton />}
>
<Datagrid>
...some fields
</Datagrid>
</List>
);
}
and the BulkActionButton:
const BulkActionButton = ({
resource,
selectedIds,
}: BulkActionProps): ReactElement | null => {
const { data, loading } = useGetMany(
'shared/courses',
selectedIds as Identifier[]
);
if (!data || loading) {
return null;
}
const someHasBeenPaid = data.some((course) => !!course?.invoiceDate);
return (
<Button
color="secondary"
disabled={someHasBeenPaid}
label={t('@app.manager.clientDepartment.invoiceCTA')}
/>
);
};
Actually the records which have a invoiceDate should not be checkable first. But the checkboxes are created internally by react-admin I don't find any documentation on how to apply some filters to enable/disabled the checkboxes or if it is even possible.