schulart und Noten in fronend. Erste versuch Zeitraum in backend
This commit is contained in:
@@ -93,11 +93,19 @@
|
||||
|
||||
const deutsch = parseInt(deutschNote);
|
||||
const mathe = parseInt(matheNote);
|
||||
|
||||
if (isNaN(deutsch) || isNaN(mathe) || deutsch > 3 && mathe > 3) {
|
||||
ablehnungHinweis = 'Du brauchst mindestens eine 3 in Deutsch oder Mathematik, um dich bewerben zu können. Bewirb dich gern erneut, wenn du die Voraussetzung erfüllst.';
|
||||
showAblehnungModal = true;
|
||||
return;
|
||||
|
||||
if (['Gymnasium', 'Gymnasialzweig'].includes(schulart) ) {
|
||||
if (isNaN(deutsch) || isNaN(mathe) || deutsch > 4 && mathe > 4) {
|
||||
ablehnungHinweis = 'Du brauchst mindestens eine 4 in Deutsch oder Mathematik, um dich bewerben zu können. Bewirb dich gern erneut, wenn du die Voraussetzung erfüllst.';
|
||||
showAblehnungModal = true;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (isNaN(deutsch) || isNaN(mathe) || deutsch > 3 && mathe > 3) {
|
||||
ablehnungHinweis = 'Du brauchst mindestens eine 3 in Deutsch oder Mathematik, um dich bewerben zu können. Bewirb dich gern erneut, wenn du die Voraussetzung erfüllst.';
|
||||
showAblehnungModal = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sozialverhalten === 'Entspricht den Erwartungen mit Einschränkungen') {
|
||||
@@ -151,11 +159,13 @@
|
||||
<!-- Schulart Dropdown -->
|
||||
<select bind:value={schulart} required class="input">
|
||||
<option value="" disabled selected hidden>Schulart wählen</option>
|
||||
<option value="Mittelschule">Mittelschule</option>
|
||||
<option value="Realschule">Realschule</option>
|
||||
<option value="Gymnasium">Gymnasium</option>
|
||||
<option value="Gymnasialzweig">Gymnasialzweig</option>
|
||||
<option value="Realschule">Realschule</option>
|
||||
<option value="FOS">Fachoberschule (FOS)</option>
|
||||
<option value="BOS">Berufsoberschule (BOS)</option>
|
||||
<option value="IGS">Integrierte Gesamtschule (IGS)</option>
|
||||
<option value="KGS">Kooperative Gesamtschule (KGS)</option>
|
||||
</select>
|
||||
<!-- Noten -->
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
|
||||
@@ -33,13 +33,16 @@
|
||||
<div class="space-y-4">
|
||||
<h1 class="text-2xl font-bold mb-4">Admin-Bereich</h1>
|
||||
<div class="flex flex-col gap-4">
|
||||
<a href="/admin/anmeldungen" class="bg-blue-600 text-white px-4 py-3 rounded text-center hover:bg-blue-700">
|
||||
<a href="/admin/anmeldungen" class="bg-blue-600 text-white px-4 py-3 rounded text-center hover:bg-blue-800">
|
||||
📝 Anmeldungen anzeigen
|
||||
</a>
|
||||
<a href="/admin/dienststellen" class="bg-green-600 text-white px-4 py-3 rounded text-center hover:bg-green-700">
|
||||
<a href="/admin/dienststellen" class="bg-green-600 text-white px-4 py-3 rounded text-center hover:bg-green-800">
|
||||
🏢 Dienststellen verwalten
|
||||
</a>
|
||||
<a href="/admin/change-password" class="bg-cyan-600 text-white px-4 py-3 rounded text-center hover:bg-green-700">
|
||||
<a href="/admin/zeitraum" class="bg-yellow-600 text-white px-4 py-3 rounded text-center hover:bg-yellow-800">
|
||||
🗓 Zeitraum verwaltung
|
||||
</a>
|
||||
<a href="/admin/change-password" class="bg-cyan-600 text-white px-4 py-3 rounded text-center hover:bg-cyan-800">
|
||||
👨💼 Passwort ädern
|
||||
</a>
|
||||
</div>
|
||||
|
||||
8
src/routes/admin/zeitraum/+page.server.ts
Normal file
8
src/routes/admin/zeitraum/+page.server.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageServerLoad = async ({ cookies }) => {
|
||||
if (cookies.get('admin_session') !== 'true') {
|
||||
throw redirect(303, '/admin'); // zurück zur Login-Seite
|
||||
}
|
||||
};
|
||||
50
src/routes/admin/zeitraum/+page.svelte
Normal file
50
src/routes/admin/zeitraum/+page.svelte
Normal file
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
let bezeichnung = ''
|
||||
let startDatum = ''
|
||||
let endDatum = ''
|
||||
let zeitraeume = []
|
||||
|
||||
onMount(async () => {
|
||||
zeitraeume = await fetchZeitraeume()
|
||||
})
|
||||
|
||||
async function handleSubmit() {
|
||||
await createPraktikumszeitraum({ bezeichnung, startDatum, endDatum })
|
||||
zeitraeume = await fetchZeitraeume()
|
||||
|
||||
// Felder zurücksetzen
|
||||
bezeichnung = ''
|
||||
startDatum = ''
|
||||
endDatum = ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1 class="text-2xl font-bold mb-4">🗓 Praktikumszeiträume verwalten</h1>
|
||||
|
||||
<form on:submit|preventDefault={handleSubmit} class="grid gap-4 max-w-xl bg-white p-4 rounded shadow">
|
||||
<input type="text" bind:value={bezeichnung} placeholder="Bezeichnung (z. B. Frühjahr 2025)" required class="input" />
|
||||
<div class="flex gap-2">
|
||||
<input type="date" bind:value={startDatum} required class="input flex-1" />
|
||||
<input type="date" bind:value={endDatum} required class="input flex-1" />
|
||||
</div>
|
||||
<button type="submit" class="bg-green-600 text-white py-2 rounded hover:bg-green-700">✅ Zeitraum speichern</button>
|
||||
</form>
|
||||
|
||||
<h2 class="text-xl font-semibold mt-8 mb-2">📋 Bereits erfasste Zeiträume</h2>
|
||||
<div class="grid gap-4">
|
||||
{#each zeitraeume as z}
|
||||
<div class="p-4 bg-gray-100 rounded shadow">
|
||||
<h3 class="font-bold">{z.bezeichnung}</h3>
|
||||
<p class="text-sm text-gray-700">
|
||||
{new Date(z.startDatum).toLocaleDateString()} – {new Date(z.endDatum).toLocaleDateString()}
|
||||
</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.input {
|
||||
@apply border p-2 rounded w-full;
|
||||
}
|
||||
</style>
|
||||
22
src/routes/api/admin/zeitraum/+server.ts
Normal file
22
src/routes/api/admin/zeitraum/+server.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { db } from '$lib/server/prisma'
|
||||
|
||||
export async function GET() {
|
||||
const zeitraeume = await db.praktikumszeitraum.findMany({
|
||||
orderBy: { startDatum: 'asc' }
|
||||
})
|
||||
return new Response(JSON.stringify(zeitraeume))
|
||||
}
|
||||
|
||||
export async function POST({ request }) {
|
||||
const { bezeichnung, startDatum, endDatum } = await request.json()
|
||||
|
||||
await db.praktikumszeitraum.create({
|
||||
data: {
|
||||
bezeichnung,
|
||||
startDatum: new Date(startDatum),
|
||||
endDatum: new Date(endDatum)
|
||||
}
|
||||
})
|
||||
|
||||
return new Response('OK')
|
||||
}
|
||||
@@ -38,7 +38,6 @@ export async function POST({ request }) {
|
||||
telefon: get('telefon'),
|
||||
email: get('email'),
|
||||
schulart: get('schulart'),
|
||||
zeitraum: get('zeitraum'),
|
||||
motivation: get('motivation'),
|
||||
wunsch1Id: parseInt(get('wunsch1Id')),
|
||||
wunsch2Id: parseInt(get('wunsch2Id')),
|
||||
|
||||
Reference in New Issue
Block a user