File tree Expand file tree Collapse file tree 3 files changed +51
-34
lines changed Expand file tree Collapse file tree 3 files changed +51
-34
lines changed Original file line number Diff line number Diff line change 1+ import { Button , Flex } from "@chakra-ui/react"
2+
3+ type PaginationFooterProps = {
4+ hasNextPage ?: boolean
5+ hasPreviousPage ?: boolean
6+ onChangePage : ( newPage : number ) => void
7+ page : number
8+ }
9+
10+ export function PaginationFooter ( {
11+ hasNextPage,
12+ hasPreviousPage,
13+ onChangePage,
14+ page,
15+ } : PaginationFooterProps ) {
16+ return (
17+ < Flex
18+ gap = { 4 }
19+ alignItems = "center"
20+ mt = { 4 }
21+ direction = "row"
22+ justifyContent = "flex-end"
23+ >
24+ < Button
25+ onClick = { ( ) => onChangePage ( page - 1 ) }
26+ isDisabled = { ! hasPreviousPage || page <= 1 }
27+ >
28+ Previous
29+ </ Button >
30+ < span > Page { page } </ span >
31+ < Button isDisabled = { ! hasNextPage } onClick = { ( ) => onChangePage ( page + 1 ) } >
32+ Next
33+ </ Button >
34+ </ Flex >
35+ )
36+ }
Original file line number Diff line number Diff line change 11import {
22 Badge ,
33 Box ,
4- Button ,
54 Container ,
65 Flex ,
76 Heading ,
@@ -23,6 +22,7 @@ import { type UserPublic, UsersService } from "../../client"
2322import AddUser from "../../components/Admin/AddUser"
2423import ActionsMenu from "../../components/Common/ActionsMenu"
2524import Navbar from "../../components/Common/Navbar"
25+ import { PaginationFooter } from "../../components/Common/PaginationFooter.tsx"
2626
2727const usersSearchSchema = z . object ( {
2828 page : z . number ( ) . catch ( 1 ) ,
@@ -128,7 +128,7 @@ function UsersTable() {
128128 < ActionsMenu
129129 type = "User"
130130 value = { user }
131- disabled = { currentUser ?. id === user . id ? true : false }
131+ disabled = { currentUser ?. id === user . id }
132132 />
133133 </ Td >
134134 </ Tr >
@@ -137,21 +137,12 @@ function UsersTable() {
137137 ) }
138138 </ Table >
139139 </ TableContainer >
140- < Flex
141- gap = { 4 }
142- alignItems = "center"
143- mt = { 4 }
144- direction = "row"
145- justifyContent = "flex-end"
146- >
147- < Button onClick = { ( ) => setPage ( page - 1 ) } isDisabled = { ! hasPreviousPage } >
148- Previous
149- </ Button >
150- < span > Page { page } </ span >
151- < Button isDisabled = { ! hasNextPage } onClick = { ( ) => setPage ( page + 1 ) } >
152- Next
153- </ Button >
154- </ Flex >
140+ < PaginationFooter
141+ onChangePage = { setPage }
142+ page = { page }
143+ hasNextPage = { hasNextPage }
144+ hasPreviousPage = { hasPreviousPage }
145+ />
155146 </ >
156147 )
157148}
Original file line number Diff line number Diff line change 11import {
2- Button ,
32 Container ,
4- Flex ,
53 Heading ,
64 SkeletonText ,
75 Table ,
@@ -21,6 +19,7 @@ import { ItemsService } from "../../client"
2119import ActionsMenu from "../../components/Common/ActionsMenu"
2220import Navbar from "../../components/Common/Navbar"
2321import AddItem from "../../components/Items/AddItem"
22+ import { PaginationFooter } from "../../components/Common/PaginationFooter.tsx"
2423
2524const itemsSearchSchema = z . object ( {
2625 page : z . number ( ) . catch ( 1 ) ,
@@ -112,21 +111,12 @@ function ItemsTable() {
112111 ) }
113112 </ Table >
114113 </ TableContainer >
115- < Flex
116- gap = { 4 }
117- alignItems = "center"
118- mt = { 4 }
119- direction = "row"
120- justifyContent = "flex-end"
121- >
122- < Button onClick = { ( ) => setPage ( page - 1 ) } isDisabled = { ! hasPreviousPage } >
123- Previous
124- </ Button >
125- < span > Page { page } </ span >
126- < Button isDisabled = { ! hasNextPage } onClick = { ( ) => setPage ( page + 1 ) } >
127- Next
128- </ Button >
129- </ Flex >
114+ < PaginationFooter
115+ page = { page }
116+ onChangePage = { setPage }
117+ hasNextPage = { hasNextPage }
118+ hasPreviousPage = { hasPreviousPage }
119+ />
130120 </ >
131121 )
132122}
You can’t perform that action at this time.
0 commit comments