Main #16
No files matched your search
+18
-7
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
|
||||
|
||||
import Card from "@/components/Card"
|
||||
import { Input } from "@/components/FormElements";
|
||||
import { Screens } from "@/components/DatabaseOverview";
|
||||
|
||||
interface Songbook {
|
||||
id: number;
|
||||
@@ -121,7 +122,7 @@ export default function AdminPage() {
|
||||
<Card title="Neues Liederbuch">
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Name des Buchs</label>
|
||||
<Input.Label>Name des Buchs</Input.Label>
|
||||
<Input.Text
|
||||
type="text"
|
||||
placeholder="z.B. Gesangbuch"
|
||||
@@ -130,7 +131,7 @@ export default function AdminPage() {
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Sprache (Optional)</label>
|
||||
<Input.Label>Sprache (Optional)</Input.Label>
|
||||
<Input.Text
|
||||
type="text"
|
||||
placeholder="z.B. Deutsch"
|
||||
@@ -150,7 +151,7 @@ export default function AdminPage() {
|
||||
<Card title="Lied hinzufügen">
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Liederbuch wählen</label>
|
||||
<Input.Label>Liederbuch wählen</Input.Label>
|
||||
<Input.Select
|
||||
value={selectedSongbookId}
|
||||
onChange={(e) => setSelectedSongbookId(e.target.value)}
|
||||
@@ -165,7 +166,7 @@ export default function AdminPage() {
|
||||
</div>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
<div className="col-span-1">
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Nummer</label>
|
||||
<Input.Label>Nummer</Input.Label>
|
||||
<Input.Text
|
||||
type="text"
|
||||
placeholder="12a"
|
||||
@@ -174,7 +175,7 @@ export default function AdminPage() {
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-2">
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Liedtitel</label>
|
||||
<Input.Label>Titel</Input.Label>
|
||||
<Input.Text
|
||||
type="text"
|
||||
placeholder="Großer Gott, wir..."
|
||||
@@ -192,7 +193,7 @@ export default function AdminPage() {
|
||||
<input type="hidden" name="songbookId" value={selectedSongbookId} />
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Ziel-Liederbuch</label>
|
||||
<Input.Label>Ziel-Liederbuch</Input.Label>
|
||||
<Input.Select
|
||||
value={selectedSongbookId}
|
||||
onChange={(e) => setSelectedSongbookId(e.target.value)}
|
||||
@@ -206,7 +207,7 @@ export default function AdminPage() {
|
||||
</Input.Select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">Datei auswählen (.csv)</label>
|
||||
<Input.Label>Datei auswählen (.csv)</Input.Label>
|
||||
<Input.File
|
||||
name="csvFile"
|
||||
accept=".csv"
|
||||
@@ -229,6 +230,16 @@ export default function AdminPage() {
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<Screens.Songs
|
||||
actionName="Auswählen"
|
||||
onSelectSong={(song) => console.log(song)}
|
||||
className=""
|
||||
/>
|
||||
<Card title="Lied zu Liederbuch hinzufügen">
|
||||
<Input.Text disabled></Input.Text>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import Image from "next/image";
|
||||
|
||||
export default function DashboardPage() {
|
||||
return (
|
||||
<>
|
||||
{/* Das Hintergrundbild brecht aus allen Containern aus und füllt das Fenster */}
|
||||
<div className="fixed inset-0 -z-10 h-screen w-screen overflow-hidden">
|
||||
{/* <Image
|
||||
src="/fakurian_purple.jpg"
|
||||
alt="Hintergrund"
|
||||
fill
|
||||
className="object-cover"
|
||||
priority
|
||||
/> */}
|
||||
</div>
|
||||
|
||||
{/* Dein Inhalt auf dieser Seite */}
|
||||
<div className="relative">
|
||||
<p>Dashboard is comming soon...</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+3
-21
@@ -1,23 +1,5 @@
|
||||
import Image from "next/image";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default function DashboardPage() {
|
||||
return (
|
||||
<>
|
||||
{/* Das Hintergrundbild brecht aus allen Containern aus und füllt das Fenster */}
|
||||
<div className="fixed inset-0 -z-10 h-screen w-screen overflow-hidden">
|
||||
{/* <Image
|
||||
src="/fakurian_purple.jpg"
|
||||
alt="Hintergrund"
|
||||
fill
|
||||
className="object-cover"
|
||||
priority
|
||||
/> */}
|
||||
</div>
|
||||
|
||||
{/* Dein Inhalt auf dieser Seite */}
|
||||
<div className="relative">
|
||||
<p>Dashboard is comming soon...</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
export default function Page() {
|
||||
redirect("/dashboard")
|
||||
}
|
||||
+4
-65
@@ -3,6 +3,7 @@
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import { Input } from "@/components/FormElements";
|
||||
import { Screens } from "@/components/DatabaseOverview";
|
||||
|
||||
interface Songbook {
|
||||
id: number;
|
||||
@@ -88,71 +89,9 @@ export default function SenderPage() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* LIEDERSUCHE */}
|
||||
<div className="p-4 sm:p-6 flex flex-col h-[500px]">
|
||||
<h2 className="text-lg font-semibold mb-3 flex items-center gap-2">
|
||||
Liedersuche & Datenbank
|
||||
</h2>
|
||||
|
||||
<div className="mb-4">
|
||||
<Input.Text
|
||||
type="text"
|
||||
placeholder="Nach Songtitel oder Nummer suchen..."
|
||||
value={song_search_name}
|
||||
onChange={(e) => search(e.target.value)}
|
||||
<Screens.Songs
|
||||
actionName="Anzeigen"
|
||||
onSelectSong={(song) => sendID(String(song.song_id), String(song.songbook_id))}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* TABELLE */}
|
||||
<div className="flex-1 overflow-auto border border-neutral-200 dark:border-neutral-800 rounded-lg bg-white dark:bg-black">
|
||||
<table className="w-full text-left border-collapse text-sm">
|
||||
<thead className="bg-neutral-100 dark:bg-neutral-900 sticky top-0 border-b border-neutral-200 dark:border-neutral-800 z-10">
|
||||
<tr>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider">Titel</th>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider">Liederbuch</th>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider text-center">Nummer</th>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider text-right">Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-neutral-200 dark:divide-neutral-800">
|
||||
{searchResults.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={4} className="p-8 text-center text-neutral-400 dark:text-neutral-500">Keine Lieder gefunden</td>
|
||||
</tr>
|
||||
) : (
|
||||
searchResults.map((song) => {
|
||||
const songBook = songbooks.find((book) => book.id === song.songbook_id);
|
||||
return (
|
||||
<tr key={`${song.songbook_id}-${song.song_id}`} className="hover:bg-neutral-100/60 dark:hover:bg-neutral-900/40 transition">
|
||||
<td className="p-3 font-medium text-neutral-900 dark:text-white max-w-[180px] sm:max-w-none truncate">
|
||||
{song.title}
|
||||
<span className="block text-xs text-neutral-500 dark:text-neutral-400 sm:hidden mt-0.5">
|
||||
{songBook ? songBook.name : "Unbekannt"}
|
||||
</span>
|
||||
</td>
|
||||
<td className="p-3 text-neutral-700 dark:text-neutral-300 hidden sm:table-cell">
|
||||
{songBook ? songBook.name : "Unbekannt"}
|
||||
</td>
|
||||
<td className="p-3 text-center font-mono text-blue-600 dark:text-blue-400 font-bold">
|
||||
{song.song_number}
|
||||
</td>
|
||||
<td className="p-3 text-right">
|
||||
<Input.Button
|
||||
onClick={() => sendID(String(song.song_id), String(song.songbook_id))}
|
||||
className="bg-white dark:bg-black hover:bg-blue-600 dark:hover:bg-blue-600 border border-neutral-300 dark:border-neutral-700 hover:border-blue-600 dark:hover:border-blue-500 hover:text-white font-medium rounded-md px-3 py-1.5 transition text-xs"
|
||||
>
|
||||
Anzeigen
|
||||
</Input.Button>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+12
-4
@@ -1,12 +1,20 @@
|
||||
import { ReactNode } from "react";
|
||||
import { ReactNode, ComponentPropsWithoutRef } from "react";
|
||||
|
||||
export default function Card({title, children}: {title: string, children: ReactNode}) {
|
||||
interface CardProps extends ComponentPropsWithoutRef<"section"> {
|
||||
title: string;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export default function Card({ title, children, className = "", ...props }: CardProps) {
|
||||
return (
|
||||
<section className="p-5 flex flex-col justify-between">
|
||||
<section
|
||||
className={`p-5 flex flex-col justify-between ${className}`}
|
||||
{...props}
|
||||
>
|
||||
<h2 className="text-lg font-semibold mb-4 flex items-center gap-2">
|
||||
{title}
|
||||
</h2>
|
||||
<div>
|
||||
<div className="flex-1 min-h-0 flex flex-col">
|
||||
{children}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import { useState, useEffect, ComponentPropsWithoutRef } from "react";
|
||||
|
||||
import Card from "./Card"
|
||||
import { Input } from "./FormElements"
|
||||
|
||||
interface SongsProps extends Omit<ComponentPropsWithoutRef<typeof Card>, "title" | "children"> {
|
||||
onSelectSong?: (song: Song) => void;
|
||||
actionName?: string;
|
||||
}
|
||||
|
||||
interface Song {
|
||||
song_id: number;
|
||||
songbook_id: number;
|
||||
song_number: string;
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface Songbook {
|
||||
id: number;
|
||||
name: string;
|
||||
language: string;
|
||||
}
|
||||
|
||||
function Songs({ actionName, onSelectSong, className = "", ...props }: SongsProps) {
|
||||
const [song_search_name, setSongSearchName] = useState("");
|
||||
const [searchResults, setSearchResults] = useState<Song[]>([]);
|
||||
const [allSongs, setAllSongs] = useState<Song[]>([]);
|
||||
const [songbooks, setSongbooks] = useState<Songbook[]>([]);
|
||||
|
||||
|
||||
const search = (query: string) => {
|
||||
setSongSearchName(query);
|
||||
if (query.trim() !== "") {
|
||||
setSearchResults(
|
||||
allSongs.filter((song) =>
|
||||
song.title.toLowerCase().includes(query.toLowerCase()) ||
|
||||
song.song_number.includes(query)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
setSearchResults(allSongs);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const getSongslist = async () => {
|
||||
try {
|
||||
const res = await fetch("/api/songs");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setAllSongs(data);
|
||||
setSearchResults(data);
|
||||
}
|
||||
} catch (error) {
|
||||
setAllSongs([]);
|
||||
console.error("Failed fetching songslist!");
|
||||
}
|
||||
};
|
||||
|
||||
async function loadSongbooks() {
|
||||
try {
|
||||
const res = await fetch("/api/songbooks");
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setSongbooks(data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Loading songbooks failed: ", error);
|
||||
}
|
||||
}
|
||||
loadSongbooks();
|
||||
getSongslist();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Card
|
||||
{...props}
|
||||
title="Alle Lieder"
|
||||
className={`h-[500px] ${className}`}
|
||||
>
|
||||
<div className="mb-4">
|
||||
<Input.Text
|
||||
type="text"
|
||||
placeholder="Nach Songtitel oder Nummer suchen..."
|
||||
value={song_search_name}
|
||||
onChange={(e) => search(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{/* TABELLE */}
|
||||
<div className="flex-1 min-h-0 overflow-auto border border-neutral-200 dark:border-neutral-800 rounded-lg bg-white dark:bg-black">
|
||||
<table className="w-full text-left border-collapse text-sm">
|
||||
<thead className="bg-neutral-100 dark:bg-neutral-900 sticky top-0 border-b border-neutral-200 dark:border-neutral-800 z-10">
|
||||
<tr>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider">Titel</th>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider">Liederbuch</th>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider text-center">Nummer</th>
|
||||
<th className="p-3 text-xs font-semibold text-neutral-600 dark:text-neutral-400 uppercase tracking-wider text-right">Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-neutral-200 dark:divide-neutral-800">
|
||||
{searchResults.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={4} className="p-8 text-center text-neutral-400 dark:text-neutral-500">Keine Lieder gefunden</td>
|
||||
</tr>
|
||||
) : (
|
||||
searchResults.map((song) => {
|
||||
const songBook = songbooks.find((book) => book.id === song.songbook_id);
|
||||
return (
|
||||
<tr key={`${song.songbook_id}-${song.song_id}`} className="hover:bg-neutral-100/60 dark:hover:bg-neutral-900/40 transition">
|
||||
<td className="p-3 font-medium text-neutral-900 dark:text-white max-w-[180px] sm:max-w-none truncate">
|
||||
{song.title}
|
||||
<span className="block text-xs text-neutral-500 dark:text-neutral-400 sm:hidden mt-0.5">
|
||||
{songBook ? songBook.name : "Unbekannt"}
|
||||
</span>
|
||||
</td>
|
||||
<td className="p-3 text-neutral-700 dark:text-neutral-300 hidden sm:table-cell">
|
||||
{songBook ? songBook.name : "Unbekannt"}
|
||||
</td>
|
||||
<td className="p-3 text-center font-mono text-blue-600 dark:text-blue-400 font-bold">
|
||||
{song.song_number}
|
||||
</td>
|
||||
<td className="p-3 text-right">
|
||||
<Input.Button
|
||||
onClick={() => onSelectSong?.(song)}
|
||||
className="bg-white dark:bg-black hover:bg-blue-600 dark:hover:bg-blue-600 border border-neutral-300 dark:border-neutral-700 hover:border-blue-600 dark:hover:border-blue-500 hover:text-white font-medium rounded-md px-3 py-1.5 transition text-xs"
|
||||
>
|
||||
{actionName}
|
||||
</Input.Button>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
|
||||
export const Screens = {
|
||||
Songs: Songs,
|
||||
}
|
||||
@@ -3,13 +3,14 @@ import { ComponentPropsWithoutRef } from "react";
|
||||
|
||||
interface TextfieldProps extends ComponentPropsWithoutRef<"input"> {}
|
||||
|
||||
function Textfield({value, onChange, placeholder}: TextfieldProps) {
|
||||
function Textfield({value, onChange, placeholder, ...props}: TextfieldProps) {
|
||||
return (
|
||||
<input
|
||||
className="w-full border border-neutral-700 rounded-lg px-4 py-2.5 placeholder-neutral-500 focus:outline-none focus:border-blue-400 text-sm"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
placeholder={placeholder}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -46,9 +47,18 @@ function Button({ children, ...props }: ComponentPropsWithoutRef<"button">) {
|
||||
)
|
||||
}
|
||||
|
||||
function Label( {children}: ComponentPropsWithoutRef<"label">) {
|
||||
return (
|
||||
<label className="block text-xs font-semibold text-neutral-400 uppercase tracking-wider mb-1.5">
|
||||
{children}
|
||||
</label>
|
||||
)
|
||||
}
|
||||
|
||||
export const Input = {
|
||||
Text: Textfield,
|
||||
Select: Dropdown,
|
||||
File: File,
|
||||
Button: Button,
|
||||
Label: Label,
|
||||
};
|
||||
@@ -5,7 +5,7 @@ export default function Header() {
|
||||
<header className="fixed top-0 left-0 w-full z-50 p-4 flex justify-between items-center backdrop-blur-md">
|
||||
<div className="font-bold text-xl">PsalmTafel</div>
|
||||
<nav className="flex gap-4 border-2 rounded-full">
|
||||
<NavItem path="/">Dashboard</NavItem>
|
||||
<NavItem path="/dashboard">Dashboard</NavItem>
|
||||
<NavItem path="/sender">Sender</NavItem>
|
||||
<NavItem path="/receiver">Empfänger</NavItem>
|
||||
<NavItem path="/admin">Verwaltung</NavItem>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "psalm-talel",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
Reference in new issue
Block a user