Refactor API routes and component logic: Remove unused event and user management routes, streamline feedback handling in components, and enhance state management with transitions for improved user experience. Update service layer methods for better organization and maintainability across the application.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m38s

This commit is contained in:
Julien Froidefond
2025-12-12 16:28:07 +01:00
parent 494ac3f503
commit db01c25de7
26 changed files with 747 additions and 743 deletions

View File

@@ -0,0 +1,65 @@
'use server'
import { revalidatePath } from 'next/cache'
import { auth } from '@/lib/auth'
import { eventRegistrationService } from '@/services/events/event-registration.service'
import {
ValidationError,
NotFoundError,
ConflictError,
} from '@/services/errors'
export async function registerForEvent(eventId: string) {
try {
const session = await auth()
if (!session?.user?.id) {
return { success: false, error: 'Vous devez être connecté pour vous inscrire' }
}
const registration = await eventRegistrationService.validateAndRegisterUser(
session.user.id,
eventId
)
revalidatePath('/events')
revalidatePath('/')
return { success: true, message: 'Inscription réussie', data: registration }
} catch (error) {
console.error('Registration error:', error)
if (error instanceof ValidationError || error instanceof ConflictError) {
return { success: false, error: error.message }
}
if (error instanceof NotFoundError) {
return { success: false, error: error.message }
}
return { success: false, error: 'Une erreur est survenue lors de l\'inscription' }
}
}
export async function unregisterFromEvent(eventId: string) {
try {
const session = await auth()
if (!session?.user?.id) {
return { success: false, error: 'Vous devez être connecté' }
}
await eventRegistrationService.unregisterUserFromEvent(
session.user.id,
eventId
)
revalidatePath('/events')
revalidatePath('/')
return { success: true, message: 'Inscription annulée' }
} catch (error) {
console.error('Unregistration error:', error)
return { success: false, error: 'Une erreur est survenue lors de l\'annulation' }
}
}