-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from rayanfer32/develop
- Loading branch information
Showing
6 changed files
with
151 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import Table from 'components/Table/Table'; | ||
import { useQuery } from 'react-query'; | ||
import styles from './trustlist.module.scss'; | ||
import Loader from 'components/atoms/NE_Loader'; | ||
import { intlNum } from 'utils/converter'; | ||
import CopyText from 'components/atoms/NE_CopyText/CopyText'; | ||
import { useNetwork } from 'hooks/useNetwork/useNetwork'; | ||
import ErrorCard from 'components/atoms/NE_ErrorCard/ErrorCard'; | ||
import PageHeader from 'components/Header/PageHeader'; | ||
import DynamicPagination from 'components/atoms/NE_Pagination'; | ||
// import DynamicPagination from 'components/Table/DynamicPagination'; | ||
import { useState } from 'react'; | ||
import ErrorMessage from 'components/atoms/ErrorMessage'; | ||
|
||
export default function Trustlist() { | ||
const [pageIndex, setPageIndex] = useState(0); | ||
const [pageSize, setPageSize] = useState(10); | ||
const [pageCount] = useState(Infinity); | ||
|
||
const { network, getTrustlist } = useNetwork(); | ||
const { isLoading, data, error } = useQuery( | ||
['trustlist', pageIndex, pageSize, network.name], | ||
getTrustlist | ||
); | ||
|
||
const columns = [ | ||
{ | ||
Header: '#ID', | ||
Cell: (props) => ( | ||
<div>{parseInt(props.cell.row.id) + 1 + pageIndex * pageSize}</div> | ||
), | ||
}, | ||
{ | ||
Header: 'Address', | ||
accessor: 'address', | ||
Cell: ({ value }) => <CopyText value={value} />, | ||
}, | ||
{ | ||
Header: 'Balance', | ||
accessor: 'balance', | ||
Cell: (props) => intlNum(props.value.toFixed(2)) + ' NXS', | ||
}, | ||
{ | ||
Header: 'Stake', | ||
accessor: 'stake', | ||
Cell: (props) => intlNum(props.value.toFixed(2)) + ' NXS', | ||
}, | ||
{ | ||
Header: 'Stake Rate', | ||
accessor: 'rate', | ||
}, | ||
{ | ||
Header: 'Trust', | ||
accessor: 'trust', | ||
Cell: (props) => intlNum(props.value), | ||
}, | ||
]; | ||
|
||
if (isLoading) { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'grid', | ||
placeItems: 'center', | ||
minHeight: '200px', | ||
margin: 'auto', | ||
}}> | ||
<Loader type="circle" size="5rem" /> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<div> | ||
<ErrorCard /> | ||
</div> | ||
); | ||
} | ||
|
||
const newData = data.data?.result?.map((item, index) => ({ | ||
key: index, | ||
...item, | ||
stake: item.stake, | ||
balance: item.balance, | ||
})); | ||
|
||
const dynamicPageControls = { | ||
canPreviousPage: pageIndex > 0, | ||
canNextPage: pageIndex < pageCount - 1, | ||
pageCount: pageCount, | ||
pageIndex: pageIndex, | ||
pageSize: pageSize, | ||
gotoPage: (pageIndex) => { | ||
setPageIndex(pageIndex); | ||
}, | ||
setPageSize: (pageSize) => { | ||
setPageIndex(0); | ||
setPageSize(pageSize); | ||
}, | ||
handleStartOfPageClick: () => { | ||
setPageIndex(0); | ||
}, | ||
handlePreviousPageClick: () => { | ||
setPageIndex(pageIndex - 1); | ||
}, | ||
handleNextPageClick: () => { | ||
setPageIndex(pageIndex + 1); | ||
}, | ||
}; | ||
|
||
return ( | ||
<> | ||
<PageHeader page={'trustlist'} /> | ||
<div className={styles.page} style={{ marginBottom: '1rem' }}> | ||
<Table | ||
columns={columns} | ||
data={data.data?.error ? [] : newData} | ||
paginate={false} | ||
/> | ||
<div style={{ marginBottom: '1rem' }}> | ||
<DynamicPagination | ||
controls={dynamicPageControls} | ||
isStaticPanination={false} | ||
/> | ||
</div> | ||
{data.data?.error && <ErrorMessage error={data.data.error} />} | ||
</div> | ||
</> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,125 +1,11 @@ | ||
import Table from 'components/Table/Table'; | ||
import { useQuery } from 'react-query'; | ||
import styles from './trustlist.module.scss'; | ||
import Loader from 'components/atoms/NE_Loader'; | ||
import { intlNum } from 'utils/converter'; | ||
import CopyText from 'components/atoms/NE_CopyText/CopyText'; | ||
import { useNetwork } from 'hooks/useNetwork/useNetwork'; | ||
import ErrorCard from 'components/atoms/NE_ErrorCard/ErrorCard'; | ||
import PageHeader from 'components/Header/PageHeader'; | ||
import DynamicPagination from 'components/atoms/NE_Pagination'; | ||
// import DynamicPagination from 'components/Table/DynamicPagination'; | ||
import { useState } from 'react'; | ||
import ErrorMessage from 'components/atoms/ErrorMessage'; | ||
|
||
export default function Trustlist() { | ||
const [pageIndex, setPageIndex] = useState(0); | ||
const [pageSize, setPageSize] = useState(10); | ||
const [pageCount] = useState(Infinity); | ||
|
||
const { network, getTrustlist } = useNetwork(); | ||
const { isLoading, data, error } = useQuery( | ||
['trustlist', pageIndex, pageSize, network.name], | ||
getTrustlist | ||
); | ||
|
||
const columns = [ | ||
{ | ||
Header: 'Address', | ||
accessor: 'address', | ||
Cell: ({ value }) => <CopyText value={value} />, | ||
}, | ||
{ | ||
Header: 'Balance', | ||
accessor: 'balance', | ||
Cell: (props) => intlNum(props.value.toFixed(2)) + ' NXS', | ||
}, | ||
{ | ||
Header: 'Stake', | ||
accessor: 'stake', | ||
Cell: (props) => intlNum(props.value.toFixed(2)) + ' NXS', | ||
}, | ||
{ | ||
Header: 'Stake Rate', | ||
accessor: 'rate', | ||
}, | ||
{ | ||
Header: 'Trust', | ||
accessor: 'trust', | ||
Cell: (props) => intlNum(props.value), | ||
}, | ||
]; | ||
|
||
if (isLoading) { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'grid', | ||
placeItems: 'center', | ||
minHeight: '200px', | ||
margin: 'auto', | ||
}}> | ||
<Loader type="circle" size="5rem" /> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<div> | ||
<ErrorCard /> | ||
</div> | ||
); | ||
} | ||
|
||
const newData = data.data?.result?.map((item, index) => ({ | ||
key: index, | ||
...item, | ||
stake: item.stake, | ||
balance: item.balance, | ||
})); | ||
|
||
const dynamicPageControls = { | ||
canPreviousPage: pageIndex > 0, | ||
canNextPage: pageIndex < pageCount - 1, | ||
pageCount: pageCount, | ||
pageIndex: pageIndex, | ||
pageSize: pageSize, | ||
gotoPage: (pageIndex) => { | ||
setPageIndex(pageIndex); | ||
}, | ||
setPageSize: (pageSize) => { | ||
setPageIndex(0); | ||
setPageSize(pageSize); | ||
}, | ||
handleStartOfPageClick: () => { | ||
setPageIndex(0); | ||
}, | ||
handlePreviousPageClick: () => { | ||
setPageIndex(pageIndex - 1); | ||
}, | ||
handleNextPageClick: () => { | ||
setPageIndex(pageIndex + 1); | ||
}, | ||
}; | ||
import Richlist from 'components/Trustlist/Trustlist'; | ||
|
||
export default function index() { | ||
return ( | ||
<> | ||
<PageHeader page={'trustlist'} /> | ||
<div className={styles.page} style={{ marginBottom: '1rem' }}> | ||
<Table | ||
columns={columns} | ||
data={data.data?.error ? [] : newData} | ||
paginate={false} | ||
/> | ||
<div style={{ marginBottom: '1rem' }}> | ||
<DynamicPagination | ||
controls={dynamicPageControls} | ||
isStaticPanination={false} | ||
/> | ||
</div> | ||
{data.data?.error && <ErrorMessage error={data.data.error} />} | ||
</div> | ||
<PageHeader page="Trustlist" /> | ||
<Richlist /> | ||
</> | ||
); | ||
} |
88b3ca4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nexus-explorer-next – ./
nexus-explorer-next-rayanfer32.vercel.app
nexplorer.vercel.app
nexplorer-main.vercel.app
nexus-explorer-next-git-main-rayanfer32.vercel.app