import { useMutation, useQuery } from "@tanstack/react-query"; import { CAM_BASE } from "../utils/config"; const fetchHotlists = async () => { const response = await fetch(`${CAM_BASE}/Hotlist-csv-metadata`); if (!response.ok) throw new Error("Cannot reach hotlist endpoint"); return response.json(); }; const deleteHotlist = async (filename: string) => { const response = await fetch(`${CAM_BASE}/Hotlist-csv-delete?filename=${filename}`); if (!response.ok) throw new Error(`Cannot delte hotlist: ${filename}`); return response.json(); }; export const useHotlistData = () => { const query = useQuery({ queryKey: ["fetchHotlists"], queryFn: fetchHotlists, }); const mutation = useMutation({ mutationKey: ["deleteHotlist"], mutationFn: (filename: string) => deleteHotlist(filename), }); return { query, mutation }; };