feat: add rowClassName prop to CardTable for dynamic row styling
This commit is contained in:
parent
f49cebb35a
commit
b4cb3f4d48
@ -53,6 +53,7 @@ interface CardTableProps<TData> {
|
|||||||
onPerPageChange?: (perPage: number) => void;
|
onPerPageChange?: (perPage: number) => void;
|
||||||
|
|
||||||
emptyText?: string;
|
emptyText?: string;
|
||||||
|
rowClassName?: (item: TData) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function useDebounce(callback: (value: string) => void, delay: number) {
|
function useDebounce(callback: (value: string) => void, delay: number) {
|
||||||
@ -87,6 +88,7 @@ export function CardTable<TData>({
|
|||||||
onPageChange,
|
onPageChange,
|
||||||
onPerPageChange,
|
onPerPageChange,
|
||||||
emptyText = 'Tidak ada data.',
|
emptyText = 'Tidak ada data.',
|
||||||
|
rowClassName,
|
||||||
}: CardTableProps<TData>) {
|
}: CardTableProps<TData>) {
|
||||||
const [localSearch, setLocalSearch] = React.useState(searchValue ?? '');
|
const [localSearch, setLocalSearch] = React.useState(searchValue ?? '');
|
||||||
|
|
||||||
@ -176,7 +178,7 @@ return true;
|
|||||||
const isExpanded = isItemExpanded(key);
|
const isExpanded = isItemExpanded(key);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={key} className="flex flex-col">
|
<div key={key} className={`flex flex-col ${rowClassName?.(item) ?? ''}`}>
|
||||||
{renderCard({
|
{renderCard({
|
||||||
item,
|
item,
|
||||||
index,
|
index,
|
||||||
|
|||||||
@ -90,6 +90,11 @@ export default function CuttingIndex({ cuttings }: Props) {
|
|||||||
pagination={pagination}
|
pagination={pagination}
|
||||||
onPageChange={handlePageChange}
|
onPageChange={handlePageChange}
|
||||||
onPerPageChange={handlePerPageChange}
|
onPerPageChange={handlePerPageChange}
|
||||||
|
rowClassName={(c) =>
|
||||||
|
c.status === 'in_progress'
|
||||||
|
? 'border-l-4 border-l-yellow-500'
|
||||||
|
: ''
|
||||||
|
}
|
||||||
renderCard={({
|
renderCard={({
|
||||||
item,
|
item,
|
||||||
index,
|
index,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user