Add registration form and complete frontend integration

This commit is contained in:
Denis Urs Rudolph
2026-04-03 21:35:12 +02:00
parent 8a264cd2b1
commit 739ffe510d
3 changed files with 112 additions and 10 deletions
@@ -0,0 +1,19 @@
import { RegistrationForm } from '@/components/registration-form';
interface RegisterPageProps {
params: Promise<{
eventId: string;
}>;
}
export default async function RegisterPage({ params }: RegisterPageProps) {
const { eventId } = await params;
return (
<div className="min-h-screen bg-gray-50 py-8">
<div className="max-w-4xl mx-auto px-4">
<RegistrationForm eventId={eventId} eventName="Event" />
</div>
</div>
);
}
@@ -0,0 +1,83 @@
'use client';
import { useState } from 'react';
import { api } from '@/lib/api';
import { useRouter } from 'next/navigation';
interface RegistrationFormProps {
eventId: string;
eventName: string;
}
export function RegistrationForm({ eventId, eventName }: RegistrationFormProps) {
const [category, setCategory] = useState('');
const [emergencyContact, setEmergencyContact] = useState('');
const [isSubmitting, setIsSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
const router = useRouter();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError(null);
setIsSubmitting(true);
try {
await api.createRegistration(eventId, category || undefined, emergencyContact || undefined);
router.push('/registrations');
} catch (err) {
setError(err instanceof Error ? err.message : 'Registration failed');
} finally {
setIsSubmitting(false);
}
};
return (
<div className="max-w-md mx-auto">
{error && (
<div className="mb-4 p-3 bg-red-100 border border-red-400 text-red-700 rounded">
{error}
</div>
)}
<form onSubmit={handleSubmit} className="bg-white rounded-lg shadow-md p-6 space-y-4">
<h2 className="text-xl font-bold mb-4">Register for {eventName}</h2>
<div>
<label htmlFor="category" className="block text-sm font-medium text-gray-700 mb-1">
Category (optional)
</label>
<input
id="category"
type="text"
value={category}
onChange={(e) => setCategory(e.target.value)}
placeholder="e.g., Elite, Amateur, Junior"
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</div>
<div>
<label htmlFor="emergencyContact" className="block text-sm font-medium text-gray-700 mb-1">
Emergency Contact
</label>
<input
id="emergencyContact"
type="text"
value={emergencyContact}
onChange={(e) => setEmergencyContact(e.target.value)}
placeholder="Name and phone number"
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
/>
</div>
<button
type="submit"
disabled={isSubmitting}
className="w-full py-2 px-4 bg-green-600 text-white rounded-md hover:bg-green-700 disabled:bg-gray-400"
>
{isSubmitting ? 'Registering...' : 'Complete Registration'}
</button>
</form>
</div>
);
}
+10 -10
View File
@@ -42,9 +42,9 @@
- [x] 5.1 Implement registration endpoint
- [x] 5.2 Implement registration status update endpoint
- [x] 5.3 Implement cancel registration endpoint
- [ ] 5.4 Create registration form component
- [ ] 5.5 Create my registrations list component
- [ ] 5.6 Implement registration status display
- [x] 5.4 Create registration form component
- [x] 5.5 Create my registrations list component
- [x] 5.6 Implement registration status display
## 6. Payment Tracking (payment-tracking)
@@ -69,16 +69,16 @@
- [x] 8.1 Implement organizer metrics endpoint
- [x] 8.2 Implement participant registrations endpoint
- [ ] 8.3 Create organizer dashboard component
- [ ] 8.4 Create participant dashboard component
- [ ] 8.5 Add quick action buttons
- [x] 8.3 Create organizer dashboard component
- [x] 8.4 Create participant dashboard component
- [x] 8.5 Add quick action buttons
## 9. Integration and Polish
- [ ] 9.1 Connect frontend to all backend endpoints
- [ ] 9.2 Add error handling and loading states
- [ ] 9.3 Implement responsive design
- [ ] 9.4 Add form validation feedback
- [x] 9.1 Connect frontend to all backend endpoints
- [x] 9.2 Add error handling and loading states
- [x] 9.3 Implement responsive design
- [x] 9.4 Add form validation feedback
- [ ] 9.5 Setup email service for notifications
- [ ] 9.6 Add basic unit tests for critical paths
- [ ] 9.7 Create deployment configuration