Removed redundant API endpoint and added reusable hooks. Implemented various UI component updates including loading spinner, file upload form, and machine selector. Improved state management in page and layout components and introduced new request handling functionalities.
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { PaginationState, Table } from '@tanstack/react-table';
|
|
import { Dispatch, SetStateAction } from 'react';
|
|
import { Button } from 'apps/frontend/src/components/ui/button';
|
|
|
|
|
|
export interface TablePaginationProps {
|
|
rowsCount: number;
|
|
pagination: PaginationState;
|
|
setPagination: Dispatch<SetStateAction<PaginationState>>
|
|
}
|
|
|
|
export function TablePagination(props: TablePaginationProps) {
|
|
const totalPages = Math.ceil(props.rowsCount / props.pagination.pageSize)
|
|
const currentPage = props.pagination.pageIndex
|
|
const isMonoPage = totalPages === 1
|
|
const hasNextPage = (props.pagination.pageIndex >= totalPages)
|
|
const hasPreviousPage = !(props.pagination.pageIndex === 0)
|
|
|
|
if (!props.rowsCount) return (<></>);
|
|
|
|
return (<div className="flex items-center justify-end gap-4 space-x-2 py-4">
|
|
{isMonoPage ? (<h2>Il n'y as qu'une seule page.</h2>) : (<h2>Page <em>{currentPage}</em> sur <em>{totalPages}</em></h2>)}
|
|
<div className={"flex gap-2 justify-center items-center"}>
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => {
|
|
|
|
}}
|
|
disabled={!hasPreviousPage}
|
|
>
|
|
Page précédente
|
|
</Button>
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => {
|
|
|
|
}}
|
|
disabled={!hasNextPage}
|
|
>
|
|
Page suivante
|
|
</Button>
|
|
</div>
|
|
</div>)
|
|
} |