A social knowledge tool for researchers built on ATProto
1import { ApiClient } from '@/api-client/ApiClient';
2import { createClientTokenManager } from '@/services/auth';
3import { useMutation, useQueryClient } from '@tanstack/react-query';
4
5export default function useDeleteCollection() {
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: (collectionId: string) => {
15 return apiClient.deleteCollection({ collectionId });
16 },
17
18 onSuccess: (data) => {
19 queryClient.invalidateQueries({ queryKey: ['collections'] });
20 queryClient.invalidateQueries({
21 queryKey: ['collection', data.collectionId],
22 });
23 },
24 });
25
26 return mutation;
27}