Add admin challenge acceptance functionality: Implement adminAcceptChallenge method in ChallengeService, allowing admins to accept pending challenges. Update ChallengeManagement component to include a button for accepting challenges, enhancing admin capabilities and user feedback handling.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m48s

This commit is contained in:
Julien Froidefond
2025-12-17 08:14:58 +01:00
parent 7c0b3bc848
commit ba3b2c17b9
3 changed files with 96 additions and 0 deletions

View File

@@ -120,6 +120,34 @@ export class ChallengeService {
});
}
/**
* Accepte un défi en tant qu'admin (bypass les vérifications utilisateur)
*/
async adminAcceptChallenge(challengeId: string): Promise<Challenge> {
const challenge = await prisma.challenge.findUnique({
where: { id: challengeId },
});
if (!challenge) {
throw new NotFoundError("Défi");
}
// Vérifier que le défi est en attente
if (challenge.status !== "PENDING") {
throw new ValidationError(
"Ce défi ne peut plus être accepté (statut: " + challenge.status + ")"
);
}
return prisma.challenge.update({
where: { id: challengeId },
data: {
status: "ACCEPTED",
acceptedAt: new Date(),
},
});
}
/**
* Annule un défi (par le challenger ou le challenged)
*/