From 22c6bea33324c8d5943f75b9dc96d46834aabfe1 Mon Sep 17 00:00:00 2001 From: Phill Pover Date: Mon, 7 Apr 2025 13:56:12 +0100 Subject: [PATCH] Changing to Number casts --- README.md | 4 ++++ frontend/src/app/actions.tsx | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ddc92dc..6e6ece1 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,13 @@ Music Collection is a demo app with a frontend written in NextJS, and the backen ## Frontend The frontend app can be accessed at [https://music.anatid.net/album](https://music.anatid.net/album), showing a list of Albums added through the app. + Clicking on the (+) symbol will allow the user to add an Album with the attributes of Album Title, Artist and Genre. + Each Album listed also has controls for editing and deleting. (TODO: Add dialog to warn of deletion). + Clicking on the Album Title will allow the user to view the full track list, showing each Songs Title, Duration and Track number. The user can also add, edit or delete each Song. (TODO: Add dialog to warn of deletion). + Messages from the API are returned to the user via a Toast style pop-up. (TODO: Authentication, User Accounts) diff --git a/frontend/src/app/actions.tsx b/frontend/src/app/actions.tsx index 61dd55e..15d7bb3 100644 --- a/frontend/src/app/actions.tsx +++ b/frontend/src/app/actions.tsx @@ -77,7 +77,7 @@ export async function createAlbum(formData: FormData) { } export async function updateAlbum(formData: FormData) { - const id = parseInt(formData.get('id')); + const id = Number(formData.get('id')); const title = formData.get('title'); const artist = formData.get('artist'); const genre = formData.get('genre'); @@ -154,10 +154,10 @@ export async function getSong(id: number) { } export async function createSong(formData: FormData) { - const albumId = parseInt(formData.get('albumId')); + const albumId = Number(formData.get('albumId')); const title = formData.get('title'); - const duration = parseInt(formData.get('duration')); - const trackNumber = parseInt(formData.get('trackNumber')); + const duration = Number(formData.get('duration')); + const trackNumber = Number(formData.get('trackNumber')); return fetch("https://api.anatid.net/song/", { method: "POST", headers: { "Content-Type": "application/json" }, @@ -178,11 +178,11 @@ export async function createSong(formData: FormData) { } export async function updateSong(formData: FormData) { - const id = parseInt(formData.get('id')); - const albumId = parseInt(formData.get('albumId')); + const id = Number(formData.get('id')); + const albumId = Number(formData.get('albumId')); const title = formData.get('title'); - const duration = parseInt(formData.get('duration')); - const trackNumber = parseInt(formData.get('trackNumber')); + const duration = Number(formData.get('duration')); + const trackNumber = Number(formData.get('trackNumber')); return fetch(`https://api.anatid.net/song/${id}`, { method: "PUT", headers: { "Content-Type": "application/json" },