Skip to content

Commit

Permalink
Merge pull request #139 from ViktorSvertoka/profile-setting-avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka authored Sep 30, 2023
2 parents 759ea66 + c0f4b63 commit cbf955a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/components/UserForm/UserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from './UserForm.styled';

import { selectUser } from '../../redux/auth/selectors';
import { updateUserParams } from '../../redux/auth/operations';
import { getUserParams, updateUserParams } from '../../redux/auth/operations';

const UserForm = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -96,7 +96,7 @@ const UserForm = () => {
...values,
};
dispatch(updateUserParams(sendData));
console.log(sendData);
dispatch(getUserParams());
};

return (
Expand Down
11 changes: 3 additions & 8 deletions src/components/UserMenu/UserMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,19 @@ import {
UserData,
} from './UserMenu.styled';
import { useDispatch, useSelector } from 'react-redux';
import { getUserParams, logOut } from '../../redux/auth/operations';
import { logOut } from '../../redux/auth/operations';
import { useState } from 'react';
import { Photo } from '../UserProfile/UserProfile.styled';
import { selectUser } from '../../redux/auth/selectors';
import { useEffect } from 'react';

export const UserMenu = () => {
const dispatch = useDispatch();
const [isActivePage, setIsActivePage] = useState('diary');

const user = useSelector(selectUser);

useEffect(() => {
dispatch(getUserParams());
}, [dispatch]);

const avatarUser = (
<Photo src={user.avatarUrl} width={46} height={46} alt="Avatar" />
<Photo src={user.avatarURL} width={46} height={46} alt="Avatar" />
);
const avatarLogo = (
<SvgLogoUserHeader fill="var(--normal-color)">
Expand Down Expand Up @@ -84,7 +79,7 @@ export const UserMenu = () => {
<use href={`${sprite}#icon-settings`}></use>
</ProfileIcon>
</NavLink>
<AvatarHeader>{user.avatarUrl ? avatarUser : avatarLogo}</AvatarHeader>
<AvatarHeader>{user.avatarURL ? avatarUser : avatarLogo}</AvatarHeader>

<LogoutBtn type="button" onClick={handleLogOut}>
<span>Logout</span>
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserProfile/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { updateAvatar } from '../../redux/auth/operations';
const UserProfile = () => {
const dispatch = useDispatch();
const user = useSelector(selectUser);
const [avatar, setAvatar] = useState('');
const [avatar, setAvatar] = useState(user.avatarURL);

const avatarUser = <Photo src={avatar} width="100%" alt="Avatar" />;
const avatarLogo = (
Expand Down

0 comments on commit cbf955a

Please sign in to comment.