From 9e9c18cd1d02a0185d0387770a7bafc18020d6c0 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Fri, 26 Jun 2020 03:03:33 +0300 Subject: display user avatar instead avatarIcon in header --- src/components/Header/Header.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/components') diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 4e25fa3..eb24ecc 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -3,7 +3,7 @@ import { AppBar, Toolbar, IconButton, - Typography + Typography, Avatar } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import AccountCircle from '@material-ui/icons/AccountCircle'; @@ -13,6 +13,7 @@ import HomeIcon from '@material-ui/icons/Home'; import SearchBar from './SearchBar'; interface PropTypes { + userImage: string | undefined; navigate: (prefix: string) => void; } @@ -25,10 +26,14 @@ const useStyles = makeStyles({ }, logo: { fontWeight: 'bold' + }, + avatar:{ + width: 24, + height: 24 } }); -const Header: React.FC = ({ navigate }) => { +const Header: React.FC = ({ navigate, userImage }) => { const classes = useStyles(); const handleHome = (): void => { @@ -56,7 +61,11 @@ const Header: React.FC = ({ navigate }) => { - + { + localStorage.getItem('token') + ? + : + } -- cgit v1.2.3 From a5fbcc34f2529a2429124572915597c0fed45ae7 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Fri, 26 Jun 2020 19:07:37 +0300 Subject: show avatar in header only if user set an avatar image --- src/components/Header/Header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index eb24ecc..a5e6817 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -62,7 +62,7 @@ const Header: React.FC = ({ navigate, userImage }) => { { - localStorage.getItem('token') + userImage!== undefined ? : } -- cgit v1.2.3 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 ++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/components/Highlight/Highlight.tsx create mode 100644 src/components/UserStatus/UserStatus.tsx (limited to 'src/components') 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; -- cgit v1.2.3 From 562f675297e03f8abb16af0a5506c51ba91e166a Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Sat, 27 Jun 2020 15:34:32 +0300 Subject: button as a component --- src/components/Highlight/Highlight.tsx | 2 +- src/components/UserStatus/UserStatus.tsx | 29 ----------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 src/components/UserStatus/UserStatus.tsx (limited to 'src/components') diff --git a/src/components/Highlight/Highlight.tsx b/src/components/Highlight/Highlight.tsx index 71764e2..8e11c34 100644 --- a/src/components/Highlight/Highlight.tsx +++ b/src/components/Highlight/Highlight.tsx @@ -13,7 +13,7 @@ const useStyles = makeStyles({ menuButton: { width: 200, height: 50, - textAlign: 'center' + textAlign: 'center', }, menuNumber: { fontWeight: 800, diff --git a/src/components/UserStatus/UserStatus.tsx b/src/components/UserStatus/UserStatus.tsx deleted file mode 100644 index 338b5d1..0000000 --- a/src/components/UserStatus/UserStatus.tsx +++ /dev/null @@ -1,29 +0,0 @@ -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; -- cgit v1.2.3 From e199f28a384dfd6fdf71e6ddaa21799096099cf9 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Sat, 27 Jun 2020 16:49:58 +0300 Subject: add dialog window for uploading avatar --- src/components/UploadImage/UploadImage.tsx | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/components/UploadImage/UploadImage.tsx (limited to 'src/components') diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx new file mode 100644 index 0000000..929151f --- /dev/null +++ b/src/components/UploadImage/UploadImage.tsx @@ -0,0 +1,69 @@ +import React, {useRef} from 'react'; +import Button from '@material-ui/core/Button'; +import TextField from '@material-ui/core/TextField'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogContentText from '@material-ui/core/DialogContentText'; +import DialogTitle from '@material-ui/core/DialogTitle'; +import {patch} from "../../requests"; +import {User} from 'which-types'; + +interface PropTypes { + displayD: boolean; + setDisplayD: (d: boolean) => void; + setUserInfo: (a: User) => void; + setUser: (a: User) => void +} + +const UploadImage: React.FC = ({displayD,setDisplayD,setUserInfo,setUser}) => { + const urlRef = useRef(null); + + const handleClose = () => { + setDisplayD(false); + }; + + const updateAvatar = (event: any) => { + const id = localStorage.getItem('userId'); + const newAvatar = urlRef.current?.value; + console.log(newAvatar); + patch(`/users/${id}`, {avatarUrl: newAvatar}).then(res => { + setUserInfo(res.data); + setUser(res.data); + }); + setDisplayD(false); + }; + + return ( +
+ + Upload an Image + + + Unfortunetly we do not support uploading images yet. Please provide a valid URL to your image. + + + + + + + + +
+ ); +}; + +export default UploadImage; -- cgit v1.2.3 From 490904d9299df636134b82d5507e629f570a1791 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Sat, 27 Jun 2020 17:53:31 +0300 Subject: change avata image right after submit --- src/components/Feed/Feed.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/Feed/Feed.tsx b/src/components/Feed/Feed.tsx index d81da99..06b5087 100644 --- a/src/components/Feed/Feed.tsx +++ b/src/components/Feed/Feed.tsx @@ -18,7 +18,7 @@ const useStyles = makeStyles(theme => ({ const Feed: React.FC = ({ polls, navigate }) => { const classes = useStyles(); - + console.log(polls); return (
{polls.map(poll => )} -- cgit v1.2.3 From 5b08023e0aa0e626264673ebb86dc82299a3b54b Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 27 Jun 2020 19:15:41 +0300 Subject: style: fix ALL linting errors --- src/components/Feed/Feed.tsx | 1 - src/components/Header/Header.tsx | 6 ++--- src/components/Highlight/Highlight.tsx | 39 ------------------------------ src/components/UploadImage/UploadImage.tsx | 25 ++++++++++--------- 4 files changed, 16 insertions(+), 55 deletions(-) delete mode 100644 src/components/Highlight/Highlight.tsx (limited to 'src/components') diff --git a/src/components/Feed/Feed.tsx b/src/components/Feed/Feed.tsx index 06b5087..0c4d84f 100644 --- a/src/components/Feed/Feed.tsx +++ b/src/components/Feed/Feed.tsx @@ -18,7 +18,6 @@ const useStyles = makeStyles(theme => ({ const Feed: React.FC = ({ polls, navigate }) => { const classes = useStyles(); - console.log(polls); return (
{polls.map(poll => )} diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index a5e6817..2e3fc20 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -27,7 +27,7 @@ const useStyles = makeStyles({ logo: { fontWeight: 'bold' }, - avatar:{ + avatar: { width: 24, height: 24 } @@ -62,8 +62,8 @@ const Header: React.FC = ({ navigate, userImage }) => { { - userImage!== undefined - ? + userImage !== undefined + ? : } diff --git a/src/components/Highlight/Highlight.tsx b/src/components/Highlight/Highlight.tsx deleted file mode 100644 index 8e11c34..0000000 --- a/src/components/Highlight/Highlight.tsx +++ /dev/null @@ -1,39 +0,0 @@ -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/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx index 929151f..42ee989 100644 --- a/src/components/UploadImage/UploadImage.tsx +++ b/src/components/UploadImage/UploadImage.tsx @@ -1,4 +1,4 @@ -import React, {useRef} from 'react'; +import React, { useRef } from 'react'; import Button from '@material-ui/core/Button'; import TextField from '@material-ui/core/TextField'; import Dialog from '@material-ui/core/Dialog'; @@ -6,28 +6,29 @@ import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; import DialogContentText from '@material-ui/core/DialogContentText'; import DialogTitle from '@material-ui/core/DialogTitle'; -import {patch} from "../../requests"; -import {User} from 'which-types'; +import { User } from 'which-types'; +import { patch } from '../../requests'; interface PropTypes { - displayD: boolean; - setDisplayD: (d: boolean) => void; - setUserInfo: (a: User) => void; - setUser: (a: User) => void + displayD: boolean; + setDisplayD: (d: boolean) => void; + setUserInfo: (a: User) => void; + setUser: (a: User) => void } -const UploadImage: React.FC = ({displayD,setDisplayD,setUserInfo,setUser}) => { +const UploadImage: React.FC = ({ + displayD, setDisplayD, setUserInfo, setUser +}) => { const urlRef = useRef(null); const handleClose = () => { setDisplayD(false); }; - const updateAvatar = (event: any) => { + const updateAvatar = () => { const id = localStorage.getItem('userId'); const newAvatar = urlRef.current?.value; - console.log(newAvatar); - patch(`/users/${id}`, {avatarUrl: newAvatar}).then(res => { + patch(`/users/${id}`, { avatarUrl: newAvatar }).then(res => { setUserInfo(res.data); setUser(res.data); }); @@ -36,7 +37,7 @@ const UploadImage: React.FC = ({displayD,setDisplayD,setUserInfo,set return (
- + Upload an Image -- cgit v1.2.3