From fe6012b7a3ffdaec29a8903fca1dfbf9d253e4b8 Mon Sep 17 00:00:00 2001 From: Oronemu Date: Tue, 16 Dec 2025 03:27:57 +0700 Subject: [PATCH] Add manual add for challanges --- frontend/src/components/EventControl.tsx | 42 +++- frontend/src/pages/LobbyPage.tsx | 268 +++++++++++++++++++---- 2 files changed, 269 insertions(+), 41 deletions(-) diff --git a/frontend/src/components/EventControl.tsx b/frontend/src/components/EventControl.tsx index dac2610..33e4b36 100644 --- a/frontend/src/components/EventControl.tsx +++ b/frontend/src/components/EventControl.tsx @@ -32,6 +32,16 @@ const EVENT_ICONS: Record = { game_choice: , } +// Default durations for events (in minutes) +const DEFAULT_DURATIONS: Record = { + golden_hour: 45, + common_enemy: null, // Until all complete + double_risk: 120, + jackpot: null, // 1 spin + swap: 60, + game_choice: 120, +} + export function EventControl({ marathonId, activeEvent, @@ -42,9 +52,17 @@ export function EventControl({ const confirm = useConfirm() const [selectedType, setSelectedType] = useState('golden_hour') const [selectedChallengeId, setSelectedChallengeId] = useState(null) + const [durationMinutes, setDurationMinutes] = useState(45) const [isStarting, setIsStarting] = useState(false) const [isStopping, setIsStopping] = useState(false) + // Update duration when event type changes + const handleTypeChange = (type: EventType) => { + setSelectedType(type) + const defaultDuration = DEFAULT_DURATIONS[type] + setDurationMinutes(defaultDuration ?? '') + } + const handleStart = async () => { if (selectedType === 'common_enemy' && !selectedChallengeId) { toast.warning('Выберите челлендж для события "Общий враг"') @@ -55,6 +73,7 @@ export function EventControl({ try { await eventsApi.start(marathonId, { type: selectedType, + duration_minutes: durationMinutes || undefined, challenge_id: selectedType === 'common_enemy' ? selectedChallengeId ?? undefined : undefined, }) onEventChange() @@ -119,7 +138,7 @@ export function EventControl({ {EVENT_TYPES.map((type) => ( )} -
{challenge.title}
-

{challenge.description}

- - {isOrganizer && ( + )) + ) : ( +

+ Нет заданий +

+ )} + + {/* Add challenge form */} + {isOrganizer && game.status === 'approved' && ( + addingChallengeToGameId === game.id ? ( +
+

Новое задание

+ setNewChallenge(prev => ({ ...prev, title: e.target.value }))} + /> +