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 useUpdateNote() { 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: (note: { cardId: string; note: string }) => { 15 return apiClient.updateNoteCard(note); 16 }, 17 18 onSuccess: (data) => { 19 queryClient.invalidateQueries({ queryKey: ['card', data.cardId] }); 20 queryClient.invalidateQueries({ queryKey: ['collection'] }); 21 queryClient.invalidateQueries({ queryKey: ['collections'] }); 22 }, 23 }); 24 25 return mutation; 26}