Feature: SEPA-Export, Push-Notifications, Onboarding + vollständige UI
- Phosphor Icons (Icon.svelte, svg-Registry) - Schema-Abgleich: alle Felder zwischen PB-Migrations und types.ts konsistent - Stripe entfernt, SEPA pain.008 XML-Export implementiert (sepa.ts) - Beiträge: vollständiges CRUD + SEPA-Einzug-Sheet mit Vorschau - Termine: vollständiges CRUD (upcoming/vergangen, datetime-local) - Mitglieder: Formulare um alle Felder erweitert (Adresse, SEPA-Mandat, Notizen) - Nachrichten: Brevo E-Mail via PocketBase-Hook, UI mit Gruppen-Filter - Push-Notifications: VAPID, Custom Service Worker (injectManifest), Subscribe/Send API-Routen, automatische Subscription nach Login - Onboarding: 3-Schritt-Flow für neue Vereine, Guard im App-Layout - Makefile: .env wird vollständig zur DS übertragen
This commit is contained in:
parent
c2c4dfd518
commit
77c6f513b5
32 changed files with 3012 additions and 399 deletions
|
|
@ -3,26 +3,81 @@
|
|||
import { page } from '$app/stores';
|
||||
import { onMount } from 'svelte';
|
||||
import { pb } from '$lib/pb';
|
||||
import Icon from '$lib/components/Icon.svelte';
|
||||
import type { IconName } from '$lib/icons';
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
onMount(() => {
|
||||
if (!pb.authStore.isValid) {
|
||||
goto('/login');
|
||||
return;
|
||||
}
|
||||
if (!pb.authStore.record?.verein_id) {
|
||||
goto('/onboarding');
|
||||
return;
|
||||
}
|
||||
registerPush();
|
||||
});
|
||||
|
||||
async function registerPush() {
|
||||
if (!('serviceWorker' in navigator) || !('PushManager' in window)) return;
|
||||
|
||||
const permission = await Notification.requestPermission();
|
||||
if (permission !== 'granted') return;
|
||||
|
||||
try {
|
||||
const reg = await navigator.serviceWorker.ready;
|
||||
|
||||
// VAPID public key vom Server holen
|
||||
const keyRes = await fetch('/api/push/key');
|
||||
const { publicKey } = await keyRes.json();
|
||||
if (!publicKey) return;
|
||||
|
||||
// Bestehende oder neue Subscription
|
||||
let sub = await reg.pushManager.getSubscription();
|
||||
if (!sub) {
|
||||
sub = await reg.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
applicationServerKey: urlBase64ToUint8Array(publicKey) as BufferSource,
|
||||
});
|
||||
}
|
||||
|
||||
// In PocketBase speichern
|
||||
await fetch('/api/push/subscribe', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: pb.authStore.token,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
subscription: sub.toJSON(),
|
||||
userId: pb.authStore.record?.id,
|
||||
}),
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('[push] Registrierung fehlgeschlagen:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function urlBase64ToUint8Array(base64String: string): Uint8Array {
|
||||
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
|
||||
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');
|
||||
const raw = atob(base64);
|
||||
return Uint8Array.from([...raw].map((c) => c.charCodeAt(0)));
|
||||
}
|
||||
|
||||
function logout() {
|
||||
pb.authStore.clear();
|
||||
goto('/login');
|
||||
}
|
||||
|
||||
const navItems = [
|
||||
{ href: '/', label: 'Übersicht', icon: '⊞' },
|
||||
{ href: '/mitglieder', label: 'Mitglieder', icon: '👥' },
|
||||
{ href: '/termine', label: 'Termine', icon: '📅' },
|
||||
{ href: '/beitraege', label: 'Beiträge', icon: '💶' },
|
||||
{ href: '/nachrichten', label: 'Nachrichten', icon: '✉️' },
|
||||
const navItems: { href: string; label: string; icon: IconName }[] = [
|
||||
{ href: '/', label: 'Übersicht', icon: 'house' },
|
||||
{ href: '/mitglieder', label: 'Mitglieder', icon: 'users' },
|
||||
{ href: '/termine', label: 'Termine', icon: 'calendar' },
|
||||
{ href: '/beitraege', label: 'Beiträge', icon: 'currency-eur' },
|
||||
{ href: '/nachrichten', label: 'Nachrichten', icon: 'envelope' },
|
||||
];
|
||||
</script>
|
||||
|
||||
|
|
@ -42,7 +97,7 @@
|
|||
href={item.href}
|
||||
class:active={$page.url.pathname === item.href}
|
||||
>
|
||||
<span class="nav-icon">{item.icon}</span>
|
||||
<Icon name={item.icon} size={22} />
|
||||
<span class="nav-label">{item.label}</span>
|
||||
</a>
|
||||
{/each}
|
||||
|
|
@ -126,11 +181,6 @@
|
|||
color: #1e40af;
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
font-size: 1.3rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
font-size: 0.65rem;
|
||||
font-weight: 500;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import Icon from '$lib/components/Icon.svelte';
|
||||
|
||||
const vereinsname = pb.authStore.record?.name ?? 'Dein Verein';
|
||||
</script>
|
||||
|
|
@ -12,19 +13,19 @@
|
|||
|
||||
<div class="cards">
|
||||
<a href="/mitglieder" class="card">
|
||||
<span class="card-icon">👥</span>
|
||||
<Icon name="users" size={40} />
|
||||
<span class="card-label">Mitglieder</span>
|
||||
</a>
|
||||
<a href="/termine" class="card">
|
||||
<span class="card-icon">📅</span>
|
||||
<Icon name="calendar" size={40} />
|
||||
<span class="card-label">Termine</span>
|
||||
</a>
|
||||
<a href="/beitraege" class="card">
|
||||
<span class="card-icon">💶</span>
|
||||
<Icon name="currency-eur" size={40} />
|
||||
<span class="card-label">Beiträge</span>
|
||||
</a>
|
||||
<a href="/nachrichten" class="card">
|
||||
<span class="card-icon">✉️</span>
|
||||
<Icon name="envelope" size={40} />
|
||||
<span class="card-label">Nachrichten</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
@ -52,6 +53,7 @@
|
|||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: #1e40af;
|
||||
transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
|
||||
|
|
@ -60,10 +62,6 @@
|
|||
box-shadow: 0 2px 8px rgba(30,64,175,.1);
|
||||
}
|
||||
|
||||
.card-icon {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.card-label {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
|
|
|
|||
|
|
@ -1,27 +1,514 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import { onMount } from 'svelte';
|
||||
import { generatePain008, downloadXml, minEinzugsdatum, type SepaPosition } from '$lib/sepa';
|
||||
import type { Beitrag, Mitglied, Verein } from '$lib/types';
|
||||
|
||||
// --- Daten ---
|
||||
let beitraege = $state<Beitrag[]>([]);
|
||||
let verein = $state<Verein | null>(null);
|
||||
let loading = $state(true);
|
||||
|
||||
// --- Beitragsart-Formular ---
|
||||
let showForm = $state(false);
|
||||
let editId = $state<string | null>(null);
|
||||
let fName = $state('');
|
||||
let fBetrag = $state('');
|
||||
let fRhythmus = $state<Beitrag['rhythmus']>('jaehrlich');
|
||||
let fBeschr = $state('');
|
||||
let saving = $state(false);
|
||||
let formError = $state('');
|
||||
|
||||
// --- SEPA-Export ---
|
||||
let sepaFor = $state<Beitrag | null>(null);
|
||||
let einzugsdatum = $state(minEinzugsdatum());
|
||||
let sepaLoading = $state(false);
|
||||
let sepaError = $state('');
|
||||
let sepaPreview = $state<{ mitglieder: Mitglied[]; ohne: number } | null>(null);
|
||||
|
||||
const rhythmusLabel: Record<Beitrag['rhythmus'], string> = {
|
||||
monatlich: 'monatlich',
|
||||
quartalsweise: 'quartalsweise',
|
||||
halbjaehrlich: 'halbjährlich',
|
||||
jaehrlich: 'jährlich',
|
||||
einmalig: 'einmalig',
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
const vid = pb.authStore.record?.verein_id as string;
|
||||
[beitraege, verein] = await Promise.all([
|
||||
pb.collection('beitraege').getFullList<Beitrag>({ sort: 'name' }),
|
||||
pb.collection('vereine').getOne<Verein>(vid).catch(() => null),
|
||||
]);
|
||||
loading = false;
|
||||
});
|
||||
|
||||
// --- Beitragsart speichern ---
|
||||
function neuerBeitrag() {
|
||||
editId = null; fName = ''; fBetrag = ''; fRhythmus = 'jaehrlich'; fBeschr = '';
|
||||
formError = ''; showForm = true;
|
||||
}
|
||||
|
||||
function bearbeiten(b: Beitrag) {
|
||||
editId = b.id; fName = b.name; fBetrag = String(b.betrag);
|
||||
fRhythmus = b.rhythmus; fBeschr = b.beschreibung ?? '';
|
||||
formError = ''; showForm = true;
|
||||
}
|
||||
|
||||
async function speichern() {
|
||||
formError = '';
|
||||
const betrag = parseFloat(fBetrag.replace(',', '.'));
|
||||
if (!fName.trim() || isNaN(betrag) || betrag <= 0) {
|
||||
formError = 'Name und gültiger Betrag sind Pflichtfelder.';
|
||||
return;
|
||||
}
|
||||
saving = true;
|
||||
try {
|
||||
const vid = pb.authStore.record?.verein_id as string;
|
||||
const data = { verein_id: vid, name: fName.trim(), betrag, rhythmus: fRhythmus, beschreibung: fBeschr.trim() };
|
||||
if (editId) {
|
||||
await pb.collection('beitraege').update(editId, data);
|
||||
beitraege = beitraege.map(b => b.id === editId ? { ...b, ...data } as Beitrag : b);
|
||||
} else {
|
||||
const neu = await pb.collection('beitraege').create<Beitrag>(data);
|
||||
beitraege = [...beitraege, neu].sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
showForm = false;
|
||||
} catch (e: unknown) {
|
||||
formError = e instanceof Error ? e.message : 'Fehler beim Speichern.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loeschen(b: Beitrag) {
|
||||
if (!confirm(`"${b.name}" wirklich löschen?`)) return;
|
||||
await pb.collection('beitraege').delete(b.id);
|
||||
beitraege = beitraege.filter(x => x.id !== b.id);
|
||||
}
|
||||
|
||||
// --- SEPA-Export ---
|
||||
async function sepaOeffnen(b: Beitrag) {
|
||||
sepaFor = b;
|
||||
sepaError = '';
|
||||
sepaPreview = null;
|
||||
einzugsdatum = minEinzugsdatum();
|
||||
sepaLoading = true;
|
||||
try {
|
||||
const alle = await pb.collection('mitglieder').getFullList<Mitglied>({
|
||||
filter: 'status = "aktiv"', sort: 'nachname,vorname',
|
||||
});
|
||||
const mit = alle.filter(m => m.iban?.trim());
|
||||
const ohne = alle.length - mit.length;
|
||||
sepaPreview = { mitglieder: mit, ohne };
|
||||
} catch (e: unknown) {
|
||||
sepaError = e instanceof Error ? e.message : 'Fehler beim Laden der Mitglieder.';
|
||||
} finally {
|
||||
sepaLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function sepaSchliessen() {
|
||||
sepaFor = null; sepaPreview = null; sepaError = '';
|
||||
}
|
||||
|
||||
async function sepaExportieren() {
|
||||
if (!sepaFor || !sepaPreview || !verein) return;
|
||||
|
||||
if (!verein.glaeubigerid || !verein.iban || !verein.bic) {
|
||||
sepaError = 'Bitte zuerst Gläubiger-ID, IBAN und BIC des Vereins in den Einstellungen hinterlegen.';
|
||||
return;
|
||||
}
|
||||
|
||||
sepaError = '';
|
||||
sepaLoading = true;
|
||||
|
||||
try {
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const positionen: SepaPosition[] = sepaPreview.mitglieder.map((m, i) => ({
|
||||
endToEndId: `VH-${sepaFor!.id.slice(0, 6)}-${String(i + 1).padStart(4, '0')}`,
|
||||
betrag: sepaFor!.betrag,
|
||||
mandatsreferenz: m.mandatsreferenz || `MANDAT-${m.id.slice(0, 8).toUpperCase()}`,
|
||||
mandatsdatum: m.mandatsdatum || today,
|
||||
debitorName: `${m.vorname} ${m.nachname}`,
|
||||
debitorIban: m.iban!,
|
||||
debitorBic: m.bic ?? '',
|
||||
verwendungszweck: `${sepaFor!.name} (${rhythmusLabel[sepaFor!.rhythmus]})`,
|
||||
}));
|
||||
|
||||
const xml = generatePain008(
|
||||
{
|
||||
glaeubigerid: verein.glaeubigerid,
|
||||
vereinIban: verein.iban,
|
||||
vereinBic: verein.bic,
|
||||
vereinName: verein.name,
|
||||
einzugsdatum,
|
||||
},
|
||||
positionen,
|
||||
);
|
||||
|
||||
downloadXml(xml, `sepa-einzug-${einzugsdatum}.xml`);
|
||||
|
||||
// Einzüge als "ausstehend" anlegen
|
||||
const vid = pb.authStore.record?.verein_id as string;
|
||||
await Promise.all(
|
||||
sepaPreview.mitglieder.map((m) =>
|
||||
pb.collection('einzuege').create({
|
||||
mitglied_id: m.id,
|
||||
beitrag_id: sepaFor!.id,
|
||||
betrag: sepaFor!.betrag,
|
||||
faellig_am: einzugsdatum,
|
||||
status: 'ausstehend',
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
sepaSchliessen();
|
||||
} catch (e: unknown) {
|
||||
sepaError = e instanceof Error ? e.message : 'Fehler beim Export.';
|
||||
} finally {
|
||||
sepaLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
const gesamtbetrag = $derived(
|
||||
sepaPreview ? sepaPreview.mitglieder.length * (sepaFor?.betrag ?? 0) : 0,
|
||||
);
|
||||
|
||||
const sepaFehlt = $derived(
|
||||
verein ? !verein.glaeubigerid || !verein.iban || !verein.bic : true,
|
||||
);
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Beiträge — vereins.haus</title></svelte:head>
|
||||
|
||||
<div class="page-header">
|
||||
<div class="top">
|
||||
<h1>Beiträge</h1>
|
||||
<button class="btn-primary">+ Beitragsart</button>
|
||||
<button class="btn-primary" onclick={neuerBeitrag}>+ Beitragsart</button>
|
||||
</div>
|
||||
|
||||
<p class="placeholder">SEPA-Beitragseinzug — in Entwicklung</p>
|
||||
{#if sepaFehlt && !loading}
|
||||
<div class="hinweis">
|
||||
SEPA-Einzug nicht möglich: Gläubiger-ID, IBAN und BIC des Vereins fehlen noch in den Einstellungen.
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if loading}
|
||||
<p class="hint">Laden…</p>
|
||||
{:else if beitraege.length === 0}
|
||||
<p class="hint">Noch keine Beitragsarten — lege die erste an!</p>
|
||||
{:else}
|
||||
<ul class="liste">
|
||||
{#each beitraege as b (b.id)}
|
||||
<li class="karte">
|
||||
<div class="karte-info">
|
||||
<span class="karte-name">{b.name}</span>
|
||||
{#if b.beschreibung}
|
||||
<span class="karte-beschr">{b.beschreibung}</span>
|
||||
{/if}
|
||||
<span class="karte-meta">
|
||||
{b.betrag.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' })}
|
||||
· {rhythmusLabel[b.rhythmus]}
|
||||
</span>
|
||||
</div>
|
||||
<div class="karte-aktionen">
|
||||
<button class="btn-sepa" onclick={() => sepaOeffnen(b)} disabled={sepaFehlt}>
|
||||
SEPA
|
||||
</button>
|
||||
<button class="btn-icon" onclick={() => bearbeiten(b)} title="Bearbeiten">✎</button>
|
||||
<button class="btn-icon btn-icon-red" onclick={() => loeschen(b)} title="Löschen">✕</button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
<!-- Beitragsart-Formular -->
|
||||
{#if showForm}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="sheet">
|
||||
<h2>{editId ? 'Beitragsart bearbeiten' : 'Neue Beitragsart'}</h2>
|
||||
|
||||
<form onsubmit={(e) => { e.preventDefault(); speichern(); }}>
|
||||
<div class="field">
|
||||
<label for="fname">Name *</label>
|
||||
<input id="fname" type="text" bind:value={fName} placeholder="z. B. Jahresbeitrag" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="fbetrag">Betrag (€) *</label>
|
||||
<input id="fbetrag" type="text" inputmode="decimal" bind:value={fBetrag} placeholder="48,00" required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="frhythmus">Rhythmus</label>
|
||||
<select id="frhythmus" bind:value={fRhythmus}>
|
||||
<option value="monatlich">Monatlich</option>
|
||||
<option value="quartalsweise">Quartalsweise</option>
|
||||
<option value="halbjaehrlich">Halbjährlich</option>
|
||||
<option value="jaehrlich">Jährlich</option>
|
||||
<option value="einmalig">Einmalig</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="fbeschr">Beschreibung</label>
|
||||
<input id="fbeschr" type="text" bind:value={fBeschr} placeholder="Optional" />
|
||||
</div>
|
||||
|
||||
{#if formError}
|
||||
<p class="error">{formError}</p>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<button type="button" class="btn-ghost" onclick={() => showForm = false}>Abbrechen</button>
|
||||
<button type="submit" class="btn-primary" disabled={saving}>
|
||||
{saving ? 'Speichern…' : 'Speichern'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- SEPA-Export -->
|
||||
{#if sepaFor}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="sheet">
|
||||
<h2>SEPA-Einzug</h2>
|
||||
<p class="sepa-sub">{sepaFor.name} · {sepaFor.betrag.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' })} · {rhythmusLabel[sepaFor.rhythmus]}</p>
|
||||
|
||||
<div class="field">
|
||||
<label for="einzugsdatum">Einzugsdatum *</label>
|
||||
<input
|
||||
id="einzugsdatum"
|
||||
type="date"
|
||||
bind:value={einzugsdatum}
|
||||
min={minEinzugsdatum()}
|
||||
/>
|
||||
<span class="field-hint">SEPA CORE: mind. 2 Bankarbeitstage Vorlauf</span>
|
||||
</div>
|
||||
|
||||
{#if sepaLoading}
|
||||
<p class="hint">Laden…</p>
|
||||
{:else if sepaPreview}
|
||||
<div class="sepa-summary">
|
||||
<div class="sepa-row">
|
||||
<span>Mitglieder mit IBAN</span>
|
||||
<strong>{sepaPreview.mitglieder.length}</strong>
|
||||
</div>
|
||||
{#if sepaPreview.ohne > 0}
|
||||
<div class="sepa-row sepa-warn">
|
||||
<span>Ohne IBAN (übersprungen)</span>
|
||||
<strong>{sepaPreview.ohne}</strong>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="sepa-row sepa-total">
|
||||
<span>Gesamtsumme</span>
|
||||
<strong>{gesamtbetrag.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' })}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if sepaPreview.mitglieder.length === 0}
|
||||
<p class="error">Keine aktiven Mitglieder mit IBAN vorhanden.</p>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if sepaError}
|
||||
<p class="error">{sepaError}</p>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<button type="button" class="btn-ghost" onclick={sepaSchliessen}>Abbrechen</button>
|
||||
<button
|
||||
class="btn-primary"
|
||||
disabled={sepaLoading || !sepaPreview || sepaPreview.mitglieder.length === 0}
|
||||
onclick={sepaExportieren}
|
||||
>
|
||||
XML herunterladen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.page-header {
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; }
|
||||
.btn-primary {
|
||||
background: #1e40af; color: #fff; border: none;
|
||||
border-radius: 8px; padding: 0.5rem 1rem;
|
||||
font-size: 0.9rem; font-weight: 600;
|
||||
|
||||
.hinweis {
|
||||
background: #fef9c3;
|
||||
border: 1px solid #fde047;
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
color: #713f12;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.hint { color: #94a3b8; font-size: 0.95rem; text-align: center; margin-top: 3rem; }
|
||||
|
||||
.liste {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.karte {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.9rem 1rem;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.karte-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
}
|
||||
.karte-name { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
|
||||
.karte-beschr { font-size: 0.78rem; color: #94a3b8; }
|
||||
.karte-meta { font-size: 0.82rem; color: #475569; }
|
||||
|
||||
.karte-aktionen {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.btn-sepa {
|
||||
padding: 0.35rem 0.7rem;
|
||||
background: #e0e7ff;
|
||||
color: #1e40af;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-sepa:hover:not(:disabled) { background: #c7d2fe; }
|
||||
.btn-sepa:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
|
||||
.btn-icon {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: none;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
color: #64748b;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, color 0.15s;
|
||||
}
|
||||
.btn-icon:hover { border-color: #94a3b8; color: #1e293b; }
|
||||
.btn-icon-red:hover { border-color: #fca5a5; color: #dc2626; }
|
||||
|
||||
/* Overlay & Sheet */
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
padding: 1rem;
|
||||
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.sheet {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 1.5rem;
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
max-height: 90dvh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
h2 { font-size: 1.1rem; font-weight: 700; color: #1e293b; margin-bottom: 0.25rem; }
|
||||
.sepa-sub { font-size: 0.85rem; color: #64748b; margin-bottom: 1.25rem; }
|
||||
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
.field-hint { font-size: 0.75rem; color: #94a3b8; }
|
||||
|
||||
input, select {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
input:focus, select:focus { outline: none; border-color: #1e40af; }
|
||||
|
||||
.sepa-summary {
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
.sepa-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0.65rem 1rem;
|
||||
font-size: 0.9rem;
|
||||
color: #1e293b;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
.sepa-row:last-child { border-bottom: none; }
|
||||
.sepa-warn { color: #92400e; background: #fffbeb; }
|
||||
.sepa-total { font-weight: 700; background: #f0f9ff; }
|
||||
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
|
||||
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
|
||||
.btn-ghost {
|
||||
padding: 0.75rem 1rem;
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
}
|
||||
.placeholder { color: #94a3b8; font-size: 0.95rem; }
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -3,35 +3,70 @@
|
|||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Mitglied, Gruppe } from '$lib/types';
|
||||
|
||||
const id = $derived($page.params.id);
|
||||
const id = $derived($page.params.id as string);
|
||||
|
||||
let gruppen = $state<any[]>([]);
|
||||
let vorname = $state('');
|
||||
let nachname = $state('');
|
||||
let email = $state('');
|
||||
let iban = $state('');
|
||||
let status = $state('aktiv');
|
||||
let gruppe_ids = $state<string[]>([]);
|
||||
let gruppen = $state<Gruppe[]>([]);
|
||||
let loading = $state(true);
|
||||
let saving = $state(false);
|
||||
let error = $state('');
|
||||
let editMode = $state(false);
|
||||
let showDelete = $state(false);
|
||||
|
||||
// Felder
|
||||
let vorname = $state('');
|
||||
let nachname = $state('');
|
||||
let email = $state('');
|
||||
let telefon = $state('');
|
||||
let geburtsdatum = $state('');
|
||||
let status = $state('aktiv');
|
||||
let eintrittsdatum = $state('');
|
||||
let austrittsdatum = $state('');
|
||||
let strasse = $state('');
|
||||
let plz = $state('');
|
||||
let ort = $state('');
|
||||
let iban = $state('');
|
||||
let bic = $state('');
|
||||
let mandatsreferenz = $state('');
|
||||
let mandatsdatum = $state('');
|
||||
let notizen = $state('');
|
||||
let gruppe_ids = $state<string[]>([]);
|
||||
|
||||
function pbDateToInput(val: string | undefined): string {
|
||||
// PocketBase gibt "2026-05-20 00:00:00.000Z" zurück, input[type=date] braucht "2026-05-20"
|
||||
if (!val) return '';
|
||||
return val.slice(0, 10);
|
||||
}
|
||||
|
||||
function loadRecord(m: Mitglied) {
|
||||
vorname = m.vorname;
|
||||
nachname = m.nachname;
|
||||
email = m.email ?? '';
|
||||
telefon = m.telefon ?? '';
|
||||
geburtsdatum = pbDateToInput(m.geburtsdatum);
|
||||
status = m.status;
|
||||
eintrittsdatum = pbDateToInput(m.eintrittsdatum);
|
||||
austrittsdatum = pbDateToInput(m.austrittsdatum);
|
||||
strasse = m.strasse ?? '';
|
||||
plz = m.plz ?? '';
|
||||
ort = m.ort ?? '';
|
||||
iban = m.iban ?? '';
|
||||
bic = m.bic ?? '';
|
||||
mandatsreferenz = m.mandatsreferenz ?? '';
|
||||
mandatsdatum = pbDateToInput(m.mandatsdatum);
|
||||
notizen = m.notizen ?? '';
|
||||
gruppe_ids = m.gruppe_ids ?? [];
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
const [m, g] = await Promise.all([
|
||||
pb.collection('mitglieder').getOne(id),
|
||||
pb.collection('gruppen').getFullList({ sort: 'name' })
|
||||
pb.collection('mitglieder').getOne<Mitglied>(id),
|
||||
pb.collection('gruppen').getFullList<Gruppe>({ sort: 'name' }),
|
||||
]);
|
||||
vorname = m.vorname;
|
||||
nachname = m.nachname;
|
||||
email = m.email ?? '';
|
||||
iban = m.iban ?? '';
|
||||
status = m.status;
|
||||
gruppe_ids = m.gruppe_ids ?? [];
|
||||
gruppen = g;
|
||||
loading = false;
|
||||
loadRecord(m);
|
||||
gruppen = g;
|
||||
loading = false;
|
||||
});
|
||||
|
||||
function toggleGruppe(gid: string) {
|
||||
|
|
@ -41,16 +76,26 @@
|
|||
}
|
||||
|
||||
async function speichern() {
|
||||
error = '';
|
||||
saving = true;
|
||||
error = ''; saving = true;
|
||||
try {
|
||||
await pb.collection('mitglieder').update(id, {
|
||||
vorname: vorname.trim(),
|
||||
nachname: nachname.trim(),
|
||||
email: email.trim(),
|
||||
iban: iban.trim(),
|
||||
vorname: vorname.trim(),
|
||||
nachname: nachname.trim(),
|
||||
email: email.trim() || null,
|
||||
telefon: telefon.trim() || null,
|
||||
geburtsdatum: geburtsdatum || null,
|
||||
status,
|
||||
gruppe_ids
|
||||
eintrittsdatum: eintrittsdatum || null,
|
||||
austrittsdatum: austrittsdatum || null,
|
||||
strasse: strasse.trim() || null,
|
||||
plz: plz.trim() || null,
|
||||
ort: ort.trim() || null,
|
||||
iban: iban.trim() || null,
|
||||
bic: bic.trim() || null,
|
||||
mandatsreferenz: mandatsreferenz.trim() || null,
|
||||
mandatsdatum: mandatsdatum || null,
|
||||
notizen: notizen.trim() || null,
|
||||
gruppe_ids,
|
||||
});
|
||||
editMode = false;
|
||||
} catch (e: unknown) {
|
||||
|
|
@ -70,15 +115,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
function gruppenName(ids: string[]) {
|
||||
function gruppenName(ids: string[]): string {
|
||||
return (ids ?? [])
|
||||
.map(gid => gruppen.find(g => g.id === gid)?.name)
|
||||
.filter(Boolean)
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
function formatDatum(iso: string): string {
|
||||
if (!iso) return '—';
|
||||
return new Date(iso).toLocaleDateString('de-DE');
|
||||
}
|
||||
|
||||
const statusFarbe: Record<string, string> = {
|
||||
aktiv: '#16a34a', passiv: '#f59e0b', ausgetreten: '#94a3b8'
|
||||
aktiv: '#16a34a', passiv: '#f59e0b', ausgetreten: '#94a3b8',
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
@ -87,7 +137,7 @@
|
|||
<div class="top">
|
||||
<a class="back" href="/mitglieder">← Mitglieder</a>
|
||||
{#if !loading}
|
||||
<button class="edit-btn" onclick={() => editMode = !editMode}>
|
||||
<button class="edit-btn" onclick={() => { editMode = !editMode; error = ''; }}>
|
||||
{editMode ? 'Abbrechen' : 'Bearbeiten'}
|
||||
</button>
|
||||
{/if}
|
||||
|
|
@ -98,99 +148,223 @@
|
|||
|
||||
{:else if !editMode}
|
||||
<!-- Detailansicht -->
|
||||
<div class="card">
|
||||
<div class="hero">
|
||||
<div class="avatar-lg">{vorname[0]}{nachname[0]}</div>
|
||||
<h1>{vorname} {nachname}</h1>
|
||||
<span class="status-badge" style="color:{statusFarbe[status] ?? '#94a3b8'}">
|
||||
{status}
|
||||
</span>
|
||||
<span class="status-badge" style="color:{statusFarbe[status] ?? '#94a3b8'}">{status}</span>
|
||||
</div>
|
||||
|
||||
<div class="detail-list">
|
||||
<div class="detail-block">
|
||||
<h2>Kontakt</h2>
|
||||
{#if email}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">E-Mail</span>
|
||||
<a href="mailto:{email}" class="detail-value link">{email}</a>
|
||||
<div class="row-detail">
|
||||
<span class="dl">E-Mail</span>
|
||||
<a href="mailto:{email}" class="dv link">{email}</a>
|
||||
</div>
|
||||
{/if}
|
||||
{#if iban}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">IBAN</span>
|
||||
<span class="detail-value mono">{iban}</span>
|
||||
{#if telefon}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Telefon</span>
|
||||
<a href="tel:{telefon}" class="dv link">{telefon}</a>
|
||||
</div>
|
||||
{/if}
|
||||
{#if gruppe_ids?.length > 0}
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">Gruppen</span>
|
||||
<span class="detail-value">{gruppenName(gruppe_ids)}</span>
|
||||
{#if strasse || plz || ort}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Adresse</span>
|
||||
<span class="dv">{[strasse, [plz, ort].filter(Boolean).join(' ')].filter(Boolean).join(', ')}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if !email && !telefon && !strasse}
|
||||
<p class="leer">Keine Kontaktdaten hinterlegt.</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="detail-block">
|
||||
<h2>Mitgliedschaft</h2>
|
||||
{#if eintrittsdatum}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Eintritt</span>
|
||||
<span class="dv">{formatDatum(eintrittsdatum)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if geburtsdatum}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Geburtsdatum</span>
|
||||
<span class="dv">{formatDatum(geburtsdatum)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if austrittsdatum}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Austritt</span>
|
||||
<span class="dv">{formatDatum(austrittsdatum)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if gruppe_ids?.length}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Gruppen</span>
|
||||
<span class="dv">{gruppenName(gruppe_ids)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if iban || bic || mandatsreferenz}
|
||||
<div class="detail-block">
|
||||
<h2>SEPA-Lastschrift</h2>
|
||||
{#if iban}
|
||||
<div class="row-detail">
|
||||
<span class="dl">IBAN</span>
|
||||
<span class="dv mono">{iban}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if bic}
|
||||
<div class="row-detail">
|
||||
<span class="dl">BIC</span>
|
||||
<span class="dv mono">{bic}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if mandatsreferenz}
|
||||
<div class="row-detail">
|
||||
<span class="dl">Mandat</span>
|
||||
<span class="dv mono">{mandatsreferenz}{mandatsdatum ? ' · ' + formatDatum(mandatsdatum) : ''}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if notizen}
|
||||
<div class="detail-block">
|
||||
<h2>Notizen</h2>
|
||||
<p class="notiz-text">{notizen}</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<button class="btn-delete" onclick={() => showDelete = true}>Mitglied löschen</button>
|
||||
|
||||
{:else}
|
||||
<!-- Bearbeitungsformular -->
|
||||
<form onsubmit={(e) => { e.preventDefault(); speichern(); }}>
|
||||
<div class="row">
|
||||
|
||||
<section>
|
||||
<h2>Stammdaten</h2>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="vorname">Vorname *</label>
|
||||
<input id="vorname" type="text" bind:value={vorname} required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nachname">Nachname *</label>
|
||||
<input id="nachname" type="text" bind:value={nachname} required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" bind:value={status}>
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="passiv">Passiv</option>
|
||||
<option value="ausgetreten">Ausgetreten</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="geburtsdatum">Geburtsdatum</label>
|
||||
<input id="geburtsdatum" type="date" bind:value={geburtsdatum} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="eintrittsdatum">Eintrittsdatum</label>
|
||||
<input id="eintrittsdatum" type="date" bind:value={eintrittsdatum} />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="austrittsdatum">Austrittsdatum</label>
|
||||
<input id="austrittsdatum" type="date" bind:value={austrittsdatum} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Kontakt</h2>
|
||||
<div class="field">
|
||||
<label for="vorname">Vorname *</label>
|
||||
<input id="vorname" type="text" bind:value={vorname} required />
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" type="email" bind:value={email} />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nachname">Nachname *</label>
|
||||
<input id="nachname" type="text" bind:value={nachname} required />
|
||||
<label for="telefon">Telefon</label>
|
||||
<input id="telefon" type="tel" bind:value={telefon} />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="strasse">Straße & Hausnummer</label>
|
||||
<input id="strasse" type="text" bind:value={strasse} />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="field" style="flex: 0 0 5rem">
|
||||
<label for="plz">PLZ</label>
|
||||
<input id="plz" type="text" inputmode="numeric" bind:value={plz} />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ort">Ort</label>
|
||||
<input id="ort" type="text" bind:value={ort} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" type="email" bind:value={email} />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="iban">IBAN</label>
|
||||
<input id="iban" type="text" bind:value={iban} />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" bind:value={status}>
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="passiv">Passiv</option>
|
||||
<option value="ausgetreten">Ausgetreten</option>
|
||||
</select>
|
||||
</div>
|
||||
<section>
|
||||
<h2>SEPA-Lastschrift</h2>
|
||||
<div class="field">
|
||||
<label for="iban">IBAN</label>
|
||||
<input id="iban" type="text" bind:value={iban} placeholder="DE12 3456 7890 …" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="bic">BIC</label>
|
||||
<input id="bic" type="text" bind:value={bic} placeholder="COBADEFFXXX" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="mandatsreferenz">Mandatsreferenz</label>
|
||||
<input id="mandatsreferenz" type="text" bind:value={mandatsreferenz} placeholder="automatisch" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="mandatsdatum">Mandatsdatum</label>
|
||||
<input id="mandatsdatum" type="date" bind:value={mandatsdatum} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if gruppen.length > 0}
|
||||
<div class="field">
|
||||
<label>Gruppen</label>
|
||||
<section>
|
||||
<h2>Gruppen</h2>
|
||||
<div class="checkboxes">
|
||||
{#each gruppen as g (g.id)}
|
||||
<label class="check-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={gruppe_ids.includes(g.id)}
|
||||
onchange={() => toggleGruppe(g.id)}
|
||||
/>
|
||||
<label class="check-label" class:active={gruppe_ids.includes(g.id)}>
|
||||
<input type="checkbox" checked={gruppe_ids.includes(g.id)} onchange={() => toggleGruppe(g.id)} />
|
||||
{g.name}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<section>
|
||||
<h2>Notizen</h2>
|
||||
<div class="field">
|
||||
<label for="notizen">Interne Notizen</label>
|
||||
<textarea id="notizen" bind:value={notizen} rows="3"></textarea>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
|
||||
<button type="submit" class="btn-primary" disabled={saving || !vorname || !nachname}>
|
||||
{saving ? 'Speichern…' : 'Änderungen speichern'}
|
||||
</button>
|
||||
<div class="actions" style="margin-bottom:5rem">
|
||||
<button type="submit" class="btn-primary" disabled={saving || !vorname || !nachname}>
|
||||
{saving ? 'Speichern…' : 'Änderungen speichern'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
<!-- Lösch-Bestätigung -->
|
||||
<!-- Lösch-Dialog -->
|
||||
{#if showDelete}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="dialog">
|
||||
|
|
@ -205,166 +379,125 @@
|
|||
{/if}
|
||||
|
||||
<style>
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
|
||||
.back { font-size: 0.9rem; color: #1e40af; text-decoration: none; }
|
||||
.edit-btn {
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
padding: 0.4rem 0.85rem;
|
||||
font-size: 0.875rem;
|
||||
color: #475569;
|
||||
cursor: pointer;
|
||||
}
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
padding: 1.5rem 1rem;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.avatar-lg {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
border-radius: 50%;
|
||||
background: #e0e7ff;
|
||||
color: #1e40af;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: 700;
|
||||
font-size: 1.3rem;
|
||||
text-transform: uppercase;
|
||||
background: none; border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
padding: 0.4rem 0.85rem; font-size: 0.875rem; color: #475569; cursor: pointer;
|
||||
}
|
||||
h1 { font-size: 1.3rem; font-weight: 700; color: #1e293b; }
|
||||
.hint { color: #94a3b8; text-align: center; margin-top: 3rem; }
|
||||
|
||||
.hero {
|
||||
display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
|
||||
padding: 1.5rem 1rem; background: #fff;
|
||||
border: 1px solid #e2e8f0; border-radius: 12px; margin-bottom: 1rem;
|
||||
}
|
||||
.avatar-lg {
|
||||
width: 4rem; height: 4rem; border-radius: 50%;
|
||||
background: #e0e7ff; color: #1e40af;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-weight: 700; font-size: 1.3rem; text-transform: uppercase;
|
||||
}
|
||||
.status-badge { font-size: 0.8rem; font-weight: 600; text-transform: capitalize; }
|
||||
.detail-list {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 1.5rem;
|
||||
|
||||
.detail-block {
|
||||
background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
|
||||
overflow: hidden; margin-bottom: 0.75rem; padding: 0.75rem 1rem;
|
||||
}
|
||||
.detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.85rem 1rem;
|
||||
.detail-block h2 {
|
||||
font-size: 0.72rem; font-weight: 700; color: #94a3b8;
|
||||
text-transform: uppercase; letter-spacing: 0.06em;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
.row-detail {
|
||||
display: flex; justify-content: space-between; align-items: baseline;
|
||||
gap: 1rem; padding: 0.45rem 0;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
gap: 1rem;
|
||||
}
|
||||
.detail-row:last-child { border-bottom: none; }
|
||||
.detail-label { font-size: 0.85rem; color: #94a3b8; flex-shrink: 0; }
|
||||
.detail-value { font-size: 0.9rem; color: #1e293b; text-align: right; }
|
||||
.detail-value.link { color: #1e40af; text-decoration: none; }
|
||||
.detail-value.mono { font-family: monospace; font-size: 0.85rem; }
|
||||
.row-detail:last-child { border-bottom: none; }
|
||||
.dl { font-size: 0.82rem; color: #94a3b8; flex-shrink: 0; }
|
||||
.dv { font-size: 0.88rem; color: #1e293b; text-align: right; }
|
||||
.dv.link { color: #1e40af; text-decoration: none; }
|
||||
.dv.mono { font-family: monospace; font-size: 0.82rem; }
|
||||
.leer { font-size: 0.85rem; color: #94a3b8; }
|
||||
.notiz-text { font-size: 0.875rem; color: #475569; white-space: pre-wrap; }
|
||||
|
||||
.btn-delete {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
background: none;
|
||||
border: 1.5px solid #fca5a5;
|
||||
border-radius: 8px;
|
||||
color: #dc2626;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
width: 100%; padding: 0.75rem; background: none;
|
||||
border: 1.5px solid #fca5a5; border-radius: 8px;
|
||||
color: #dc2626; font-size: 0.9rem; cursor: pointer;
|
||||
transition: background 0.15s; margin-bottom: 5rem;
|
||||
}
|
||||
.btn-delete:hover { background: #fef2f2; }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
input, select {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
background: #fff;
|
||||
transition: border-color 0.15s;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
/* Formular */
|
||||
section {
|
||||
margin-bottom: 1.5rem; padding-bottom: 1.5rem;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
input:focus, select:focus { outline: none; border-color: #1e40af; }
|
||||
section:last-of-type { border-bottom: none; }
|
||||
section h2 {
|
||||
font-size: 0.72rem; font-weight: 700; color: #94a3b8;
|
||||
text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.85rem;
|
||||
}
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
|
||||
input, select, textarea {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
font-size: 1rem; background: #fff; width: 100%;
|
||||
box-sizing: border-box; font-family: inherit; resize: vertical;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
input:focus, select:focus, textarea:focus { outline: none; border-color: #1e40af; }
|
||||
|
||||
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
||||
.check-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
display: flex; align-items: center; gap: 0.4rem;
|
||||
padding: 0.4rem 0.75rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 20px;
|
||||
font-size: 0.875rem; cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.check-label:has(input:checked) { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label.active { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label input { display: none; }
|
||||
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 1rem; }
|
||||
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin-top: 0.5rem;
|
||||
transition: background 0.15s;
|
||||
flex: 1; padding: 0.75rem; background: #1e40af; color: #fff;
|
||||
border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
|
||||
cursor: pointer; transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
.hint { color: #94a3b8; text-align: center; margin-top: 3rem; }
|
||||
.btn-ghost {
|
||||
padding: 0.75rem 1rem; background: none;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
font-size: 1rem; color: #64748b; cursor: pointer;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
padding: 1rem;
|
||||
position: fixed; inset: 0; background: rgba(0,0,0,0.4);
|
||||
display: flex; align-items: flex-end; justify-content: center;
|
||||
z-index: 100; padding: 1rem;
|
||||
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
.dialog {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 1.5rem;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
background: #fff; border-radius: 16px; padding: 1.5rem;
|
||||
width: 100%; max-width: 400px;
|
||||
}
|
||||
.dialog p { font-size: 1rem; color: #1e293b; margin-bottom: 0.5rem; }
|
||||
.dialog-sub { font-size: 0.875rem; color: #94a3b8; }
|
||||
.dialog-sub { font-size: 0.875rem !important; color: #94a3b8; }
|
||||
.dialog-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
|
||||
.btn-ghost {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 0.95rem;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-danger {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
flex: 1; padding: 0.75rem; background: #dc2626; color: #fff;
|
||||
border: none; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
|
||||
cursor: pointer; transition: background 0.15s;
|
||||
}
|
||||
.btn-danger:hover { background: #b91c1c; }
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -4,14 +4,31 @@
|
|||
import { onMount } from 'svelte';
|
||||
|
||||
let gruppen = $state<any[]>([]);
|
||||
let vorname = $state('');
|
||||
let nachname = $state('');
|
||||
let email = $state('');
|
||||
let iban = $state('');
|
||||
let status = $state('aktiv');
|
||||
let gruppe_ids = $state<string[]>([]);
|
||||
let error = $state('');
|
||||
let loading = $state(false);
|
||||
|
||||
// Stammdaten
|
||||
let vorname = $state('');
|
||||
let nachname = $state('');
|
||||
let email = $state('');
|
||||
let telefon = $state('');
|
||||
let geburtsdatum = $state('');
|
||||
let status = $state('aktiv');
|
||||
let eintrittsdatum = $state('');
|
||||
let gruppe_ids = $state<string[]>([]);
|
||||
let notizen = $state('');
|
||||
|
||||
// Adresse
|
||||
let strasse = $state('');
|
||||
let plz = $state('');
|
||||
let ort = $state('');
|
||||
|
||||
// SEPA
|
||||
let iban = $state('');
|
||||
let bic = $state('');
|
||||
let mandatsreferenz = $state('');
|
||||
let mandatsdatum = $state('');
|
||||
|
||||
let error = $state('');
|
||||
let loading = $state(false);
|
||||
|
||||
onMount(async () => {
|
||||
gruppen = await pb.collection('gruppen').getFullList({ sort: 'name' });
|
||||
|
|
@ -24,18 +41,27 @@
|
|||
}
|
||||
|
||||
async function speichern() {
|
||||
error = '';
|
||||
loading = true;
|
||||
error = ''; loading = true;
|
||||
try {
|
||||
const verein_id = (pb.authStore.record ?? pb.authStore.model)?.verein_id;
|
||||
const verein_id = pb.authStore.record?.verein_id as string;
|
||||
await pb.collection('mitglieder').create({
|
||||
verein_id,
|
||||
vorname: vorname.trim(),
|
||||
nachname: nachname.trim(),
|
||||
email: email.trim(),
|
||||
iban: iban.trim(),
|
||||
vorname: vorname.trim(),
|
||||
nachname: nachname.trim(),
|
||||
email: email.trim() || null,
|
||||
telefon: telefon.trim() || null,
|
||||
geburtsdatum: geburtsdatum || null,
|
||||
status,
|
||||
gruppe_ids
|
||||
eintrittsdatum: eintrittsdatum || null,
|
||||
strasse: strasse.trim() || null,
|
||||
plz: plz.trim() || null,
|
||||
ort: ort.trim() || null,
|
||||
iban: iban.trim() || null,
|
||||
bic: bic.trim() || null,
|
||||
mandatsreferenz: mandatsreferenz.trim() || null,
|
||||
mandatsdatum: mandatsdatum || null,
|
||||
notizen: notizen.trim() || null,
|
||||
gruppe_ids,
|
||||
});
|
||||
goto('/mitglieder');
|
||||
} catch (e: unknown) {
|
||||
|
|
@ -54,54 +80,117 @@
|
|||
</div>
|
||||
|
||||
<form onsubmit={(e) => { e.preventDefault(); speichern(); }}>
|
||||
<div class="row">
|
||||
|
||||
<section>
|
||||
<h2>Stammdaten</h2>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="vorname">Vorname *</label>
|
||||
<input id="vorname" type="text" bind:value={vorname} required autocomplete="given-name" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nachname">Nachname *</label>
|
||||
<input id="nachname" type="text" bind:value={nachname} required autocomplete="family-name" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" bind:value={status}>
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="passiv">Passiv</option>
|
||||
<option value="ausgetreten">Ausgetreten</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="geburtsdatum">Geburtsdatum</label>
|
||||
<input id="geburtsdatum" type="date" bind:value={geburtsdatum} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="eintrittsdatum">Eintrittsdatum</label>
|
||||
<input id="eintrittsdatum" type="date" bind:value={eintrittsdatum} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Kontakt</h2>
|
||||
<div class="field">
|
||||
<label for="vorname">Vorname *</label>
|
||||
<input id="vorname" type="text" bind:value={vorname} required autocomplete="given-name" />
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" type="email" bind:value={email} autocomplete="email" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nachname">Nachname *</label>
|
||||
<input id="nachname" type="text" bind:value={nachname} required autocomplete="family-name" />
|
||||
<label for="telefon">Telefon</label>
|
||||
<input id="telefon" type="tel" bind:value={telefon} autocomplete="tel" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" type="email" bind:value={email} autocomplete="email" />
|
||||
</div>
|
||||
<section>
|
||||
<h2>Adresse</h2>
|
||||
<div class="field">
|
||||
<label for="strasse">Straße & Hausnummer</label>
|
||||
<input id="strasse" type="text" bind:value={strasse} autocomplete="street-address" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="field" style="flex: 0 0 5rem">
|
||||
<label for="plz">PLZ</label>
|
||||
<input id="plz" type="text" inputmode="numeric" bind:value={plz} autocomplete="postal-code" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="ort">Ort</label>
|
||||
<input id="ort" type="text" bind:value={ort} autocomplete="address-level2" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="field">
|
||||
<label for="iban">IBAN</label>
|
||||
<input id="iban" type="text" bind:value={iban} placeholder="DE12 3456 7890 …" />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" bind:value={status}>
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="passiv">Passiv</option>
|
||||
<option value="ausgetreten">Ausgetreten</option>
|
||||
</select>
|
||||
</div>
|
||||
<section>
|
||||
<h2>SEPA-Lastschrift</h2>
|
||||
<div class="field">
|
||||
<label for="iban">IBAN</label>
|
||||
<input id="iban" type="text" bind:value={iban} placeholder="DE12 3456 7890 …" autocomplete="off" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="bic">BIC</label>
|
||||
<input id="bic" type="text" bind:value={bic} placeholder="COBADEFFXXX" autocomplete="off" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="mandatsreferenz">Mandatsreferenz</label>
|
||||
<input id="mandatsreferenz" type="text" bind:value={mandatsreferenz} placeholder="wird automatisch vergeben" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="mandatsdatum">Mandatsdatum</label>
|
||||
<input id="mandatsdatum" type="date" bind:value={mandatsdatum} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if gruppen.length > 0}
|
||||
<div class="field">
|
||||
<label>Gruppen</label>
|
||||
<section>
|
||||
<h2>Gruppen</h2>
|
||||
<div class="checkboxes">
|
||||
{#each gruppen as g (g.id)}
|
||||
<label class="check-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={gruppe_ids.includes(g.id)}
|
||||
onchange={() => toggleGruppe(g.id)}
|
||||
/>
|
||||
<label class="check-label" class:active={gruppe_ids.includes(g.id)}>
|
||||
<input type="checkbox" checked={gruppe_ids.includes(g.id)} onchange={() => toggleGruppe(g.id)} />
|
||||
{g.name}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<section>
|
||||
<h2>Notizen</h2>
|
||||
<div class="field">
|
||||
<label for="notizen">Interne Notizen</label>
|
||||
<textarea id="notizen" bind:value={notizen} rows="3" placeholder="Nur für Vorstand sichtbar"></textarea>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if error}
|
||||
<p class="error">{error}</p>
|
||||
{/if}
|
||||
|
|
@ -112,63 +201,59 @@
|
|||
{loading ? 'Speichern…' : 'Mitglied anlegen'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.top { margin-bottom: 1.25rem; }
|
||||
.back { font-size: 0.9rem; color: #1e40af; text-decoration: none; display: block; margin-bottom: 0.5rem; }
|
||||
h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
input, select {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
background: #fff;
|
||||
transition: border-color 0.15s;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
section {
|
||||
margin-bottom: 1.5rem;
|
||||
padding-bottom: 1.5rem;
|
||||
border-bottom: 1px solid #f1f5f9;
|
||||
}
|
||||
input:focus, select:focus { outline: none; border-color: #1e40af; }
|
||||
section:last-of-type { border-bottom: none; }
|
||||
h2 { font-size: 0.8rem; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.85rem; }
|
||||
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; }
|
||||
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
|
||||
input, select, textarea {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
font-size: 1rem; background: #fff; width: 100%;
|
||||
box-sizing: border-box; font-family: inherit; resize: vertical;
|
||||
transition: border-color 0.15s;
|
||||
}
|
||||
input:focus, select:focus, textarea:focus { outline: none; border-color: #1e40af; }
|
||||
|
||||
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
||||
.check-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
display: flex; align-items: center; gap: 0.4rem;
|
||||
padding: 0.4rem 0.75rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 20px;
|
||||
font-size: 0.875rem; cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.check-label:has(input:checked) { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label.active { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label input { display: none; }
|
||||
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
|
||||
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; margin-bottom: 5rem; }
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
transition: background 0.15s;
|
||||
flex: 1; padding: 0.75rem; background: #1e40af; color: #fff;
|
||||
border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
|
||||
cursor: pointer; transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
.btn-ghost {
|
||||
padding: 0.75rem 1rem;
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
color: #64748b;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
padding: 0.75rem 1rem; background: none;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
font-size: 1rem; color: #64748b; text-decoration: none; text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,27 +1,328 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Nachricht, Gruppe } from '$lib/types';
|
||||
|
||||
let nachrichten = $state<Nachricht[]>([]);
|
||||
let gruppen = $state<Gruppe[]>([]);
|
||||
let loading = $state(true);
|
||||
|
||||
// Formular
|
||||
let showForm = $state(false);
|
||||
let fBetreff = $state('');
|
||||
let fText = $state('');
|
||||
let fGruppeIds = $state<string[]>([]);
|
||||
let sending = $state(false);
|
||||
let sendError = $state('');
|
||||
let sendSuccess = $state('');
|
||||
|
||||
onMount(async () => {
|
||||
[nachrichten, gruppen] = await Promise.all([
|
||||
pb.collection('nachrichten').getFullList<Nachricht>({ sort: '-gesendet_am' }),
|
||||
pb.collection('gruppen').getFullList<Gruppe>({ sort: 'name' }),
|
||||
]);
|
||||
loading = false;
|
||||
});
|
||||
|
||||
function toggleGruppe(id: string) {
|
||||
fGruppeIds = fGruppeIds.includes(id)
|
||||
? fGruppeIds.filter((g) => g !== id)
|
||||
: [...fGruppeIds, id];
|
||||
}
|
||||
|
||||
function neueNachricht() {
|
||||
fBetreff = ''; fText = ''; fGruppeIds = [];
|
||||
sendError = ''; sendSuccess = ''; showForm = true;
|
||||
}
|
||||
|
||||
async function senden() {
|
||||
if (!fBetreff.trim() || !fText.trim()) {
|
||||
sendError = 'Betreff und Nachricht sind Pflichtfelder.';
|
||||
return;
|
||||
}
|
||||
sendError = ''; sending = true;
|
||||
|
||||
try {
|
||||
const verein_id = pb.authStore.record?.verein_id as string;
|
||||
const autor_id = pb.authStore.record?.id as string;
|
||||
|
||||
const record = await pb.collection('nachrichten').create<Nachricht>({
|
||||
verein_id,
|
||||
autor_id,
|
||||
betreff: fBetreff.trim(),
|
||||
text: fText.trim(),
|
||||
gruppe_ids: fGruppeIds,
|
||||
gesendet_am: new Date().toISOString(),
|
||||
});
|
||||
|
||||
nachrichten = [record, ...nachrichten];
|
||||
showForm = false;
|
||||
|
||||
// Push-Benachrichtigung an alle abonnierten Geräte im Verein
|
||||
fetch('/api/push/senden', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: pb.authStore.token,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
titel: fBetreff.trim(),
|
||||
body: fText.trim().slice(0, 120),
|
||||
url: '/nachrichten',
|
||||
}),
|
||||
}).catch(() => {});
|
||||
|
||||
sendSuccess = 'Nachricht wurde gespeichert und per E-Mail versendet.';
|
||||
} catch (e: unknown) {
|
||||
sendError = e instanceof Error ? e.message : 'Fehler beim Senden.';
|
||||
} finally {
|
||||
sending = false;
|
||||
}
|
||||
}
|
||||
|
||||
function formatDatum(iso: string | undefined): string {
|
||||
if (!iso) return '';
|
||||
return new Date(iso).toLocaleDateString('de-DE', {
|
||||
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit',
|
||||
});
|
||||
}
|
||||
|
||||
const gruppenLabel = (ids: string[]) =>
|
||||
ids.length === 0
|
||||
? 'Alle Mitglieder'
|
||||
: ids.map((id) => gruppen.find((g) => g.id === id)?.name ?? id).join(', ');
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Nachrichten — vereins.haus</title></svelte:head>
|
||||
|
||||
<div class="page-header">
|
||||
<div class="top">
|
||||
<h1>Nachrichten</h1>
|
||||
<button class="btn-primary">+ Nachricht</button>
|
||||
<button class="btn-primary" onclick={neueNachricht}>+ Nachricht</button>
|
||||
</div>
|
||||
|
||||
<p class="placeholder">Nachrichten & Push-Benachrichtigungen — in Entwicklung</p>
|
||||
{#if sendSuccess}
|
||||
<div class="success">{sendSuccess}</div>
|
||||
{/if}
|
||||
|
||||
{#if loading}
|
||||
<p class="hint">Laden…</p>
|
||||
{:else if nachrichten.length === 0}
|
||||
<p class="hint">Noch keine Nachrichten versendet.</p>
|
||||
{:else}
|
||||
<ul class="liste">
|
||||
{#each nachrichten as n (n.id)}
|
||||
<li class="karte">
|
||||
<div class="karte-header">
|
||||
<span class="karte-betreff">{n.betreff}</span>
|
||||
<span class="karte-datum">{formatDatum(n.gesendet_am)}</span>
|
||||
</div>
|
||||
<span class="karte-meta">{gruppenLabel(n.gruppe_ids ?? [])}</span>
|
||||
{#if n.text}
|
||||
<p class="karte-vorschau">{n.text.slice(0, 120)}{n.text.length > 120 ? '…' : ''}</p>
|
||||
{/if}
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
<!-- Nachricht verfassen -->
|
||||
{#if showForm}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="sheet">
|
||||
<h2>Neue Nachricht</h2>
|
||||
|
||||
<form onsubmit={(e) => { e.preventDefault(); senden(); }}>
|
||||
<div class="field">
|
||||
<label for="fbetreff">Betreff *</label>
|
||||
<input id="fbetreff" type="text" bind:value={fBetreff} placeholder="Betreff" required />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="ftext">Nachricht *</label>
|
||||
<textarea id="ftext" bind:value={fText} rows="6" placeholder="Text der Nachricht…" required></textarea>
|
||||
</div>
|
||||
|
||||
{#if gruppen.length > 0}
|
||||
<div class="field">
|
||||
<span class="field-label">Empfänger</span>
|
||||
<div class="checkboxes">
|
||||
<label class="check-label alle" class:active={fGruppeIds.length === 0}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={fGruppeIds.length === 0}
|
||||
onchange={() => (fGruppeIds = [])}
|
||||
/>
|
||||
Alle Mitglieder
|
||||
</label>
|
||||
{#each gruppen as g (g.id)}
|
||||
<label class="check-label" class:active={fGruppeIds.includes(g.id)}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={fGruppeIds.includes(g.id)}
|
||||
onchange={() => toggleGruppe(g.id)}
|
||||
/>
|
||||
{g.name}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<p class="versand-info">
|
||||
Die Nachricht wird an alle aktiven Mitglieder
|
||||
{fGruppeIds.length > 0 ? 'der gewählten Gruppen' : ''}
|
||||
mit hinterlegter E-Mail-Adresse gesendet.
|
||||
</p>
|
||||
|
||||
{#if sendError}
|
||||
<p class="error">{sendError}</p>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<button type="button" class="btn-ghost" onclick={() => (showForm = false)}>
|
||||
Abbrechen
|
||||
</button>
|
||||
<button type="submit" class="btn-primary" disabled={sending}>
|
||||
{sending ? 'Senden…' : 'Senden'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.page-header {
|
||||
.top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; }
|
||||
.btn-primary {
|
||||
background: #1e40af; color: #fff; border: none;
|
||||
border-radius: 8px; padding: 0.5rem 1rem;
|
||||
font-size: 0.9rem; font-weight: 600;
|
||||
|
||||
.success {
|
||||
background: #dcfce7;
|
||||
border: 1px solid #86efac;
|
||||
border-radius: 8px;
|
||||
padding: 0.75rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
color: #166534;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.hint { color: #94a3b8; font-size: 0.95rem; text-align: center; margin-top: 3rem; }
|
||||
|
||||
.liste { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
|
||||
|
||||
.karte {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
padding: 0.9rem 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.karte-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.karte-betreff { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
|
||||
.karte-datum { font-size: 0.75rem; color: #94a3b8; flex-shrink: 0; }
|
||||
.karte-meta { font-size: 0.78rem; color: #64748b; }
|
||||
.karte-vorschau { font-size: 0.85rem; color: #475569; margin: 0; }
|
||||
|
||||
/* Sheet */
|
||||
.overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
padding: 1rem;
|
||||
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
.sheet {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 1.5rem;
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
max-height: 92dvh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
h2 { font-size: 1.1rem; font-weight: 700; color: #1e293b; margin-bottom: 1rem; }
|
||||
|
||||
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
|
||||
label, .field-label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
|
||||
input, textarea {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
transition: border-color 0.15s;
|
||||
font-family: inherit;
|
||||
resize: vertical;
|
||||
}
|
||||
input:focus, textarea:focus { outline: none; border-color: #1e40af; }
|
||||
|
||||
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.25rem; }
|
||||
.check-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
padding: 0.35rem 0.7rem;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 20px;
|
||||
font-size: 0.82rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.check-label.active { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label input { display: none; }
|
||||
|
||||
.versand-info {
|
||||
font-size: 0.8rem;
|
||||
color: #94a3b8;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
|
||||
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
padding: 0.75rem;
|
||||
background: #1e40af;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
|
||||
.btn-ghost {
|
||||
padding: 0.75rem 1rem;
|
||||
background: none;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
font-size: 1rem;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
}
|
||||
.placeholder { color: #94a3b8; font-size: 0.95rem; }
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,27 +1,395 @@
|
|||
<script lang="ts">
|
||||
import { pb } from '$lib/pb';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Termin, Gruppe } from '$lib/types';
|
||||
|
||||
let termine = $state<Termin[]>([]);
|
||||
let gruppen = $state<Gruppe[]>([]);
|
||||
let loading = $state(true);
|
||||
|
||||
// Formular
|
||||
let showForm = $state(false);
|
||||
let editId = $state<string | null>(null);
|
||||
let fTitel = $state('');
|
||||
let fBeschr = $state('');
|
||||
let fBeginn = $state('');
|
||||
let fEnde = $state('');
|
||||
let fOrt = $state('');
|
||||
let fGruppeIds = $state<string[]>([]);
|
||||
let saving = $state(false);
|
||||
let formError = $state('');
|
||||
|
||||
let showDelete = $state<string | null>(null);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const upcoming = $derived(
|
||||
termine
|
||||
.filter(t => new Date(t.beginn) >= now)
|
||||
.sort((a, b) => new Date(a.beginn).getTime() - new Date(b.beginn).getTime())
|
||||
);
|
||||
const vergangen = $derived(
|
||||
termine
|
||||
.filter(t => new Date(t.beginn) < now)
|
||||
.sort((a, b) => new Date(b.beginn).getTime() - new Date(a.beginn).getTime())
|
||||
);
|
||||
|
||||
onMount(async () => {
|
||||
[termine, gruppen] = await Promise.all([
|
||||
pb.collection('termine').getFullList<Termin>({ sort: 'beginn' }),
|
||||
pb.collection('gruppen').getFullList<Gruppe>({ sort: 'name' }),
|
||||
]);
|
||||
loading = false;
|
||||
});
|
||||
|
||||
function toLocal(iso: string | undefined): string {
|
||||
if (!iso) return '';
|
||||
const d = new Date(iso);
|
||||
// datetime-local format: YYYY-MM-DDTHH:MM
|
||||
return new Date(d.getTime() - d.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
|
||||
}
|
||||
|
||||
function fromLocal(local: string): string {
|
||||
return local ? new Date(local).toISOString() : '';
|
||||
}
|
||||
|
||||
function neuerTermin() {
|
||||
editId = null;
|
||||
fTitel = ''; fBeschr = ''; fBeginn = ''; fEnde = ''; fOrt = ''; fGruppeIds = [];
|
||||
formError = ''; showForm = true;
|
||||
}
|
||||
|
||||
function bearbeiten(t: Termin) {
|
||||
editId = t.id;
|
||||
fTitel = t.titel;
|
||||
fBeschr = t.beschreibung ?? '';
|
||||
fBeginn = toLocal(t.beginn);
|
||||
fEnde = toLocal(t.ende);
|
||||
fOrt = t.ort ?? '';
|
||||
fGruppeIds = t.gruppe_ids ?? [];
|
||||
formError = ''; showForm = true;
|
||||
}
|
||||
|
||||
async function speichern() {
|
||||
if (!fTitel.trim() || !fBeginn) {
|
||||
formError = 'Titel und Beginn sind Pflichtfelder.';
|
||||
return;
|
||||
}
|
||||
formError = ''; saving = true;
|
||||
try {
|
||||
const vid = pb.authStore.record?.verein_id as string;
|
||||
const data = {
|
||||
verein_id: vid,
|
||||
titel: fTitel.trim(),
|
||||
beschreibung: fBeschr.trim() || null,
|
||||
beginn: fromLocal(fBeginn),
|
||||
ende: fEnde ? fromLocal(fEnde) : null,
|
||||
ort: fOrt.trim() || null,
|
||||
gruppe_ids: fGruppeIds,
|
||||
};
|
||||
if (editId) {
|
||||
const updated = await pb.collection('termine').update<Termin>(editId, data);
|
||||
termine = termine.map(t => t.id === editId ? updated : t);
|
||||
} else {
|
||||
const neu = await pb.collection('termine').create<Termin>(data);
|
||||
termine = [...termine, neu];
|
||||
}
|
||||
showForm = false;
|
||||
} catch (e: unknown) {
|
||||
formError = e instanceof Error ? e.message : 'Fehler beim Speichern.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loeschen(id: string) {
|
||||
await pb.collection('termine').delete(id);
|
||||
termine = termine.filter(t => t.id !== id);
|
||||
showDelete = null;
|
||||
}
|
||||
|
||||
function toggleGruppe(id: string) {
|
||||
fGruppeIds = fGruppeIds.includes(id)
|
||||
? fGruppeIds.filter(g => g !== id)
|
||||
: [...fGruppeIds, id];
|
||||
}
|
||||
|
||||
function formatDatum(iso: string): string {
|
||||
return new Date(iso).toLocaleDateString('de-DE', {
|
||||
weekday: 'short', day: '2-digit', month: 'long', year: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
function formatZeit(iso: string): string {
|
||||
return new Date(iso).toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
|
||||
function gruppenLabel(ids: string[]): string {
|
||||
if (!ids?.length) return '';
|
||||
return ids.map(id => gruppen.find(g => g.id === id)?.name).filter(Boolean).join(', ');
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head><title>Termine — vereins.haus</title></svelte:head>
|
||||
|
||||
<div class="page-header">
|
||||
<div class="top">
|
||||
<h1>Termine</h1>
|
||||
<button class="btn-primary">+ Termin</button>
|
||||
<button class="btn-primary" onclick={neuerTermin}>+ Termin</button>
|
||||
</div>
|
||||
|
||||
<p class="placeholder">Terminkalender — in Entwicklung</p>
|
||||
{#if loading}
|
||||
<p class="hint">Laden…</p>
|
||||
{:else if termine.length === 0}
|
||||
<p class="hint">Noch keine Termine – lege den ersten an!</p>
|
||||
{:else}
|
||||
{#if upcoming.length > 0}
|
||||
<ul class="liste">
|
||||
{#each upcoming as t (t.id)}
|
||||
<li class="karte">
|
||||
<div class="karte-datum-col">
|
||||
<span class="tag">{new Date(t.beginn).toLocaleDateString('de-DE', { weekday: 'short' })}</span>
|
||||
<span class="tag-zahl">{new Date(t.beginn).getDate()}</span>
|
||||
<span class="monat">{new Date(t.beginn).toLocaleDateString('de-DE', { month: 'short' })}</span>
|
||||
</div>
|
||||
<div class="karte-info">
|
||||
<span class="karte-titel">{t.titel}</span>
|
||||
<span class="karte-meta">
|
||||
{formatZeit(t.beginn)}{t.ende ? ' – ' + formatZeit(t.ende) : ''}{t.ort ? ' · ' + t.ort : ''}
|
||||
</span>
|
||||
{#if t.gruppe_ids?.length}
|
||||
<span class="karte-gruppen">{gruppenLabel(t.gruppe_ids)}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="karte-aktionen">
|
||||
<button class="btn-icon" onclick={() => bearbeiten(t)} title="Bearbeiten">✎</button>
|
||||
<button class="btn-icon btn-icon-red" onclick={() => showDelete = t.id} title="Löschen">✕</button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
{#if vergangen.length > 0}
|
||||
<details class="vergangen">
|
||||
<summary>Vergangene Termine ({vergangen.length})</summary>
|
||||
<ul class="liste vergangen-liste">
|
||||
{#each vergangen as t (t.id)}
|
||||
<li class="karte karte-grau">
|
||||
<div class="karte-datum-col">
|
||||
<span class="tag">{new Date(t.beginn).toLocaleDateString('de-DE', { weekday: 'short' })}</span>
|
||||
<span class="tag-zahl">{new Date(t.beginn).getDate()}</span>
|
||||
<span class="monat">{new Date(t.beginn).toLocaleDateString('de-DE', { month: 'short' })}</span>
|
||||
</div>
|
||||
<div class="karte-info">
|
||||
<span class="karte-titel">{t.titel}</span>
|
||||
<span class="karte-meta">{formatDatum(t.beginn)}{t.ort ? ' · ' + t.ort : ''}</span>
|
||||
</div>
|
||||
<div class="karte-aktionen">
|
||||
<button class="btn-icon btn-icon-red" onclick={() => showDelete = t.id} title="Löschen">✕</button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</details>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<!-- Termin-Formular -->
|
||||
{#if showForm}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="sheet">
|
||||
<h2>{editId ? 'Termin bearbeiten' : 'Neuer Termin'}</h2>
|
||||
|
||||
<form onsubmit={(e) => { e.preventDefault(); speichern(); }}>
|
||||
<div class="field">
|
||||
<label for="ftitel">Titel *</label>
|
||||
<input id="ftitel" type="text" bind:value={fTitel} placeholder="z. B. Jahreshauptversammlung" required />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="field">
|
||||
<label for="fbeginn">Beginn *</label>
|
||||
<input id="fbeginn" type="datetime-local" bind:value={fBeginn} required />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="fende">Ende</label>
|
||||
<input id="fende" type="datetime-local" bind:value={fEnde} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="fort">Ort</label>
|
||||
<input id="fort" type="text" bind:value={fOrt} placeholder="z. B. Vereinsheim" />
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="fbeschr">Beschreibung</label>
|
||||
<textarea id="fbeschr" bind:value={fBeschr} rows="3" placeholder="Optional"></textarea>
|
||||
</div>
|
||||
|
||||
{#if gruppen.length > 0}
|
||||
<div class="field">
|
||||
<span class="field-label">Für Gruppen</span>
|
||||
<div class="checkboxes">
|
||||
{#each gruppen as g (g.id)}
|
||||
<label class="check-label" class:active={fGruppeIds.includes(g.id)}>
|
||||
<input type="checkbox" checked={fGruppeIds.includes(g.id)} onchange={() => toggleGruppe(g.id)} />
|
||||
{g.name}
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if formError}
|
||||
<p class="error">{formError}</p>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<button type="button" class="btn-ghost" onclick={() => showForm = false}>Abbrechen</button>
|
||||
<button type="submit" class="btn-primary" disabled={saving}>
|
||||
{saving ? 'Speichern…' : 'Speichern'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Lösch-Bestätigung -->
|
||||
{#if showDelete}
|
||||
<div class="overlay" role="dialog" aria-modal="true">
|
||||
<div class="dialog">
|
||||
<p>Termin wirklich löschen?</p>
|
||||
<p class="dialog-sub">Diese Aktion kann nicht rückgängig gemacht werden.</p>
|
||||
<div class="dialog-actions">
|
||||
<button class="btn-ghost" onclick={() => showDelete = null}>Abbrechen</button>
|
||||
<button class="btn-danger" onclick={() => loeschen(showDelete!)}>Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
|
||||
h1 { font-size: 1.4rem; font-weight: 700; color: #1e293b; }
|
||||
.btn-primary {
|
||||
background: #1e40af; color: #fff; border: none;
|
||||
border-radius: 8px; padding: 0.5rem 1rem;
|
||||
font-size: 0.9rem; font-weight: 600;
|
||||
.hint { color: #94a3b8; font-size: 0.95rem; text-align: center; margin-top: 3rem; }
|
||||
|
||||
.liste { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
|
||||
|
||||
.karte {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 0.75rem;
|
||||
padding: 0.85rem 1rem;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.placeholder { color: #94a3b8; font-size: 0.95rem; }
|
||||
.karte-grau { background: #f8fafc; opacity: 0.75; }
|
||||
|
||||
.karte-datum-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
min-width: 2.2rem;
|
||||
padding-top: 0.1rem;
|
||||
}
|
||||
.tag { font-size: 0.65rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; }
|
||||
.tag-zahl { font-size: 1.4rem; font-weight: 700; color: #1e40af; line-height: 1.1; }
|
||||
.monat { font-size: 0.65rem; color: #94a3b8; text-transform: uppercase; }
|
||||
|
||||
.karte-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
|
||||
.karte-titel { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
|
||||
.karte-meta { font-size: 0.78rem; color: #64748b; }
|
||||
.karte-gruppen { font-size: 0.72rem; color: #94a3b8; }
|
||||
|
||||
.karte-aktionen { display: flex; gap: 0.35rem; flex-shrink: 0; }
|
||||
|
||||
.btn-icon {
|
||||
width: 1.9rem; height: 1.9rem;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
background: none; border: 1px solid #e2e8f0; border-radius: 6px;
|
||||
color: #64748b; font-size: 0.85rem; cursor: pointer;
|
||||
transition: border-color 0.15s, color 0.15s;
|
||||
}
|
||||
.btn-icon:hover { border-color: #94a3b8; color: #1e293b; }
|
||||
.btn-icon-red:hover { border-color: #fca5a5; color: #dc2626; }
|
||||
|
||||
.vergangen { margin-top: 0.5rem; }
|
||||
.vergangen summary {
|
||||
font-size: 0.85rem; color: #94a3b8; cursor: pointer;
|
||||
padding: 0.5rem 0; list-style: none; user-select: none;
|
||||
}
|
||||
.vergangen-liste { margin-top: 0.5rem; }
|
||||
|
||||
/* Sheet & Overlay */
|
||||
.overlay {
|
||||
position: fixed; inset: 0;
|
||||
background: rgba(0,0,0,0.4);
|
||||
display: flex; align-items: flex-end; justify-content: center;
|
||||
z-index: 100; padding: 1rem;
|
||||
padding-bottom: calc(1rem + env(safe-area-inset-bottom));
|
||||
}
|
||||
.sheet {
|
||||
background: #fff; border-radius: 16px; padding: 1.5rem;
|
||||
width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto;
|
||||
}
|
||||
h2 { font-size: 1.1rem; font-weight: 700; color: #1e293b; margin-bottom: 1rem; }
|
||||
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
|
||||
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
|
||||
label, .field-label { font-size: 0.875rem; font-weight: 500; color: #475569; }
|
||||
|
||||
input, textarea {
|
||||
padding: 0.65rem 0.85rem;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
font-size: 1rem; background: #fff; width: 100%;
|
||||
box-sizing: border-box; font-family: inherit;
|
||||
transition: border-color 0.15s; resize: vertical;
|
||||
}
|
||||
input:focus, textarea:focus { outline: none; border-color: #1e40af; }
|
||||
|
||||
.checkboxes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.2rem; }
|
||||
.check-label {
|
||||
display: flex; align-items: center; gap: 0.35rem;
|
||||
padding: 0.35rem 0.7rem;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 20px;
|
||||
font-size: 0.82rem; cursor: pointer;
|
||||
transition: border-color 0.15s, background 0.15s;
|
||||
}
|
||||
.check-label.active { border-color: #1e40af; background: #e0e7ff; color: #1e40af; }
|
||||
.check-label input { display: none; }
|
||||
|
||||
.error { color: #dc2626; font-size: 0.875rem; margin-bottom: 0.75rem; }
|
||||
|
||||
.actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
|
||||
|
||||
.btn-primary {
|
||||
flex: 1; padding: 0.75rem; background: #1e40af; color: #fff;
|
||||
border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
|
||||
cursor: pointer; transition: background 0.15s;
|
||||
}
|
||||
.btn-primary:hover:not(:disabled) { background: #1d3a9e; }
|
||||
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
|
||||
|
||||
.btn-ghost {
|
||||
padding: 0.75rem 1rem; background: none;
|
||||
border: 1.5px solid #e2e8f0; border-radius: 8px;
|
||||
font-size: 1rem; color: #64748b; cursor: pointer;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
background: #fff; border-radius: 16px; padding: 1.5rem;
|
||||
width: 100%; max-width: 400px;
|
||||
}
|
||||
.dialog p { font-size: 1rem; color: #1e293b; margin-bottom: 0.4rem; font-weight: 600; }
|
||||
.dialog-sub { font-size: 0.875rem; color: #94a3b8; font-weight: 400 !important; }
|
||||
.dialog-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
|
||||
.btn-danger {
|
||||
flex: 1; padding: 0.75rem; background: #dc2626; color: #fff;
|
||||
border: none; border-radius: 8px; font-size: 0.95rem; font-weight: 600;
|
||||
cursor: pointer; transition: background 0.15s;
|
||||
}
|
||||
.btn-danger:hover { background: #b91c1c; }
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue