Compare commits
4 Commits
73df14614e
...
90a46bdf96
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90a46bdf96 | ||
|
|
12253f50ac | ||
|
|
0b4b131dad | ||
|
|
3dd73a98ca |
@@ -1,6 +0,0 @@
|
|||||||
export default {
|
|
||||||
plugins: {
|
|
||||||
tailwindcss: {},
|
|
||||||
autoprefixer: {},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
BIN
src/favicon.ico
Normal file
BIN
src/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import '/src/app.css';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
let anrede = '';
|
let anrede = '';
|
||||||
@@ -158,6 +159,16 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.input {
|
.input {
|
||||||
@apply w-full border border-gray-300 rounded-xl p-3 focus:outline-none focus:ring-2 focus:ring-blue-500;
|
width: 100%;
|
||||||
|
border: 1px solid #d1d5db; /* border-gray-300 */
|
||||||
|
border-radius: 0.75rem; /* rounded-xl */
|
||||||
|
padding: 0.75rem; /* p-3 */
|
||||||
|
outline: none;
|
||||||
|
transition: box-shadow 0.2s;
|
||||||
|
}
|
||||||
|
.input:focus {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 0 2px #3b82f6; /* focus:ring-2 focus:ring-blue-500 */
|
||||||
|
border-color: #3b82f6;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
interface Anmeldung {
|
interface Anmeldung {
|
||||||
|
pdfs: any;
|
||||||
anrede: string;
|
anrede: string;
|
||||||
vorname: string;
|
vorname: string;
|
||||||
nachname: string;
|
nachname: string;
|
||||||
@@ -91,7 +92,3 @@
|
|||||||
class="bg-red-600 text-white px-4 py-3 rounded text-center hover:bg-red-700">
|
class="bg-red-600 text-white px-4 py-3 rounded text-center hover:bg-red-700">
|
||||||
Logout
|
Logout
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
/* Removed unused .input selector */
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { onMount } from 'svelte';
|
|
||||||
let dienststellen: { id: number; name: string; plaetze: number }[] = [];
|
|
||||||
let neuerName = '';
|
|
||||||
let neuePlaetze = 0;
|
|
||||||
let fehlermeldung = '';
|
|
||||||
|
|
||||||
async function ladeDienststellen() {
|
|
||||||
const res = await fetch('/api/admin/dienststellen');
|
|
||||||
dienststellen = await res.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function hinzufuegen() {
|
|
||||||
fehlermeldung = '';
|
|
||||||
if (!neuerName.trim()) return;
|
|
||||||
const res = await fetch('/api/admin/dienststellen', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({ name: neuerName, plaetze: neuePlaetze }),
|
|
||||||
headers: { 'Content-Type': 'application/json' }
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res.ok) {
|
|
||||||
neuerName = '';
|
|
||||||
await ladeDienststellen();
|
|
||||||
} else {
|
|
||||||
const err = await res.json();
|
|
||||||
fehlermeldung = err.error || 'Fehler beim Hinzufügen';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loeschen(id: number) {
|
|
||||||
if (!confirm('Diese Dienststelle wirklich löschen?')) return;
|
|
||||||
await fetch(`/api/admin/dienststellen?id=${id}`, { method: 'DELETE' });
|
|
||||||
await ladeDienststellen();
|
|
||||||
}
|
|
||||||
|
|
||||||
onMount(ladeDienststellen);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="p-6 max-w-xl mx-auto space-y-6">
|
|
||||||
<h1 class="text-2xl font-bold">Dienststellen verwalten</h1>
|
|
||||||
|
|
||||||
<div class="flex gap-2">
|
|
||||||
<input bind:value={neuerName} placeholder="Neue Dienststelle" class="input w-full" />
|
|
||||||
<input type="number" bind:value={neuePlaetze} placeholder="Anzahl Plätze" class="input w-1/4" />
|
|
||||||
<button on:click={() => (neuePlaetze = 0)} class="text-sm text-gray-500 hover:underline">Zurücksetzen</button>
|
|
||||||
<button on:click={hinzufuegen} class="bg-blue-600 text-white px-4 py-2 rounded">Hinzufügen</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#if fehlermeldung}
|
|
||||||
<p class="text-red-600">{fehlermeldung}</p>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<ul class="divide-y border rounded">
|
|
||||||
{#each dienststellen as d}
|
|
||||||
<li class="flex justify-between items-center p-2">
|
|
||||||
<span>{d.name}</span>
|
|
||||||
<span class="text-sm text-gray-500">{d.plaetze} Plätze</span>
|
|
||||||
<button on:click={() => (neuerName = d.name, neuePlaetze = d.plaetze)} class="text-sm text-blue-600 hover:underline">Bearbeiten</button>
|
|
||||||
<button on:click={() => loeschen(d.id)} class="text-sm text-red-600 hover:underline">Löschen</button>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
<button
|
|
||||||
on:click={async () => {
|
|
||||||
await fetch('/api/admin/logout', { method: 'POST' });
|
|
||||||
location.reload();
|
|
||||||
}}
|
|
||||||
class="bg-red-600 text-white px-4 py-3 rounded text-center hiver:bg-red-700">
|
|
||||||
Logout
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.input {
|
|
||||||
@apply border rounded px-3 py-2;
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,9 @@ import type { RequestHandler } from './$types';
|
|||||||
|
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
function checkAuth(cookies: any) {
|
import type { Cookies } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
function checkAuth(cookies: Cookies) {
|
||||||
return cookies.get('admin_session') === 'true';
|
return cookies.get('admin_session') === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,10 +29,47 @@ export const POST: RequestHandler = async ({ cookies, request }) => {
|
|||||||
} });
|
} });
|
||||||
return json(created);
|
return json(created);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.error('Fehler beim Hinzufuegen:', e);
|
||||||
return json({ error: 'Dienststelle existiert bereits' }, { status: 400 });
|
return json({ error: 'Dienststelle existiert bereits' }, { status: 400 });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const PATCH: RequestHandler = async ({ cookies, request }) => {
|
||||||
|
if (!checkAuth(cookies)) return new Response('Nicht erlaubt', { status: 401 });
|
||||||
|
|
||||||
|
const { id, name, plaetze } = await request.json();
|
||||||
|
|
||||||
|
if (typeof id !== 'number' || isNaN(id) || !name || typeof plaetze !== 'number' || plaetze < 0) {
|
||||||
|
return json({ error: 'Ungültige Eingabedaten' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await prisma.dienststelle.findUnique({ where: { id } });
|
||||||
|
if (!existing) {
|
||||||
|
return json({ error: 'Dienststelle nicht gefunden' }, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const konflikt = await prisma.dienststelle.findFirst({
|
||||||
|
where: {
|
||||||
|
name,
|
||||||
|
NOT: { id },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (konflikt) {
|
||||||
|
return json({ error: 'Eine andere Dienststelle mit diesem Namen existiert bereits' }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updated = await prisma.dienststelle.update({
|
||||||
|
where: { id },
|
||||||
|
data: { name, plaetze },
|
||||||
|
});
|
||||||
|
return json(updated);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Fehler beim Update:', e);
|
||||||
|
return json({ error: 'Update fehlgeschlagen' }, { status: 400 });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const DELETE: RequestHandler = async ({ cookies, url }) => {
|
export const DELETE: RequestHandler = async ({ cookies, url }) => {
|
||||||
if (!checkAuth(cookies)) return new Response('Nicht erlaubt', { status: 401 });
|
if (!checkAuth(cookies)) return new Response('Nicht erlaubt', { status: 401 });
|
||||||
const id = Number(url.searchParams.get('id'));
|
const id = Number(url.searchParams.get('id'));
|
||||||
|
|||||||
1
static/favicon.ico
Symbolic link
1
static/favicon.ico
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
favicon.png
|
||||||
BIN
static/uploads/ccd2d90b-348e-4dd8-bc33-7a7ef1a9faf0.pdf
Normal file
BIN
static/uploads/ccd2d90b-348e-4dd8-bc33-7a7ef1a9faf0.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user