1- import React , { useCallback , useMemo } from 'react'
2- import { NavLink , RouteComponentProps } from 'react-router-dom'
1+ import React , { useCallback } from 'react'
2+ import { RouteComponentProps } from 'react-router-dom'
33import { useTranslation } from 'react-i18next'
44import { Stack , SearchBox , getTheme } from 'office-ui-fabric-react'
5- import { Search as SearchIcon } from 'grommet-icons'
5+ import { Pagination } from '@uifabric/experiments'
6+ import {
7+ Search as SearchIcon ,
8+ LinkDown as LinkDownIcon ,
9+ LinkBottom as LinkBottomIcon ,
10+ LinkTop as LinkTopIcon ,
11+ LinkUp as LinkUpIcon ,
12+ } from 'grommet-icons'
613
714import TransactionList from 'components/TransactionList'
815import { StateWithDispatch } from 'states/stateProvider/reducer'
@@ -17,6 +24,10 @@ const { semanticColors } = theme
1724registerIcons ( {
1825 icons : {
1926 Search : < SearchIcon size = "16px" color = { semanticColors . menuIcon } /> ,
27+ FirstPage : < LinkTopIcon size = "16px" color = { semanticColors . menuIcon } style = { { transform : 'rotate(-90deg)' } } /> ,
28+ LastPage : < LinkBottomIcon size = "16px" color = { semanticColors . menuIcon } style = { { transform : 'rotate(-90deg)' } } /> ,
29+ PrevPage : < LinkUpIcon size = "16px" color = { semanticColors . menuIcon } style = { { transform : 'rotate(-90deg)' } } /> ,
30+ NextPage : < LinkDownIcon size = "16px" color = { semanticColors . menuIcon } style = { { transform : 'rotate(-90deg)' } } /> ,
2031 } ,
2132} )
2233
@@ -33,7 +44,6 @@ const History = ({
3344
3445 const { keywords, onKeywordsChange } = useSearch ( search , incomingKeywords , id , dispatch )
3546 const onSearch = useCallback ( ( ) => history . push ( `${ Routes . History } ?keywords=${ keywords } ` ) , [ history , keywords ] )
36- const totalPages = useMemo ( ( ) => Math . ceil ( totalCount / pageSize ) || 1 , [ totalCount , pageSize ] )
3747
3848 return (
3949 < Stack >
@@ -48,28 +58,26 @@ const History = ({
4858 />
4959 </ Stack >
5060 < TransactionList walletID = { id } items = { items } dispatch = { dispatch } />
51- < div style = { { display : 'flex' , justifyContent : 'center' } } >
52- < NavLink to = { `${ Routes . History } ?pageNo=1` } > { t ( 'history.first' ) } </ NavLink >
53- < NavLink
54- to = { `${ Routes . History } ?pageNo=${ pageNo - 1 } ` }
55- style = { {
56- pointerEvents : pageNo - 1 < 1 ? 'none' : 'auto' ,
57- color : pageNo - 1 < 1 ? 'grey' : '#007bff' ,
58- } }
59- >
60- { t ( 'history.previous' ) }
61- </ NavLink >
62- < NavLink
63- to = { `${ Routes . History } ?pageNo=${ pageNo + 1 } ` }
64- style = { {
65- pointerEvents : pageNo + 1 > totalPages ? 'none' : 'auto' ,
66- color : pageNo + 1 > totalPages ? 'grey' : '#007bff' ,
67- } }
68- >
69- { t ( 'history.next' ) }
70- </ NavLink >
71- < NavLink to = { `${ Routes . History } ?pageNo=${ totalPages } ` } > { t ( 'history.last' ) } </ NavLink >
72- </ div >
61+ < Pagination
62+ selectedPageIndex = { pageNo - 1 }
63+ pageCount = { Math . ceil ( totalCount / pageSize ) }
64+ itemsPerPage = { pageSize }
65+ totalItemCount = { totalCount }
66+ previousPageAriaLabel = { t ( 'pagination.previous-page' ) }
67+ nextPageAriaLabel = { t ( 'pagination.next-page' ) }
68+ firstPageAriaLabel = { t ( 'pagination.first-page' ) }
69+ lastPageAriaLabel = { t ( 'pagination.last-page' ) }
70+ pageAriaLabel = { t ( 'pagination-page' ) }
71+ selectedAriaLabel = { t ( 'pagination-selected' ) }
72+ firstPageIconProps = { { iconName : 'FirstPage' } }
73+ previousPageIconProps = { { iconName : 'PrevPage' } }
74+ nextPageIconProps = { { iconName : 'NextPage' } }
75+ lastPageIconProps = { { iconName : 'LastPage' } }
76+ format = "buttons"
77+ onPageChange = { ( idx : number ) => {
78+ history . push ( `${ Routes . History } ?pageNo=${ idx + 1 } ` )
79+ } }
80+ />
7381 </ Stack >
7482 )
7583}
0 commit comments