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
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m48s
This commit is contained in:
@@ -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)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user