diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-25 21:59:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 21:59:33 +0300 |
commit | f94fa6fb208a903ce46b943b34b94fa65d264b84 (patch) | |
tree | a2f63401fbed4dd54cd91d3a6fd272758fd9c8c0 | |
parent | 665917f67707a40604157c7e7ccf26837e18aa81 (diff) | |
parent | c0efa234a39ed174ecbd5b5240191aa9c22b901e (diff) | |
download | which-ui-f94fa6fb208a903ce46b943b34b94fa65d264b84.tar.gz |
Merge pull request #45 from which-ecosystem/poll-date
Display Date on PollCard
-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 f82091c..72c2daf 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), @@ -54,6 +62,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); @@ -89,6 +98,7 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll, navigate }) => { /> )} title={author.username} + subheader={date} /> <div className={classes.imagesBlock}> <CardActionArea onDoubleClick={handleLeft}> |