Made logout hook
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user