From 2975e6088d82c51ec855d42f54546070e753f58b Mon Sep 17 00:00:00 2001 From: grngxd <36968271+grngxd@users.noreply.github.com> Date: Sun, 15 Jun 2025 10:13:30 +0100 Subject: [PATCH] fix delete route --- src/components/dashboard/File.tsx | 6 +++--- src/lib/api.ts | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/dashboard/File.tsx b/src/components/dashboard/File.tsx index 2884cf1..50c1e02 100644 --- a/src/components/dashboard/File.tsx +++ b/src/components/dashboard/File.tsx @@ -19,9 +19,9 @@ const formatSize = (bytes: number) => { export default component$(({ file }: FileProps) => { const files = useNanostore$(dashboardFiles); - const deleteFile = $(async (uid: string, name: string) => { + const deleteFile = $(async (id: string) => { if (!confirm("Are you sure you want to delete this file?")) return; - console.log(await api.delete(uid, name)); + await api.delete(id); files.value = await api.list(); }); @@ -93,7 +93,7 @@ export default component$(({ file }: FileProps) => { diff --git a/src/lib/api.ts b/src/lib/api.ts index b01a837..c75a9b8 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -5,18 +5,14 @@ export const client = ky.create({ prefixUrl: '/api', credentials: 'include' }); -// TODO: make wrapper for apiclient fr + export const api = { file: async (uid: string) => await client.get(uid), - list: async () => { - return await client.get('list').json(); - }, + list: async () => await client.get('list').json(), upload: async (file: File) => { const formData = new FormData(); formData.append('file', file); return await client.post('upload', { body: formData }); }, - delete: async (uid: string, file: string) => { - return await client.delete(uid).json(); - }, + delete: async (uid: string) => await client.delete(uid).json(), } \ No newline at end of file