diff --git a/frontend/src/app/actions.tsx b/frontend/src/app/actions.tsx index 88b51df..e9004b1 100644 --- a/frontend/src/app/actions.tsx +++ b/frontend/src/app/actions.tsx @@ -57,6 +57,20 @@ export async function deleteAlbum(formData: FormData) { }); } +export async function getSongs() { + return await fetch(`https://api.anatid.net/song/`, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }); +} + +export async function getSong(id: number) { + return await fetch(`https://api.anatid.net/song/${id}`, { + method: "GET", + headers: { "Content-Type": "application/json" }, + }); +} + export async function createSong(formData: FormData) { const albumId = formData.get('album-id'); const title = formData.get('title'); diff --git a/frontend/src/app/album/[id]/page.tsx b/frontend/src/app/album/[id]/page.tsx index ad15b3a..05f8d0e 100644 --- a/frontend/src/app/album/[id]/page.tsx +++ b/frontend/src/app/album/[id]/page.tsx @@ -5,7 +5,7 @@ import { useParams } from 'next/navigation' import { Album } from '@/entities/album.entity'; import { Song } from '@/entities/song.entity'; import { TimeUtils } from '@/utils/time.util'; -import { createSong } from '@/app/actions'; +import { createSong, getAlbum } from '@/app/actions'; import Button from 'react-bootstrap/Button'; import Modal from 'react-bootstrap/Modal'; @@ -20,7 +20,7 @@ export default function Page() { useEffect(() => { async function fetchAlbum(id: string) { - const response = await fetch(`https://api.anatid.net/album/${id}`); + const response = await getAlbum(parseInt(id)); const data = await response.json(); setAlbum(data); } diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index 5156f0e..c831c12 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -52,7 +52,7 @@ export default function Page() { const id = event.currentTarget.getAttribute('id'); if (id) { try { - const response = await getAlbum(id); + const response = await getAlbum(parseInt(id)); const data = await response.json(); setFormAlbumTitle(data.title); setFormAlbumArtist(data.artist); @@ -71,8 +71,8 @@ export default function Page() { return ( <>
- - + + @@ -101,10 +101,10 @@ export default function Page() {
- + - +