diff --git a/frontend/src/components/NewModalSubscripton.js b/frontend/src/components/NewModalSubscripton.js index 6d613e14..9fb40a2b 100644 --- a/frontend/src/components/NewModalSubscripton.js +++ b/frontend/src/components/NewModalSubscripton.js @@ -21,11 +21,18 @@ import { useForm } from "react-hook-form"; import { GithubPicker } from "react-color"; import { BiRefresh } from "react-icons/bi"; import { makeColor } from "../core/utils/makeColor"; -const NewSubscription = ({ isFreeOption, onClose }) => { +const NewSubscription = ({ + isFreeOption, + onClose, + initialAddress, + initialType, +}) => { const [color, setColor] = useState(makeColor()); const { typesCache, createSubscription } = useSubscriptions(); const { handleSubmit, errors, register } = useForm({}); - const [radioState, setRadioState] = useState("ethereum_blockchain"); + const [radioState, setRadioState] = useState( + initialType ?? "ethereum_blockchain" + ); let { getRootProps, getRadioProps } = useRadioGroup({ name: "type", defaultValue: radioState, @@ -78,6 +85,8 @@ const NewSubscription = ({ isFreeOption, onClose }) => { autoComplete="off" my={2} placeholder="Enter address" + defaultValue={initialAddress ?? undefined} + isReadOnly={!!initialAddress} name="address" ref={register({ required: "address is required!" })} > @@ -98,6 +107,7 @@ const NewSubscription = ({ isFreeOption, onClose }) => { const radio = getRadioProps({ value: type.id, isDisabled: + (initialAddress && initialType) || !type.active || (isFreeOption && type.id !== "ethereum_blockchain"), }); diff --git a/frontend/src/components/NewSubscription.js b/frontend/src/components/NewSubscription.js index 8acd08b2..230ea755 100644 --- a/frontend/src/components/NewSubscription.js +++ b/frontend/src/components/NewSubscription.js @@ -21,12 +21,20 @@ import { CirclePicker } from "react-color"; import { BiRefresh } from "react-icons/bi"; import { makeColor } from "../core/utils/makeColor"; import { useForm } from "react-hook-form"; -const _NewSubscription = ({ isFreeOption, onClose, setIsLoading }) => { +const _NewSubscription = ({ + isFreeOption, + onClose, + setIsLoading, + initialAddress, + initialType, +}) => { const [color, setColor] = useState(makeColor()); const { handleSubmit, errors, register } = useForm({}); const { typesCache, createSubscription } = useSubscriptions(); // const { handleSubmit, errors, register } = useForm({}); - const [radioState, setRadioState] = useState("ethereum_blockchain"); + const [radioState, setRadioState] = useState( + initialType ?? "ethereum_blockchain" + ); let { getRootProps, getRadioProps } = useRadioGroup({ name: "type", defaultValue: radioState, @@ -52,7 +60,7 @@ const _NewSubscription = ({ isFreeOption, onClose, setIsLoading }) => { createSubscription.mutate({ ...props, color: color, - type: isFreeOption ? 0 : radioState, + type: isFreeOption ? "ethereum_blockchain" : radioState, }); }, [createSubscription, isFreeOption, color, radioState] @@ -107,6 +115,7 @@ const _NewSubscription = ({ isFreeOption, onClose, setIsLoading }) => { const radio = getRadioProps({ value: type.id, isDisabled: + (initialAddress && initialType) || !type.active || (isFreeOption && type.id !== "ethereum_blockchain"), }); diff --git a/frontend/src/components/StreamEntry.js b/frontend/src/components/StreamEntry.js index 4e8e7194..8f399b21 100644 --- a/frontend/src/components/StreamEntry.js +++ b/frontend/src/components/StreamEntry.js @@ -67,6 +67,9 @@ const StreamEntry_ = ({ entry, showOnboardingTooltips, className }) => { maxW="150px" > ui.setCurrentTransaction(entry)} h="full" diff --git a/frontend/src/components/stream-cards/EthereumWhalewatch.js b/frontend/src/components/stream-cards/EthereumWhalewatch.js index 11fccb4f..c412a8d0 100644 --- a/frontend/src/components/stream-cards/EthereumWhalewatch.js +++ b/frontend/src/components/stream-cards/EthereumWhalewatch.js @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useState } from "react"; +import React, { useEffect, useState } from "react"; import { Text, Stack, @@ -6,22 +6,31 @@ import { useClipboard, Heading, Image, - useMediaQuery, Spacer, Spinner, chakra, + SimpleGrid, + Box, + Modal, + ModalContent, + ModalOverlay, + IconButton, + useDisclosure, } from "@chakra-ui/react"; -import UIContext from "../../core/providers/UIProvider/context"; import { useToast } from "../../core/hooks"; import { useSubscriptions } from "../../core/hooks"; +import moment from "moment"; +import { AiOutlineMonitor } from "react-icons/ai"; +import NewSubscription from "../NewModalSubscripton"; const EthereumWhalewatchCard_ = ({ entry, showOnboardingTooltips, className, }) => { + const [newSubscriptionWhaleType, setNewSubscriptionWhaleType] = useState(); + const { isOpen, onOpen, onClose } = useDisclosure(); const { subscriptionsCache, subscriptionTypeIcons } = useSubscriptions(); - const ui = useContext(UIContext); const [copyString, setCopyString] = useState(false); const [icon, setIcon] = useState(null); const { onCopy, hasCopied } = useClipboard(copyString, 1); @@ -41,8 +50,6 @@ const EthereumWhalewatchCard_ = ({ setIcon(subscriptionTypeIcons.ethereum_whalewatch); } }, [subscriptionTypeIcons, setIcon]); - - const [showFullView] = useMediaQuery(["(min-width: 420px)"]); if (subscriptionsCache.isLoading) return ; const whales = { @@ -64,14 +71,35 @@ const EthereumWhalewatchCard_ = ({ }); const rowLabels = { - transactionsOut: "Number of transactions sent", - transactionsIn: "Number of transactions received", + transactionsOut: "transactions sent", + transactionsIn: "transactions received", valueOut: "WEI sent", valueIn: "WEI received", }; + const subscribeClicked = (whaleType) => { + setNewSubscriptionWhaleType(whaleType); + onOpen(); + }; return ( + + + + + + + {icon ? : ""} - + Ethereum whale watch - {`${entry.event_data.date_range.start_time} to ${entry.event_data.date_range.end_time}`} + {`${moment(entry.event_data.date_range.start_time).format( + "ll [from] LT" + )} to ${moment(entry.event_data.date_range.end_time).format( + moment(entry.event_data.date_range.start_time).format("l") === + moment(entry.event_data.date_range.end_time).format("l") + ? "LT" + : "lll" + )}`} - {Object.keys(whales).map((whaleType) => { - return ( - - - + + + Whale + + + Address + + + Value + + {Object.keys(whales).map((whaleType) => { + return ( + <> + {rowLabels[whaleType]} - - - - + + setCopyString(whales[whaleType].address)} + isTruncated + > + {whales[whaleType].label} + + + {whales[whaleType].label === whales[whaleType].address && ( + + + subscribeClicked(whaleType)} + colorScheme="secondary" + variant="outline" + m={0} + boxSize="24px" + icon={} + /> + + + )} + + setCopyString(whales[whaleType].address)} + textAlign="left" + pl={2} > - {whales[whaleType].label} -- {whales[whaleType].statistic} - - - - ); - })} + {whales[whaleType].statistic} + + + ); + })} + ); };