Added toast and add logout

This commit is contained in:
Manik Maity
2024-11-08 19:24:23 +05:30
parent 700b0136fc
commit 9f689beb9d
6 changed files with 64 additions and 1 deletions

View File

@@ -1,13 +1,27 @@
import React from 'react'
import { Link } from 'react-router-dom'
import useUserStore from '../../store/useStore';
import { useMutation } from 'react-query';
import logoutService from '../../services/logoutService';
import { toast } from 'react-toastify';
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 = () => {
setUser({});
mutation.mutate();
}