File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/components/DownloadTable Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,20 @@ export function DownloadTable({
25
25
const [ tableLoadingState , setTableLoadingState ] = useState ( "idle" ) ;
26
26
const [ tablePage , setTablePage ] = useState ( 1 ) ;
27
27
const [ selectedVersion , setSelectedVersion ] = useState ( undefined ) ;
28
+ const [ totalPages , setTotalPages ] = useState ( 0 ) ;
28
29
29
30
const rowsPerPage = 10 ;
30
31
31
32
useEffect ( ( ) => {
32
33
setTableData ( initialTableData ) ;
33
34
} , [ initialTableData ] ) ;
34
35
36
+ useEffect ( ( ) => {
37
+ if ( tableData ?. pageInfo ?. total && pageSize ) {
38
+ setTotalPages ( Math . ceil ( tableData . pageInfo . total / pageSize ) ) ;
39
+ }
40
+ } , [ tableData , pageSize ] ) ;
41
+
35
42
const tableRows = React . useMemo ( ( ) => {
36
43
const start = ( tablePage - 1 ) * rowsPerPage ;
37
44
const end = start + rowsPerPage ;
@@ -65,7 +72,7 @@ export function DownloadTable({
65
72
showControls
66
73
showShadow
67
74
page = { tablePage }
68
- total = { Math . ceil ( tableData ?. pageInfo ?. total / pageSize ) }
75
+ total = { totalPages }
69
76
onChange = { async ( page ) => {
70
77
setTableLoadingState ( "loadingMore" ) ;
71
78
page = page - 1 ;
You can’t perform that action at this time.
0 commit comments