-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation of the transaction history table #145
Conversation
98d383f
to
8890b18
Compare
- set a correct size - remove the `textTransform` property
<TextSm> | ||
{`Page ${ | ||
table.getState().pagination.pageIndex + 1 | ||
} of ${table.getPageCount()}`} | ||
</TextSm> |
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.
Please pay no attention to this text. When this is confirmed with Sorin, I will update this.
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.
Done in #190
@@ -65,6 +65,22 @@ const Button: ComponentSingleStyleConfig = { | |||
|
|||
return defaultStyles | |||
}, | |||
pagination: { |
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.
It isn't the best name for a variant. So please share your opinion on how to name it better. 🤔
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.
It's ok for me.
443a43c
to
c9505c3
Compare
dapp/src/types/transaction.ts
Outdated
@@ -0,0 +1,22 @@ | |||
type TransactionInfoAction = "stake" | "unstake" | "receive" | |||
|
|||
enum TransactionInfoStatus { |
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.
Let's use const instead of enum: https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh
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.
Good point! Let's use maybe union at this point to make it as simple as possible. However, when we start working on the subgraph and integrating it into the dapp, think about using const. At this moment, it's difficult to plan how these data should look.
3cc2abb
dapp/src/theme/Table.ts
Outdated
|
||
const KEYS = [...parts.keys, "cellContainer", "cell", "divider"] as const | ||
|
||
const { defineMultiStyleConfig, definePartsStyle } = |
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.
This approach does not meet the conditions of unbound-method eslint rule. On the main branch currently is disabled, but take a look at this commit and add a solution like this: 27cac22
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.
</Tbody> | ||
</ChakraTable> | ||
</TableContainer> | ||
<HStack mt={6}> |
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.
Let's split this file into 3 standalone files: tableHeader / tableContent(or tableBody) / tablePagination(or tableFooter). This will make it more readable.
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.
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.
Let's create utils dir, and move pagination.tsx file into this:
src/components/TransactionHistory/Table/utils/pagination.tsx
because the current naming convention suggests a logic related to pagination functionality in this file
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.
pageSize: 2, | ||
} | ||
|
||
export type UseTransactionHistoryTableResult = Table<StakeHistory> |
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.
Move this type to src/types/.
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.
@@ -65,6 +65,22 @@ const Button: ComponentSingleStyleConfig = { | |||
|
|||
return defaultStyles | |||
}, | |||
pagination: { |
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.
It's ok for me.
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.
LGTM 🚀 Just one minor comment.
IMPORTANT: Please before merging check if eslint rules are fulfilled (comment temporary overrides
block in .eslintrc) and run: pnpm run format
import { Box, Divider, useMultiStyleConfig } from "@chakra-ui/react" | ||
import { TextSm } from "#/components/shared/Typography" | ||
|
||
function Cell({ |
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.
Let's create a stanandaloneTable/Cell.tsx
for this function.
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.
Let me fix it in the next PR.
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.
Done in #182
Ref #38 This PR adds a basic table for transaction history. To create the tables used the [TanStack](https://tanstack.com/table/v8) package. This library was chosen because: - Ability to add sorting or pagination functions - We can easily add custom cells by this library - Many examples from the [React Table docs](https://react-table.tanstack.com/docs/examples/basic) are portable to use Chakra UI's components by converting `<table />` to `<Table />`, `<td />` to `<Td />`, etc. (Easy integration with chakra UI) This is the basic implementation of the table. The issue of sorting or custom cell styles will be done in the next steps. The goal is to simplify the review and break down the code into smaller parts. <img width="1389" alt="Screenshot 2024-01-15 at 10 51 14" src="https://github.com/thesis/acre/assets/23117945/5805864a-e4e1-49dd-98a0-357119ed4fd9"> Currently, the positioning of the elements for the overview page doesn't look good. Several elements will be added to this view. In the scope of this PR, let's focus on the implantation of A basic table. Let's fix it in the next PR.
Ref #38
What
This PR adds a basic table for transaction history. To create the tables used the TanStack package. This library was chosen because:
<table />
to<Table />
,<td />
to<Td />
, etc. (Easy integration with chakra UI)This is the basic implementation of the table. The issue of sorting or custom cell styles will be done in the next steps. The goal is to simplify the review and break down the code into smaller parts.
UI
Some note
Currently, the positioning of the elements for the overview page doesn't look good. Several elements will be added to this view. In the scope of this PR, let's focus on the implantation of A basic table. Let's fix it in the next PR.