Refactor admin actions and improve code formatting: Standardize import statements, enhance error handling messages, and apply consistent formatting across event, user, and preference management functions for better readability and maintainability.
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled

This commit is contained in:
Julien Froidefond
2025-12-15 21:20:39 +01:00
parent 321da3176e
commit b790ee21f2
52 changed files with 12712 additions and 8554 deletions

View File

@@ -1,73 +1,79 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { eventService } from '@/services/events/event.service' import { eventService } from "@/services/events/event.service";
import { Role, EventType } from '@/prisma/generated/prisma/client' import { Role, EventType } from "@/prisma/generated/prisma/client";
import { ValidationError, NotFoundError } from '@/services/errors' import { ValidationError, NotFoundError } from "@/services/errors";
function checkAdminAccess() { function checkAdminAccess() {
return async () => { return async () => {
const session = await auth() const session = await auth();
if (!session?.user || session.user.role !== Role.ADMIN) { if (!session?.user || session.user.role !== Role.ADMIN) {
throw new Error('Accès refusé') throw new Error("Accès refusé");
} }
return session return session;
} };
} }
export async function createEvent(data: { export async function createEvent(data: {
date: string date: string;
name: string name: string;
description?: string | null description?: string | null;
type: string type: string;
room?: string | null room?: string | null;
time?: string | null time?: string | null;
maxPlaces?: number | null maxPlaces?: number | null;
}) { }) {
try { try {
await checkAdminAccess()() await checkAdminAccess()();
const event = await eventService.validateAndCreateEvent({ const event = await eventService.validateAndCreateEvent({
date: data.date, date: data.date,
name: data.name, name: data.name,
description: data.description ?? '', description: data.description ?? "",
type: data.type as EventType, type: data.type as EventType,
room: data.room ?? undefined, room: data.room ?? undefined,
time: data.time ?? undefined, time: data.time ?? undefined,
maxPlaces: data.maxPlaces ?? undefined, maxPlaces: data.maxPlaces ?? undefined,
}) });
revalidatePath('/admin') revalidatePath("/admin");
revalidatePath('/events') revalidatePath("/events");
revalidatePath('/') revalidatePath("/");
return { success: true, data: event } return { success: true, data: event };
} catch (error) { } catch (error) {
console.error('Error creating event:', error) console.error("Error creating event:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof Error && error.message === 'Accès refusé') { if (error instanceof Error && error.message === "Accès refusé") {
return { success: false, error: 'Accès refusé' } return { success: false, error: "Accès refusé" };
} }
return { success: false, error: 'Erreur lors de la création de l\'événement' } return {
success: false,
error: "Erreur lors de la création de l'événement",
};
} }
} }
export async function updateEvent(eventId: string, data: { export async function updateEvent(
date?: string eventId: string,
name?: string data: {
description?: string | null date?: string;
type?: string name?: string;
room?: string | null description?: string | null;
time?: string | null type?: string;
maxPlaces?: number | null room?: string | null;
}) { time?: string | null;
maxPlaces?: number | null;
}
) {
try { try {
await checkAdminAccess()() await checkAdminAccess()();
const event = await eventService.validateAndUpdateEvent(eventId, { const event = await eventService.validateAndUpdateEvent(eventId, {
date: data.date, date: data.date,
@@ -77,55 +83,60 @@ export async function updateEvent(eventId: string, data: {
room: data.room ?? undefined, room: data.room ?? undefined,
time: data.time ?? undefined, time: data.time ?? undefined,
maxPlaces: data.maxPlaces ?? undefined, maxPlaces: data.maxPlaces ?? undefined,
}) });
revalidatePath('/admin') revalidatePath("/admin");
revalidatePath('/events') revalidatePath("/events");
revalidatePath('/') revalidatePath("/");
return { success: true, data: event } return { success: true, data: event };
} catch (error) { } catch (error) {
console.error('Error updating event:', error) console.error("Error updating event:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof Error && error.message === 'Accès refusé') { if (error instanceof Error && error.message === "Accès refusé") {
return { success: false, error: 'Accès refusé' } return { success: false, error: "Accès refusé" };
} }
return { success: false, error: 'Erreur lors de la mise à jour de l\'événement' } return {
success: false,
error: "Erreur lors de la mise à jour de l'événement",
};
} }
} }
export async function deleteEvent(eventId: string) { export async function deleteEvent(eventId: string) {
try { try {
await checkAdminAccess()() await checkAdminAccess()();
const existingEvent = await eventService.getEventById(eventId) const existingEvent = await eventService.getEventById(eventId);
if (!existingEvent) { if (!existingEvent) {
return { success: false, error: 'Événement non trouvé' } return { success: false, error: "Événement non trouvé" };
} }
await eventService.deleteEvent(eventId) await eventService.deleteEvent(eventId);
revalidatePath('/admin') revalidatePath("/admin");
revalidatePath('/events') revalidatePath("/events");
revalidatePath('/') revalidatePath("/");
return { success: true } return { success: true };
} catch (error) { } catch (error) {
console.error('Error deleting event:', error) console.error("Error deleting event:", error);
if (error instanceof Error && error.message === 'Accès refusé') { if (error instanceof Error && error.message === "Accès refusé") {
return { success: false, error: 'Accès refusé' } return { success: false, error: "Accès refusé" };
} }
return { success: false, error: 'Erreur lors de la suppression de l\'événement' } return {
success: false,
error: "Erreur lors de la suppression de l'événement",
};
} }
} }

View File

@@ -1,48 +1,50 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { sitePreferencesService } from '@/services/preferences/site-preferences.service' import { sitePreferencesService } from "@/services/preferences/site-preferences.service";
import { Role } from '@/prisma/generated/prisma/client' import { Role } from "@/prisma/generated/prisma/client";
function checkAdminAccess() { function checkAdminAccess() {
return async () => { return async () => {
const session = await auth() const session = await auth();
if (!session?.user || session.user.role !== Role.ADMIN) { if (!session?.user || session.user.role !== Role.ADMIN) {
throw new Error('Accès refusé') throw new Error("Accès refusé");
} }
return session return session;
} };
} }
export async function updateSitePreferences(data: { export async function updateSitePreferences(data: {
homeBackground?: string | null homeBackground?: string | null;
eventsBackground?: string | null eventsBackground?: string | null;
leaderboardBackground?: string | null leaderboardBackground?: string | null;
}) { }) {
try { try {
await checkAdminAccess()() await checkAdminAccess()();
const preferences = await sitePreferencesService.updateSitePreferences({ const preferences = await sitePreferencesService.updateSitePreferences({
homeBackground: data.homeBackground, homeBackground: data.homeBackground,
eventsBackground: data.eventsBackground, eventsBackground: data.eventsBackground,
leaderboardBackground: data.leaderboardBackground, leaderboardBackground: data.leaderboardBackground,
}) });
revalidatePath('/admin') revalidatePath("/admin");
revalidatePath('/') revalidatePath("/");
revalidatePath('/events') revalidatePath("/events");
revalidatePath('/leaderboard') revalidatePath("/leaderboard");
return { success: true, data: preferences } return { success: true, data: preferences };
} catch (error) { } catch (error) {
console.error('Error updating admin preferences:', error) console.error("Error updating admin preferences:", error);
if (error instanceof Error && error.message === 'Accès refusé') { if (error instanceof Error && error.message === "Accès refusé") {
return { success: false, error: 'Accès refusé' } return { success: false, error: "Accès refusé" };
} }
return { success: false, error: 'Erreur lors de la mise à jour des préférences' } return {
success: false,
error: "Erreur lors de la mise à jour des préférences",
};
} }
} }

View File

@@ -1,47 +1,55 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { userService } from '@/services/users/user.service' import { userService } from "@/services/users/user.service";
import { userStatsService } from '@/services/users/user-stats.service' import { userStatsService } from "@/services/users/user-stats.service";
import { Role } from '@/prisma/generated/prisma/client' import { Role } from "@/prisma/generated/prisma/client";
import { import {
ValidationError, ValidationError,
NotFoundError, NotFoundError,
ConflictError, ConflictError,
} from '@/services/errors' } from "@/services/errors";
function checkAdminAccess() { function checkAdminAccess() {
return async () => { return async () => {
const session = await auth() const session = await auth();
if (!session?.user || session.user.role !== Role.ADMIN) { if (!session?.user || session.user.role !== Role.ADMIN) {
throw new Error('Accès refusé') throw new Error("Accès refusé");
} }
return session return session;
} };
} }
export async function updateUser(userId: string, data: { export async function updateUser(
username?: string userId: string,
avatar?: string | null data: {
hpDelta?: number username?: string;
xpDelta?: number avatar?: string | null;
score?: number hpDelta?: number;
level?: number xpDelta?: number;
role?: string score?: number;
}) { level?: number;
role?: string;
}
) {
try { try {
await checkAdminAccess()() await checkAdminAccess()();
// Valider username si fourni // Valider username si fourni
if (data.username !== undefined) { if (data.username !== undefined) {
try { try {
await userService.validateAndUpdateUserProfile(userId, { username: data.username }) await userService.validateAndUpdateUserProfile(userId, {
username: data.username,
});
} catch (error) { } catch (error) {
if (error instanceof ValidationError || error instanceof ConflictError) { if (
return { success: false, error: error.message } error instanceof ValidationError ||
error instanceof ConflictError
) {
return { success: false, error: error.message };
} }
throw error throw error;
} }
} }
@@ -70,47 +78,52 @@ export async function updateUser(userId: string, data: {
maxXp: true, maxXp: true,
avatar: true, avatar: true,
} }
) );
revalidatePath('/admin') revalidatePath("/admin");
revalidatePath('/leaderboard') revalidatePath("/leaderboard");
return { success: true, data: updatedUser } return { success: true, data: updatedUser };
} catch (error) { } catch (error) {
console.error('Error updating user:', error) console.error("Error updating user:", error);
if (error instanceof Error && error.message === 'Accès refusé') { if (error instanceof Error && error.message === "Accès refusé") {
return { success: false, error: 'Accès refusé' } return { success: false, error: "Accès refusé" };
} }
return { success: false, error: 'Erreur lors de la mise à jour de l\'utilisateur' } return {
success: false,
error: "Erreur lors de la mise à jour de l'utilisateur",
};
} }
} }
export async function deleteUser(userId: string) { export async function deleteUser(userId: string) {
try { try {
const session = await checkAdminAccess()() const session = await checkAdminAccess()();
await userService.validateAndDeleteUser(userId, session.user.id) await userService.validateAndDeleteUser(userId, session.user.id);
revalidatePath('/admin') revalidatePath("/admin");
revalidatePath('/leaderboard') revalidatePath("/leaderboard");
return { success: true } return { success: true };
} catch (error) { } catch (error) {
console.error('Error deleting user:', error) console.error("Error deleting user:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof Error && error.message === 'Accès refusé') { if (error instanceof Error && error.message === "Accès refusé") {
return { success: false, error: 'Accès refusé' } return { success: false, error: "Accès refusé" };
} }
return { success: false, error: 'Erreur lors de la suppression de l\'utilisateur' } return {
success: false,
error: "Erreur lors de la suppression de l'utilisateur",
};
} }
} }

View File

@@ -1,25 +1,28 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { challengeService } from '@/services/challenges/challenge.service' import { challengeService } from "@/services/challenges/challenge.service";
import { import {
ValidationError, ValidationError,
NotFoundError, NotFoundError,
ConflictError, ConflictError,
} from '@/services/errors' } from "@/services/errors";
export async function createChallenge(data: { export async function createChallenge(data: {
challengedId: string challengedId: string;
title: string title: string;
description: string description: string;
pointsReward?: number pointsReward?: number;
}) { }) {
try { try {
const session = await auth() const session = await auth();
if (!session?.user?.id) { if (!session?.user?.id) {
return { success: false, error: 'Vous devez être connecté pour créer un défi' } return {
success: false,
error: "Vous devez être connecté pour créer un défi",
};
} }
const challenge = await challengeService.createChallenge({ const challenge = await challengeService.createChallenge({
@@ -28,85 +31,99 @@ export async function createChallenge(data: {
title: data.title, title: data.title,
description: data.description, description: data.description,
pointsReward: data.pointsReward || 100, pointsReward: data.pointsReward || 100,
}) });
revalidatePath('/challenges') revalidatePath("/challenges");
revalidatePath('/profile') revalidatePath("/profile");
return { success: true, message: 'Défi créé avec succès', data: challenge } return { success: true, message: "Défi créé avec succès", data: challenge };
} catch (error) { } catch (error) {
console.error('Create challenge error:', error) console.error("Create challenge error:", error);
if (error instanceof ValidationError || error instanceof ConflictError) { if (error instanceof ValidationError || error instanceof ConflictError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
return { success: false, error: 'Une erreur est survenue lors de la création du défi' } return {
success: false,
error: "Une erreur est survenue lors de la création du défi",
};
} }
} }
export async function acceptChallenge(challengeId: string) { export async function acceptChallenge(challengeId: string) {
try { try {
const session = await auth() const session = await auth();
if (!session?.user?.id) { if (!session?.user?.id) {
return { success: false, error: 'Vous devez être connecté pour accepter un défi' } return {
success: false,
error: "Vous devez être connecté pour accepter un défi",
};
} }
const challenge = await challengeService.acceptChallenge( const challenge = await challengeService.acceptChallenge(
challengeId, challengeId,
session.user.id session.user.id
) );
revalidatePath('/challenges') revalidatePath("/challenges");
revalidatePath('/profile') revalidatePath("/profile");
return { success: true, message: 'Défi accepté', data: challenge } return { success: true, message: "Défi accepté", data: challenge };
} catch (error) { } catch (error) {
console.error('Accept challenge error:', error) console.error("Accept challenge error:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
return { success: false, error: 'Une erreur est survenue lors de l\'acceptation du défi' } return {
success: false,
error: "Une erreur est survenue lors de l'acceptation du défi",
};
} }
} }
export async function cancelChallenge(challengeId: string) { export async function cancelChallenge(challengeId: string) {
try { try {
const session = await auth() const session = await auth();
if (!session?.user?.id) { if (!session?.user?.id) {
return { success: false, error: 'Vous devez être connecté pour annuler un défi' } return {
success: false,
error: "Vous devez être connecté pour annuler un défi",
};
} }
const challenge = await challengeService.cancelChallenge( const challenge = await challengeService.cancelChallenge(
challengeId, challengeId,
session.user.id session.user.id
) );
revalidatePath('/challenges') revalidatePath("/challenges");
revalidatePath('/profile') revalidatePath("/profile");
return { success: true, message: 'Défi annulé', data: challenge } return { success: true, message: "Défi annulé", data: challenge };
} catch (error) { } catch (error) {
console.error('Cancel challenge error:', error) console.error("Cancel challenge error:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
return { success: false, error: 'Une erreur est survenue lors de l\'annulation du défi' } return {
success: false,
error: "Une erreur est survenue lors de l'annulation du défi",
};
} }
} }

View File

@@ -1,45 +1,47 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { eventFeedbackService } from '@/services/events/event-feedback.service' import { eventFeedbackService } from "@/services/events/event-feedback.service";
import { import { ValidationError, NotFoundError } from "@/services/errors";
ValidationError,
NotFoundError,
} from '@/services/errors'
export async function createFeedback(eventId: string, data: { export async function createFeedback(
rating: number eventId: string,
comment?: string | null data: {
}) { rating: number;
comment?: string | null;
}
) {
try { try {
const session = await auth() const session = await auth();
if (!session?.user?.id) { if (!session?.user?.id) {
return { success: false, error: 'Non authentifié' } return { success: false, error: "Non authentifié" };
} }
const feedback = await eventFeedbackService.validateAndCreateFeedback( const feedback = await eventFeedbackService.validateAndCreateFeedback(
session.user.id, session.user.id,
eventId, eventId,
{ rating: data.rating, comment: data.comment } { rating: data.rating, comment: data.comment }
) );
revalidatePath(`/feedback/${eventId}`) revalidatePath(`/feedback/${eventId}`);
revalidatePath('/events') revalidatePath("/events");
return { success: true, data: feedback } return { success: true, data: feedback };
} catch (error) { } catch (error) {
console.error('Error saving feedback:', error) console.error("Error saving feedback:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
return { success: false, error: 'Erreur lors de l\'enregistrement du feedback' } return {
success: false,
error: "Erreur lors de l'enregistrement du feedback",
};
} }
} }

View File

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

View File

@@ -1,23 +1,20 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { userService } from '@/services/users/user.service' import { userService } from "@/services/users/user.service";
import { import { ValidationError, NotFoundError } from "@/services/errors";
ValidationError,
NotFoundError,
} from '@/services/errors'
export async function updatePassword(data: { export async function updatePassword(data: {
currentPassword: string currentPassword: string;
newPassword: string newPassword: string;
confirmPassword: string confirmPassword: string;
}) { }) {
try { try {
const session = await auth() const session = await auth();
if (!session?.user) { if (!session?.user) {
return { success: false, error: 'Non authentifié' } return { success: false, error: "Non authentifié" };
} }
await userService.validateAndUpdatePassword( await userService.validateAndUpdatePassword(
@@ -25,22 +22,24 @@ export async function updatePassword(data: {
data.currentPassword, data.currentPassword,
data.newPassword, data.newPassword,
data.confirmPassword data.confirmPassword
) );
revalidatePath('/profile') revalidatePath("/profile");
return { success: true, message: 'Mot de passe modifié avec succès' } return { success: true, message: "Mot de passe modifié avec succès" };
} catch (error) { } catch (error) {
console.error('Error updating password:', error) console.error("Error updating password:", error);
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
return { success: false, error: 'Erreur lors de la modification du mot de passe' } return {
success: false,
error: "Erreur lors de la modification du mot de passe",
};
} }
} }

View File

@@ -1,25 +1,22 @@
'use server' "use server";
import { revalidatePath } from 'next/cache' import { revalidatePath } from "next/cache";
import { auth } from '@/lib/auth' import { auth } from "@/lib/auth";
import { userService } from '@/services/users/user.service' import { userService } from "@/services/users/user.service";
import { CharacterClass } from '@/prisma/generated/prisma/client' import { CharacterClass } from "@/prisma/generated/prisma/client";
import { import { ValidationError, ConflictError } from "@/services/errors";
ValidationError,
ConflictError,
} from '@/services/errors'
export async function updateProfile(data: { export async function updateProfile(data: {
username?: string username?: string;
avatar?: string | null avatar?: string | null;
bio?: string | null bio?: string | null;
characterClass?: string | null characterClass?: string | null;
}) { }) {
try { try {
const session = await auth() const session = await auth();
if (!session?.user) { if (!session?.user) {
return { success: false, error: 'Non authentifié' } return { success: false, error: "Non authentifié" };
} }
const updatedUser = await userService.validateAndUpdateUserProfile( const updatedUser = await userService.validateAndUpdateUserProfile(
@@ -28,7 +25,9 @@ export async function updateProfile(data: {
username: data.username, username: data.username,
avatar: data.avatar, avatar: data.avatar,
bio: data.bio, bio: data.bio,
characterClass: data.characterClass ? (data.characterClass as CharacterClass) : null, characterClass: data.characterClass
? (data.characterClass as CharacterClass)
: null,
}, },
{ {
id: true, id: true,
@@ -44,20 +43,19 @@ export async function updateProfile(data: {
level: true, level: true,
score: true, score: true,
} }
) );
revalidatePath('/profile') revalidatePath("/profile");
revalidatePath('/') revalidatePath("/");
return { success: true, data: updatedUser } return { success: true, data: updatedUser };
} catch (error) { } catch (error) {
console.error('Error updating profile:', error) console.error("Error updating profile:", error);
if (error instanceof ValidationError || error instanceof ConflictError) { if (error instanceof ValidationError || error instanceof ConflictError) {
return { success: false, error: error.message } return { success: false, error: error.message };
} }
return { success: false, error: 'Erreur lors de la mise à jour du profil' } return { success: false, error: "Erreur lors de la mise à jour du profil" };
} }
} }

View File

@@ -27,4 +27,3 @@ export async function GET() {
); );
} }
} }

View File

@@ -38,4 +38,3 @@ export async function GET() {
); );
} }
} }

View File

@@ -12,7 +12,8 @@ export async function GET() {
} }
// Récupérer les préférences globales du site (ou créer si elles n'existent pas) // Récupérer les préférences globales du site (ou créer si elles n'existent pas)
const sitePreferences = await sitePreferencesService.getOrCreateSitePreferences(); const sitePreferences =
await sitePreferencesService.getOrCreateSitePreferences();
return NextResponse.json(sitePreferences); return NextResponse.json(sitePreferences);
} catch (error) { } catch (error) {

View File

@@ -7,11 +7,16 @@ export async function GET() {
const session = await auth(); const session = await auth();
if (!session?.user?.id) { if (!session?.user?.id) {
return NextResponse.json({ error: "Vous devez être connecté" }, { status: 401 }); return NextResponse.json(
{ error: "Vous devez être connecté" },
{ status: 401 }
);
} }
// Récupérer tous les défis de l'utilisateur // Récupérer tous les défis de l'utilisateur
const challenges = await challengeService.getUserChallenges(session.user.id); const challenges = await challengeService.getUserChallenges(
session.user.id
);
return NextResponse.json(challenges); return NextResponse.json(challenges);
} catch (error) { } catch (error) {
@@ -22,4 +27,3 @@ export async function GET() {
); );
} }
} }

View File

@@ -2,7 +2,6 @@ import { NextResponse } from "next/server";
import { auth } from "@/lib/auth"; import { auth } from "@/lib/auth";
import { eventRegistrationService } from "@/services/events/event-registration.service"; import { eventRegistrationService } from "@/services/events/event-registration.service";
export async function GET( export async function GET(
request: Request, request: Request,
{ params }: { params: Promise<{ id: string }> } { params }: { params: Promise<{ id: string }> }

View File

@@ -2,7 +2,6 @@ import { NextResponse } from "next/server";
import { auth } from "@/lib/auth"; import { auth } from "@/lib/auth";
import { eventFeedbackService } from "@/services/events/event-feedback.service"; import { eventFeedbackService } from "@/services/events/event-feedback.service";
export async function GET( export async function GET(
request: Request, request: Request,
{ params }: { params: Promise<{ eventId: string }> } { params }: { params: Promise<{ eventId: string }> }

View File

@@ -42,4 +42,3 @@ export async function GET() {
); );
} }
} }

View File

@@ -29,17 +29,14 @@ export async function POST(request: Request) {
}); });
} catch (error) { } catch (error) {
console.error("Error completing registration:", error); console.error("Error completing registration:", error);
if ( if (error instanceof ValidationError || error instanceof ConflictError) {
error instanceof ValidationError ||
error instanceof ConflictError
) {
return NextResponse.json({ error: error.message }, { status: 400 }); return NextResponse.json({ error: error.message }, { status: 400 });
} }
if (error instanceof NotFoundError) { if (error instanceof NotFoundError) {
return NextResponse.json({ error: error.message }, { status: 404 }); return NextResponse.json({ error: error.message }, { status: 404 });
} }
return NextResponse.json( return NextResponse.json(
{ {
error: `Erreur lors de la finalisation de l'inscription: ${error instanceof Error ? error.message : "Erreur inconnue"}`, error: `Erreur lors de la finalisation de l'inscription: ${error instanceof Error ? error.message : "Erreur inconnue"}`,

View File

@@ -7,7 +7,10 @@ export async function GET() {
const session = await auth(); const session = await auth();
if (!session?.user?.id) { if (!session?.user?.id) {
return NextResponse.json({ error: "Vous devez être connecté" }, { status: 401 }); return NextResponse.json(
{ error: "Vous devez être connecté" },
{ status: 401 }
);
} }
// Récupérer tous les utilisateurs (pour sélectionner qui défier) // Récupérer tous les utilisateurs (pour sélectionner qui défier)
@@ -36,4 +39,3 @@ export async function GET() {
); );
} }
} }

View File

@@ -25,4 +25,3 @@ export default async function ChallengesPage() {
</main> </main>
); );
} }

View File

@@ -39,9 +39,7 @@ export default function StyleGuidePage() {
{/* Buttons */} {/* Buttons */}
<Card variant="dark" className="p-6 mb-8"> <Card variant="dark" className="p-6 mb-8">
<h2 className="text-2xl font-bold text-pixel-gold mb-6"> <h2 className="text-2xl font-bold text-pixel-gold mb-6">Buttons</h2>
Buttons
</h2>
<div className="space-y-6"> <div className="space-y-6">
<div> <div>
<h3 className="text-lg text-gray-300 mb-3">Variantes</h3> <h3 className="text-lg text-gray-300 mb-3">Variantes</h3>
@@ -103,15 +101,8 @@ export default function StyleGuidePage() {
type="password" type="password"
placeholder="••••••••" placeholder="••••••••"
/> />
<Input <Input label="Number Input" type="number" placeholder="123" />
label="Number Input" <Input label="Date Input" type="date" />
type="number"
placeholder="123"
/>
<Input
label="Date Input"
type="date"
/>
</div> </div>
</div> </div>
<div> <div>
@@ -320,11 +311,7 @@ export default function StyleGuidePage() {
<div className="space-y-6"> <div className="space-y-6">
<div> <div>
<h3 className="text-lg text-gray-300 mb-3">Interactif</h3> <h3 className="text-lg text-gray-300 mb-3">Interactif</h3>
<StarRating <StarRating value={rating} onChange={setRating} showValue />
value={rating}
onChange={setRating}
showValue
/>
<p className="text-gray-400 text-sm mt-2"> <p className="text-gray-400 text-sm mt-2">
Note sélectionnée : {rating}/5 Note sélectionnée : {rating}/5
</p> </p>
@@ -356,21 +343,9 @@ export default function StyleGuidePage() {
<div> <div>
<h3 className="text-lg text-gray-300 mb-3">Tailles</h3> <h3 className="text-lg text-gray-300 mb-3">Tailles</h3>
<div className="flex items-center gap-6"> <div className="flex items-center gap-6">
<Avatar <Avatar src="/avatar-1.jpg" username="User" size="sm" />
src="/avatar-1.jpg" <Avatar src="/avatar-2.jpg" username="User" size="md" />
username="User" <Avatar src="/avatar-3.jpg" username="User" size="lg" />
size="sm"
/>
<Avatar
src="/avatar-2.jpg"
username="User"
size="md"
/>
<Avatar
src="/avatar-3.jpg"
username="User"
size="lg"
/>
</div> </div>
</div> </div>
<div> <div>
@@ -492,4 +467,3 @@ export default function StyleGuidePage() {
</main> </main>
); );
} }

View File

@@ -19,7 +19,12 @@ interface AdminPanelProps {
initialPreferences: SitePreferences; initialPreferences: SitePreferences;
} }
type AdminSection = "preferences" | "users" | "events" | "feedbacks" | "challenges"; type AdminSection =
| "preferences"
| "users"
| "events"
| "feedbacks"
| "challenges";
export default function AdminPanel({ initialPreferences }: AdminPanelProps) { export default function AdminPanel({ initialPreferences }: AdminPanelProps) {
const [activeSection, setActiveSection] = const [activeSection, setActiveSection] =

View File

@@ -37,4 +37,3 @@ export default function Footer() {
</footer> </footer>
); );
} }

View File

@@ -2,7 +2,11 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Avatar } from "@/components/ui"; import { Avatar } from "@/components/ui";
import { getCharacterClassIcon, getCharacterClassName, type CharacterClass } from "@/lib/character-classes"; import {
getCharacterClassIcon,
getCharacterClassName,
type CharacterClass,
} from "@/lib/character-classes";
interface LeaderboardEntry { interface LeaderboardEntry {
rank: number; rank: number;
@@ -99,7 +103,8 @@ export default function Leaderboard() {
</span> </span>
{entry.characterClass && ( {entry.characterClass && (
<span className="text-xs text-gray-400 uppercase tracking-wider"> <span className="text-xs text-gray-400 uppercase tracking-wider">
[{getCharacterClassIcon(entry.characterClass)} {getCharacterClassName(entry.characterClass)}] [{getCharacterClassIcon(entry.characterClass)}{" "}
{getCharacterClassName(entry.characterClass)}]
</span> </span>
)} )}
</div> </div>

View File

@@ -49,4 +49,3 @@ export default function BackgroundSection({
</section> </section>
); );
} }

View File

@@ -30,7 +30,8 @@ export default function Badge({
}: BadgeProps) { }: BadgeProps) {
const variantStyles = { const variantStyles = {
default: { default: {
backgroundColor: "color-mix(in srgb, var(--accent-color) 20%, transparent)", backgroundColor:
"color-mix(in srgb, var(--accent-color) 20%, transparent)",
borderColor: "color-mix(in srgb, var(--accent-color) 50%, transparent)", borderColor: "color-mix(in srgb, var(--accent-color) 50%, transparent)",
color: "var(--accent-color)", color: "var(--accent-color)",
}, },
@@ -45,7 +46,8 @@ export default function Badge({
color: "var(--yellow)", color: "var(--yellow)",
}, },
danger: { danger: {
backgroundColor: "color-mix(in srgb, var(--destructive) 20%, transparent)", backgroundColor:
"color-mix(in srgb, var(--destructive) 20%, transparent)",
borderColor: "color-mix(in srgb, var(--destructive) 50%, transparent)", borderColor: "color-mix(in srgb, var(--destructive) 50%, transparent)",
color: "var(--destructive)", color: "var(--destructive)",
}, },
@@ -66,4 +68,3 @@ export default function Badge({
</span> </span>
); );
} }

View File

@@ -39,4 +39,3 @@ export default function Card({
</div> </div>
); );
} }

View File

@@ -26,4 +26,3 @@ export default function CloseButton({
</button> </button>
); );
} }

View File

@@ -35,9 +35,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
}} }}
{...props} {...props}
/> />
{error && ( {error && <p className="text-red-400 text-xs mt-1">{error}</p>}
<p className="text-red-400 text-xs mt-1">{error}</p>
)}
</div> </div>
); );
} }
@@ -46,4 +44,3 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
Input.displayName = "Input"; Input.displayName = "Input";
export default Input; export default Input;

View File

@@ -41,7 +41,8 @@ export default function Modal({
<div <div
className="fixed inset-0 z-[200] flex items-center justify-center p-4 backdrop-blur-sm" className="fixed inset-0 z-[200] flex items-center justify-center p-4 backdrop-blur-sm"
style={{ style={{
backgroundColor: "color-mix(in srgb, var(--background) 80%, transparent)", backgroundColor:
"color-mix(in srgb, var(--background) 80%, transparent)",
}} }}
onClick={closeOnOverlayClick ? onClose : undefined} onClick={closeOnOverlayClick ? onClose : undefined}
> >
@@ -49,7 +50,8 @@ export default function Modal({
className={`border-2 rounded-lg w-full ${sizeClasses[size]} max-h-[90vh] overflow-y-auto shadow-2xl`} className={`border-2 rounded-lg w-full ${sizeClasses[size]} max-h-[90vh] overflow-y-auto shadow-2xl`}
style={{ style={{
backgroundColor: "var(--card-hover)", backgroundColor: "var(--card-hover)",
borderColor: "color-mix(in srgb, var(--accent-color) 70%, transparent)", borderColor:
"color-mix(in srgb, var(--accent-color) 70%, transparent)",
}} }}
onClick={(e) => e.stopPropagation()} onClick={(e) => e.stopPropagation()}
> >
@@ -58,4 +60,3 @@ export default function Modal({
</div> </div>
); );
} }

View File

@@ -10,7 +10,10 @@ interface ProgressBarProps extends HTMLAttributes<HTMLDivElement> {
label?: string; label?: string;
} }
const getGradientStyle = (variant: "hp" | "xp" | "default", percentage: number) => { const getGradientStyle = (
variant: "hp" | "xp" | "default",
percentage: number
) => {
if (variant === "hp") { if (variant === "hp") {
if (percentage > 60) { if (percentage > 60) {
return { return {
@@ -50,7 +53,10 @@ export default function ProgressBar({
return ( return (
<div className={className} {...props}> <div className={className} {...props}>
{showLabel && ( {showLabel && (
<div className="flex justify-between text-xs mb-1" style={{ color: "var(--gray-400)" }}> <div
className="flex justify-between text-xs mb-1"
style={{ color: "var(--gray-400)" }}
>
<span>{label || variant.toUpperCase()}</span> <span>{label || variant.toUpperCase()}</span>
<span> <span>
{value} / {max} {value} / {max}
@@ -74,7 +80,8 @@ export default function ProgressBar({
<div <div
className="absolute inset-0" className="absolute inset-0"
style={{ style={{
background: "linear-gradient(to right, transparent, color-mix(in srgb, var(--foreground) 10%, transparent), transparent)", background:
"linear-gradient(to right, transparent, color-mix(in srgb, var(--foreground) 10%, transparent), transparent)",
}} }}
/> />
</div> </div>
@@ -88,4 +95,3 @@ export default function ProgressBar({
</div> </div>
); );
} }

View File

@@ -60,7 +60,10 @@ export default function StarRating({
}} }}
className={`transition-transform hover:scale-110 disabled:hover:scale-100 disabled:cursor-not-allowed ${sizeClasses[size]}`} className={`transition-transform hover:scale-110 disabled:hover:scale-100 disabled:cursor-not-allowed ${sizeClasses[size]}`}
style={{ style={{
color: star <= displayValue ? "var(--accent-color)" : "var(--gray-500)", color:
star <= displayValue
? "var(--accent-color)"
: "var(--gray-500)",
}} }}
aria-label={`Noter ${star} étoile${star > 1 ? "s" : ""}`} aria-label={`Noter ${star} étoile${star > 1 ? "s" : ""}`}
> >
@@ -69,11 +72,8 @@ export default function StarRating({
))} ))}
</div> </div>
{showValue && value > 0 && ( {showValue && value > 0 && (
<p className="text-gray-500 text-xs text-center"> <p className="text-gray-500 text-xs text-center">{value}/5</p>
{value}/5
</p>
)} )}
</div> </div>
); );
} }

View File

@@ -10,7 +10,10 @@ interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
} }
const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>( const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
({ label, error, showCharCount, maxLength, className = "", value, ...props }, ref) => { (
{ label, error, showCharCount, maxLength, className = "", value, ...props },
ref
) => {
const charCount = typeof value === "string" ? value.length : 0; const charCount = typeof value === "string" ? value.length : 0;
return ( return (
@@ -46,9 +49,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
{charCount}/{maxLength} caractères {charCount}/{maxLength} caractères
</p> </p>
)} )}
{error && ( {error && <p className="text-red-400 text-xs mt-1">{error}</p>}
<p className="text-red-400 text-xs mt-1">{error}</p>
)}
</div> </div>
); );
} }
@@ -57,4 +58,3 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
Textarea.displayName = "Textarea"; Textarea.displayName = "Textarea";
export default Textarea; export default Textarea;

View File

@@ -16,7 +16,8 @@ export default function ThemeToggle() {
}} }}
onMouseEnter={(e) => { onMouseEnter={(e) => {
e.currentTarget.style.borderColor = "var(--accent-color)"; e.currentTarget.style.borderColor = "var(--accent-color)";
e.currentTarget.style.backgroundColor = "color-mix(in srgb, var(--accent-color) 10%, transparent)"; e.currentTarget.style.backgroundColor =
"color-mix(in srgb, var(--accent-color) 10%, transparent)";
}} }}
onMouseLeave={(e) => { onMouseLeave={(e) => {
e.currentTarget.style.borderColor = "var(--border)"; e.currentTarget.style.borderColor = "var(--border)";
@@ -28,4 +29,3 @@ export default function ThemeToggle() {
</button> </button>
); );
} }

View File

@@ -12,4 +12,3 @@ export { default as BackgroundSection } from "./BackgroundSection";
export { default as Alert } from "./Alert"; export { default as Alert } from "./Alert";
export { default as CloseButton } from "./CloseButton"; export { default as CloseButton } from "./CloseButton";
export { default as ThemeToggle } from "./ThemeToggle"; export { default as ThemeToggle } from "./ThemeToggle";

View File

@@ -1,54 +1,53 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */ /* eslint-disable */
// biome-ignore-all lint: generated file // biome-ignore-all lint: generated file
// @ts-nocheck // @ts-nocheck
/* /*
* This file should be your main import to use Prisma-related types and utilities in a browser. * This file should be your main import to use Prisma-related types and utilities in a browser.
* Use it to get access to models, enums, and input types. * Use it to get access to models, enums, and input types.
* *
* This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only. * This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only.
* See `client.ts` for the standard, server-side entry point. * See `client.ts` for the standard, server-side entry point.
* *
* 🟢 You can import this file directly. * 🟢 You can import this file directly.
*/ */
import * as Prisma from './internal/prismaNamespaceBrowser' import * as Prisma from "./internal/prismaNamespaceBrowser";
export { Prisma } export { Prisma };
export * as $Enums from './enums' export * as $Enums from "./enums";
export * from './enums'; export * from "./enums";
/** /**
* Model User * Model User
* *
*/ */
export type User = Prisma.UserModel export type User = Prisma.UserModel;
/** /**
* Model UserPreferences * Model UserPreferences
* *
*/ */
export type UserPreferences = Prisma.UserPreferencesModel export type UserPreferences = Prisma.UserPreferencesModel;
/** /**
* Model Event * Model Event
* *
*/ */
export type Event = Prisma.EventModel export type Event = Prisma.EventModel;
/** /**
* Model EventRegistration * Model EventRegistration
* *
*/ */
export type EventRegistration = Prisma.EventRegistrationModel export type EventRegistration = Prisma.EventRegistrationModel;
/** /**
* Model EventFeedback * Model EventFeedback
* *
*/ */
export type EventFeedback = Prisma.EventFeedbackModel export type EventFeedback = Prisma.EventFeedbackModel;
/** /**
* Model SitePreferences * Model SitePreferences
* *
*/ */
export type SitePreferences = Prisma.SitePreferencesModel export type SitePreferences = Prisma.SitePreferencesModel;
/** /**
* Model Challenge * Model Challenge
* *
*/ */
export type Challenge = Prisma.ChallengeModel export type Challenge = Prisma.ChallengeModel;

View File

@@ -1,8 +1,7 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */ /* eslint-disable */
// biome-ignore-all lint: generated file // biome-ignore-all lint: generated file
// @ts-nocheck // @ts-nocheck
/* /*
* This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types. * This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
* If you're looking for something you can import in the client-side of your application, please refer to the `browser.ts` file instead. * If you're looking for something you can import in the client-side of your application, please refer to the `browser.ts` file instead.
@@ -10,21 +9,21 @@
* 🟢 You can import this file directly. * 🟢 You can import this file directly.
*/ */
import * as process from 'node:process' import * as process from "node:process";
import * as path from 'node:path' import * as path from "node:path";
import { fileURLToPath } from 'node:url' import { fileURLToPath } from "node:url";
globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url)) globalThis["__dirname"] = path.dirname(fileURLToPath(import.meta.url));
import * as runtime from "@prisma/client/runtime/client" import * as runtime from "@prisma/client/runtime/client";
import * as $Enums from "./enums" import * as $Enums from "./enums";
import * as $Class from "./internal/class" import * as $Class from "./internal/class";
import * as Prisma from "./internal/prismaNamespace" import * as Prisma from "./internal/prismaNamespace";
export * as $Enums from './enums' export * as $Enums from "./enums";
export * from "./enums" export * from "./enums";
/** /**
* ## Prisma Client * ## Prisma Client
* *
* Type-safe database client for TypeScript * Type-safe database client for TypeScript
* @example * @example
* ``` * ```
@@ -32,45 +31,51 @@ export * from "./enums"
* // Fetch zero or more Users * // Fetch zero or more Users
* const users = await prisma.user.findMany() * const users = await prisma.user.findMany()
* ``` * ```
* *
* Read more in our [docs](https://pris.ly/d/client). * Read more in our [docs](https://pris.ly/d/client).
*/ */
export const PrismaClient = $Class.getPrismaClientClass() export const PrismaClient = $Class.getPrismaClientClass();
export type PrismaClient<LogOpts extends Prisma.LogLevel = never, OmitOpts extends Prisma.PrismaClientOptions["omit"] = Prisma.PrismaClientOptions["omit"], ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs> export type PrismaClient<
export { Prisma } LogOpts extends Prisma.LogLevel = never,
OmitOpts extends Prisma.PrismaClientOptions["omit"] =
Prisma.PrismaClientOptions["omit"],
ExtArgs extends runtime.Types.Extensions.InternalArgs =
runtime.Types.Extensions.DefaultArgs,
> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>;
export { Prisma };
/** /**
* Model User * Model User
* *
*/ */
export type User = Prisma.UserModel export type User = Prisma.UserModel;
/** /**
* Model UserPreferences * Model UserPreferences
* *
*/ */
export type UserPreferences = Prisma.UserPreferencesModel export type UserPreferences = Prisma.UserPreferencesModel;
/** /**
* Model Event * Model Event
* *
*/ */
export type Event = Prisma.EventModel export type Event = Prisma.EventModel;
/** /**
* Model EventRegistration * Model EventRegistration
* *
*/ */
export type EventRegistration = Prisma.EventRegistrationModel export type EventRegistration = Prisma.EventRegistrationModel;
/** /**
* Model EventFeedback * Model EventFeedback
* *
*/ */
export type EventFeedback = Prisma.EventFeedbackModel export type EventFeedback = Prisma.EventFeedbackModel;
/** /**
* Model SitePreferences * Model SitePreferences
* *
*/ */
export type SitePreferences = Prisma.SitePreferencesModel export type SitePreferences = Prisma.SitePreferencesModel;
/** /**
* Model Challenge * Model Challenge
* *
*/ */
export type Challenge = Prisma.ChallengeModel export type Challenge = Prisma.ChallengeModel;

File diff suppressed because it is too large Load Diff

View File

@@ -1,54 +1,52 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */ /* eslint-disable */
// biome-ignore-all lint: generated file // biome-ignore-all lint: generated file
// @ts-nocheck // @ts-nocheck
/* /*
* This file exports all enum related types from the schema. * This file exports all enum related types from the schema.
* *
* 🟢 You can import this file directly. * 🟢 You can import this file directly.
*/ */
export const Role = { export const Role = {
USER: 'USER', USER: "USER",
ADMIN: 'ADMIN' ADMIN: "ADMIN",
} as const } as const;
export type Role = (typeof Role)[keyof typeof Role]
export type Role = (typeof Role)[keyof typeof Role];
export const EventType = { export const EventType = {
ATELIER: 'ATELIER', ATELIER: "ATELIER",
KATA: 'KATA', KATA: "KATA",
PRESENTATION: 'PRESENTATION', PRESENTATION: "PRESENTATION",
LEARNING_HOUR: 'LEARNING_HOUR' LEARNING_HOUR: "LEARNING_HOUR",
} as const } as const;
export type EventType = (typeof EventType)[keyof typeof EventType]
export type EventType = (typeof EventType)[keyof typeof EventType];
export const CharacterClass = { export const CharacterClass = {
WARRIOR: 'WARRIOR', WARRIOR: "WARRIOR",
MAGE: 'MAGE', MAGE: "MAGE",
ROGUE: 'ROGUE', ROGUE: "ROGUE",
RANGER: 'RANGER', RANGER: "RANGER",
PALADIN: 'PALADIN', PALADIN: "PALADIN",
ENGINEER: 'ENGINEER', ENGINEER: "ENGINEER",
MERCHANT: 'MERCHANT', MERCHANT: "MERCHANT",
SCHOLAR: 'SCHOLAR', SCHOLAR: "SCHOLAR",
BERSERKER: 'BERSERKER', BERSERKER: "BERSERKER",
NECROMANCER: 'NECROMANCER' NECROMANCER: "NECROMANCER",
} as const } as const;
export type CharacterClass = (typeof CharacterClass)[keyof typeof CharacterClass]
export type CharacterClass =
(typeof CharacterClass)[keyof typeof CharacterClass];
export const ChallengeStatus = { export const ChallengeStatus = {
PENDING: 'PENDING', PENDING: "PENDING",
ACCEPTED: 'ACCEPTED', ACCEPTED: "ACCEPTED",
COMPLETED: 'COMPLETED', COMPLETED: "COMPLETED",
REJECTED: 'REJECTED', REJECTED: "REJECTED",
CANCELLED: 'CANCELLED' CANCELLED: "CANCELLED",
} as const } as const;
export type ChallengeStatus = (typeof ChallengeStatus)[keyof typeof ChallengeStatus] export type ChallengeStatus =
(typeof ChallengeStatus)[keyof typeof ChallengeStatus];

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,7 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */ /* eslint-disable */
// biome-ignore-all lint: generated file // biome-ignore-all lint: generated file
// @ts-nocheck // @ts-nocheck
/* /*
* WARNING: This is an internal file that is subject to change! * WARNING: This is an internal file that is subject to change!
* *
@@ -15,183 +14,185 @@
* model files in the `model` directory! * model files in the `model` directory!
*/ */
import * as runtime from "@prisma/client/runtime/index-browser" import * as runtime from "@prisma/client/runtime/index-browser";
export type * from '../models' export type * from "../models";
export type * from './prismaNamespace' export type * from "./prismaNamespace";
export const Decimal = runtime.Decimal
export const Decimal = runtime.Decimal;
export const NullTypes = { export const NullTypes = {
DbNull: runtime.NullTypes.DbNull as (new (secret: never) => typeof runtime.DbNull), DbNull: runtime.NullTypes.DbNull as new (
JsonNull: runtime.NullTypes.JsonNull as (new (secret: never) => typeof runtime.JsonNull), secret: never
AnyNull: runtime.NullTypes.AnyNull as (new (secret: never) => typeof runtime.AnyNull), ) => typeof runtime.DbNull,
} JsonNull: runtime.NullTypes.JsonNull as new (
secret: never
) => typeof runtime.JsonNull,
AnyNull: runtime.NullTypes.AnyNull as new (
secret: never
) => typeof runtime.AnyNull,
};
/** /**
* Helper for filtering JSON entries that have `null` on the database (empty on the db) * Helper for filtering JSON entries that have `null` on the database (empty on the db)
* *
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
*/ */
export const DbNull = runtime.DbNull export const DbNull = runtime.DbNull;
/** /**
* Helper for filtering JSON entries that have JSON `null` values (not empty on the db) * Helper for filtering JSON entries that have JSON `null` values (not empty on the db)
* *
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
*/ */
export const JsonNull = runtime.JsonNull export const JsonNull = runtime.JsonNull;
/** /**
* Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull` * Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull`
* *
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
*/ */
export const AnyNull = runtime.AnyNull export const AnyNull = runtime.AnyNull;
export const ModelName = { export const ModelName = {
User: 'User', User: "User",
UserPreferences: 'UserPreferences', UserPreferences: "UserPreferences",
Event: 'Event', Event: "Event",
EventRegistration: 'EventRegistration', EventRegistration: "EventRegistration",
EventFeedback: 'EventFeedback', EventFeedback: "EventFeedback",
SitePreferences: 'SitePreferences', SitePreferences: "SitePreferences",
Challenge: 'Challenge' Challenge: "Challenge",
} as const } as const;
export type ModelName = (typeof ModelName)[keyof typeof ModelName] export type ModelName = (typeof ModelName)[keyof typeof ModelName];
/* /*
* Enums * Enums
*/ */
export const TransactionIsolationLevel = { export const TransactionIsolationLevel = {
Serializable: 'Serializable' Serializable: "Serializable",
} as const } as const;
export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]
export type TransactionIsolationLevel =
(typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel];
export const UserScalarFieldEnum = { export const UserScalarFieldEnum = {
id: 'id', id: "id",
email: 'email', email: "email",
password: 'password', password: "password",
username: 'username', username: "username",
role: 'role', role: "role",
score: 'score', score: "score",
level: 'level', level: "level",
hp: 'hp', hp: "hp",
maxHp: 'maxHp', maxHp: "maxHp",
xp: 'xp', xp: "xp",
maxXp: 'maxXp', maxXp: "maxXp",
avatar: 'avatar', avatar: "avatar",
createdAt: 'createdAt', createdAt: "createdAt",
updatedAt: 'updatedAt', updatedAt: "updatedAt",
bio: 'bio', bio: "bio",
characterClass: 'characterClass' characterClass: "characterClass",
} as const } as const;
export type UserScalarFieldEnum = (typeof UserScalarFieldEnum)[keyof typeof UserScalarFieldEnum]
export type UserScalarFieldEnum =
(typeof UserScalarFieldEnum)[keyof typeof UserScalarFieldEnum];
export const UserPreferencesScalarFieldEnum = { export const UserPreferencesScalarFieldEnum = {
id: 'id', id: "id",
userId: 'userId', userId: "userId",
homeBackground: 'homeBackground', homeBackground: "homeBackground",
eventsBackground: 'eventsBackground', eventsBackground: "eventsBackground",
leaderboardBackground: 'leaderboardBackground', leaderboardBackground: "leaderboardBackground",
theme: 'theme', theme: "theme",
createdAt: 'createdAt', createdAt: "createdAt",
updatedAt: 'updatedAt' updatedAt: "updatedAt",
} as const } as const;
export type UserPreferencesScalarFieldEnum = (typeof UserPreferencesScalarFieldEnum)[keyof typeof UserPreferencesScalarFieldEnum]
export type UserPreferencesScalarFieldEnum =
(typeof UserPreferencesScalarFieldEnum)[keyof typeof UserPreferencesScalarFieldEnum];
export const EventScalarFieldEnum = { export const EventScalarFieldEnum = {
id: 'id', id: "id",
date: 'date', date: "date",
name: 'name', name: "name",
description: 'description', description: "description",
type: 'type', type: "type",
room: 'room', room: "room",
time: 'time', time: "time",
maxPlaces: 'maxPlaces', maxPlaces: "maxPlaces",
createdAt: 'createdAt', createdAt: "createdAt",
updatedAt: 'updatedAt' updatedAt: "updatedAt",
} as const } as const;
export type EventScalarFieldEnum = (typeof EventScalarFieldEnum)[keyof typeof EventScalarFieldEnum]
export type EventScalarFieldEnum =
(typeof EventScalarFieldEnum)[keyof typeof EventScalarFieldEnum];
export const EventRegistrationScalarFieldEnum = { export const EventRegistrationScalarFieldEnum = {
id: 'id', id: "id",
userId: 'userId', userId: "userId",
eventId: 'eventId', eventId: "eventId",
createdAt: 'createdAt' createdAt: "createdAt",
} as const } as const;
export type EventRegistrationScalarFieldEnum = (typeof EventRegistrationScalarFieldEnum)[keyof typeof EventRegistrationScalarFieldEnum]
export type EventRegistrationScalarFieldEnum =
(typeof EventRegistrationScalarFieldEnum)[keyof typeof EventRegistrationScalarFieldEnum];
export const EventFeedbackScalarFieldEnum = { export const EventFeedbackScalarFieldEnum = {
id: 'id', id: "id",
userId: 'userId', userId: "userId",
eventId: 'eventId', eventId: "eventId",
rating: 'rating', rating: "rating",
comment: 'comment', comment: "comment",
createdAt: 'createdAt', createdAt: "createdAt",
updatedAt: 'updatedAt' updatedAt: "updatedAt",
} as const } as const;
export type EventFeedbackScalarFieldEnum = (typeof EventFeedbackScalarFieldEnum)[keyof typeof EventFeedbackScalarFieldEnum]
export type EventFeedbackScalarFieldEnum =
(typeof EventFeedbackScalarFieldEnum)[keyof typeof EventFeedbackScalarFieldEnum];
export const SitePreferencesScalarFieldEnum = { export const SitePreferencesScalarFieldEnum = {
id: 'id', id: "id",
homeBackground: 'homeBackground', homeBackground: "homeBackground",
eventsBackground: 'eventsBackground', eventsBackground: "eventsBackground",
leaderboardBackground: 'leaderboardBackground', leaderboardBackground: "leaderboardBackground",
createdAt: 'createdAt', createdAt: "createdAt",
updatedAt: 'updatedAt' updatedAt: "updatedAt",
} as const } as const;
export type SitePreferencesScalarFieldEnum = (typeof SitePreferencesScalarFieldEnum)[keyof typeof SitePreferencesScalarFieldEnum]
export type SitePreferencesScalarFieldEnum =
(typeof SitePreferencesScalarFieldEnum)[keyof typeof SitePreferencesScalarFieldEnum];
export const ChallengeScalarFieldEnum = { export const ChallengeScalarFieldEnum = {
id: 'id', id: "id",
challengerId: 'challengerId', challengerId: "challengerId",
challengedId: 'challengedId', challengedId: "challengedId",
title: 'title', title: "title",
description: 'description', description: "description",
pointsReward: 'pointsReward', pointsReward: "pointsReward",
status: 'status', status: "status",
adminId: 'adminId', adminId: "adminId",
adminComment: 'adminComment', adminComment: "adminComment",
winnerId: 'winnerId', winnerId: "winnerId",
createdAt: 'createdAt', createdAt: "createdAt",
acceptedAt: 'acceptedAt', acceptedAt: "acceptedAt",
completedAt: 'completedAt', completedAt: "completedAt",
updatedAt: 'updatedAt' updatedAt: "updatedAt",
} as const } as const;
export type ChallengeScalarFieldEnum = (typeof ChallengeScalarFieldEnum)[keyof typeof ChallengeScalarFieldEnum]
export type ChallengeScalarFieldEnum =
(typeof ChallengeScalarFieldEnum)[keyof typeof ChallengeScalarFieldEnum];
export const SortOrder = { export const SortOrder = {
asc: 'asc', asc: "asc",
desc: 'desc' desc: "desc",
} as const } as const;
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder];
export const NullsOrder = { export const NullsOrder = {
first: 'first', first: "first",
last: 'last' last: "last",
} as const } as const;
export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder]
export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder];

View File

@@ -1,18 +1,17 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */ /* eslint-disable */
// biome-ignore-all lint: generated file // biome-ignore-all lint: generated file
// @ts-nocheck // @ts-nocheck
/* /*
* This is a barrel export file for all models and their related types. * This is a barrel export file for all models and their related types.
* *
* 🟢 You can import this file directly. * 🟢 You can import this file directly.
*/ */
export type * from './models/User' export type * from "./models/User";
export type * from './models/UserPreferences' export type * from "./models/UserPreferences";
export type * from './models/Event' export type * from "./models/Event";
export type * from './models/EventRegistration' export type * from "./models/EventRegistration";
export type * from './models/EventFeedback' export type * from "./models/EventFeedback";
export type * from './models/SitePreferences' export type * from "./models/SitePreferences";
export type * from './models/Challenge' export type * from "./models/Challenge";
export type * from './commonInputTypes' export type * from "./commonInputTypes";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,4 +4,3 @@
* Tous les services doivent importer depuis ici, pas directement depuis lib/prisma.ts * Tous les services doivent importer depuis ici, pas directement depuis lib/prisma.ts
*/ */
export { prisma } from "@/lib/prisma"; export { prisma } from "@/lib/prisma";

View File

@@ -2,14 +2,20 @@
* Erreurs métier personnalisées * Erreurs métier personnalisées
*/ */
export class BusinessError extends Error { export class BusinessError extends Error {
constructor(message: string, public code?: string) { constructor(
message: string,
public code?: string
) {
super(message); super(message);
this.name = "BusinessError"; this.name = "BusinessError";
} }
} }
export class ValidationError extends BusinessError { export class ValidationError extends BusinessError {
constructor(message: string, public field?: string) { constructor(
message: string,
public field?: string
) {
super(message, "VALIDATION_ERROR"); super(message, "VALIDATION_ERROR");
this.name = "ValidationError"; this.name = "ValidationError";
} }
@@ -28,4 +34,3 @@ export class ConflictError extends BusinessError {
this.name = "ConflictError"; this.name = "ConflictError";
} }
} }

View File

@@ -1,8 +1,5 @@
import { prisma } from "../database"; import { prisma } from "../database";
import type { import type { Event, Prisma } from "@/prisma/generated/prisma/client";
Event,
Prisma,
} from "@/prisma/generated/prisma/client";
import { EventType } from "@/prisma/generated/prisma/client"; import { EventType } from "@/prisma/generated/prisma/client";
import { ValidationError, NotFoundError } from "../errors"; import { ValidationError, NotFoundError } from "../errors";
import { calculateEventStatus } from "@/lib/eventStatus"; import { calculateEventStatus } from "@/lib/eventStatus";

View File

@@ -1,5 +1,10 @@
import { prisma } from "../database"; import { prisma } from "../database";
import type { User, Role, Prisma, CharacterClass } from "@/prisma/generated/prisma/client"; import type {
User,
Role,
Prisma,
CharacterClass,
} from "@/prisma/generated/prisma/client";
import { NotFoundError } from "../errors"; import { NotFoundError } from "../errors";
import { userService } from "./user.service"; import { userService } from "./user.service";