task(E6-frontend): guest panel with ribbon entry and api client
This commit is contained in:
@@ -764,3 +764,51 @@ export async function aiChat(
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// ─── Guests (Task E6) ──────────────────────────────────
|
||||
export interface Guest {
|
||||
id: string;
|
||||
drawing_id: string;
|
||||
name: string;
|
||||
email?: string | null;
|
||||
category: string;
|
||||
seat_element_id?: string | null;
|
||||
notes?: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export async function listGuests(token: string, drawingId: string): Promise<Guest[]> {
|
||||
const res = await fetch(`${API_BASE}/api/drawings/${drawingId}/guests`, {
|
||||
headers: authHeaders(token),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to list guests: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function createGuest(token: string, drawingId: string, data: { name: string; email?: string; category?: string; notes?: string }): Promise<Guest> {
|
||||
const res = await fetch(`${API_BASE}/api/drawings/${drawingId}/guests`, {
|
||||
method: 'POST',
|
||||
headers: authHeaders(token),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to create guest: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function updateGuest(token: string, id: string, data: Partial<{ name: string; email: string; category: string; seat_element_id: string; notes: string }>): Promise<Guest> {
|
||||
const res = await fetch(`${API_BASE}/api/guests/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: authHeaders(token),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to update guest: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function deleteGuest(token: string, id: string): Promise<void> {
|
||||
const res = await fetch(`${API_BASE}/api/guests/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: authHeaders(token),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to delete guest: ${res.status}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user