@@ -9,14 +9,17 @@ import moment from "moment";
9
9
import { useEffect , useState } from "react" ;
10
10
import { useLocation } from "react-router" ;
11
11
import { Link } from "react-router-dom" ;
12
+ import Pagination from "../Pagination/Pagination" ;
12
13
import { getGitpodService } from "../service/service" ;
13
14
import { PageWithAdminSubMenu } from "./PageWithAdminSubMenu" ;
14
15
import UserDetail from "./UserDetail" ;
15
16
16
17
export default function UserSearch ( ) {
17
18
const location = useLocation ( ) ;
19
+ const pageLength = 50 ;
18
20
const [ searchResult , setSearchResult ] = useState < AdminGetListResult < User > > ( { rows : [ ] , total : 0 } ) ;
19
21
const [ searchTerm , setSearchTerm ] = useState ( "" ) ;
22
+ const [ currentPage , setCurrentPage ] = useState ( 0 ) ;
20
23
const [ searching , setSearching ] = useState ( false ) ;
21
24
const [ currentUser , setCurrentUserState ] = useState < User | undefined > ( undefined ) ;
22
25
@@ -46,16 +49,21 @@ export default function UserSearch() {
46
49
try {
47
50
const result = await getGitpodService ( ) . server . adminGetUsers ( {
48
51
searchTerm,
49
- limit : 50 ,
52
+ limit : pageLength ,
50
53
orderBy : "creationDate" ,
51
- offset : 0 ,
54
+ offset : currentPage * pageLength ,
52
55
orderDir : "desc" ,
53
56
} ) ;
54
57
setSearchResult ( result ) ;
55
58
} finally {
56
59
setSearching ( false ) ;
57
60
}
58
61
} ;
62
+
63
+ const updatePage = ( page : number ) => {
64
+ setCurrentPage ( page ) ;
65
+ search ( ) ;
66
+ } ;
59
67
return (
60
68
< PageWithAdminSubMenu title = "Users" subtitle = "Search and manage all users." >
61
69
< div className = "pt-8 flex" >
@@ -103,6 +111,11 @@ export default function UserSearch() {
103
111
< UserEntry user = { u } />
104
112
) ) }
105
113
</ div >
114
+ < Pagination
115
+ currentPage = { currentPage }
116
+ setPage = { updatePage }
117
+ totalNumberOfPages = { searchResult . total / pageLength }
118
+ />
106
119
</ PageWithAdminSubMenu >
107
120
) ;
108
121
}
0 commit comments