MCPcopy Index your code
hub / github.com/code100x/cms / Pagination

Function Pagination

src/components/Pagination.tsx:14–81  ·  view source on GitHub ↗
({ dataLength = 1 })

Source from the content-addressed store, hash-verified

12 dataLength: number;
13}
14const Pagination: React.FC<IPagination> = ({ dataLength = 1 }) => {
15 const searchParams = useSearchParams();
16 const path = usePathname();
17 const paramsObj = searchParamsToObject(searchParams as any); // build fix (eslint)
18 const paginationQ = paginationData(paramsObj);
19 return (
20 <div className="flex items-center justify-center space-x-4">
21 {paginationQ.pageNumber > 1 && (
22 <Link
23 className="flex items-center justify-center space-x-2 rounded-md border border-gray-300 px-4 py-2 dark:border-gray-600 dark:text-gray-300"
24 href={getUpdatedUrl(`${path}/`, paramsObj, {
25 page: paginationQ.pageNumber - 1,
26 limit: paginationQ.pageSize,
27 })}
28 >
29 <span className="material-icons flex h-4 w-4 items-center justify-center text-gray-500 dark:text-gray-400">
30 <svg
31 xmlns="http://www.w3.org/2000/svg"
32 fill="none"
33 viewBox="0 0 24 24"
34 strokeWidth={1.5}
35 stroke="currentColor"
36 className="h-6 w-6"
37 >
38 <path
39 strokeLinecap="round"
40 strokeLinejoin="round"
41 d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"
42 />
43 </svg>
44 </span>
45 <span className="sr-only"> {paginationQ.pageNumber - 1}</span>
46 </Link>
47 )}
48
49 <span className="rounded-md bg-gray-200 px-4 py-2 text-gray-700 dark:bg-gray-700 dark:text-gray-300">
50 {paginationQ.pageNumber}
51 </span>
52 {dataLength >= paginationQ.pageSize && (
53 <Link
54 className="flex items-center justify-center space-x-2 rounded-md border border-gray-300 px-4 py-2 dark:border-gray-600 dark:text-gray-300"
55 href={getUpdatedUrl(`${path}/`, paramsObj, {
56 page: paginationQ.pageNumber + 1,
57 limit: paginationQ.pageSize,
58 })}
59 >
60 <span className="material-icons flex h-4 w-4 items-center justify-center text-gray-500 dark:text-gray-400">
61 <svg
62 xmlns="http://www.w3.org/2000/svg"
63 fill="none"
64 viewBox="0 0 24 24"
65 strokeWidth={1.5}
66 stroke="currentColor"
67 className="h-6 w-6"
68 >
69 <path
70 strokeLinecap="round"
71 strokeLinejoin="round"

Callers

nothing calls this directly

Calls 3

searchParamsToObjectFunction · 0.90
paginationDataFunction · 0.90
getUpdatedUrlFunction · 0.90

Tested by

no test coverage detected