Main #21
+52
-1
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { uploadCSVAction } from "./actions";
|
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 Card from "@/components/Card"
|
||||||
import { Input } from "@/components/FormElements";
|
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 () => {
|
const addSongbook = async () => {
|
||||||
if (!newBookName) {
|
if (!newBookName) {
|
||||||
alert("Der Name des Liederbuches darf nicht leer sein!");
|
alert("Der Name des Liederbuches darf nicht leer sein!");
|
||||||
@@ -353,6 +378,32 @@ export default function AdminPage() {
|
|||||||
</Input.Button>
|
</Input.Button>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
<Card title="Aus Liederbuch löschen">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div>
|
||||||
|
<Input.Label>Ziel-Liederbuch</Input.Label>
|
||||||
|
<Input.Select
|
||||||
|
value={selectedSongbookId}
|
||||||
|
onChange={(e) => setSelectedSongbookId(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="">-- Bitte wählen --</option>
|
||||||
|
{songInfos.length > 0 ? (
|
||||||
|
songInfos.map((info) => (
|
||||||
|
<option key={info.songbook_id} value={String(info.songbook_id)}>
|
||||||
|
{info.songbook_name} (Nr. {info.song_number})
|
||||||
|
</option>
|
||||||
|
))
|
||||||
|
): ""}
|
||||||
|
</Input.Select>
|
||||||
|
</div>
|
||||||
|
<Input.Button
|
||||||
|
onClick={removeSong}
|
||||||
|
className="w-full mt-6 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg px-4 py-2.5 transition text-sm shadow-sm"
|
||||||
|
>
|
||||||
|
Lied aus Liederbuch löschen
|
||||||
|
</Input.Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
</Card>
|
</Card>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user