Made logout hook

This commit is contained in:
Manik Maity
2024-11-08 22:26:36 +05:30
parent b84a031770
commit bd1d3e988d
3 changed files with 40 additions and 21 deletions

View File

@@ -4,26 +4,11 @@ import useUserStore from '../../store/useStore';
import { useMutation } from 'react-query';
import logoutService from '../../services/logoutService';
import { toast } from 'react-toastify';
import useLogout from '../../hooks/useLogout';
function ProfileImage({userData}) {
const {setUser} = useUserStore();
const mutation = useMutation(logoutService, {
onSuccess: (data) => {
setUser({});
toast.success(data?.message);
},
onError: (error) => {
toast.error("Something went wrong");
console.log(error);
},
});
const handleLogout = () => {
mutation.mutate();
}
const {handleLogout} = useLogout();
return (
<div className="flex-none">