-
Notifications
You must be signed in to change notification settings - Fork 24
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 #1093 from kadena-community/feat/graph/show-tx-pag…
…e-and-recent-tx [@kadena/graph-client][@kadena/graph] Show recent and all transactions (Feature)
- Loading branch information
Showing
18 changed files
with
290 additions
and
228 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@kadena/graph-client': patch | ||
'@kadena/graph': patch | ||
--- | ||
|
||
Show tx overview in block page and create transactions page; make transactions query dynamically assign filters; minor fixes and refactoring |
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
131 changes: 131 additions & 0 deletions
131
...s/graph-client/src/components/extended-transactions-table/extended-transactions-table.tsx
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 { Box, Button, Link, Table } from '@kadena/react-ui'; | ||
|
||
import type { GetTransactionsQuery } from '@/__generated__/sdk'; | ||
import routes from '@/constants/routes'; | ||
import type { FetchMoreOptions, FetchMoreQueryOptions } from '@apollo/client'; | ||
import React from 'react'; | ||
|
||
type DataType = GetTransactionsQuery; | ||
|
||
interface IVariableType { | ||
first: number | null; | ||
last: number | null; | ||
after: string | null; | ||
before: string | null; | ||
} | ||
|
||
interface IExpandedTransactionsTableProps { | ||
transactions: GetTransactionsQuery['transactions']; | ||
fetchMore: ( | ||
fetchMoreOptions: FetchMoreQueryOptions<IVariableType, DataType> & | ||
FetchMoreOptions, | ||
) => Promise<any>; | ||
} | ||
|
||
export const ExtendedTransactionsTable = ( | ||
props: IExpandedTransactionsTableProps, | ||
): JSX.Element => { | ||
const { transactions, fetchMore } = props; | ||
const pageSize: number = 10; | ||
|
||
return ( | ||
<> | ||
<Box marginBottom="$3"> | ||
<span>{`Showing ${pageSize} results per page`}</span> | ||
|
||
<Button | ||
variant="compact" | ||
onClick={() => | ||
fetchMore({ | ||
variables: { | ||
first: pageSize, | ||
last: null, | ||
after: transactions.pageInfo.endCursor, | ||
before: null, | ||
}, | ||
updateQuery: (prev, { fetchMoreResult }) => { | ||
if (!fetchMoreResult) return prev; | ||
return fetchMoreResult; | ||
}, | ||
}) | ||
} | ||
disabled={!transactions.pageInfo.hasNextPage} | ||
style={{ float: 'right' }} | ||
> | ||
Next Page | ||
</Button> | ||
<Button | ||
variant="compact" | ||
onClick={() => | ||
fetchMore({ | ||
variables: { | ||
first: null, | ||
last: pageSize, | ||
after: null, | ||
before: transactions.pageInfo.startCursor, | ||
}, | ||
updateQuery: (prev, { fetchMoreResult }) => { | ||
if (!fetchMoreResult) return prev; | ||
|
||
if (fetchMoreResult.transactions.edges.length < pageSize) { | ||
return { | ||
...prev, | ||
transactions: { | ||
...fetchMoreResult.transactions, | ||
edges: [ | ||
...fetchMoreResult.transactions.edges, | ||
...prev.transactions.edges, | ||
].slice(0, pageSize), | ||
}, | ||
}; | ||
} | ||
|
||
return fetchMoreResult; | ||
}, | ||
}) | ||
} | ||
disabled={!transactions.pageInfo.hasPreviousPage} | ||
style={{ float: 'right', marginRight: '10px' }} | ||
> | ||
Previous Page | ||
</Button> | ||
</Box> | ||
<Table.Root wordBreak="break-word"> | ||
<Table.Head> | ||
<Table.Tr> | ||
<Table.Th>Chain</Table.Th> | ||
<Table.Th>Timestamp</Table.Th> | ||
<Table.Th>Block Height</Table.Th> | ||
<Table.Th>Request Key</Table.Th> | ||
<Table.Th>Code</Table.Th> | ||
</Table.Tr> | ||
</Table.Head> | ||
<Table.Body> | ||
{transactions.edges.map((edge, index) => { | ||
return ( | ||
<Table.Tr key={index}> | ||
<Table.Td>{edge?.node.chainId}</Table.Td> | ||
<Table.Td> | ||
{new Date(edge?.node.creationTime).toLocaleString()} | ||
</Table.Td> | ||
<Table.Td>{edge?.node.height}</Table.Td> | ||
<Table.Td> | ||
<Link | ||
href={`${routes.TRANSACTIONS}/${edge?.node.requestKey}`} | ||
> | ||
{edge?.node.requestKey} | ||
</Link> | ||
</Table.Td> | ||
<Table.Td> | ||
{edge?.node.code || ( | ||
<span style={{ color: 'lightgray' }}>N/A</span> | ||
)} | ||
</Table.Td> | ||
</Table.Tr> | ||
); | ||
})} | ||
</Table.Body> | ||
</Table.Root> | ||
</> | ||
); | ||
}; |
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
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
Oops, something went wrong.