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 [formModalButtonLabel, setFormModalButtonLabel] = useState("Add");
|
||||||
|
|
||||||
const params = useParams<{ id: string }>();
|
const params = useParams<{ id: string }>();
|
||||||
const id = params.id;
|
const albumId = params.id;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchAlbum(id: string) {
|
async function fetchAlbum(id: string) {
|
||||||
try {
|
try {
|
||||||
const data = await getAlbum(parseInt(id));
|
const data = await getAlbum(parseInt(albumId));
|
||||||
setAlbum(data);
|
setAlbum(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error getting album with id ${id}`, error);
|
console.error(`Error getting album with id ${albumId}`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchAlbum(id);
|
fetchAlbum(albumId);
|
||||||
}, [id]);
|
}, [albumId]);
|
||||||
|
|
||||||
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -60,7 +60,7 @@ export default function Page() {
|
|||||||
const handleCreate = async () => {
|
const handleCreate = async () => {
|
||||||
setFormModalTitle("Add Song");
|
setFormModalTitle("Add Song");
|
||||||
setFormModalButtonLabel("Add");
|
setFormModalButtonLabel("Add");
|
||||||
setFormAlbumId("");
|
setFormAlbumId(albumId);
|
||||||
setFormSongId("");
|
setFormSongId("");
|
||||||
setFormSongTitle("");
|
setFormSongTitle("");
|
||||||
setFormSongDuration("");
|
setFormSongDuration("");
|
||||||
@ -69,20 +69,20 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleEdit = async (event: MouseEvent<HTMLElement>) => {
|
const handleEdit = async (event: MouseEvent<HTMLElement>) => {
|
||||||
const id = event.currentTarget.getAttribute('song-id');
|
const songId = event.currentTarget.getAttribute('song-id');
|
||||||
if (id) {
|
if (songId) {
|
||||||
try {
|
try {
|
||||||
const data = await getAlbum(parseInt(id));
|
const data = await getSong(parseInt(songId));
|
||||||
setFormModalTitle("Edit Song");
|
setFormModalTitle("Edit Song");
|
||||||
setFormModalButtonLabel("Save");
|
setFormModalButtonLabel("Save");
|
||||||
setFormSongId(data.id)
|
setFormSongId(data.id)
|
||||||
setFormAlbumId(data.albumId);
|
setFormAlbumId(albumId);
|
||||||
setFormSongTitle(data.title);
|
setFormSongTitle(data.title);
|
||||||
setFormSongDuration(data.duration);
|
setFormSongDuration(data.duration);
|
||||||
setFormSongTrackNumber(data.trackNumber);
|
setFormSongTrackNumber(data.trackNumber);
|
||||||
handleShow();
|
handleShow();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error getting song with ID ${id}:`, error);
|
console.error(`Error getting song with ID ${data.id}:`, error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("Couldn't get ID of clicked element");
|
console.error("Couldn't get ID of clicked element");
|
||||||
@ -90,12 +90,12 @@ export default function Page() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleDelete = async (event: MouseEvent<HTMLElement>) => {
|
const handleDelete = async (event: MouseEvent<HTMLElement>) => {
|
||||||
const id = event.currentTarget.getAttribute('song-id');
|
const songId = event.currentTarget.getAttribute('song-id');
|
||||||
if (id) {
|
if (songId) {
|
||||||
try {
|
try {
|
||||||
await deleteSong(parseInt(id));
|
await deleteSong(parseInt(songId));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error deleting song with ID ${id}:`, error);
|
console.error(`Error deleting song with ID ${songId}:`, error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("Couldn't get ID of clicked element");
|
console.error("Couldn't get ID of clicked element");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user