import React, { useState } from 'react'; import { Typography, Card, CardHeader, CardContent, IconButton, Avatar, Grid, Menu, MenuItem, } from "@material-ui/core"; import { makeStyles } from "@material-ui/core/styles"; import TimerIcon from '@material-ui/icons/Timer'; import MoreVertIcon from '@material-ui/icons/MoreVert'; import { del } from "../../requests"; const useStyles = makeStyles(theme => ({ root: { padding: theme.spacing(1), '& .MuiTypography-h3': { color: theme.palette.secondary.main, margin: theme.spacing(2), }, }, })); const SolutionCard = ({ solution, removeThisCard }) => { const classes = useStyles(); const [anchorEl, setAnchorEl] = useState(null); const author = solution.author? solution.author.username : 'anonymous'; const handleOpenMenu = event => { setAnchorEl(event.currentTarget); }; const handleClose = () => { setAnchorEl(null); }; const handleDelete = () => { del(`solutions/${solution.id}/`); handleClose(); removeThisCard(solution.id); }; return ( ) : ({author[0].toUpperCase()}) } title={author} subheader="04.01.2020 13:20" action={( )} /> Delete { solution.result } ) }; export default SolutionCard;