diff --git a/frontend/src/app/actions.tsx b/frontend/src/app/actions.tsx new file mode 100644 index 0000000..38362ae --- /dev/null +++ b/frontend/src/app/actions.tsx @@ -0,0 +1,24 @@ +'use server' + +export async function createAlbum(formData: FormData) { + const title = formData.get('title'); + const artist = formData.get('artist'); + const genre = formData.get('genre'); + await fetch("https://api.anatid.net/album", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + title: title, + artist: artist, + genre: genre, + }), + }); +} +// +// export async function updateAlbum(formData: FormData) { +// +// } +// +// export async function deleteAlbum(formData: FormData) { +// +// } diff --git a/frontend/src/app/album/page.tsx b/frontend/src/app/album/page.tsx index fe5ba66..3e8804d 100644 --- a/frontend/src/app/album/page.tsx +++ b/frontend/src/app/album/page.tsx @@ -3,6 +3,7 @@ import { useState, useEffect } from 'react'; import Link from 'next/link'; import { Album } from '@/entities/album.entity'; +import { CreateAlbumButton } from '@/app/ui/button'; export default function Page() { const [albums, setAlbums] = useState([]); @@ -19,16 +20,19 @@ export default function Page() { if (!albums) return
Loading...
return ( - +
+ + {CreateAlbumButton()} +
); } diff --git a/frontend/src/app/ui/button.tsx b/frontend/src/app/ui/button.tsx new file mode 100644 index 0000000..aad9164 --- /dev/null +++ b/frontend/src/app/ui/button.tsx @@ -0,0 +1,7 @@ +'use client' + +import { createAlbum } from '@/app/actions' + +export function CreateAlbumButton() { + return +} diff --git a/frontend/src/app/ui/form.tsx b/frontend/src/app/ui/form.tsx new file mode 100644 index 0000000..e4877f7 --- /dev/null +++ b/frontend/src/app/ui/form.tsx @@ -0,0 +1,12 @@ +import { createAlbum } from '@/app/actions' + +export function CreateAlbumForm() { + return ( +
+ + + + +
+ ) +}