schoenheit
This commit is contained in:
@@ -1,113 +1,113 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
interface Anmeldung {
|
interface Anmeldung {
|
||||||
pdfs: any;
|
pdfs: any;
|
||||||
anrede: string;
|
anrede: string;
|
||||||
vorname: string;
|
vorname: string;
|
||||||
nachname: string;
|
nachname: string;
|
||||||
email: string;
|
email: string;
|
||||||
noteDeutsch?: string;
|
noteDeutsch?: string;
|
||||||
noteMathe?: string;
|
noteMathe?: string;
|
||||||
sozialverhalten?: string;
|
sozialverhalten?: string;
|
||||||
wunsch1?: { name: string };
|
wunsch1?: { name: string };
|
||||||
wunsch2?: { name: string };
|
wunsch2?: { name: string };
|
||||||
wunsch3?: { name: string };
|
wunsch3?: { name: string };
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
let anmeldungen: Anmeldung[] = [];
|
let anmeldungen: Anmeldung[] = [];
|
||||||
|
|
||||||
async function ladeAnmeldungen() {
|
async function ladeAnmeldungen() {
|
||||||
const res = await fetch('/api/admin/anmeldungen');
|
const res = await fetch('/api/admin/anmeldungen');
|
||||||
anmeldungen = await res.json();
|
anmeldungen = await res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loeschen(id: number) {
|
||||||
|
if (!confirm('Diese Anmeldung wirklich löschen?')) return;
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/admin/anmeldungen?id=${id}`, { method: 'DELETE' });
|
||||||
|
if (!res.ok) {
|
||||||
|
const errorText = await res.text();
|
||||||
|
throw new Error(`Fehler beim Löschen (${res.status}): ${errorText}`);
|
||||||
}
|
}
|
||||||
|
await ladeAnmeldungen();
|
||||||
async function loeschen(id: number) {
|
} catch (error) {
|
||||||
if (!confirm('Diese Anmeldung wirklich löschen?')) return;
|
console.error(error);
|
||||||
try {
|
alert('Fehler beim Löschen der Anmeldung.\n' + (error as Error).message);
|
||||||
const res = await fetch(`/api/admin/anmeldungen?id=${id}`, { method: 'DELETE' });
|
|
||||||
if (!res.ok) {
|
|
||||||
const errorText = await res.text();
|
|
||||||
throw new Error(`Fehler beim Löschen (${res.status}): ${errorText}`);
|
|
||||||
}
|
}
|
||||||
await ladeAnmeldungen();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
alert('Fehler beim Löschen der Anmeldung.\n' + (error as Error).message);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function annehmen(id: number) {
|
async function annehmen(id: number) {
|
||||||
if (!confirm('Diese Anmeldung wirklich annehmen?')) return;
|
if (!confirm('Diese Anmeldung wirklich annehmen?')) return;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/admin/anmeldungen?id=${id}`, { method: 'POST' });
|
const res = await fetch(`/api/admin/anmeldungen?id=${id}`, { method: 'POST' });
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const errorText = await res.text();
|
const errorText = await res.text();
|
||||||
throw new Error(`Fehler beim Annehmen (${res.status}): ${errorText}`);
|
throw new Error(`Fehler beim Annehmen (${res.status}): ${errorText}`);
|
||||||
|
}
|
||||||
|
await ladeAnmeldungen();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
alert('Fehler beim Annehmen der Anmeldung.\n' + (error as Error).message);
|
||||||
}
|
}
|
||||||
await ladeAnmeldungen();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
alert('Fehler beim Annehmen der Anmeldung.\n' + (error as Error).message);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function ablehnen(id: number) {
|
async function ablehnen(id: number) {
|
||||||
if (!confirm('Diese Anmeldung wirklich annehmen?')) return;
|
if (!confirm('Diese Anmeldung wirklich annehmen?')) return;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/admin/anmeldungen?id=${id}`, { method: 'POST' });
|
const res = await fetch(`/api/admin/anmeldungen?id=${id}`, { method: 'POST' });
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
const errorText = await res.text();
|
const errorText = await res.text();
|
||||||
throw new Error(`Fehler beim Annehmen (${res.status}): ${errorText}`);
|
throw new Error(`Fehler beim Annehmen (${res.status}): ${errorText}`);
|
||||||
|
}
|
||||||
|
await ladeAnmeldungen();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
alert('Fehler beim Annehmen der Anmeldung.\n' + (error as Error).message);
|
||||||
}
|
}
|
||||||
await ladeAnmeldungen();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
alert('Fehler beim Annehmen der Anmeldung.\n' + (error as Error).message);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onMount(ladeAnmeldungen);
|
onMount(ladeAnmeldungen);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="p-6 max-w-8xl mx-auto">
|
||||||
<div class="p-6 max-w-8xl mx-auto">
|
<h1 class="text-2xl font-bold mb-4 text-center">Alle Anmeldungen</h1>
|
||||||
<h1 class="text-2xl font-bold mb-4 text-center">Alle Anmeldungen</h1>
|
<table class="w-full border text-sm">
|
||||||
<table class="w-full border text-sm">
|
<thead>
|
||||||
<thead>
|
<tr class="bg-gray-200">
|
||||||
<tr class="bg-gray-200">
|
<th class="p-2 text-left">Name</th>
|
||||||
<th class="p-2 text-left">Name</th>
|
<th class="p-2 text-left">E-Mail</th>
|
||||||
<th class="p-2 text-left">E-Mail</th>
|
<th class="p-2 text-left">Wunsch Dienststelle</th>
|
||||||
<th class="p-2 text-left">Wunsch Dienststelle</th>
|
<th class="p-2 text-left">Note Deutsch</th>
|
||||||
<th class="p-2 text-left">Note Deutsch</th>
|
<th class="p-2 text-left">Note Mathe</th>
|
||||||
<th class="p-2 text-left">Note Mathe</th>
|
<th class="p-2 text-left">Sozialverhalten</th>
|
||||||
<th class="p-2 text-left">Sozialverhalten</th>
|
<th class="p-2 text-left">Datum</th>
|
||||||
<th class="p-2 text-left">Datum</th>
|
<th class="p-2 text-left">Dateien</th>
|
||||||
<th class="p-2 text-left">Dateien</th>
|
<th class="p-2 text-left">Aktionen</th>
|
||||||
<th class="p-2 text-left">Aktionen</th>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
<tbody>
|
||||||
<tbody>
|
{#each anmeldungen as a}
|
||||||
{#each anmeldungen as a}
|
<tr class="border-t">
|
||||||
<tr class="border-t">
|
<td class="p-2">{a.anrede} {a.vorname} {a.nachname}</td>
|
||||||
<td class="p-2">{a.anrede} {a.vorname} {a.nachname}</td>
|
<td class="p-2">{a.email}</td>
|
||||||
<td class="p-2">{a.email}</td>
|
<td class="p-2">
|
||||||
<td class="p-2">
|
1: {a.wunsch1?.name}<br><br>
|
||||||
1: {a.wunsch1?.name}<br><br>
|
2: {a.wunsch2?.name}<br><br>
|
||||||
2: {a.wunsch2?.name}<br><br>
|
3: {a.wunsch3?.name}
|
||||||
3: {a.wunsch3?.name}
|
</td>
|
||||||
</td>
|
<td class="p-2">{a.noteDeutsch || '—'}</td>
|
||||||
<td class="p-2">{a.noteDeutsch || '—'}</td>
|
<td class="p-2">{a.noteMathe || '—'}</td>
|
||||||
<td class="p-2">{a.noteMathe || '—'}</td>
|
<td class="p-2">{a.sozialverhalten || '—'}</td>
|
||||||
<td class="p-2">{a.sozialverhalten || '—'}</td>
|
<td class="p-2">{new Date(a.timestamp).toLocaleDateString()}</td>
|
||||||
<td class="p-2">{new Date(a.timestamp).toLocaleDateString()}</td>
|
<td class="p-2">
|
||||||
<td class="p-2">
|
{#each a.pdfs as pdf}
|
||||||
{#each a.pdfs as pdf}
|
<li>
|
||||||
<li>
|
<a href={pdf.pfad} target="_blank" class="text-blue-600 hover:underline">
|
||||||
<a href={pdf.pfad} target="_blank" class="text-blue-600 hover:underline">
|
PDF ansehen
|
||||||
PDF ansehen
|
</a>
|
||||||
</a>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</td>
|
</td>
|
||||||
<td class="p-2 text-right">
|
<td class="p-2 text-right">
|
||||||
@@ -140,4 +140,4 @@ async function ablehnen(id: number) {
|
|||||||
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>
|
||||||
</button>
|
</div>
|
||||||
Reference in New Issue
Block a user