fix delete route
This commit is contained in:
parent
7926efa222
commit
2975e6088d
2 changed files with 6 additions and 10 deletions
|
@ -19,9 +19,9 @@ const formatSize = (bytes: number) => {
|
|||
export default component$(({ file }: FileProps) => {
|
||||
const files = useNanostore$<StereoFile[]>(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) => {
|
|||
|
||||
<button
|
||||
class="bg-red-600/50 backdrop-blur-lg hover:bg-red-600/75 transition-all duration-200 text-white p-2 rounded-lg active:scale-95"
|
||||
onClick$={async () => await deleteFile(file.Owner, file.Name)}
|
||||
onClick$={async () => await deleteFile(file.ID)}
|
||||
>
|
||||
<SolarTrashBin2Bold class="w-6 h-6"/>
|
||||
</button>
|
||||
|
|
|
@ -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<Blob>(uid),
|
||||
list: async () => {
|
||||
return await client.get('list').json<StereoFile[]>();
|
||||
},
|
||||
list: async () => await client.get('list').json<StereoFile[]>(),
|
||||
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(),
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue