Skip to content

Commit

Permalink
mutate user data
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvyshnevska committed Oct 9, 2024
1 parent 1c982df commit 395ce75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
3 changes: 2 additions & 1 deletion FrontEnd/src/pages/AdminPage/AdminProfile/AdminInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AdminSubmitButton from '../../../components/MiniComponents/AdminSubmitBut

import classes from './AdminInfo.module.css';

const AdminInfo = ({ user }) => {
const AdminInfo = ({ user, mutate }) => {
const {
register,
handleSubmit,
Expand All @@ -24,6 +24,7 @@ const AdminInfo = ({ user }) => {
axios.patch(`${process.env.REACT_APP_BASE_API_URL}/api/auth/users/me/`, data)
.then(() => {
toast.success('Зміни успішно збережено');
mutate();
})
.catch((error) => {
console.error(
Expand Down
28 changes: 16 additions & 12 deletions FrontEnd/src/pages/AdminPage/AdminProfile/AdminProfilePage.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import { NavLink, Route, Routes } from 'react-router-dom';

import { useAuth } from '../../../hooks';

import BreadCrumbs from '../../../components/BreadCrumbs/BreadCrumbs';
import ChangeAdminPassword from './ChangeAdminPassword';
import AdminInfo from './AdminInfo';

import classes from './AdminProfilePage.module.css';

const AdminProfilePage = ({ user }) => {
const ADMIN_PAGE_TABS = [
{
title: 'Загальна інформація',
link: '/admin-info',
},
{
title: 'Змінити пароль',
link: '/change-password',
},
];

const AdminProfilePage = () => {

const ADMIN_PAGE_TABS = [
{
title: 'Загальна інформація',
link: '/admin-info',
},
{
title: 'Змінити пароль',
link: '/change-password',
},
];
const { user, mutate } = useAuth();

return (
<div className={classes['admin-profile__container']}>
Expand All @@ -37,7 +41,7 @@ const AdminProfilePage = ({ user }) => {
<Routes>
<Route
path="admin-info"
element={<AdminInfo user={user}/>} />
element={<AdminInfo user={user} mutate={mutate} />} />
<Route
path="change-password"
element={<ChangeAdminPassword user={user}/>} />
Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/src/routes/AdminRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function AdminRouter() {
<Route path="/automoderation" element={<AutoApproveDelay />} />
<Route path="/email" element={<ModerationEmail />} />
<Route path="/contacts" element={<Contacts />} />
<Route path="/admin-profile/*" element={<AdminProfilePage user={user}/>} />
<Route path="/admin-profile/*" element={<AdminProfilePage />} />
</>
) : (
<Route path="/customadmin/" />
Expand Down

0 comments on commit 395ce75

Please sign in to comment.