feat: wire 10 dead buttons across 6 modules to their server actions
Every module had buttons that rendered visually but did nothing when clicked. Server actions existed for all of them. Created client components with dialogs/forms and wired them in. BOOKINGS MODULE: - BookingStatusActions: Check-in/Check-out/Cancel buttons now call updateBookingStatus server action with loading states + toast - CreateRoomDialog: 'Neues Zimmer' opens dialog with room number, name, capacity, price/night fields → calls createRoom - CreateGuestDialog: 'Neuer Gast' opens dialog with first/last name, email, phone fields → calls createGuest COURSES MODULE: - EnrollParticipantDialog: 'Teilnehmer anmelden' on participants page opens dialog with first/last name, email, phone → calls enrollParticipant EVENTS MODULE: - EventRegistrationDialog: 'Anmeldung' button on event detail opens dialog with participant data + DOB → calls registerForEvent - CreateHolidayPassDialog: 'Neuer Ferienpass' opens dialog with name, year, description, price, date range → calls createHolidayPass NEWSLETTER MODULE: - CreateTemplateDialog: 'Neue Vorlage' opens dialog with name, subject, HTML body → calls createTemplate SITE-BUILDER MODULE: - Posts 'Neuer Beitrag' button now links to /posts/new page All dialogs use German labels, helpful placeholders, loading spinners, toast notifications, and form validation appropriate for association board members (Vereinsvorstände, 40-65, moderate tech skills).
This commit is contained in:
@@ -35,5 +35,8 @@
|
||||
"react": "catalog:",
|
||||
"react-hook-form": "catalog:",
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide-react": "catalog:"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
'use client';
|
||||
|
||||
import { useAction } from 'next-safe-action/hooks';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { Plus, Loader2 } from 'lucide-react';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@kit/ui/dialog';
|
||||
import { Input } from '@kit/ui/input';
|
||||
import { Label } from '@kit/ui/label';
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
|
||||
import { createHolidayPass } from '../server/actions/event-actions';
|
||||
|
||||
interface CreateHolidayPassDialogProps {
|
||||
accountId: string;
|
||||
}
|
||||
|
||||
export function CreateHolidayPassDialog({ accountId }: CreateHolidayPassDialogProps) {
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useState(false);
|
||||
const currentYear = new Date().getFullYear();
|
||||
const [form, setForm] = useState({ name: '', year: String(currentYear), description: '', price: '0', validFrom: '', validUntil: '' });
|
||||
|
||||
const action = useAction(createHolidayPass, {
|
||||
onSuccess: () => {
|
||||
toast.success('Ferienpass erstellt');
|
||||
setOpen(false);
|
||||
setForm({ name: '', year: String(currentYear), description: '', price: '0', validFrom: '', validUntil: '' });
|
||||
router.refresh();
|
||||
},
|
||||
onError: () => toast.error('Fehler beim Erstellen'),
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button><Plus className="mr-2 h-4 w-4" />Neuer Ferienpass</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Ferienpass erstellen</DialogTitle>
|
||||
<DialogDescription>Erstellen Sie einen neuen Ferienpass für Ihr Ferienprogramm.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>Name *</Label>
|
||||
<Input placeholder="z.B. Sommerferienprogramm" value={form.name} onChange={(e) => setForm(s => ({ ...s, name: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Jahr *</Label>
|
||||
<Input type="number" value={form.year} onChange={(e) => setForm(s => ({ ...s, year: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Beschreibung</Label>
|
||||
<Input placeholder="Optional" value={form.description} onChange={(e) => setForm(s => ({ ...s, description: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>Preis (€)</Label>
|
||||
<Input type="number" step="0.01" min="0" value={form.price} onChange={(e) => setForm(s => ({ ...s, price: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Gültig ab</Label>
|
||||
<Input type="date" value={form.validFrom} onChange={(e) => setForm(s => ({ ...s, validFrom: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Gültig bis</Label>
|
||||
<Input type="date" value={form.validUntil} onChange={(e) => setForm(s => ({ ...s, validUntil: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setOpen(false)}>Abbrechen</Button>
|
||||
<Button
|
||||
onClick={() => action.execute({
|
||||
accountId,
|
||||
name: form.name,
|
||||
year: Number(form.year),
|
||||
description: form.description || undefined,
|
||||
price: Number(form.price) || 0,
|
||||
validFrom: form.validFrom || undefined,
|
||||
validUntil: form.validUntil || undefined,
|
||||
})}
|
||||
disabled={action.isPending || !form.name || !form.year}
|
||||
>
|
||||
{action.isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Erstellen
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
'use client';
|
||||
|
||||
import { useAction } from 'next-safe-action/hooks';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { UserPlus, Loader2 } from 'lucide-react';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@kit/ui/dialog';
|
||||
import { Input } from '@kit/ui/input';
|
||||
import { Label } from '@kit/ui/label';
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
|
||||
import { registerForEvent } from '../server/actions/event-actions';
|
||||
|
||||
interface EventRegistrationDialogProps {
|
||||
eventId: string;
|
||||
eventName: string;
|
||||
}
|
||||
|
||||
export function EventRegistrationDialog({ eventId, eventName }: EventRegistrationDialogProps) {
|
||||
const router = useRouter();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [form, setForm] = useState({ firstName: '', lastName: '', email: '', phone: '', dateOfBirth: '' });
|
||||
|
||||
const action = useAction(registerForEvent, {
|
||||
onSuccess: ({ data }) => {
|
||||
if (data?.success) {
|
||||
toast.success('Anmeldung erfolgreich');
|
||||
setOpen(false);
|
||||
setForm({ firstName: '', lastName: '', email: '', phone: '', dateOfBirth: '' });
|
||||
router.refresh();
|
||||
} else {
|
||||
toast.error(data?.error ?? 'Fehler bei der Anmeldung');
|
||||
}
|
||||
},
|
||||
onError: () => toast.error('Fehler bei der Anmeldung'),
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button><UserPlus className="mr-2 h-4 w-4" />Anmeldung</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Anmeldung zu „{eventName}"</DialogTitle>
|
||||
<DialogDescription>Melden Sie einen Teilnehmer an.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="grid gap-4 py-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>Vorname *</Label>
|
||||
<Input value={form.firstName} onChange={(e) => setForm(s => ({ ...s, firstName: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Nachname *</Label>
|
||||
<Input value={form.lastName} onChange={(e) => setForm(s => ({ ...s, lastName: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>E-Mail</Label>
|
||||
<Input type="email" value={form.email} onChange={(e) => setForm(s => ({ ...s, email: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid gap-2">
|
||||
<Label>Telefon</Label>
|
||||
<Input value={form.phone} onChange={(e) => setForm(s => ({ ...s, phone: e.target.value }))} />
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>Geburtsdatum</Label>
|
||||
<Input type="date" value={form.dateOfBirth} onChange={(e) => setForm(s => ({ ...s, dateOfBirth: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setOpen(false)}>Abbrechen</Button>
|
||||
<Button
|
||||
onClick={() => action.execute({
|
||||
eventId,
|
||||
firstName: form.firstName,
|
||||
lastName: form.lastName,
|
||||
email: form.email || undefined,
|
||||
phone: form.phone || undefined,
|
||||
dateOfBirth: form.dateOfBirth || undefined,
|
||||
})}
|
||||
disabled={action.isPending || !form.firstName || !form.lastName}
|
||||
>
|
||||
{action.isPending && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Anmelden
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1 +1,3 @@
|
||||
export { CreateEventForm } from './create-event-form';
|
||||
export { EventRegistrationDialog } from './event-registration-dialog';
|
||||
export { CreateHolidayPassDialog } from './create-holiday-pass-dialog';
|
||||
|
||||
Reference in New Issue
Block a user