Portal/rsconcept/frontend/src/features/auth/backend/useLogout.tsx

16 lines
429 B
TypeScript
Raw Normal View History

2025-01-21 20:33:05 +03:00
import { useMutation, useQueryClient } from '@tanstack/react-query';
2025-02-19 19:15:57 +03:00
import { KEYS } from '@/backend/configuration';
2025-01-21 20:33:05 +03:00
import { authApi } from './api';
export const useLogout = () => {
2025-01-23 19:41:31 +03:00
const client = useQueryClient();
2025-01-21 20:33:05 +03:00
const mutation = useMutation({
2025-02-19 19:15:57 +03:00
mutationKey: [KEYS.auth, 'logout'],
2025-01-21 20:33:05 +03:00
mutationFn: authApi.logout,
onSuccess: () => client.resetQueries()
2025-01-21 20:33:05 +03:00
});
2025-02-11 20:15:34 +03:00
return { logout: () => mutation.mutateAsync() };
2025-01-21 20:33:05 +03:00
};