import { useQuery, useMutation } from '@tanstack/react-query'; import type { Sticky, ClusterResponse } from '../types/types'; const API_BASE = `${import.meta.env.VITE_API_BASE}/v1/notes`; const fetchStickies = async (): Promise => { const response = await fetch(API_BASE); if (!response.ok) { throw new Error('Failed to fetch stickies'); } return response.json(); }; const fetchClusters = async (): Promise => { const response = await fetch(`${API_BASE}/cluster`, { method: 'POST', }); if (!response.ok) { throw new Error('Failed to cluster stickies'); } return response.json(); }; export const useGetStickies = () => { return useQuery({ queryKey: ['stickies'], queryFn: fetchStickies, }); }; export const useClusterStickies = () => { return useMutation({ mutationFn: fetchClusters, }); };