A social knowledge tool for researchers built on ATProto
at development 26 lines 813 B view raw
1import { ApiClient } from '@/api-client/ApiClient'; 2import { createClientTokenManager } from '@/services/auth'; 3import { useMutation, useQueryClient } from '@tanstack/react-query'; 4 5export default function useRemoveCardFromLibrary() { 6 const apiClient = new ApiClient( 7 process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3000', 8 createClientTokenManager(), 9 ); 10 11 const queryClient = useQueryClient(); 12 13 const mutation = useMutation({ 14 mutationFn: (cardId: string) => { 15 return apiClient.removeCardFromLibrary({ cardId }); 16 }, 17 18 onSuccess: () => { 19 queryClient.invalidateQueries({ queryKey: ['my cards'] }); 20 queryClient.invalidateQueries({ queryKey: ['collections'] }); 21 queryClient.invalidateQueries({ queryKey: ['collection'] }); 22 }, 23 }); 24 25 return mutation; 26}