import { request } from "./core";

export interface SavedSearch {
  id: number;
  name: string;
  query: Record<string, string>;
  created_at: string;
}

export async function listSavedSearches(): Promise<SavedSearch[]> {
  return request<SavedSearch[]>("/api/searches/saved");
}

export async function createSavedSearch(
  name: string,
  query: Record<string, string>
): Promise<SavedSearch> {
  return request<SavedSearch>("/api/searches/saved", {
    method: "POST",
    body: JSON.stringify({ name, query }),
  });
}

export async function deleteSavedSearch(id: number): Promise<void> {
  await request<Record<string, never>>(`/api/searches/saved/${id}`, {
    method: "DELETE",
  });
}
