adds deleting
This commit is contained in:
@@ -96,7 +96,10 @@ export function setAuthToken(token: string | null) {
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const headers = new Headers(init?.headers ?? {});
|
||||
headers.set("Content-Type", "application/json");
|
||||
const hasBody = init?.body !== undefined && init.body !== null;
|
||||
if (hasBody && !headers.has("Content-Type")) {
|
||||
headers.set("Content-Type", "application/json");
|
||||
}
|
||||
if (authToken) {
|
||||
headers.set("Authorization", `Bearer ${authToken}`);
|
||||
}
|
||||
@@ -143,6 +146,10 @@ export async function getChat(chatId: string) {
|
||||
return data.chat;
|
||||
}
|
||||
|
||||
export async function deleteChat(chatId: string) {
|
||||
await api<{ deleted: true }>(`/v1/chats/${chatId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export async function listSearches() {
|
||||
const data = await api<{ searches: SearchSummary[] }>("/v1/searches");
|
||||
return data.searches;
|
||||
@@ -161,6 +168,10 @@ export async function getSearch(searchId: string) {
|
||||
return data.search;
|
||||
}
|
||||
|
||||
export async function deleteSearch(searchId: string) {
|
||||
await api<{ deleted: true }>(`/v1/searches/${searchId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export async function runSearch(
|
||||
searchId: string,
|
||||
body: {
|
||||
|
||||
Reference in New Issue
Block a user