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:
rene 2026-05-20 13:01:11 +02:00
parent c2c4dfd518
commit 77c6f513b5
32 changed files with 3012 additions and 399 deletions

View file

@ -65,7 +65,7 @@ deploy: check-ssh
@COPYFILE_DISABLE=1 tar czf - $(TAR_EXCLUDE) . | ssh $(DS_HOST) "tar xzf - -C $(DS_PATH)/"
@echo "→ .env auf DS aktualisieren..."
@if [ -f .env ]; then \
grep -E "BREVO_KEY" .env | ssh $(DS_HOST) "cat > $(DS_PATH)/.env"; \
cat .env | ssh $(DS_HOST) "cat > $(DS_PATH)/.env"; \
fi
@echo "→ PocketBase Hooks synchronisieren..."
@if ls $(HOOKS_SRC)/*.pb.js 2>/dev/null | grep -q .; then \

188
app/package-lock.json generated
View file

@ -8,17 +8,21 @@
"name": "vereinshaus",
"version": "0.1.0",
"dependencies": {
"pocketbase": "^0.26.9"
"pocketbase": "^0.26.9",
"web-push": "^3.6.7"
},
"devDependencies": {
"@sveltejs/adapter-node": "^5.5.4",
"@sveltejs/kit": "^2.57.0",
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@types/web-push": "^3.6.4",
"svelte": "^5.55.2",
"svelte-check": "^4.4.6",
"typescript": "^6.0.2",
"vite": "^8.0.7",
"vite-plugin-pwa": "^1.3.0"
"vite-plugin-pwa": "^1.3.0",
"workbox-core": "^7.4.1",
"workbox-precaching": "^7.4.1"
}
},
"node_modules/@apideck/better-ajv-errors": {
@ -2639,6 +2643,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
"version": "25.9.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.1.tgz",
"integrity": "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": ">=7.24.0 <7.24.7"
}
},
"node_modules/@types/resolve": {
"version": "1.20.2",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz",
@ -2653,6 +2667,16 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/web-push": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/@types/web-push/-/web-push-3.6.4.tgz",
"integrity": "sha512-GnJmSr40H3RAnj0s34FNTcJi1hmWFV5KXugE0mYWnYhgTAHLJ/dJKAwDmvPJYMke0RplY2XE9LnM4hqSqKIjhQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/acorn": {
"version": "8.16.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
@ -2666,6 +2690,15 @@
"node": ">=0.4.0"
}
},
"node_modules/agent-base": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",
"integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==",
"license": "MIT",
"engines": {
"node": ">= 14"
}
},
"node_modules/ajv": {
"version": "8.20.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
@ -2732,6 +2765,18 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/asn1.js": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
"integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==",
"license": "MIT",
"dependencies": {
"bn.js": "^4.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"safer-buffer": "^2.1.0"
}
},
"node_modules/async": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
@ -2850,6 +2895,12 @@
"node": ">=6.0.0"
}
},
"node_modules/bn.js": {
"version": "4.12.3",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.3.tgz",
"integrity": "sha512-fGTi3gxV/23FTYdAoUtLYp6qySe2KE3teyZitipKNRuVYcBkoP/bB3guXN/XVKUe9mxCHXnc9C4ocyz8OmgN0g==",
"license": "MIT"
},
"node_modules/brace-expansion": {
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
@ -2897,6 +2948,12 @@
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
}
},
"node_modules/buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
"license": "BSD-3-Clause"
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@ -3139,7 +3196,6 @@
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
@ -3231,6 +3287,15 @@
"node": ">= 0.4"
}
},
"node_modules/ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"license": "Apache-2.0",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/ejs": {
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
@ -3879,6 +3944,28 @@
"node": ">= 0.4"
}
},
"node_modules/http_ece": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http_ece/-/http_ece-1.2.0.tgz",
"integrity": "sha512-JrF8SSLVmcvc5NducxgyOrKXe3EsyHMgBFgSaIUGmArKe+rwr0uphRkRXvwiom3I+fpIfoItveHrfudL8/rxuA==",
"license": "MIT",
"engines": {
"node": ">=16"
}
},
"node_modules/https-proxy-agent": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz",
"integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==",
"license": "MIT",
"dependencies": {
"agent-base": "^7.1.2",
"debug": "4"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/idb": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz",
@ -3886,6 +3973,12 @@
"dev": true,
"license": "ISC"
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/internal-slot": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",
@ -4421,6 +4514,27 @@
"node": ">=0.10.0"
}
},
"node_modules/jwa": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz",
"integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==",
"license": "MIT",
"dependencies": {
"buffer-equal-constant-time": "^1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jws": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz",
"integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==",
"license": "MIT",
"dependencies": {
"jwa": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/kleur": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz",
@ -4753,6 +4867,12 @@
"node": ">= 0.4"
}
},
"node_modules/minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
"license": "ISC"
},
"node_modules/minimatch": {
"version": "10.2.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz",
@ -4769,6 +4889,15 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/minipass": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
@ -4803,7 +4932,6 @@
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"dev": true,
"license": "MIT"
},
"node_modules/nanoid": {
@ -5311,6 +5439,26 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safe-push-apply": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz",
@ -5346,6 +5494,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
@ -6022,6 +6176,13 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/undici-types": {
"version": "7.24.6",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
"dev": true,
"license": "MIT"
},
"node_modules/unicode-canonical-property-names-ecmascript": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz",
@ -6260,6 +6421,25 @@
}
}
},
"node_modules/web-push": {
"version": "3.6.7",
"resolved": "https://registry.npmjs.org/web-push/-/web-push-3.6.7.tgz",
"integrity": "sha512-OpiIUe8cuGjrj3mMBFWY+e4MMIkW3SVT+7vEIjvD9kejGUypv8GPDf84JdPWskK8zMRIJ6xYGm+Kxr8YkPyA0A==",
"license": "MPL-2.0",
"dependencies": {
"asn1.js": "^5.3.0",
"http_ece": "1.2.0",
"https-proxy-agent": "^7.0.0",
"jws": "^4.0.0",
"minimist": "^1.2.5"
},
"bin": {
"web-push": "src/cli.js"
},
"engines": {
"node": ">= 16"
}
},
"node_modules/webidl-conversions": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",

View file

@ -15,13 +15,17 @@
"@sveltejs/adapter-node": "^5.5.4",
"@sveltejs/kit": "^2.57.0",
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@types/web-push": "^3.6.4",
"svelte": "^5.55.2",
"svelte-check": "^4.4.6",
"typescript": "^6.0.2",
"vite": "^8.0.7",
"vite-plugin-pwa": "^1.3.0"
"vite-plugin-pwa": "^1.3.0",
"workbox-core": "^7.4.1",
"workbox-precaching": "^7.4.1"
},
"dependencies": {
"pocketbase": "^0.26.9"
"pocketbase": "^0.26.9",
"web-push": "^3.6.7"
}
}

View file

@ -0,0 +1,20 @@
<script lang="ts">
import { icons, type IconName } from '$lib/icons';
let { name, size = 24, class: cls = '' }: { name: IconName; size?: number; class?: string } = $props();
</script>
<span
class="ph-icon {cls}"
style="width:{size}px;height:{size}px;display:inline-flex;align-items:center;justify-content:center;"
aria-hidden="true"
>
{@html icons[name]}
</span>
<style>
.ph-icon :global(svg) {
width: 100%;
height: 100%;
}
</style>

15
app/src/lib/icons.ts Normal file
View file

@ -0,0 +1,15 @@
import house from './icons/house.svg?raw';
import users from './icons/users.svg?raw';
import calendar from './icons/calendar.svg?raw';
import currencyEur from './icons/currency-eur.svg?raw';
import envelope from './icons/envelope.svg?raw';
export const icons = {
house,
users,
calendar,
'currency-eur': currencyEur,
envelope,
} as const;
export type IconName = keyof typeof icons;

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><rect x="40" y="40" width="176" height="176" rx="8" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="176" y1="24" x2="176" y2="56" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="80" y1="24" x2="80" y2="56" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="40" y1="88" x2="216" y2="88" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><polyline points="88 128 104 120 104 184" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><path d="M138.14,128a16,16,0,1,1,26.64,17.63L136,184h32" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>

After

Width:  |  Height:  |  Size: 980 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><line x1="40" y1="112" x2="136" y2="112" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="40" y1="144" x2="120" y2="144" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><path d="M184,197.67A72,72,0,0,1,64,144V112A72,72,0,0,1,184,58.33" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>

After

Width:  |  Height:  |  Size: 561 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><polyline points="224 56 128 144 32 56" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><path d="M32,56H224a0,0,0,0,1,0,0V192a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56A0,0,0,0,1,32,56Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="110.55" y1="128" x2="34.47" y2="197.74" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="221.53" y1="197.74" x2="145.45" y2="128" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>

After

Width:  |  Height:  |  Size: 743 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><path d="M104,216V152h48v64h64V120a8,8,0,0,0-2.34-5.66l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,40,120v96Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>

After

Width:  |  Height:  |  Size: 321 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><circle cx="84" cy="108" r="52" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><path d="M10.23,200a88,88,0,0,1,147.54,0" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><path d="M172,160a87.93,87.93,0,0,1,73.77,40" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><path d="M152.69,59.7A52,52,0,1,1,172,160" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>

After

Width:  |  Height:  |  Size: 675 B

109
app/src/lib/sepa.ts Normal file
View file

@ -0,0 +1,109 @@
export interface SepaKopf {
glaeubigerid: string;
vereinIban: string;
vereinBic: string;
vereinName: string;
einzugsdatum: string; // YYYY-MM-DD
}
export interface SepaPosition {
endToEndId: string;
betrag: number;
mandatsreferenz: string;
mandatsdatum: string; // YYYY-MM-DD
debitorName: string;
debitorIban: string;
debitorBic: string;
verwendungszweck: string;
}
function x(str: string): string {
return str
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
}
function iban(raw: string): string {
return raw.replace(/\s/g, '').toUpperCase();
}
export function generatePain008(kopf: SepaKopf, positionen: SepaPosition[]): string {
if (positionen.length === 0) throw new Error('Keine Positionen für den SEPA-Export.');
const now = new Date().toISOString().slice(0, 19);
const msgId = `VH-${Date.now()}`;
const ctrlSum = positionen.reduce((s, p) => s + p.betrag, 0).toFixed(2);
const nbOfTxs = positionen.length;
const txXml = positionen.map((p) => `
<DrctDbtTxInf>
<PmtId><EndToEndId>${x(p.endToEndId)}</EndToEndId></PmtId>
<InstdAmt Ccy="EUR">${p.betrag.toFixed(2)}</InstdAmt>
<DrctDbtTx>
<MndtRltdInf>
<MndtId>${x(p.mandatsreferenz)}</MndtId>
<DtOfSgntr>${p.mandatsdatum}</DtOfSgntr>
</MndtRltdInf>
<CdtrSchmeId><Id><PrvtId><Othr>
<Id>${x(kopf.glaeubigerid)}</Id>
<SchmeNm><Prtry>SEPA</Prtry></SchmeNm>
</Othr></PrvtId></Id></CdtrSchmeId>
</DrctDbtTx>
<DbtrAgt><FinInstnId>${p.debitorBic ? `<BIC>${x(p.debitorBic)}</BIC>` : '<Othr><Id>NOTPROVIDED</Id></Othr>'}</FinInstnId></DbtrAgt>
<Dbtr><Nm>${x(p.debitorName)}</Nm></Dbtr>
<DbtrAcct><Id><IBAN>${iban(p.debitorIban)}</IBAN></Id></DbtrAcct>
<RmtInf><Ustrd>${x(p.verwendungszweck.slice(0, 140))}</Ustrd></RmtInf>
</DrctDbtTxInf>`).join('');
return `<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.003.02"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CstmrDrctDbtInitn>
<GrpHdr>
<MsgId>${msgId}</MsgId>
<CreDtTm>${now}</CreDtTm>
<NbOfTxs>${nbOfTxs}</NbOfTxs>
<CtrlSum>${ctrlSum}</CtrlSum>
<InitgPty><Nm>${x(kopf.vereinName)}</Nm></InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>${msgId}-PI</PmtInfId>
<PmtMtd>DD</PmtMtd>
<NbOfTxs>${nbOfTxs}</NbOfTxs>
<CtrlSum>${ctrlSum}</CtrlSum>
<PmtTpInf>
<SvcLvl><Cd>SEPA</Cd></SvcLvl>
<LclInstrm><Cd>CORE</Cd></LclInstrm>
<SeqTp>RCUR</SeqTp>
</PmtTpInf>
<ReqdColltnDt>${kopf.einzugsdatum}</ReqdColltnDt>
<Cdtr><Nm>${x(kopf.vereinName)}</Nm></Cdtr>
<CdtrAcct><Id><IBAN>${iban(kopf.vereinIban)}</IBAN></Id></CdtrAcct>
<CdtrAgt><FinInstnId><BIC>${x(kopf.vereinBic)}</BIC></FinInstnId></CdtrAgt>
<CdtrSchmeId><Id><PrvtId><Othr>
<Id>${x(kopf.glaeubigerid)}</Id>
<SchmeNm><Prtry>SEPA</Prtry></SchmeNm>
</Othr></PrvtId></Id></CdtrSchmeId>${txXml}
</PmtInf>
</CstmrDrctDbtInitn>
</Document>`;
}
export function downloadXml(xml: string, dateiname: string) {
const blob = new Blob([xml], { type: 'application/xml;charset=utf-8' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = dateiname;
a.click();
URL.revokeObjectURL(url);
}
export function minEinzugsdatum(): string {
// SEPA CORE RCUR: mindestens 2 Bankarbeitstage Vorlaufzeit (vereinfacht: +3 Tage)
const d = new Date();
d.setDate(d.getDate() + 3);
return d.toISOString().slice(0, 10);
}

View file

@ -1,18 +1,20 @@
export type Plan = 'free' | 'starter' | 'wachstum' | 'verband';
export type MitgliedStatus = 'aktiv' | 'passiv' | 'ausgetreten';
export type EinzugStatus = 'ausstehend' | 'eingezogen' | 'fehlgeschlagen';
export type Rhythmus = 'monatlich' | 'quartalsweise' | 'halbjaehrlich' | 'jaehrlich';
export type EinzugStatus = 'ausstehend' | 'eingezogen' | 'fehlgeschlagen' | 'storniert';
export type Rhythmus = 'monatlich' | 'quartalsweise' | 'halbjaehrlich' | 'jaehrlich' | 'einmalig';
export interface Verein {
id: string;
name: string;
adresse: string;
plz: string;
ort: string;
bundesland: string;
adresse?: string;
plz?: string;
ort?: string;
bundesland?: string;
plan: Plan;
stripe_customer_id?: string;
dosb_mitglied: boolean;
glaeubigerid?: string;
iban?: string;
bic?: string;
}
export interface Mitglied {
@ -20,19 +22,21 @@ export interface Mitglied {
verein_id: string;
vorname: string;
nachname: string;
email: string;
email?: string;
telefon?: string;
geburtsdatum?: string;
eintrittsdatum: string;
eintrittsdatum?: string;
austrittsdatum?: string;
strasse: string;
plz: string;
ort: string;
strasse?: string;
plz?: string;
ort?: string;
iban?: string;
bic?: string;
gruppe_ids: string[];
status: MitgliedStatus;
notizen?: string;
mandatsreferenz?: string;
mandatsdatum?: string;
}
export interface Gruppe {
@ -53,13 +57,11 @@ export interface Beitrag {
export interface Einzug {
id: string;
verein_id: string;
mitglied_id: string;
beitrag_id: string;
betrag: number;
faelligkeitsdatum: string;
faellig_am?: string;
status: EinzugStatus;
stripe_payment_intent_id?: string;
}
export interface Termin {
@ -80,5 +82,5 @@ export interface Nachricht {
betreff: string;
text: string;
gruppe_ids: string[];
gesendet_am: string;
gesendet_am?: string;
}

View file

@ -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;

View file

@ -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;

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -17,20 +17,9 @@
}
loading = true;
try {
const user = await pb.collection('users').create({
email,
password,
passwordConfirm,
name: vereinsname
});
await pb.collection('vereine').create({
name: vereinsname,
plan: 'free',
dosb_mitglied: false,
user_id: user.id
});
await pb.collection('users').create({ email, password, passwordConfirm, name: vereinsname });
await pb.collection('users').authWithPassword(email, password);
goto('/');
goto('/onboarding');
} catch (e: unknown) {
error = e instanceof Error ? e.message : 'Registrierung fehlgeschlagen.';
} finally {

View file

@ -0,0 +1,6 @@
import { json } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
export async function GET() {
return json({ publicKey: env.PUBLIC_VAPID_KEY ?? '' });
}

View file

@ -0,0 +1,57 @@
import { json } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
import webpush from 'web-push';
const PB_URL = () => env.PB_URL ?? 'http://localhost:8090';
export async function POST({ request }) {
const authHeader = request.headers.get('Authorization') ?? '';
const { titel, body, url = '/nachrichten' } = await request.json();
if (!titel) return json({ error: 'Titel fehlt.' }, { status: 400 });
const vapidPublic = env.PUBLIC_VAPID_KEY ?? '';
const vapidPrivate = env.VAPID_PRIVATE_KEY ?? '';
const vapidSubject = env.VAPID_SUBJECT ?? 'mailto:info@vereins.haus';
if (!vapidPublic || !vapidPrivate) {
return json({ error: 'VAPID-Keys nicht konfiguriert.' }, { status: 500 });
}
webpush.setVapidDetails(vapidSubject, vapidPublic, vapidPrivate);
// Alle Push-Subscriptions des Vereins laden (listRule erlaubt verein-weite Abfrage)
const subRes = await fetch(
`${PB_URL()}/api/collections/push_subscriptions/records?perPage=500`,
{ headers: { Authorization: authHeader } },
);
if (!subRes.ok) return json({ sent: 0 });
const { items } = await subRes.json();
if (!items?.length) return json({ sent: 0 });
const payload = JSON.stringify({ title: titel, body, url });
let sent = 0;
await Promise.allSettled(
items.map(async (sub: { endpoint: string; p256dh: string; auth: string; id: string }) => {
try {
await webpush.sendNotification(
{ endpoint: sub.endpoint, keys: { p256dh: sub.p256dh, auth: sub.auth } },
payload,
);
sent++;
} catch (err: unknown) {
// 410 Gone = Subscription abgelaufen → löschen
if ((err as { statusCode?: number }).statusCode === 410) {
await fetch(
`${PB_URL()}/api/collections/push_subscriptions/records/${sub.id}`,
{ method: 'DELETE', headers: { Authorization: authHeader } },
).catch(() => {});
}
}
}),
);
return json({ sent });
}

View file

@ -0,0 +1,67 @@
import { json } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
const PB_URL = () => env.PB_URL ?? 'http://localhost:8090';
export async function POST({ request }) {
const authHeader = request.headers.get('Authorization') ?? '';
const { subscription, userId } = await request.json();
if (!subscription?.endpoint || !userId) {
return json({ error: 'Ungültige Subscription.' }, { status: 400 });
}
// Alte Subscription dieses Users löschen (Gerätewechsel)
const listRes = await fetch(
`${PB_URL()}/api/collections/push_subscriptions/records?filter=user_id%3D"${userId}"&perPage=50`,
{ headers: { Authorization: authHeader } },
);
if (listRes.ok) {
const { items } = await listRes.json();
await Promise.all(
(items ?? []).map((r: { id: string }) =>
fetch(`${PB_URL()}/api/collections/push_subscriptions/records/${r.id}`, {
method: 'DELETE',
headers: { Authorization: authHeader },
}),
),
);
}
// Neue Subscription speichern
const res = await fetch(`${PB_URL()}/api/collections/push_subscriptions/records`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: authHeader },
body: JSON.stringify({
user_id: userId,
endpoint: subscription.endpoint,
p256dh: subscription.keys.p256dh,
auth: subscription.keys.auth,
}),
});
if (!res.ok) return json({ error: 'Fehler beim Speichern.' }, { status: 500 });
return json({ success: true });
}
export async function DELETE({ request }) {
const authHeader = request.headers.get('Authorization') ?? '';
const { userId } = await request.json();
const listRes = await fetch(
`${PB_URL()}/api/collections/push_subscriptions/records?filter=user_id%3D"${userId}"&perPage=50`,
{ headers: { Authorization: authHeader } },
);
if (!listRes.ok) return json({ success: true });
const { items } = await listRes.json();
await Promise.all(
(items ?? []).map((r: { id: string }) =>
fetch(`${PB_URL()}/api/collections/push_subscriptions/records/${r.id}`, {
method: 'DELETE',
headers: { Authorization: authHeader },
}),
),
);
return json({ success: true });
}

View file

@ -0,0 +1,331 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { onMount } from 'svelte';
import { pb } from '$lib/pb';
let schritt = $state(1);
let loading = $state(false);
let error = $state('');
// Formular
let vereinsname = $state('');
let ort = $state('');
let fertigName = $state('');
onMount(() => {
if (!pb.authStore.isValid) {
goto('/login');
return;
}
if (pb.authStore.record?.verein_id) {
goto('/');
}
// Vereinsname aus Registration vorbelegen
vereinsname = pb.authStore.record?.name ?? '';
});
async function vereinAnlegen() {
if (!vereinsname.trim()) return;
error = ''; loading = true;
try {
const verein = await pb.collection('vereine').create({
name: vereinsname.trim(),
ort: ort.trim() || null,
plan: 'free',
dosb_mitglied: false,
});
await pb.collection('users').update(pb.authStore.record!.id, {
verein_id: verein.id,
});
// Auth-Token aktualisieren damit verein_id im Record steht
await pb.collection('users').authRefresh();
fertigName = verein.name;
schritt = 3;
} catch (e: unknown) {
error = e instanceof Error ? e.message : 'Fehler beim Anlegen.';
} finally {
loading = false;
}
}
</script>
<svelte:head><title>Einrichtung — vereins.haus</title></svelte:head>
<div class="shell">
<div class="logo">vereins.haus</div>
<div class="card">
<!-- Fortschritt -->
<div class="dots">
{#each [1, 2, 3] as s}
<span class="dot" class:active={schritt >= s}></span>
{/each}
</div>
{#if schritt === 1}
<!-- Willkommen -->
<div class="step">
<div class="icon-ring">👋</div>
<h1>Schön, dass du dabei bist!</h1>
<p class="beschr">
vereins.haus hilft deinem Vorstand, Mitglieder, Termine und
Beiträge zu verwalten übersichtlich, mobil und ohne Excel.
</p>
<p class="beschr">
Die Einrichtung dauert weniger als eine Minute.
</p>
<button class="btn-primary" onclick={() => (schritt = 2)}>
Los geht's →
</button>
</div>
{:else if schritt === 2}
<!-- Verein anlegen -->
<div class="step">
<h1>Dein Verein</h1>
<p class="beschr">Wie heißt dein Verein? Du kannst alle Angaben später noch ändern.</p>
<form onsubmit={(e) => { e.preventDefault(); vereinAnlegen(); }}>
<div class="field">
<label for="vname">Name des Vereins *</label>
<input
id="vname"
type="text"
bind:value={vereinsname}
placeholder="z. B. TSV Musterstadt 1923"
required
/>
</div>
<div class="field">
<label for="vort">Ort</label>
<input
id="vort"
type="text"
bind:value={ort}
placeholder="z. B. Musterstadt"
/>
</div>
{#if error}
<p class="error">{error}</p>
{/if}
<div class="btn-row">
<button type="button" class="btn-ghost" onclick={() => (schritt = 1)}>
← Zurück
</button>
<button type="submit" class="btn-primary" disabled={loading || !vereinsname.trim()}>
{loading ? 'Anlegen…' : 'Weiter →'}
</button>
</div>
</form>
</div>
{:else}
<!-- Fertig -->
<div class="step">
<div class="icon-ring success"></div>
<h1>Alles bereit!</h1>
<p class="beschr">
<strong>{fertigName}"</strong> wurde eingerichtet. Du kannst jetzt loslegen.
</p>
<ul class="naechstes">
<li>
<span class="naechstes-icon">👤</span>
<div>
<strong>Mitglieder anlegen</strong>
<span>Namen, E-Mail und IBAN für den SEPA-Einzug</span>
</div>
</li>
<li>
<span class="naechstes-icon">💶</span>
<div>
<strong>Beitragsarten definieren</strong>
<span>Jahresbeitrag, Sonderumlage mit SEPA-Export</span>
</div>
</li>
<li>
<span class="naechstes-icon">📅</span>
<div>
<strong>Termine eintragen</strong>
<span>Versammlung, Training, Ausflug</span>
</div>
</li>
</ul>
<button class="btn-primary" onclick={() => goto('/')}>
Zum Dashboard →
</button>
</div>
{/if}
</div>
</div>
<style>
.shell {
min-height: 100dvh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 1.5rem 1rem;
background: #f8fafc;
}
.logo {
font-size: 1.2rem;
font-weight: 700;
color: #1e40af;
letter-spacing: -0.02em;
margin-bottom: 1.5rem;
}
.card {
background: #fff;
border: 1px solid #e2e8f0;
border-radius: 16px;
padding: 2rem 1.5rem;
width: 100%;
max-width: 420px;
}
.dots {
display: flex;
gap: 0.5rem;
justify-content: center;
margin-bottom: 1.75rem;
}
.dot {
width: 0.5rem;
height: 0.5rem;
border-radius: 50%;
background: #e2e8f0;
transition: background 0.3s;
}
.dot.active { background: #1e40af; }
.step {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.icon-ring {
width: 3.5rem;
height: 3.5rem;
border-radius: 50%;
background: #e0e7ff;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
margin: 0 auto 0.25rem;
}
.icon-ring.success {
background: #dcfce7;
color: #16a34a;
font-size: 1.6rem;
font-weight: 700;
}
h1 {
font-size: 1.3rem;
font-weight: 700;
color: #1e293b;
text-align: center;
margin: 0;
}
.beschr {
font-size: 0.9rem;
color: #64748b;
text-align: center;
line-height: 1.55;
margin: 0;
}
.field {
display: flex;
flex-direction: column;
gap: 0.3rem;
margin-bottom: 0.85rem;
}
label { font-size: 0.875rem; font-weight: 500; color: #475569; }
input {
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 { outline: none; border-color: #1e40af; }
.error { color: #dc2626; font-size: 0.875rem; margin: 0; }
.btn-row {
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;
}
.naechstes {
list-style: none;
padding: 0;
display: flex;
flex-direction: column;
gap: 0;
border: 1px solid #e2e8f0;
border-radius: 10px;
overflow: hidden;
margin: 0.25rem 0;
}
.naechstes li {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.75rem 1rem;
border-bottom: 1px solid #f1f5f9;
}
.naechstes li:last-child { border-bottom: none; }
.naechstes-icon { font-size: 1.1rem; flex-shrink: 0; }
.naechstes div {
display: flex;
flex-direction: column;
gap: 0.1rem;
}
.naechstes strong { font-size: 0.875rem; color: #1e293b; }
.naechstes span { font-size: 0.78rem; color: #94a3b8; }
</style>

45
app/src/sw.ts Normal file
View file

@ -0,0 +1,45 @@
/// <reference lib="webworker" />
import { cleanupOutdatedCaches, precacheAndRoute } from 'workbox-precaching';
import { registerRoute } from 'workbox-routing';
import { NetworkFirst } from 'workbox-strategies';
declare const self: ServiceWorkerGlobalScope;
cleanupOutdatedCaches();
precacheAndRoute(self.__WB_MANIFEST);
// PocketBase API: NetworkFirst (offline-fähig aus Cache)
registerRoute(
({ url }) => url.hostname === 'api.vereins.haus',
new NetworkFirst({
cacheName: 'pocketbase-api',
networkTimeoutSeconds: 5,
}),
);
self.addEventListener('push', (event) => {
const data = event.data?.json() ?? {};
const title = data.title ?? 'vereins.haus';
const options: NotificationOptions = {
body: data.body ?? '',
icon: '/icons/icon-192.png',
badge: '/icons/icon-192.png',
tag: data.tag ?? 'vereinshaus',
data: { url: data.url ?? '/nachrichten' },
};
event.waitUntil(self.registration.showNotification(title, options));
});
self.addEventListener('notificationclick', (event) => {
event.notification.close();
const url = (event.notification.data as { url: string })?.url ?? '/';
event.waitUntil(
self.clients
.matchAll({ type: 'window', includeUncontrolled: true })
.then((list) => {
const existing = list.find((c) => c.url.includes(url));
if (existing) return existing.focus();
return self.clients.openWindow(url);
}),
);
});

View file

@ -6,6 +6,9 @@ export default defineConfig({
plugins: [
sveltekit(),
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'sw.ts',
registerType: 'autoUpdate',
manifest: {
name: 'vereins.haus',
@ -21,19 +24,9 @@ export default defineConfig({
{ src: '/icons/apple-touch-icon.png', sizes: '180x180', type: 'image/png' }
]
},
workbox: {
injectManifest: {
globPatterns: ['**/*.{js,css,html,svg,png,ico}'],
runtimeCaching: [
{
urlPattern: /^https:\/\/api\.vereins\.haus\/.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'pocketbase-api',
expiration: { maxEntries: 100, maxAgeSeconds: 60 * 60 * 24 }
}
}
]
}
})
]
},
}),
],
});

View file

@ -14,6 +14,7 @@ services:
environment:
- TZ=Europe/Berlin
- BREVO_KEY=${BREVO_KEY}
- BREVO_SENDER=${BREVO_SENDER:-noreply@vereins.haus}
networks:
- default
- npm_bridge
@ -31,6 +32,10 @@ services:
- TZ=Europe/Berlin
- HOST=0.0.0.0
- PORT=3000
- PUBLIC_VAPID_KEY=${PUBLIC_VAPID_KEY}
- VAPID_PRIVATE_KEY=${VAPID_PRIVATE_KEY}
- VAPID_SUBJECT=${VAPID_SUBJECT:-mailto:info@vereins.haus}
- PB_URL=http://pocketbase:8090
networks:
- default
- npm_bridge

View file

@ -0,0 +1,86 @@
onRecordAfterCreateSuccess(function(e) {
if (!e.record) return;
var key = $os.getenv("BREVO_KEY");
if (!key) {
console.log("[nachrichten] BREVO_KEY nicht gesetzt E-Mail übersprungen.");
return;
}
var vereinId = e.record.getString("verein_id");
var betreff = e.record.getString("betreff");
var text = e.record.getString("text");
var gruppeIds = e.record.getStringSlice("gruppe_ids");
// Vereinsname für Absender
var vereinName = "Ihr Verein";
try {
var verein = $app.findRecordById("vereine", vereinId);
vereinName = verein.getString("name");
} catch(err) {}
// Mitglieder-Filter
var filter = 'verein_id = "' + vereinId + '" && status = "aktiv" && email != ""';
if (gruppeIds && gruppeIds.length > 0) {
var gruppenParts = [];
for (var i = 0; i < gruppeIds.length; i++) {
gruppenParts.push('gruppe_ids ~ "' + gruppeIds[i] + '"');
}
filter += " && (" + gruppenParts.join(" || ") + ")";
}
var mitglieder;
try {
mitglieder = $app.findRecordsByFilter("mitglieder", filter, "nachname", 500, 0);
} catch(err) {
console.error("[nachrichten] Mitglieder laden fehlgeschlagen: " + String(err));
return;
}
var empfaenger = [];
for (var j = 0; j < mitglieder.length; j++) {
var m = mitglieder[j];
var email = m.getString("email");
if (email) {
empfaenger.push({
email: email,
name: m.getString("vorname") + " " + m.getString("nachname")
});
}
}
if (empfaenger.length === 0) {
console.log("[nachrichten] Keine Empfänger mit E-Mail gefunden.");
return;
}
var sender = $os.getenv("BREVO_SENDER") || "noreply@vereins.haus";
var htmlContent = text
? text.replace(/\n/g, "<br>")
: "<p>(Kein Inhalt)</p>";
// In 50er-Batches senden (Brevo-Limit)
var BATCH = 50;
for (var b = 0; b < empfaenger.length; b += BATCH) {
var batch = empfaenger.slice(b, b + BATCH);
var body = JSON.stringify({
sender: { name: vereinName, email: sender },
to: [batch[0]],
bcc: batch.slice(1),
subject: betreff,
htmlContent: htmlContent
});
try {
$http.send({
url: "https://api.brevo.com/v3/smtp/email",
method: "POST",
headers: { "api-key": key, "Content-Type": "application/json" },
body: body
});
console.log("[nachrichten] Batch " + (b / BATCH + 1) + " gesendet (" + batch.length + " Empfänger).");
} catch(err) {
console.error("[nachrichten] Brevo Fehler Batch " + (b / BATCH + 1) + ": " + String(err));
}
}
}, "nachrichten");

View file

@ -0,0 +1,194 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
// vereine: +adresse, +dosb_mitglied; -stripe_customer_id
{
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.fields.removeById("text1888339527") // stripe_customer_id
c.fields.addAt(2, new Field({
"type": "text", "id": "text2001000001", "name": "adresse",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "bool", "id": "bool2001000002", "name": "dosb_mitglied",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false
}))
app.save(c)
}
// gruppen: +beschreibung
{
const c = app.findCollectionByNameOrId("pbc_3099069179")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000003", "name": "beschreibung",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// mitglieder: +telefon, geburtsdatum, eintrittsdatum, austrittsdatum, strasse, plz, ort, bic, notizen
{
const c = app.findCollectionByNameOrId("pbc_2707111162")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000010", "name": "telefon",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000011", "name": "geburtsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000012", "name": "eintrittsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000013", "name": "austrittsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000014", "name": "strasse",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000015", "name": "plz",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000016", "name": "ort",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000017", "name": "bic",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000018", "name": "notizen",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// beitraege: +beschreibung; rhythmus +halbjaehrlich (einmalig bleibt)
{
const c = app.findCollectionByNameOrId("pbc_3218207135")
const rhythmus = c.fields.getById("select917011370")
rhythmus.values = ["monatlich", "quartalsweise", "halbjaehrlich", "jaehrlich", "einmalig"]
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000020", "name": "beschreibung",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// einzuege: -stripe_payment_intent_id; status bezahlt→eingezogen
{
const c = app.findCollectionByNameOrId("pbc_659326735")
c.fields.removeById("text4235393406") // stripe_payment_intent_id
const status = c.fields.getById("select2063623452")
status.values = ["ausstehend", "eingezogen", "fehlgeschlagen", "storniert"]
app.save(c)
}
// termine: +beschreibung
{
const c = app.findCollectionByNameOrId("pbc_2279568741")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000030", "name": "beschreibung",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// nachrichten: +autor_id (relation zu users)
{
const c = app.findCollectionByNameOrId("pbc_1415911511")
c.fields.addAt(2, new Field({
"type": "relation", "id": "relation2001000040", "name": "autor_id",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"cascadeDelete": false, "collectionId": "_pb_users_auth_", "maxSelect": 1, "minSelect": 0
}))
app.save(c)
}
}, (app) => {
// vereine rollback
{
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.fields.removeById("text2001000001")
c.fields.removeById("bool2001000002")
c.fields.addAt(99, new Field({
"type": "text", "id": "text1888339527", "name": "stripe_customer_id",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// gruppen rollback
{
const c = app.findCollectionByNameOrId("pbc_3099069179")
c.fields.removeById("text2001000003")
app.save(c)
}
// mitglieder rollback
{
const c = app.findCollectionByNameOrId("pbc_2707111162")
for (const id of ["text2001000010","date2001000011","date2001000012","date2001000013",
"text2001000014","text2001000015","text2001000016","text2001000017","text2001000018"]) {
c.fields.removeById(id)
}
app.save(c)
}
// beitraege rollback
{
const c = app.findCollectionByNameOrId("pbc_3218207135")
const rhythmus = c.fields.getById("select917011370")
rhythmus.values = ["monatlich", "quartalsweise", "jaehrlich", "einmalig"]
c.fields.removeById("text2001000020")
app.save(c)
}
// einzuege rollback
{
const c = app.findCollectionByNameOrId("pbc_659326735")
const status = c.fields.getById("select2063623452")
status.values = ["ausstehend", "bezahlt", "fehlgeschlagen", "storniert"]
c.fields.addAt(99, new Field({
"type": "text", "id": "text4235393406", "name": "stripe_payment_intent_id",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// termine rollback
{
const c = app.findCollectionByNameOrId("pbc_2279568741")
c.fields.removeById("text2001000030")
app.save(c)
}
// nachrichten rollback
{
const c = app.findCollectionByNameOrId("pbc_1415911511")
c.fields.removeById("relation2001000040")
app.save(c)
}
})

View file

@ -0,0 +1,58 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
// vereine: +glaeubigerid, +iban, +bic (Vereinskonto für SEPA-Einzug)
{
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000050", "name": "glaeubigerid",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000051", "name": "iban",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000052", "name": "bic",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
app.save(c)
}
// mitglieder: +mandatsreferenz, +mandatsdatum (SEPA-Mandat des Mitglieds)
{
const c = app.findCollectionByNameOrId("pbc_2707111162")
c.fields.addAt(99, new Field({
"type": "text", "id": "text2001000053", "name": "mandatsreferenz",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"autogeneratePattern": "", "min": 0, "max": 0, "pattern": ""
}))
c.fields.addAt(99, new Field({
"type": "date", "id": "date2001000054", "name": "mandatsdatum",
"help": "", "hidden": false, "presentable": false, "required": false, "system": false,
"min": "", "max": ""
}))
app.save(c)
}
}, (app) => {
{
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.fields.removeById("text2001000050")
c.fields.removeById("text2001000051")
c.fields.removeById("text2001000052")
app.save(c)
}
{
const c = app.findCollectionByNameOrId("pbc_2707111162")
c.fields.removeById("text2001000053")
c.fields.removeById("date2001000054")
app.save(c)
}
})

View file

@ -0,0 +1,14 @@
/// <reference path="../pb_data/types.d.ts" />
// Erlaubt allen Usern desselben Vereins, die Subscriptions ihrer Vereinsmitglieder zu lesen
// (notwendig damit die /api/push/senden Route alle Geräte des Vereins erreicht)
migrate((app) => {
const c = app.findCollectionByNameOrId("pbc_1438754935") // push_subscriptions
c.listRule = '@request.auth.verein_id = user_id.verein_id'
c.viewRule = '@request.auth.id = user_id'
app.save(c)
}, (app) => {
const c = app.findCollectionByNameOrId("pbc_1438754935")
c.listRule = '@request.auth.id = user_id'
c.viewRule = '@request.auth.id = user_id'
app.save(c)
})

View file

@ -0,0 +1,11 @@
/// <reference path="../pb_data/types.d.ts" />
// Erlaubt eingeloggten Nutzern, einen Verein anzulegen (Onboarding)
migrate((app) => {
const c = app.findCollectionByNameOrId("pbc_3589557411") // vereine
c.createRule = "@request.auth.id != ''"
app.save(c)
}, (app) => {
const c = app.findCollectionByNameOrId("pbc_3589557411")
c.createRule = null
app.save(c)
})