From 3fb2053146fc57c735307b16ec87f0c703dd196c Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Mon, 7 Apr 2025 14:05:29 +0100 Subject: [PATCH] Fixing if/elses --- frontend/src/app/album/[id]/page.tsx | 6 ++++-- frontend/src/app/album/page.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/album/[id]/page.tsx b/frontend/src/app/album/[id]/page.tsx index 20ce14a..8406365 100644 --- a/frontend/src/app/album/[id]/page.tsx +++ b/frontend/src/app/album/[id]/page.tsx @@ -54,16 +54,18 @@ export default function Page() { await createSong(formData).then(response => { if (response.ok) { handleSnackbar(`Successfully created Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); + } else + handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); } - handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); }) .catch(error => {handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } else { await updateSong(formData).then(response => { if (response.ok) { handleSnackbar(`Successfully created Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); + } else { + handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); } - handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); }) .catch(error => {handleSnackbar(`Failed to create Song with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index 1a20e4b..3e6477f 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -50,8 +50,9 @@ export default function Page() { .then(response => { if (response.ok) { handleSnackbar(`Successfully created Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); + } else { + handleSnackbar(`Failed to create Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); } - handleSnackbar(`Failed to create Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); }) .catch(error => {handleSnackbar(`Failed to create Album with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); } else { @@ -59,8 +60,9 @@ export default function Page() { .then(response => { if (response.ok) { handleSnackbar(`Successfully updated Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, true); + } else { + handleSnackbar(`Failed to update Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); } - handleSnackbar(`Failed to update Album with ID ${formData.get("id")}: ${JSON.stringify(response)}`, false); }) .catch(error => {handleSnackbar(`Failed to update Album with ID ${formData.get("id")}: ${JSON.stringify(error)}`, false);}); }