diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index 40f5fd7..7096150 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -17,6 +17,14 @@ interface PropTypes { navigate: (prefix: string, id: string) => void; } +const DATE_FORMAT = { + month: 'long', + day: 'numeric', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', +}; + const useStyles = makeStyles(theme => ({ root: { maxWidth: theme.spacing(75), @@ -50,6 +58,7 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => { const [poll, setPoll] = useState<Poll>(initialPoll); const classes = useStyles(); const { author, contents: { left, right }, userChoice } = poll; + const date: String = new Date(poll.createdAt).toLocaleString('default', DATE_FORMAT); const handleNavigate = () => { navigate('profile', poll.author._id); @@ -88,6 +97,7 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => { /> )} title={author.username} + subheader={date} /> <div className={classes.imagesBlock}> <CardActionArea onDoubleClick={handleLeft}> |