From cf78d7cea230765a6c7b700de6d1d9c95c7a1667 Mon Sep 17 00:00:00 2001 From: Robin Schanbacher Date: Tue, 28 Jul 2026 17:03:28 +0200 Subject: [PATCH] feat: add ability to remove song from songbook --- app/admin/page.tsx | 53 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/app/admin/page.tsx b/app/admin/page.tsx index 0dc873c..72af9c2 100644 --- a/app/admin/page.tsx +++ b/app/admin/page.tsx @@ -1,7 +1,7 @@ "use client"; import { uploadCSVAction } from "./actions"; -import { useEffect, useState } from "react"; +import { JSXElementConstructor, Key, ReactElement, ReactNode, ReactPortal, useEffect, useState } from "react"; import Card from "@/components/Card" import { Input } from "@/components/FormElements"; @@ -143,6 +143,31 @@ export default function AdminPage() { } } + const removeSong = async () => { + if (!selectedSongbookId || !selectedSong) { + alert("Alle Felder ausfüllen!"); + return; + } + + try { + const res = await fetch("/api/songs/remove", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + songbookId: selectedSongbookId, + songId: selectedSong.song_id + }) + }); + if (res.ok) { + alert("Lied erfolgreich aus dem Liederbuch gelöscht!"); + } else { + alert("Fehler beim Senden."); + } + } catch (error) { + console.error("Failed sending current songID:", error); + } + } + const addSongbook = async () => { if (!newBookName) { alert("Der Name des Liederbuches darf nicht leer sein!"); @@ -353,6 +378,32 @@ export default function AdminPage() { + +
+
+ Ziel-Liederbuch + setSelectedSongbookId(e.target.value)} + > + + {songInfos.length > 0 ? ( + songInfos.map((info) => ( + + )) + ): ""} + +
+ + Lied aus Liederbuch löschen + +
+