From ae8f789ca3b73dbf06b868bc69bf9aa3dce78bd9 Mon Sep 17 00:00:00 2001 From: yhtiyar Date: Tue, 3 Aug 2021 15:42:49 +0300 Subject: [PATCH] fix StreamEntry --- frontend/src/components/StreamEntry.js | 362 ++++++++++++++++++++----- 1 file changed, 299 insertions(+), 63 deletions(-) diff --git a/frontend/src/components/StreamEntry.js b/frontend/src/components/StreamEntry.js index 7bf845a5..15508570 100644 --- a/frontend/src/components/StreamEntry.js +++ b/frontend/src/components/StreamEntry.js @@ -9,94 +9,330 @@ import { useQuery } from "react-query"; const StreamEntry = ({ entry, filterCallback, filterConstants }) => { const ui = useContext(UIContext); const router = useRouter(); - useQuery(["currentTransaction", entry.hash], ()=> entry) - + const [copyString, setCopyString] = useState(false); + const { onCopy, hasCopied } = useClipboard(copyString, 1); + const toast = useToast(); + + useEffect(() => { + if (hasCopied && copyString) { + toast("Copied to clipboard", "success"); + setCopyString(false); + } else if (copyString) { + onCopy(); + } + }, [copyString, onCopy, hasCopied, toast]); const handleViewClicked = (entryId) => { ui.setEntryId(entryId); ui.setEntriesViewMode("entry"); - router.push({ pathname: `/stream/${entry.hash}`, query: router.query, }); }; + const [showFullView] = useMediaQuery(["(min-width: 420px)"]); + return ( - - - filterCallback({ - direction: filterConstants.DIRECTIONS.SOURCE, - type: filterConstants.FILTER_TYPES.ADDRESS, - value: entry.from_address, - conditon: filterConstants.CONDITION.EQUAL, - }) - } - > - {"From:"} - {`${entry.from_label} - ${entry.from_address}`} - {" "} - - filterCallback({ - direction: filterConstants.DIRECTIONS.DESTINATION, - type: filterConstants.FILTER_TYPES.ADDRESS, - value: entry.to_address, - conditon: filterConstants.CONDITION.EQUAL, - }) - } - > - {"To:"} - {`${entry.to_label} - ${entry.to_address}`} - {" "} - - Gas Price: {entry.gasPrice} - - - Gas: {entry.gas} - - - Value: {entry.value} - - - - - {moment(entry.created_at).format("DD MMM, YYYY, h:mm:ss")}{" "} - - } - onClick={() => { handleViewClicked(entry)}} - /> + + {true && ( + + + + Ethereum blockhain + + + + + From: + + + setCopyString(entry.from_address)} + > + {entry.from_label ?? entry.from_address} + + + + + + To: + + + setCopyString(entry.to_address)} + > + {entry.to_label ?? entry.to_address} + + + + + + + + Gas Price: + + + setCopyString(entry.gasPrice)} + > + {entry.gasPrice} + + + + + + Gas: + + + setCopyString(entry.gas)} + > + {entry.gas} + + + + + + Value: + + + setCopyString(entry.value)} + > + {entry.value} + + + + {entry.timestamp && ( + + + {moment(entry.timestamp) + // .format("DD MMM, YYYY, h:mm:ss") + .fromNow()}{" "} + + + )} + + + )} + + handleViewClicked(entry)} + h="full" + // minH="24px" + borderLeftRadius={0} + variant="solid" + px={0} + minW="24px" + colorScheme="suggested" + icon={} + /> + + ); };