diff --git a/dapp/src/components/TransactionHistory/Table/Cell/Custom.tsx b/dapp/src/components/TransactionHistory/Table/Cell/Custom.tsx new file mode 100644 index 000000000..89048619c --- /dev/null +++ b/dapp/src/components/TransactionHistory/Table/Cell/Custom.tsx @@ -0,0 +1,27 @@ +import React from "react" +import { TransactionInfo } from "#/types" +import Cell from "." +import { ContentType, getCustomContent } from "./utils/content" + +function CustomCell({ + type, + transaction1, + transaction2, +}: { + type: ContentType + transaction1: TransactionInfo + transaction2: TransactionInfo +}) { + if (type === "date") { + return + } + + return ( + + ) +} + +export default CustomCell diff --git a/dapp/src/components/TransactionHistory/Table/Cell/components/BlockExplorer.tsx b/dapp/src/components/TransactionHistory/Table/Cell/components/BlockExplorer.tsx new file mode 100644 index 000000000..e7f833602 --- /dev/null +++ b/dapp/src/components/TransactionHistory/Table/Cell/components/BlockExplorer.tsx @@ -0,0 +1,21 @@ +import React from "react" +import { Chain, ExplorerDataType } from "#/types" +import { BLOCK_EXPLORER } from "#/constants" +import ViewInBlockExplorer from "#/components/shared/ViewInBlockExplorer" +import SimpleText from "./SimpleText" + +function BlockExplorer({ txHash, chain }: { txHash?: string; chain: Chain }) { + if (txHash) { + return ( + + ) + } + return {BLOCK_EXPLORER[chain].title} +} + +export default BlockExplorer diff --git a/dapp/src/components/TransactionHistory/Table/Cell/components/SimpleText.tsx b/dapp/src/components/TransactionHistory/Table/Cell/components/SimpleText.tsx new file mode 100644 index 000000000..01b98160a --- /dev/null +++ b/dapp/src/components/TransactionHistory/Table/Cell/components/SimpleText.tsx @@ -0,0 +1,9 @@ +import React from "react" +import { TextSm } from "#/components/shared/Typography" +import { TextProps } from "@chakra-ui/react" + +function SimpleText({ ...textProps }: TextProps) { + return +} + +export default SimpleText diff --git a/dapp/src/components/TransactionHistory/Table/Cells/Status.tsx b/dapp/src/components/TransactionHistory/Table/Cell/components/Status.tsx similarity index 100% rename from dapp/src/components/TransactionHistory/Table/Cells/Status.tsx rename to dapp/src/components/TransactionHistory/Table/Cell/components/Status.tsx diff --git a/dapp/src/components/TransactionHistory/Table/Cells/CellWrapper.tsx b/dapp/src/components/TransactionHistory/Table/Cell/index.tsx similarity index 92% rename from dapp/src/components/TransactionHistory/Table/Cells/CellWrapper.tsx rename to dapp/src/components/TransactionHistory/Table/Cell/index.tsx index 25ff877d6..ae185cbcb 100644 --- a/dapp/src/components/TransactionHistory/Table/Cells/CellWrapper.tsx +++ b/dapp/src/components/TransactionHistory/Table/Cell/index.tsx @@ -1,7 +1,7 @@ import React from "react" import { Box, Divider, useMultiStyleConfig } from "@chakra-ui/react" -function CellWrapper({ +function Cell({ children1, children2, }: { @@ -24,4 +24,4 @@ function CellWrapper({ ) } -export default CellWrapper +export default Cell diff --git a/dapp/src/components/TransactionHistory/Table/Cell/utils/content.tsx b/dapp/src/components/TransactionHistory/Table/Cell/utils/content.tsx new file mode 100644 index 000000000..c32f38366 --- /dev/null +++ b/dapp/src/components/TransactionHistory/Table/Cell/utils/content.tsx @@ -0,0 +1,52 @@ +import React from "react" +import { TransactionInfo } from "#/types" +import { CurrencyBalance } from "#/components/shared/CurrencyBalance" +import CurrencyIcon from "#/components/shared/CurrencyIcon" +import { displayBlockTimestamp } from "#/utils" +import BlockExplorer from "../components/BlockExplorer" +import SimpleText from "../components/SimpleText" +import Status from "../components/Status" + +export type ContentType = + | "currency-balance" + | "block-explorer" + | "currency-icon" + | "date" + | "status" + +export const getCustomContent = ( + type: ContentType, + transaction: TransactionInfo, +) => { + switch (type) { + case "currency-balance": + return ( + + ) + case "block-explorer": { + return ( + + ) + } + case "currency-icon": { + return + } + case "date": { + return ( + + {displayBlockTimestamp(transaction.timestamp)} + + ) + } + case "status": { + return + } + default: + // eslint-disable-next-line react/jsx-no-useless-fragment + return <> + } +} diff --git a/dapp/src/components/TransactionHistory/Table/Cells/CustomCell.tsx b/dapp/src/components/TransactionHistory/Table/Cells/CustomCell.tsx deleted file mode 100644 index add60b27d..000000000 --- a/dapp/src/components/TransactionHistory/Table/Cells/CustomCell.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import React from "react" -import ViewInBlockExplorer from "#/components/shared/ViewInBlockExplorer" -import { ExplorerDataType, TransactionInfo } from "#/types" -import { CurrencyBalance } from "#/components/shared/CurrencyBalance" -import CurrencyIcon from "#/components/shared/CurrencyIcon" -import { TextSm } from "#/components/shared/Typography" -import { displayBlockTimestamp } from "#/utils" -import CellWrapper from "./CellWrapper" -import Status from "./Status" - -type CellType = - | "currency-balance" - | "block-explorer" - | "currency-icon" - | "date" - | "status" - -const getCustomComponent = (type: CellType, transaction: TransactionInfo) => { - switch (type) { - case "currency-balance": - return ( - - ) - case "block-explorer": { - return ( - - ) - } - case "currency-icon": { - return - } - case "date": { - return ( - - {displayBlockTimestamp(transaction.timestamp)} - - ) - } - case "status": { - return - } - default: - // eslint-disable-next-line react/jsx-no-useless-fragment - return <> - } -} - -function CustomCell({ - type, - transaction1, - transaction2, -}: { - type: CellType - transaction1: TransactionInfo - transaction2: TransactionInfo -}) { - if (type === "date") { - return - } - - return ( - - ) -} - -export default CustomCell diff --git a/dapp/src/components/TransactionHistory/Table/Cells/TextCell.tsx b/dapp/src/components/TransactionHistory/Table/Cells/TextCell.tsx deleted file mode 100644 index 2919cf689..000000000 --- a/dapp/src/components/TransactionHistory/Table/Cells/TextCell.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react" -import { TextSm } from "#/components/shared/Typography" -import CellWrapper from "./CellWrapper" - -function TextCell({ - value1, - value2, -}: { - value1: string | number - value2: string | number -}) { - return ( - {value1}} - children2={{value2}} - /> - ) -} - -export default TextCell diff --git a/dapp/src/components/TransactionHistory/Table/utils/columns.tsx b/dapp/src/components/TransactionHistory/Table/utils/columns.tsx index 0f04b505b..4569c203c 100644 --- a/dapp/src/components/TransactionHistory/Table/utils/columns.tsx +++ b/dapp/src/components/TransactionHistory/Table/utils/columns.tsx @@ -2,8 +2,9 @@ import React from "react" import { ColumnDef, createColumnHelper } from "@tanstack/react-table" import { StakeHistory } from "#/types" import { capitalize, truncateAddress } from "#/utils" -import TextCell from "../Cells/TextCell" -import CustomCell from "../Cells/CustomCell" +import CustomCell from "../Cell/Custom" +import Cell from "../Cell" +import SimpleText from "../Cell/components/SimpleText" const columnHelper = createColumnHelper() // When defining the columns for the table, columnHelper.accessor ts returns a type issue. @@ -29,9 +30,13 @@ export const COLUMNS: ColumnDef[] = [ columnHelper.display({ header: "Action", cell: ({ row: { original } }) => ( - {capitalize(original.callTx.action)} + } + children2={ + {capitalize(original.receiptTx.action)} + } /> ), }), @@ -58,9 +63,13 @@ export const COLUMNS: ColumnDef[] = [ columnHelper.display({ header: "Account", cell: ({ row: { original } }) => ( - {truncateAddress(original.callTx.account)} + } + children2={ + {truncateAddress(original.receiptTx.account)} + } /> ), }), diff --git a/dapp/src/types/transaction.ts b/dapp/src/types/transaction.ts index ca6705c5e..7285acedd 100644 --- a/dapp/src/types/transaction.ts +++ b/dapp/src/types/transaction.ts @@ -16,7 +16,7 @@ export type TransactionInfo = { action: TransactionInfoAction asset: Asset account: string - txHash: string + txHash?: string status: TransactionInfoStatus }