-
Notifications
You must be signed in to change notification settings - Fork 17
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 #271 from alleslabs/pages/tx-list
feat(pages): create transaction list page
- Loading branch information
Showing
11 changed files
with
495 additions
and
69 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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import type { ChangeEvent } from "react"; | ||
import { useEffect } from "react"; | ||
|
||
import { useChainId } from "lib/app-provider"; | ||
import { Pagination } from "lib/components/pagination"; | ||
import { usePaginator } from "lib/components/pagination/usePaginator"; | ||
import { EmptyState } from "lib/components/state"; | ||
import { TransactionsTable } from "lib/components/table"; | ||
import { useTxs, useTxsCount } from "lib/services/txService"; | ||
|
||
interface TxsTableProps { | ||
isViewMore: boolean; | ||
} | ||
|
||
export const TxsTable = ({ isViewMore }: TxsTableProps) => { | ||
const chainId = useChainId(); | ||
const { data: countTxs = 0 } = useTxsCount(); | ||
|
||
const { | ||
pagesQuantity, | ||
currentPage, | ||
setCurrentPage, | ||
pageSize, | ||
setPageSize, | ||
offset, | ||
} = usePaginator({ | ||
total: countTxs, | ||
initialState: { | ||
pageSize: isViewMore ? 5 : 10, | ||
currentPage: 1, | ||
isDisabled: false, | ||
}, | ||
}); | ||
|
||
const { data: txs, isLoading } = useTxs(offset, pageSize); | ||
|
||
const onPageChange = (nextPage: number) => { | ||
setCurrentPage(nextPage); | ||
}; | ||
|
||
const onPageSizeChange = (e: ChangeEvent<HTMLSelectElement>) => { | ||
const size = Number(e.target.value); | ||
setPageSize(size); | ||
setCurrentPage(1); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!isViewMore) setPageSize(10); | ||
setCurrentPage(1); | ||
}, [chainId, isViewMore, setCurrentPage, setPageSize]); | ||
return ( | ||
<> | ||
<TransactionsTable | ||
transactions={txs} | ||
isLoading={isLoading} | ||
emptyState={ | ||
<EmptyState | ||
withBorder | ||
imageVariant="empty" | ||
message="There are no transactions in this network." | ||
/> | ||
} | ||
showAction={false} | ||
showRelations={false} | ||
/> | ||
{!isViewMore && countTxs > 10 && ( | ||
<Pagination | ||
currentPage={currentPage} | ||
pagesQuantity={pagesQuantity} | ||
offset={offset} | ||
totalData={countTxs} | ||
pageSize={pageSize} | ||
onPageChange={onPageChange} | ||
onPageSizeChange={onPageSizeChange} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
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,21 @@ | ||
import { Flex, Heading, Text } from "@chakra-ui/react"; | ||
|
||
import PageContainer from "lib/components/PageContainer"; | ||
|
||
import { TxsTable } from "./components/TxsTable"; | ||
|
||
const Txs = () => ( | ||
<PageContainer> | ||
<Flex direction="column" gap={2} mb={10}> | ||
<Heading variant="h5" as="h5"> | ||
Transactions | ||
</Heading> | ||
<Text variant="body2" color="text.dark"> | ||
This page displays all transactions in this network sorted by recency | ||
</Text> | ||
</Flex> | ||
<TxsTable isViewMore={false} /> | ||
</PageContainer> | ||
); | ||
|
||
export default Txs; |
Oops, something went wrong.
a1cd338
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:
terra-celatone-frontend-staging – ./
terra-celatone-frontend-staging-git-develop-alleslabs.vercel.app
terra-staging.celat.one
terra-celatone-frontend-staging.vercel.app
terra-celatone-frontend-staging-alleslabs.vercel.app
a1cd338
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:
osmosis-celatone-frontend-staging – ./
osmosis-celatone-frontend-staging-git-develop-alleslabs.vercel.app
celatone-frontend-staging.vercel.app
celatone-staging.osmosis.zone
osmosis-celatone-frontend-staging-alleslabs.vercel.app
osmosis-staging.celat.one