- added hotlists being displayed

- functionality to delete hotlist
This commit is contained in:
2025-11-19 13:55:21 +00:00
parent ea93053dd3
commit 0b3dcbb265
7 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
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 };
};