diff --git a/src/components/App/App.jsx b/src/components/App/App.jsx index b6eaece..9a213b4 100644 --- a/src/components/App/App.jsx +++ b/src/components/App/App.jsx @@ -2,11 +2,9 @@ import { lazy, Suspense, useEffect } from "react"; import { Route, Routes } from "react-router-dom"; import { Toaster } from "react-hot-toast"; import { useDispatch, useSelector } from "react-redux"; -import { refreshUser, getUserInfo } from "../../redux/auth/operations"; -import { - selectIsRefreshing, - selectIsLoggedIn, -} from "../../redux/auth/selectors"; +import { refreshUser } from "../../redux/auth/operations"; +import { selectIsRefreshing } from "../../redux/auth/selectror"; + import RestrictedRoute from "../RestrictedRoute/RestrictedRoute"; import PrivateRoute from "../PrivateRoute/PrivateRoute"; @@ -19,18 +17,18 @@ const NotFoundPage = lazy(() => import("../../pages/NotFoundPage")); export const App = () => { const isRefreshing = useSelector(selectIsRefreshing); - const isLoggedIn = useSelector(selectIsLoggedIn); + // const isLoggedIn = useSelector(selectIsLoggedIn); const dispatch = useDispatch(); useEffect(() => { dispatch(refreshUser()); }, [dispatch]); - useEffect(() => { - if (isLoggedIn) { - dispatch(getUserInfo()); - } - }, [dispatch, isLoggedIn]); + // useEffect(() => { + // if (isLoggedIn) { + // dispatch(getUserInfo()); + // } + // }, [dispatch, isLoggedIn]); return ( <> {isRefreshing ? ( diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index d08d478..f76ddf5 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -62,7 +62,12 @@ export default function Header({ openSideBar, sideBarOpen }) {

{user.name}

{isModalOpen && } diff --git a/src/components/UserEditModal/UserEditModal.jsx b/src/components/UserEditModal/UserEditModal.jsx index 5a9f6c4..126e5e4 100644 --- a/src/components/UserEditModal/UserEditModal.jsx +++ b/src/components/UserEditModal/UserEditModal.jsx @@ -28,10 +28,20 @@ export default function UserEditModal({ onClose }) { const fileInputRef = useRef(null); - const handleSubmit = (values, actions) => { - // отправляем операцию aпдейтюзера и передаем ей обьект с данными имя мыло пароль - dispatch(updateUserInfo(values)); - actions.resetForm(); + const handleSubmit = async (values) => { + console.log(values); + try { + const sendInfo = { + avatarURL: values.avatarURL, + name: values.name, + email: values.email, + password: values.password, + }; + await dispatch(updateUserInfo(sendInfo)).unwrap(); + // отправляем операцию aпдейтюзера и передаем ей обьект с данными имя мыло пароль + } catch (error) { + console.log(error); + } }; const handleMenuClick = (ev) => { @@ -66,7 +76,12 @@ export default function UserEditModal({ onClose }) {

Edit Profile

- +