Skip to content
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

Merged
merged 23 commits into from
Jan 18, 2024

Conversation

kkosiorowska
Copy link
Contributor

@kkosiorowska kkosiorowska commented Jan 11, 2024

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:

  • Ability to add sorting or pagination functions
  • We can easily add custom cells by this library
  • Many examples from the React Table docs 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.

UI

Screenshot 2024-01-15 at 10 51 14

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.

@kkosiorowska kkosiorowska self-assigned this Jan 11, 2024
Comment on lines 72 to 76
<TextSm>
{`Page ${
table.getState().pagination.pageIndex + 1
} of ${table.getPageCount()}`}
</TextSm>
Copy link
Contributor Author

@kkosiorowska kkosiorowska Jan 15, 2024

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.

Copy link
Contributor Author

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: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r-czajkowski @ioay

It isn't the best name for a variant. So please share your opinion on how to name it better. 🤔

Copy link
Contributor

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.

@kkosiorowska kkosiorowska marked this pull request as ready for review January 15, 2024 12:48
@@ -0,0 +1,22 @@
type TransactionInfoAction = "stake" | "unstake" | "receive"

enum TransactionInfoStatus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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


const KEYS = [...parts.keys, "cellContainer", "cell", "divider"] as const

const { defineMultiStyleConfig, definePartsStyle } =
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dapp/src/static/icons/ArrowLeft.tsx Show resolved Hide resolved
dapp/src/static/icons/ArrowRight.tsx Show resolved Hide resolved
</Tbody>
</ChakraTable>
</TableContainer>
<HStack mt={6}>
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

Copy link
Contributor Author

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>
Copy link
Contributor

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/.

Copy link
Contributor Author

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: {
Copy link
Contributor

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.

Copy link
Contributor

@ioay ioay left a 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({
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #182

@kkosiorowska kkosiorowska merged commit 094e27c into main Jan 18, 2024
11 checks passed
@kkosiorowska kkosiorowska deleted the transaction-table branch January 18, 2024 12:02
ioay pushed a commit that referenced this pull request Jan 18, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants