feat: MyEasyCMS v2 — Full SaaS rebuild
Complete rebuild of 22-year-old PHP CMS as modern SaaS: Database (15 migrations, 42+ tables): - Foundation: account_settings, audit_log, GDPR register, cms_files - Module Engine: modules, fields, records, permissions, relations + RPC - Members: 45+ field member profiles, departments, roles, honors, SEPA mandates - Courses: courses, sessions, categories, instructors, locations, attendance - Bookings: rooms, guests, bookings with availability - Events: events, registrations, holiday passes - Finance: SEPA batches/items (pain.008/001 XML), invoices - Newsletter: campaigns, templates, recipients, subscriptions - Site Builder: site_pages (Puck JSON), site_settings, cms_posts - Portal Auth: member_portal_invitations, user linking Feature Packages (9): - @kit/module-builder — dynamic low-code CRUD engine - @kit/member-management — 31 API methods, 21 actions, 8 components - @kit/course-management, @kit/booking-management, @kit/event-management - @kit/finance — SEPA XML generator + IBAN validator - @kit/newsletter — campaigns + dispatch - @kit/document-generator — PDF/Excel/Word - @kit/site-builder — Puck visual editor, 15 blocks, public rendering Pages (60+): - Dashboard with real stats from all APIs - Full CRUD for all 8 domains with react-hook-form + Zod - Recharts statistics - German i18n throughout - Member portal with auth + invitation system - Public club websites via Puck at /club/[slug] Infrastructure: - Dockerfile (multi-stage, standalone output) - docker-compose.yml (Supabase self-hosted + Next.js) - Kong API gateway config - .env.production.example
This commit is contained in:
69
packages/features/member-management/src/lib/member-utils.ts
Normal file
69
packages/features/member-management/src/lib/member-utils.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Client-side utility functions for member display.
|
||||
*/
|
||||
|
||||
export function computeAge(dateOfBirth: string | null | undefined): number | null {
|
||||
if (!dateOfBirth) return null;
|
||||
const birth = new Date(dateOfBirth);
|
||||
const today = new Date();
|
||||
let age = today.getFullYear() - birth.getFullYear();
|
||||
const m = today.getMonth() - birth.getMonth();
|
||||
if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
|
||||
return age;
|
||||
}
|
||||
|
||||
export function computeMembershipYears(entryDate: string | null | undefined): number {
|
||||
if (!entryDate) return 0;
|
||||
const entry = new Date(entryDate);
|
||||
const today = new Date();
|
||||
let years = today.getFullYear() - entry.getFullYear();
|
||||
const m = today.getMonth() - entry.getMonth();
|
||||
if (m < 0 || (m === 0 && today.getDate() < entry.getDate())) years--;
|
||||
return Math.max(0, years);
|
||||
}
|
||||
|
||||
export function formatSalutation(salutation: string | null | undefined, firstName: string, lastName: string): string {
|
||||
if (salutation) return `${salutation} ${firstName} ${lastName}`;
|
||||
return `${firstName} ${lastName}`;
|
||||
}
|
||||
|
||||
export function formatAddress(member: Record<string, unknown>): string {
|
||||
const parts: string[] = [];
|
||||
if (member.street) {
|
||||
let line = String(member.street);
|
||||
if (member.house_number) line += ` ${member.house_number}`;
|
||||
parts.push(line);
|
||||
}
|
||||
if (member.street2) parts.push(String(member.street2));
|
||||
if (member.postal_code || member.city) {
|
||||
parts.push(`${member.postal_code ?? ''} ${member.city ?? ''}`.trim());
|
||||
}
|
||||
return parts.join(', ');
|
||||
}
|
||||
|
||||
export function formatIban(iban: string | null | undefined): string {
|
||||
if (!iban) return '—';
|
||||
const cleaned = iban.replace(/\s/g, '');
|
||||
return cleaned.replace(/(.{4})/g, '$1 ').trim();
|
||||
}
|
||||
|
||||
export function getMemberStatusColor(status: string): 'default' | 'secondary' | 'destructive' | 'outline' {
|
||||
switch (status) {
|
||||
case 'active': return 'default';
|
||||
case 'inactive': return 'secondary';
|
||||
case 'pending': return 'outline';
|
||||
case 'resigned':
|
||||
case 'excluded':
|
||||
case 'deceased': return 'destructive';
|
||||
default: return 'secondary';
|
||||
}
|
||||
}
|
||||
|
||||
export const STATUS_LABELS: Record<string, string> = {
|
||||
active: 'Aktiv',
|
||||
inactive: 'Inaktiv',
|
||||
pending: 'Ausstehend',
|
||||
resigned: 'Ausgetreten',
|
||||
excluded: 'Ausgeschlossen',
|
||||
deceased: 'Verstorben',
|
||||
};
|
||||
Reference in New Issue
Block a user