From f74de4147b791b8defb7bbbf8967ca23dbbe8fc8 Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Mon, 25 Jan 2021 10:54:37 -0800 Subject: [PATCH] Show squeak details inside dialog (#692) --- .../SqueakDetailItem/SqueakDetailItem.js | 27 +++- .../SqueakDetailsDialog.js | 133 ++++++++++++++++++ .../SqueakDetailsDialog/package.json | 6 + .../components/SqueakDetailsDialog/styles.js | 43 ++++++ 4 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/SqueakDetailsDialog/SqueakDetailsDialog.js create mode 100644 frontend/src/components/SqueakDetailsDialog/package.json create mode 100644 frontend/src/components/SqueakDetailsDialog/styles.js diff --git a/frontend/src/components/SqueakDetailItem/SqueakDetailItem.js b/frontend/src/components/SqueakDetailItem/SqueakDetailItem.js index 4d388ef6..efc16a96 100644 --- a/frontend/src/components/SqueakDetailItem/SqueakDetailItem.js +++ b/frontend/src/components/SqueakDetailItem/SqueakDetailItem.js @@ -31,6 +31,7 @@ import Widget from "../../components/Widget"; import MakeSqueakDialog from "../../components/MakeSqueakDialog"; import DeleteSqueakDialog from "../../components/DeleteSqueakDialog"; import BuySqueakDialog from "../../components/BuySqueakDialog"; +import SqueakDetailsDialog from "../../components/SqueakDetailsDialog"; import { @@ -57,6 +58,7 @@ export default function SqueakDetailItem({ const [replyDialogOpen, setReplyDialogOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const [buyDialogOpen, setBuyDialogOpen] = useState(false); + const [viewDetailsDialogOpen, setViewDetailsDialogOpen] = useState(false); const handleClickOpen = () => { setReplyDialogOpen(true); @@ -83,6 +85,14 @@ export default function SqueakDetailItem({ setBuyDialogOpen(false); }; + const handleClickOpenViewDetailsDialog = () => { + setViewDetailsDialogOpen(true); + }; + + const handleCloseViewDetailsDialog = () => { + setViewDetailsDialogOpen(false); + }; + const goToSqueakAddressPage = () => { history.push("/app/squeakaddress/" + squeak.getAuthorAddress()); }; @@ -139,7 +149,8 @@ export default function SqueakDetailItem({ return; } //handleClickOpenDeleteDialog(); - goToSqueakDetailPage(); + // goToSqueakDetailPage(); + handleClickOpenViewDetailsDialog(); } const onUnlockClick = (event) => { @@ -307,6 +318,19 @@ export default function SqueakDetailItem({ ) } + function ViewDetailsDialogContent() { + return ( + <> + + + ) + } + return ( <> ) } diff --git a/frontend/src/components/SqueakDetailsDialog/SqueakDetailsDialog.js b/frontend/src/components/SqueakDetailsDialog/SqueakDetailsDialog.js new file mode 100644 index 00000000..6c7888e3 --- /dev/null +++ b/frontend/src/components/SqueakDetailsDialog/SqueakDetailsDialog.js @@ -0,0 +1,133 @@ +import React, {useState, useEffect} from 'react'; +import { + Paper, + IconButton, + Menu, + MenuItem, + Typography, + Grid, + Box, + Link, + Dialog, + DialogTitle, + DialogContent, + DialogContentText, + TextField, + DialogActions, + Button, + FormControl, + InputLabel, + Select, +} from "@material-ui/core"; + +import { MoreVert as MoreIcon } from "@material-ui/icons"; +import {useHistory} from "react-router-dom"; +import classnames from "classnames"; + +// styles +import useStyles from "./styles"; + +import Widget from "../../components/Widget"; + +import { + getSqueakDetailsRequest, +} from "../../squeakclient/requests" + + +export default function SqueakDetailsDialog({ + open, + handleClose, + hash, + squeak, + ...props +}) { + var classes = useStyles(); + const history = useHistory(); + + const [squeakDetails, setSqueakDetails] = useState(null); + + const getSqueakDetails = (hash) => { + getSqueakDetailsRequest(hash, setSqueakDetails); + }; + + useEffect(()=>{ + getSqueakDetails(hash) + },[hash]); + + function MakeCancelButton() { + return ( + + ) + } + + function SqueakDetailsContent() { + return ( + <> + + + +
+
+ + + Hash + + +  {squeak.getSqueakHash()} + +
+ +
+ + + Address + + +  {squeak.getAuthorAddress()} + +
+ +
+ + Raw Data + + +
+ +
+
+
+
+ + ) + } + + return ( + + View Squeak Details +
+ + {squeak && squeakDetails && + SqueakDetailsContent() + } + + + {MakeCancelButton()} + +
+
+ ) +} diff --git a/frontend/src/components/SqueakDetailsDialog/package.json b/frontend/src/components/SqueakDetailsDialog/package.json new file mode 100644 index 00000000..44c0da8a --- /dev/null +++ b/frontend/src/components/SqueakDetailsDialog/package.json @@ -0,0 +1,6 @@ +{ + "name": "SqueakDetailsDialog", + "version": "0.0.0", + "private": true, + "main": "SqueakDetailsDialog.js" +} diff --git a/frontend/src/components/SqueakDetailsDialog/styles.js b/frontend/src/components/SqueakDetailsDialog/styles.js new file mode 100644 index 00000000..f2d64da1 --- /dev/null +++ b/frontend/src/components/SqueakDetailsDialog/styles.js @@ -0,0 +1,43 @@ +import { makeStyles } from "@material-ui/styles"; + +export default makeStyles(theme => ({ + widgetWrapper: { + display: "flex", + minHeight: "100%", + }, + widgetHeader: { + padding: theme.spacing(3), + paddingBottom: theme.spacing(1), + display: "flex", + justifyContent: "space-between", + alignItems: "center", + }, + widgetRoot: { + boxShadow: theme.customShadows.widget, + }, + widgetBody: { + paddingBottom: theme.spacing(3), + paddingRight: theme.spacing(3), + paddingLeft: theme.spacing(3), + }, + noPadding: { + padding: 0, + }, + paper: { + display: "flex", + flexDirection: "column", + flexGrow: 1, + overflow: "hidden", + }, + moreButton: { + margin: -theme.spacing(1), + padding: 0, + width: 40, + height: 40, + color: theme.palette.text.hint, + "&:hover": { + backgroundColor: theme.palette.primary.main, + color: "rgba(255, 255, 255, 0.35)", + }, + }, +}));