From 9534bab6ce133cb72079888cc049506841c633b2 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 7 Jan 2024 11:38:25 -0600 Subject: [PATCH] Just U is left... --- islands/Admin.tsx | 33 ++++++++++++++++++++++++++++++++- routes/api/user.ts | 8 +++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/islands/Admin.tsx b/islands/Admin.tsx index 078cb2d..f4f5aa5 100644 --- a/islands/Admin.tsx +++ b/islands/Admin.tsx @@ -9,6 +9,13 @@ export interface Props { todos: Todo[] } +async function promptDeleteUser(id: string, name: string) { + if (confirm(`Are you sure you want to delete ${name} (${id})?`)) { + await fetch(`/api/user?id=${id}`, { method: 'DELETE' }) + location.reload() + } +} + export function Admin({ users, todos }: Props) { const addUserDialog = createRef() const usersById: Record = {} @@ -35,6 +42,7 @@ export function Admin({ users, todos }: Props) { action='/api/user' method='post' encType='multipart/form-data' + onSubmit={() => console.log('Submitting...')} >