import { useMutation, useQueryClient } from '@tanstack/react-query';

import { AuthService } from '@/client/services/AuthService';

export function useLogout() {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: () => AuthService.authLogout(),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ['auth', 'me'] });
      queryClient.clear();
    },
  });
}
