text: import React from 'react'
  
  import {Card,CardActions,CardContent,CardMedia,Button,Typography} from '@material-ui/core';
  
  import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward';
  import DeleteIcon from '@material-ui/icons/Delete';
  import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
  import useStyles from './styles';
  import moment from 'moment';
  import { deletePost,likePost } from '../../../actions/Posts';
  import {useDispatch} from 'react-redux';
  
  function Post({post,setCurrentId}) {
      const dispatch=useDispatch();
      const classes=useStyles();
  
      return (
          <Card className={classes.card}>
              <CardMedia className={classes.media} image={post.selectedFile} title={post.title}/>
              <div className={classes.overlay}>
                  <Typography variant="h6">{post.creator}</Typography>
              </div>
              <div className={classes.overlay2}>
                  <Button 
                  style={{color: 'white'}} 
                  size="small" 
                  onClick={()=>setCurrentId(post._id)}
                  >
                      <MoreHorizIcon fontSize="default"/>
                  </Button>
              </div>
              <div className={classes.details}>
                  <Typography variant="body2" color="textSecondary" component="h2">{post.tags.map((tag)=>`#${tag} `)}</Typography>
              </div>
              <Typography className={classes.title} gutterBottom variant="h5" component="h2">{post.title}</Typography>
              <CardContent>
                  <Typography variant="body2" color="textSecondary" component="p">{post.message}</Typography>
              </CardContent>
              <CardActions className={classes.cardActions}>
                  <Button size="small" color="primary" 
                      onClick={() => dispatch(likePost(post._id))}
                  ><ArrowUpwardIcon fontSize="small" />&nbsp; UpVote &nbsp; {post.likeCount} </Button>
                  <Button size="small" color="primary" 
                      onClick={() => dispatch(deletePost(post._id))}
                  ><DeleteIcon fontSize="small" /> Delete</Button>
              </CardActions>
          </Card>
      )
  }
  
  export default Post;
  