|
@@ -6,7 +6,7 @@ import { muteUser } from '../service/muteUser';
|
|
|
import './userInfo.scss';
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
import { getUserAvatar } from '../../../reducers/userDataReducer';
|
|
|
-import { useEffect } from 'react';
|
|
|
+import { useEffect, useState } from 'react';
|
|
|
import { store } from '../../../store';
|
|
|
|
|
|
|
|
@@ -21,50 +21,50 @@ export const UserInfo = () => {
|
|
|
cursor: 'pointer'
|
|
|
};
|
|
|
|
|
|
+
|
|
|
const MOBILE_AVATAR_STYLE = { margin: '5px auto'};
|
|
|
+
|
|
|
+ const [displayType, setDisplayType] = useState('none');
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
-
|
|
|
- //add foto loading function
|
|
|
- const avatarImg = useSelector(state => state.getUserSocketReducer.avatar)
|
|
|
-
|
|
|
- let displayType = 'block';
|
|
|
-
|
|
|
|
|
|
const loadAvatarHandler = () => {
|
|
|
-
|
|
|
-
|
|
|
+ setDisplayType('block')
|
|
|
+ setTimeout(() => {
|
|
|
+ setDisplayType('none')
|
|
|
+ }, 4000)
|
|
|
}
|
|
|
+ const SERVER_URL = process.env.REACT_APP_SERVER_URL|| 'http://localhost:5000/';
|
|
|
|
|
|
const allUsers = useSelector(state => state.getUserSocketReducer.allUsers)
|
|
|
const user = useSelector(state => state.getUserSocketReducer.socketUserData)
|
|
|
const usersOnline = [...new Set(useSelector(state => state.getUserSocketReducer.usersOnline))];//Set?
|
|
|
const socket = useSelector(state => state.getUserSocketReducer.socket)
|
|
|
-
|
|
|
-
|
|
|
const isTabletorMobile = (window.screen.width < 730);
|
|
|
-
|
|
|
+ let userAvatarUrl = SERVER_URL + user.avatar;
|
|
|
const inputHandler = (e) => {
|
|
|
const file = e.target.files[0]
|
|
|
dispatch(getUserAvatar(file))
|
|
|
- console.log(avatarImg)
|
|
|
+ setDisplayType('none')
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
return (
|
|
|
<>
|
|
|
- <Input
|
|
|
- type="file"
|
|
|
- accept="image/png, image/jpeg"
|
|
|
- name='file'
|
|
|
- style = {{display: displayType}}
|
|
|
- onChange = {e => inputHandler(e)}
|
|
|
- />
|
|
|
<Avatar
|
|
|
- sx={ isTabletorMobile ? MOBILE_AVATAR_STYLE : PC_AVATAR_STYLE}
|
|
|
+ sx={isTabletorMobile ? MOBILE_AVATAR_STYLE : PC_AVATAR_STYLE} //add deleting function after update avatar
|
|
|
onClick={() => loadAvatarHandler()}
|
|
|
- src="/static/images/avatar/2.jpg" />
|
|
|
-
|
|
|
+ src={userAvatarUrl} >
|
|
|
+ </Avatar>
|
|
|
+ <input
|
|
|
+ type="file"
|
|
|
+ accept="image/png, image/jpeg"
|
|
|
+ name='file'
|
|
|
+ style = {{
|
|
|
+ display: displayType
|
|
|
+ }}
|
|
|
+ onChange = {e => inputHandler(e)}
|
|
|
+ />
|
|
|
{user.isAdmin ?
|
|
|
allUsers.map((item) =>
|
|
|
<div
|