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/pages/ProfilePage/ProfileInfo.tsx | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'src/pages/ProfilePage/ProfileInfo.tsx') diff --git a/src/pages/ProfilePage/ProfileInfo.tsx b/src/pages/ProfilePage/ProfileInfo.tsx index b68075f..6578764 100644 --- a/src/pages/ProfilePage/ProfileInfo.tsx +++ b/src/pages/ProfilePage/ProfileInfo.tsx @@ -6,6 +6,7 @@ import CameraAltIcon from '@material-ui/icons/CameraAlt'; import MoreMenu from "./MoreMenu"; import {patch} from '../../requests'; import Highlight from "../../components/Highlight/Highlight"; +import UploadImage from "../../components/UploadImage/UploadImage"; interface PropTypes { @@ -13,6 +14,8 @@ interface PropTypes { logOut: () => void; savedPolls: number; totalVotes: number; + setUserInfo: (a: User) => void; + setUser: (a:User) => void; } const useStyles = makeStyles({ @@ -67,22 +70,14 @@ const StyledBadge = withStyles((theme) => ({ }, }))(Badge); -const ProfileInfo: React.FC = ({user, logOut,savedPolls, totalVotes}) => { +const ProfileInfo: React.FC = ({user, logOut,savedPolls, totalVotes, setUserInfo,setUser}) => { const classes = useStyles(); - const [input,setInput] = useState('hide'); - const urlRef = useRef(); + const [input,setInput] = useState(false); const handleClick = () => { - input === 'hide' ? setInput('show') : setInput('hide'); + input === false ? setInput(true) : setInput(false); }; - const updateAvatar = (event: any) => { - const id = localStorage.getItem('userId'); - const newAvatar = urlRef.current?.value; - patch(`/users/${id}`, {avatarUrl: newAvatar}).then(res => { - console.log(res); - }) - }; return (
@@ -109,20 +104,7 @@ const ProfileInfo: React.FC = ({user, logOut,savedPolls, totalVotes})
- { - input === 'show' - ?
- - - - : null - } + : } -- cgit v1.2.3