Continued updating the code to work with entities better
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {useListSearch} from "@/hooks/useListSearch";
|
||||
import usePagination from "@/hooks/usePagination";
|
||||
import { clsx } from "clsx";
|
||||
import {ReactNode} from "react";
|
||||
import Checkbox from "../Low/Checkbox";
|
||||
import Separator from "../Low/Separator";
|
||||
@@ -10,20 +11,21 @@ interface Props<T> {
|
||||
pageSize?: number;
|
||||
firstCard?: () => ReactNode;
|
||||
renderCard: (item: T) => ReactNode;
|
||||
className?: string
|
||||
}
|
||||
|
||||
export default function CardList<T>({list, searchFields, renderCard, firstCard, pageSize = 20}: Props<T>) {
|
||||
export default function CardList<T>({list, searchFields, renderCard, firstCard, className, pageSize = 20}: Props<T>) {
|
||||
const {rows, renderSearch} = useListSearch(searchFields, list);
|
||||
|
||||
const {items, page, renderMinimal} = usePagination(rows, pageSize);
|
||||
const {items, page, render, renderMinimal} = usePagination(rows, pageSize);
|
||||
|
||||
return (
|
||||
<section className="flex flex-col gap-4 w-full">
|
||||
<div className="w-full flex items-center gap-4">
|
||||
{renderSearch()}
|
||||
{renderMinimal()}
|
||||
{searchFields.length > 0 && renderSearch()}
|
||||
{searchFields.length > 0 ? renderMinimal() : render()}
|
||||
</div>
|
||||
<div className="w-full h-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<div className={clsx("w-full h-full grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4", className)}>
|
||||
{page === 0 && !!firstCard && firstCard()}
|
||||
{items.map(renderCard)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user