Fixing song and album ids
Some checks failed
Music Collection CI Workflow / deploy (push) Has been cancelled
Music Collection CI Workflow / test (./backend) (push) Successful in 28s
Music Collection CI Workflow / test (./frontend) (push) Successful in 35s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Successful in 48s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been cancelled
Some checks failed
Music Collection CI Workflow / deploy (push) Has been cancelled
Music Collection CI Workflow / test (./backend) (push) Successful in 28s
Music Collection CI Workflow / test (./frontend) (push) Successful in 35s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Successful in 48s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been cancelled
This commit is contained in:
parent
773feae410
commit
0b19e19a27
@ -25,19 +25,19 @@ export default function Page() {
|
||||
const [formModalButtonLabel, setFormModalButtonLabel] = useState("Add");
|
||||
|
||||
const params = useParams<{ id: string }>();
|
||||
const id = params.id;
|
||||
const albumId = params.id;
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchAlbum(id: string) {
|
||||
try {
|
||||
const data = await getAlbum(parseInt(id));
|
||||
const data = await getAlbum(parseInt(albumId));
|
||||
setAlbum(data);
|
||||
} catch (error) {
|
||||
console.error(`Error getting album with id ${id}`, error);
|
||||
console.error(`Error getting album with id ${albumId}`, error);
|
||||
}
|
||||
}
|
||||
fetchAlbum(id);
|
||||
}, [id]);
|
||||
fetchAlbum(albumId);
|
||||
}, [albumId]);
|
||||
|
||||
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
@ -60,7 +60,7 @@ export default function Page() {
|
||||
const handleCreate = async () => {
|
||||
setFormModalTitle("Add Song");
|
||||
setFormModalButtonLabel("Add");
|
||||
setFormAlbumId("");
|
||||
setFormAlbumId(albumId);
|
||||
setFormSongId("");
|
||||
setFormSongTitle("");
|
||||
setFormSongDuration("");
|
||||
@ -69,20 +69,20 @@ export default function Page() {
|
||||
}
|
||||
|
||||
const handleEdit = async (event: MouseEvent<HTMLElement>) => {
|
||||
const id = event.currentTarget.getAttribute('song-id');
|
||||
if (id) {
|
||||
const songId = event.currentTarget.getAttribute('song-id');
|
||||
if (songId) {
|
||||
try {
|
||||
const data = await getAlbum(parseInt(id));
|
||||
const data = await getSong(parseInt(songId));
|
||||
setFormModalTitle("Edit Song");
|
||||
setFormModalButtonLabel("Save");
|
||||
setFormSongId(data.id)
|
||||
setFormAlbumId(data.albumId);
|
||||
setFormAlbumId(albumId);
|
||||
setFormSongTitle(data.title);
|
||||
setFormSongDuration(data.duration);
|
||||
setFormSongTrackNumber(data.trackNumber);
|
||||
handleShow();
|
||||
} catch (error) {
|
||||
console.error(`Error getting song with ID ${id}:`, error);
|
||||
console.error(`Error getting song with ID ${data.id}:`, error);
|
||||
}
|
||||
} else {
|
||||
console.error("Couldn't get ID of clicked element");
|
||||
@ -90,12 +90,12 @@ export default function Page() {
|
||||
}
|
||||
|
||||
const handleDelete = async (event: MouseEvent<HTMLElement>) => {
|
||||
const id = event.currentTarget.getAttribute('song-id');
|
||||
if (id) {
|
||||
const songId = event.currentTarget.getAttribute('song-id');
|
||||
if (songId) {
|
||||
try {
|
||||
await deleteSong(parseInt(id));
|
||||
await deleteSong(parseInt(songId));
|
||||
} catch (error) {
|
||||
console.error(`Error deleting song with ID ${id}:`, error);
|
||||
console.error(`Error deleting song with ID ${songId}:`, error);
|
||||
}
|
||||
} else {
|
||||
console.error("Couldn't get ID of clicked element");
|
||||
|
Loading…
x
Reference in New Issue
Block a user