Feature/fixe bugs

This commit is contained in:
2024-12-01 13:08:16 +00:00
committed by AmirHossein Mahmoodi
parent 5bc366a30e
commit c40fccac6b
18 changed files with 767 additions and 74 deletions

View File

@@ -1,5 +1,4 @@
"use client";
import { Box, Divider, IconButton, Tooltip } from "@mui/material";
import PowerSettingsNewIcon from "@mui/icons-material/PowerSettingsNew";
import ModeEditIcon from "@mui/icons-material/ModeEdit";
@@ -8,9 +7,12 @@ import { useState } from "react";
import Update from "@/core/components/Profile/Update";
import ChangePass from "@/core/components/Profile/ChangePass";
import { useAuth } from "@/lib/contexts/auth";
import useRequest from "@/lib/hooks/useRequest";
import { LOGOUT_USER_ROUTE } from "@/core/utils/routes";
const ProfileActions = () => {
const { getUser } = useAuth();
const { getUser, logout } = useAuth();
const requestServer = useRequest();
const [openUpdate, setOpenUpdate] = useState(false);
const [openChangePass, setOpenChangePass] = useState(false);
@@ -18,6 +20,11 @@ const ProfileActions = () => {
getUser();
setOpenUpdate(true);
};
const handleLogout = () => {
requestServer(LOGOUT_USER_ROUTE, "post").then(() => {
logout();
});
};
return (
<>
@@ -29,7 +36,7 @@ const ProfileActions = () => {
</Tooltip>
<Divider orientation="vertical" variant="middle" flexItem sx={{ mx: 1 }} />
<Tooltip title="خروج" arrow>
<IconButton aria-label="خروج" color="error">
<IconButton onClick={handleLogout} aria-label="خروج" color="error">
<PowerSettingsNewIcon />
</IconButton>
</Tooltip>