generated from TetiZ/vite-react-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from AnWhiteM/redux-registr-login
commit
- Loading branch information
Showing
4 changed files
with
105 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
import svg from "../../img/icons.svg"; | ||
import css from "./Logout.module.css"; | ||
import toast from "react-hot-toast"; | ||
// import { useDispatch } from "react-redux"; | ||
|
||
// import { logOut } from "../../redux/auth/operations"; | ||
import { useDispatch } from "react-redux"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { logOut } from "../../redux/auth/operations"; | ||
|
||
export default function Logout() { | ||
// const dispatch = useDispatch(); | ||
const dispatch = useDispatch(); | ||
const navigate = useNavigate(); | ||
|
||
const handleLogout = async () => { | ||
try { | ||
await dispatch(logOut()).unwrap(); | ||
toast.success("Ти вийшов)"); | ||
navigate("/auth/login"); | ||
} catch (error) { | ||
toast.error("Помилка при виході"); | ||
} | ||
}; | ||
|
||
const Notify = () => toast.success("Ти вийшов)"); | ||
return ( | ||
<div className={css.container}> | ||
<svg onClick={Notify} className={css.icon} width="32px" height="32px"> | ||
<use className={css.icon} href={svg + "#icon-login"}></use> | ||
<div onClick={handleLogout} className={css.container}> | ||
<svg className={css.icon} width="32px" height="32px"> | ||
<use className={css.icon} href={`${svg}#icon-login`}></use> | ||
</svg> | ||
<p> Log out </p> | ||
</div> | ||
); | ||
} | ||
// onClick={() => dispatch(logOut())} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters