diff --git a/frontend/src/app/actions.tsx b/frontend/src/app/actions.tsx index 79d0802..709e6f1 100644 --- a/frontend/src/app/actions.tsx +++ b/frontend/src/app/actions.tsx @@ -11,14 +11,34 @@ export async function createAlbum(formData: FormData) { title: title, artist: artist, genre: genre, - }), + }) + }); +} + +export async function updateAlbum(formData: FormData) { + const id = formData.get('id'); + const title = formData.get('title'); + const artist = formData.get('artist'); + const genre = formData.get('genre'); + return await fetch("https://api.anatid.net/album", { + method: "PUT", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + id: id, + title: title, + artist: artist, + genre: genre, + }) + }); +} + +export async function deleteAlbum(formData: FormData) { + const id = formData.get('id'); + return await fetch("https://api.anatid.net/album", { + method: "DELETE", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + id: id, + }) }); } -// -// export async function updateAlbum(formData: FormData) { -// -// } -// -// export async function deleteAlbum(formData: FormData) { -// -// } diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index d3fbbe3..960bc5e 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -21,13 +21,13 @@ export default function Page() { setAlbums(data); } fetchAlbums(); - }, []); + }); const handleSubmit = async (event: FormEvent) => { event.preventDefault(); const formData = new FormData(event.currentTarget); - const response = await createAlbum(formData) + const response = await createAlbum(formData); const data = response.json(); handleClose(); return data;