Revert "Refactor challenge access checks and update text encoding: Remove unnecessary session variable in update and delete challenge functions. Update text in ChallengeManagement and ChallengesSection components for proper HTML encoding, enhancing display consistency."
This reverts commit 5e810202bb.
This commit is contained in:
@@ -97,7 +97,7 @@ export async function updateChallenge(
|
||||
}
|
||||
) {
|
||||
try {
|
||||
await checkAdminAccess()
|
||||
const session = await checkAdminAccess()
|
||||
|
||||
const challenge = await challengeService.updateChallenge(challengeId, {
|
||||
title: data.title,
|
||||
@@ -128,7 +128,7 @@ export async function updateChallenge(
|
||||
|
||||
export async function deleteChallenge(challengeId: string) {
|
||||
try {
|
||||
await checkAdminAccess()
|
||||
const session = await checkAdminAccess()
|
||||
|
||||
await challengeService.deleteChallenge(challengeId)
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ export default function ChallengeManagement() {
|
||||
{acceptedChallenges.length} défi{acceptedChallenges.length > 1 ? "s" : ""} en attente de validation
|
||||
{pendingChallenges.length > 0 && (
|
||||
<span className="ml-2">
|
||||
• {pendingChallenges.length} défi{pendingChallenges.length > 1 ? "s" : ""} en attente d'acceptation
|
||||
• {pendingChallenges.length} défi{pendingChallenges.length > 1 ? "s" : ""} en attente d'acceptation
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -241,7 +241,7 @@ export default function ChallengeManagement() {
|
||||
? "bg-green-500/20 text-green-400"
|
||||
: "bg-yellow-500/20 text-yellow-400"
|
||||
}`}>
|
||||
{challenge.status === "ACCEPTED" ? "Accepté" : "En attente d'acceptation"}
|
||||
{challenge.status === "ACCEPTED" ? "Accepté" : "En attente d'acceptation"}
|
||||
</span>
|
||||
</div>
|
||||
{challenge.acceptedAt && (
|
||||
|
||||
@@ -159,7 +159,7 @@ export default function ChallengesSection({ backgroundImage }: ChallengesSection
|
||||
const getStatusLabel = (status: string) => {
|
||||
switch (status) {
|
||||
case "PENDING":
|
||||
return "En attente d'acceptation";
|
||||
return "En attente d'acceptation";
|
||||
case "ACCEPTED":
|
||||
return "Accepté - En attente de validation admin";
|
||||
case "COMPLETED":
|
||||
@@ -308,7 +308,7 @@ export default function ChallengesSection({ backgroundImage }: ChallengesSection
|
||||
) : challenges.length === 0 ? (
|
||||
<Card variant="dark" className="p-6 text-center">
|
||||
<p className="text-gray-400">
|
||||
Vous n'avez aucun défi pour le moment.
|
||||
Vous n'avez aucun défi pour le moment.
|
||||
</p>
|
||||
</Card>
|
||||
) : (
|
||||
|
||||
@@ -4,7 +4,7 @@ import type {
|
||||
ChallengeStatus,
|
||||
Prisma,
|
||||
} from "@/prisma/generated/prisma/client";
|
||||
import { ValidationError, NotFoundError } from "../errors";
|
||||
import { ValidationError, NotFoundError, ConflictError } from "../errors";
|
||||
|
||||
export interface CreateChallengeInput {
|
||||
challengerId: string;
|
||||
@@ -293,13 +293,13 @@ export class ChallengeService {
|
||||
updateData.status = data.status;
|
||||
}
|
||||
if (data.adminId !== undefined) {
|
||||
updateData.admin = data.adminId ? { connect: { id: data.adminId } } : { disconnect: true };
|
||||
updateData.adminId = data.adminId;
|
||||
}
|
||||
if (data.adminComment !== undefined) {
|
||||
updateData.adminComment = data.adminComment;
|
||||
}
|
||||
if (data.winnerId !== undefined) {
|
||||
updateData.winner = data.winnerId ? { connect: { id: data.winnerId } } : { disconnect: true };
|
||||
updateData.winnerId = data.winnerId;
|
||||
}
|
||||
|
||||
return prisma.challenge.update({
|
||||
|
||||
Reference in New Issue
Block a user