fix: logout from modal
This commit is contained in:
@@ -6,8 +6,6 @@ import StyledModal from "../../common/component/styled/Modal";
|
|||||||
import Button from "../../common/component/styled/Button";
|
import Button from "../../common/component/styled/Button";
|
||||||
import Checkbox from "../../common/component/styled/Checkbox";
|
import Checkbox from "../../common/component/styled/Checkbox";
|
||||||
import useLogout from "../../common/hook/useLogout";
|
import useLogout from "../../common/hook/useLogout";
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import { useAppSelector } from "../../app/store";
|
|
||||||
|
|
||||||
const StyledConfirm = styled(StyledModal)`
|
const StyledConfirm = styled(StyledModal)`
|
||||||
.clear {
|
.clear {
|
||||||
@@ -34,8 +32,6 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const LogoutConfirmModal: FC<Props> = ({ closeModal }) => {
|
const LogoutConfirmModal: FC<Props> = ({ closeModal }) => {
|
||||||
const token = useAppSelector((store) => store.authData.token);
|
|
||||||
const navigateTo = useNavigate();
|
|
||||||
const [clearLocal, setClearLocal] = useState(false);
|
const [clearLocal, setClearLocal] = useState(false);
|
||||||
const { logout, exited, exiting, clearLocalData } = useLogout();
|
const { logout, exited, exiting, clearLocalData } = useLogout();
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
@@ -54,11 +50,6 @@ const LogoutConfirmModal: FC<Props> = ({ closeModal }) => {
|
|||||||
toast.success("Logout Successfully");
|
toast.success("Logout Successfully");
|
||||||
}
|
}
|
||||||
}, [exited, clearLocal]);
|
}, [exited, clearLocal]);
|
||||||
useEffect(() => {
|
|
||||||
if (!token) {
|
|
||||||
navigateTo("/login");
|
|
||||||
}
|
|
||||||
}, [token]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal id="modal-modal">
|
<Modal id="modal-modal">
|
||||||
|
|||||||
Reference in New Issue
Block a user