From 634db87b8cacc385452bb78fe5a61c1f9e01c12c Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Mon, 7 Apr 2025 14:43:24 +0100 Subject: [PATCH] Removing unnecessary checks --- frontend/src/app/album/[id]/page.tsx | 17 ++++++++--------- frontend/src/app/album/page.tsx | 27 +++++++++++++-------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/frontend/src/app/album/[id]/page.tsx b/frontend/src/app/album/[id]/page.tsx index f77f583..68e7c36 100644 --- a/frontend/src/app/album/[id]/page.tsx +++ b/frontend/src/app/album/[id]/page.tsx @@ -51,13 +51,13 @@ export default function Page() { const formData = new FormData(event.currentTarget); try { if (formData.get('id') == "") { - await createSong(formData).then(response => { - handleSnackbar(`Successfully created Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); + await createSong(formData).then(() => { + handleSnackbar(`Successfully created Song with ID ${formData.get("id")}`, true); }) .catch(error => {handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } else { - await updateSong(formData).then(response => { - handleSnackbar(`Successfully created Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); + await updateSong(formData).then(() => { + handleSnackbar(`Successfully created Song with ID ${formData.get("id")}`, true); }) .catch(error => {handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } @@ -105,11 +105,10 @@ export default function Page() { const handleDelete = async (event: MouseEvent) => { const songId = event.currentTarget.getAttribute('song-id'); if (songId) { - try { - await deleteSong(parseInt(songId)); - } catch (error) { - handleSnackbar(`Error deleting song with ID ${songId}: ${JSON.stringify(error)}`, false); - } + await deleteSong(parseInt(songId)).then(() => { + handleSnackbar(`Successfully deleted Song with ID ${songId}`, true); + }) + .catch(error => {handleSnackbar(`Error deleting song with ID ${songId}: ${JSON.stringify(error)}`, false);}); revalidateAlbum(); const data = await getAlbum(parseInt(albumId)); setAlbum(data); diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index 60ae4b5..50eefc8 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -47,16 +47,16 @@ export default function Page() { try { if (formData.get('id') == "") { await createAlbum(formData) - .then(response => { - handleSnackbar(`Successfully created Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); - }) - .catch(error => {handleSnackbar(`Failed to create Album with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); + .then(() => { + handleSnackbar(`Successfully created Album with ID ${formData.get("id")}`, true); + }) + .catch(error => {handleSnackbar(`Failed to create Album with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } else { await updateAlbum(formData) - .then(response => { - handleSnackbar(`Successfully updated Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); - }) - .catch(error => {handleSnackbar(`Failed to update Album with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); + .then(() => { + handleSnackbar(`Successfully updated Album with ID ${formData.get("id")}`, true); + }) + .catch(error => {handleSnackbar(`Failed to update Album with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } revalidateAlbums(); const data = await getAlbums(); @@ -100,12 +100,11 @@ export default function Page() { const handleDelete = async (event: MouseEvent) => { const id = event.currentTarget.getAttribute('album-id'); if (id) { - try { - await deleteAlbum(parseInt(id)); - handleSnackbar(`Successfully deleted Album with ID ${id}`, true); - } catch (error) { - handleSnackbar(`Error deleting Album with ID ${id}: ${JSON.stringify(error)}`, false); - } + await deleteAlbum(parseInt(id)) + .then(() => { + handleSnackbar(`Successfully updated Deleted with ID ${id}`, true); + }) + .catch(error => {handleSnackbar(`Failed to Delete Album with ID ${id}: ${JSON.stringify(error)}`, false);}); revalidateAlbums(); const data = await getAlbums(); setAlbums(data);