From 28a0027e212cfe2b3f5d397464dbbfe14a5a186c Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Fri, 26 Jun 2020 23:54:55 +0300 Subject: take all info from user to highlight --- src/components/Highlight/Highlight.tsx | 39 ++++++++++++++++++++++++++++++++ src/components/UserStatus/UserStatus.tsx | 29 ++++++++++++++++++++++++ src/pages/ProfilePage/ProfileInfo.tsx | 31 ++++++++----------------- src/pages/ProfilePage/ProfilePage.tsx | 11 ++++++++- 4 files changed, 88 insertions(+), 22 deletions(-) create mode 100644 src/components/Highlight/Highlight.tsx create mode 100644 src/components/UserStatus/UserStatus.tsx (limited to 'src') diff --git a/src/components/Highlight/Highlight.tsx b/src/components/Highlight/Highlight.tsx new file mode 100644 index 0000000..71764e2 --- /dev/null +++ b/src/components/Highlight/Highlight.tsx @@ -0,0 +1,39 @@ +import React, {useState} from 'react'; +import {makeStyles} from '@material-ui/core/styles'; + +interface PropTypes { + text: string; + value: any; +} + +const useStyles = makeStyles({ + root: { + position: 'relative' + }, + menuButton: { + width: 200, + height: 50, + textAlign: 'center' + }, + menuNumber: { + fontWeight: 800, + color: 'black' + }, + menuText: { + color: 'darkgray' + }, +}); + + +const Highlight: React.FC = ({text, value}) => { + const classes = useStyles(); + + return ( +
+
{value}
+
{text}
+
+ ); +}; + +export default Highlight; diff --git a/src/components/UserStatus/UserStatus.tsx b/src/components/UserStatus/UserStatus.tsx new file mode 100644 index 0000000..338b5d1 --- /dev/null +++ b/src/components/UserStatus/UserStatus.tsx @@ -0,0 +1,29 @@ +import React, {useState} from 'react'; +import {makeStyles} from '@material-ui/core/styles'; + +const useStyles = makeStyles({ + root: { + position: 'relative' + }, + status: { + textAlign: 'center', + color: 'darkgray' + }, +}); + + +const UserStatus: React.FC = () => { + const classes = useStyles(); + + const changeStatus = () => { + + }; + + return ( +
+ I am not alcoholic +
+ ); +}; + +export default UserStatus; diff --git a/src/pages/ProfilePage/ProfileInfo.tsx b/src/pages/ProfilePage/ProfileInfo.tsx index 07a6df0..a445b51 100644 --- a/src/pages/ProfilePage/ProfileInfo.tsx +++ b/src/pages/ProfilePage/ProfileInfo.tsx @@ -5,11 +5,15 @@ import {User} from 'which-types'; import CameraAltIcon from '@material-ui/icons/CameraAlt'; import MoreMenu from "./MoreMenu"; import {patch} from '../../requests'; +import Highlight from "../../components/Highlight/Highlight"; +import UserStatus from "../../components/UserStatus/UserStatus"; interface PropTypes { user: User | undefined; logOut: () => void; + savedPolls: number; + totalVotes: number; } const useStyles = makeStyles({ @@ -51,11 +55,7 @@ const useStyles = makeStyles({ }, menuText: { color: 'darkgray' - }, - status: { - textAlign: 'center', - color: 'darkgray' - }, + } }); @@ -69,7 +69,7 @@ const StyledBadge = withStyles((theme) => ({ }, }))(Badge); -const ProfileInfo: React.FC = ({user, logOut}) => { +const ProfileInfo: React.FC = ({user, logOut,savedPolls, totalVotes}) => { const classes = useStyles(); const [input,setInput] = useState('hide'); const urlRef = useRef(); @@ -131,22 +131,11 @@ const ProfileInfo: React.FC = ({user, logOut}) => {
{user?.username}
-
- I am not alcoholic -
+
-
-
11
-
Polls
-
-
-
05.05.2020
-
Since
-
-
-
17
-
Total votes
-
+ + +
); diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 363d4ff..3506995 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -14,6 +14,7 @@ interface PropTypes { const ProfilePage: React.FC = ({ logOut, id, navigate }) => { const [userInfo, setUserInfo] = useState(); const [polls, setPolls] = useState([]); + const [totalVotes, setTotalVotes] = useState(0); useEffect(() => { get(`/users/${id}`).then(response => { @@ -24,13 +25,21 @@ const ProfilePage: React.FC = ({ logOut, id, navigate }) => { useEffect(() => { get(`/profiles/${id}`).then(response => { setPolls(response.data); + // const x = response.data.reduce((a: any, c: any) => a.contents.left.votes + c.contents.left.votes); + // const y = response.data.reduce((a: any, c: any) => a.contents.right.votes + c.contents.right.votes); + let sum = 0; + for(let i = 0;i - + ); -- cgit v1.2.3