aboutsummaryrefslogtreecommitdiff
path: root/src/components/SolutionCard
diff options
context:
space:
mode:
authorEug-VS <eug-vs@keemail.me>2020-01-05 03:24:01 +0300
committerEug-VS <eug-vs@keemail.me>2020-01-05 03:24:01 +0300
commit5919ca26792796c99bfac316a9dfca0b9257fe76 (patch)
tree4eb56d29f623e78f6b9d518825987de900d2f341 /src/components/SolutionCard
parentdd622def55c52255493c467e2be2f8e3473a1256 (diff)
downloadchrono-cube-ui-5919ca26792796c99bfac316a9dfca0b9257fe76.tar.gz
Parse date to SolutionCard
Diffstat (limited to 'src/components/SolutionCard')
-rw-r--r--src/components/SolutionCard/SolutionCard.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/components/SolutionCard/SolutionCard.js b/src/components/SolutionCard/SolutionCard.js
index f2d814c..7cca74c 100644
--- a/src/components/SolutionCard/SolutionCard.js
+++ b/src/components/SolutionCard/SolutionCard.js
@@ -19,6 +19,14 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';
import { del } from "../../requests";
+const DATE_FORMAT = {
+ month: 'long',
+ day: 'numeric',
+ year: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+};
+
const useStyles = makeStyles(theme => ({
root: {
padding: theme.spacing(1),
@@ -30,11 +38,12 @@ const useStyles = makeStyles(theme => ({
},
}));
-const SolutionCard = ({ solution, removeThisCard }) => {
+const SolutionCard = ({ data, removeThisCard }) => {
const classes = useStyles();
const [anchorEl, setAnchorEl] = useState(null);
- const author = solution.author? solution.author.username : 'anonymous';
+ const author = data.author? data.author.username : 'anonymous';
+ const date = new Date(data.date);
const handleOpenMenu = event => {
setAnchorEl(event.currentTarget);
@@ -45,9 +54,9 @@ const SolutionCard = ({ solution, removeThisCard }) => {
};
const handleDelete = () => {
- del(`solutions/${solution.id}/`);
+ del(`solutions/${data.id}/`);
handleClose();
- removeThisCard(solution.id);
+ removeThisCard(data.id);
};
return (
@@ -60,7 +69,7 @@ const SolutionCard = ({ solution, removeThisCard }) => {
(<Avatar>{author[0].toUpperCase()}</Avatar>)
}
title={author}
- subheader="04.01.2020 13:20"
+ subheader={date.toLocaleString('default', DATE_FORMAT)}
action={(
<IconButton onClick={handleOpenMenu}>
<MoreVertIcon />
@@ -82,7 +91,7 @@ const SolutionCard = ({ solution, removeThisCard }) => {
</Grid>
<Grid item>
<Typography variant="h3">
- { solution.result }
+ { data.result }
</Typography>
</Grid>
</Grid>