wrapping some components.

This commit is contained in:
killian-larcher
2024-11-11 19:12:34 +01:00
parent 7dcb8f0eed
commit 262322cfa6
13 changed files with 145 additions and 68 deletions
@@ -42,14 +42,14 @@ export const CardsWithPagination = (props: cardsWithPaginationProps) => {
return (
<div className={cn("", className)}>
<div className={cn(`grid auto-rows-min gap-4 md:grid-cols-${numberOfColumns}`)}>
<div className={cn("flex flex-col h-full justify-between", className)}>
<div className={cn(`grid h-max auto-rows-min gap-4 md:grid-cols-${numberOfColumns}`)}>
{currentCards.map((card, key) => (
<CardItem key={key} {...card}/>
))}
</div>
<PaginationNavigation
className="mt-8 justify-end"
className="justify-end"
totalPages={totalPages}
currentPage={currentPage}
goToPage={goToPage}
@@ -25,7 +25,7 @@ export const PaginationNavigation = (props: paginationNavigationProps) => {
const {className, totalPages, currentPage, goToPage, goToPrevPage, goToNextPage, maxVisiblePages = 3} = props
return (
<Pagination className={cn("w-auto m-0", className)}>
<Pagination className={cn("", className)}>
<PaginationContent>
<PaginationItem>
<PaginationPrevious onClick={goToPrevPage}/>
@@ -30,9 +30,9 @@ export function DataTableWithPagination<TData, TValue>({columns, data}: DataTabl
})
return (
<div>
<div className="flex flex-col justify-between h-full">
<DataTable table={table}/>
<TablePagination table={table}/>
<TablePagination table={table} pageSizeOptions={[5, 10, 20, 50, 100]}/>
</div>
)
}
@@ -1,3 +1,4 @@
import {useEffect} from "react";
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select";
import {cn} from "@/lib/utils";
@@ -12,8 +13,12 @@ export const TablePaginationSize = (props: tablePaginationSizeProps) => {
const {className, table, pageSizeOptions = [10, 20, 30, 40, 50]} = props
useEffect(() => {
table.setPageSize(Number(pageSizeOptions[0]))
}, []);
return (
<div className={cn("flex items-center space-x-2", className)}>
<div className={cn("flex items-center justify-center space-x-2", className)}>
<p className="whitespace-nowrap text-sm font-medium">Rows per page</p>
<Select
value={`${table.getState().pagination.pageSize}`}
@@ -8,16 +8,17 @@ interface tablePaginationProps {
className?: string
table: any
maxVisiblePages?: number
pageSizeOptions?: number[]
}
export function TablePagination(props: tablePaginationProps) {
const {className, table, maxVisiblePages = 3} = props
const {className, table, maxVisiblePages = 3, pageSizeOptions = [10, 20, 30, 40, 50]} = props
return (
<div className={cn("flex justify-between mt-8", className)}>
<TablePaginationSize table={table}/>
<TablePaginationNavigation table={table} maxVisiblePages={maxVisiblePages}/>
<div className={cn("flex mt-6", className)}>
<TablePaginationSize table={table} pageSizeOptions={pageSizeOptions}/>
<TablePaginationNavigation table={table} maxVisiblePages={maxVisiblePages} className="justify-end"/>
</div>
)
}