aboutsummaryrefslogtreecommitdiff
path: root/src/containers
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-10-10 12:14:04 +0300
committerGitHub <noreply@github.com>2020-10-10 12:14:04 +0300
commite7fb5387af7d3397df49b913795b956fc375e39d (patch)
treec10166f9d4a132855c4d4ff26295760fd654c12c /src/containers
parent40ac5922118015aae943872717730d7068976b1a (diff)
parent5ee4f42b577449a58469fd3c7892455d097a6c79 (diff)
downloadwhich-ui-e7fb5387af7d3397df49b913795b956fc375e39d.tar.gz
Merge pull request #106 from which-ecosystem/feat/date-format
Imrove date formats
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/Profile/ProfileInfo.tsx13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/containers/Profile/ProfileInfo.tsx b/src/containers/Profile/ProfileInfo.tsx
index 1f5a103..da952e9 100644
--- a/src/containers/Profile/ProfileInfo.tsx
+++ b/src/containers/Profile/ProfileInfo.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useCallback } from 'react';
+import React, { useState, useCallback, useMemo } from 'react';
import { Badge, Typography, CircularProgress } from '@material-ui/core/';
import { CameraAlt, CheckCircleOutline } from '@material-ui/icons/';
import { makeStyles } from '@material-ui/core/styles';
@@ -92,6 +92,15 @@ const useStyles = makeStyles(theme => ({
}));
+const formatDate = (value: Date | string = ''): string => {
+ const date = new Date(value);
+ const day = (`0${date.getDate()}`).slice(-2);
+ const month = (`0${date.getMonth()}`).slice(-2);
+ const year = date.getFullYear();
+ return `${year}-${month}-${day}`;
+};
+
+
const ProfileInfo: React.FC<PropTypes> = ({
savedPolls, totalVotes, setUserInfo, userInfo
}) => {
@@ -99,7 +108,7 @@ const ProfileInfo: React.FC<PropTypes> = ({
const { user } = useAuth();
const [progress, setProgress] = useState<number>(0);
- const dateSince = new Date(userInfo?.createdAt || '').toLocaleDateString();
+ const dateSince = useMemo(() => formatDate(userInfo?.createdAt), [userInfo]);
const handleUpdateAvatar = useCallback(async (file: File) => {
if (user) {