From 00f10b276405613c86c5c19bda9cc1bb7bcc5f16 Mon Sep 17 00:00:00 2001 From: Kristie Huang Date: Sun, 28 Nov 2021 18:49:23 -0800 Subject: [PATCH] Tx modal broken --- src/components/account/AccountModal.tsx | 19 +-- .../account/TransactionsModalFooter.tsx | 127 ++++++++++++++++++ 2 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 src/components/account/TransactionsModalFooter.tsx diff --git a/src/components/account/AccountModal.tsx b/src/components/account/AccountModal.tsx index 6e59b7a..23fdd4c 100644 --- a/src/components/account/AccountModal.tsx +++ b/src/components/account/AccountModal.tsx @@ -19,6 +19,7 @@ import Identicon from "./Identicon"; import { useYobot } from "src/contexts/YobotContext"; import { NoShadowButton, NoShadowLink } from "src/components"; import { getNetworkPrefix } from "src/utils"; +import TransactionsModalFooter from "./TransactionsModalFooter"; type AccountModalProps = { isOpen: any; @@ -176,23 +177,7 @@ const AccountModal = ({ isOpen, onClose }: AccountModalProps) => { - - - Your transactions will appear here... - - + ); diff --git a/src/components/account/TransactionsModalFooter.tsx b/src/components/account/TransactionsModalFooter.tsx new file mode 100644 index 0000000..1a10aab --- /dev/null +++ b/src/components/account/TransactionsModalFooter.tsx @@ -0,0 +1,127 @@ +// TransactionsModalFooter.tsx +import React, { useEffect, useMemo } from "react"; +import { + Box, + Button, + Flex, + Link as ChakraLink, + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalFooter, + ModalBody, + ModalCloseButton, + Stack, + Text, +} from "@chakra-ui/react"; +import { getNetworkPrefix } from "src/utils"; +import { ExternalLinkIcon, CopyIcon } from "@chakra-ui/icons"; +import styled from "@emotion/styled"; +import { useYobot } from "src/contexts"; + +const TransactionListWrapper = styled.div` +`; + +const pendingTransactions : (mapping string[]) = []; +// "{action} bid for {_quantity} of {_token_address} NFTs at {priceInEth} ETH each." + +const addPendingTx = (tx) => { + pendingTransactions.push(tx); +}; + +const addSuccessfulTx = (tx) => { + pendingTransactions.remove(tx); + +}; + +const TransactionsModalFooter = () => { + const { chainId, actions } = useYobot(); + + const fetchTransactions = async () => { + for (const action of actions) { + let values = action["returnValues"]; + if (values !== undefined) { + let _address = values["0"]; + let _token_address = values["1"]; + let _action = values["4"]; + console.log(values); + } + } + } + + useEffect(() => {fetchTransactions()}); + + // const sortedRecentTransactions = useMemo(() => { + // const txs = Object.values(allTransactions) + // return txs.filter(isTransactionRecent).sort(newTransactionsFirst) + // }, [allTransactions]) + + function renderTransactions(transactions: string[]) { + return ( + + {transactions.map((_token_address, i) => { + return ( + + 0 ? getNetworkPrefix(chainId) : "" + }etherscan.io/address/${_token_address}`} + > + {_token_address} + + + + + + ) + })} + + ) + } + + const pendingTransactions = []; + const confirmedTransactions = []; + // const pendingTransactions = sortedRecentTransactions.filter((tx) => !tx.receipt).map((tx) => tx.hash) + // const confirmedTransactions = sortedRecentTransactions.filter((tx) => tx.receipt).map((tx) => tx.hash) + + return ( + + {!!pendingTransactions.length || !!confirmedTransactions.length ? ( + + Recent Transactions + + // {renderTransactions(pendingTransactions)} + // {renderTransactions(confirmedTransactions)} + ) : ( + + Your transactions will appear here... + + )} + + ); +}; + +export default TransactionsModalFooter;