2025-12-15 22:31:42 +07:00
|
|
|
|
import { useState, useEffect, useRef } from 'react'
|
2025-12-14 02:38:35 +07:00
|
|
|
|
import { useParams, useNavigate, Link } from 'react-router-dom'
|
2025-12-15 03:22:29 +07:00
|
|
|
|
import { marathonsApi, eventsApi, challengesApi } from '@/api'
|
|
|
|
|
|
import type { Marathon, ActiveEvent, Challenge } from '@/types'
|
2025-12-17 02:03:33 +07:00
|
|
|
|
import { NeonButton, GlassCard, StatsCard } from '@/components/ui'
|
2025-12-14 02:38:35 +07:00
|
|
|
|
import { useAuthStore } from '@/store/auth'
|
2025-12-16 01:50:40 +07:00
|
|
|
|
import { useToast } from '@/store/toast'
|
|
|
|
|
|
import { useConfirm } from '@/store/confirm'
|
2025-12-15 03:22:29 +07:00
|
|
|
|
import { EventBanner } from '@/components/EventBanner'
|
|
|
|
|
|
import { EventControl } from '@/components/EventControl'
|
2025-12-15 22:31:42 +07:00
|
|
|
|
import { ActivityFeed, type ActivityFeedRef } from '@/components/ActivityFeed'
|
2025-12-17 02:03:33 +07:00
|
|
|
|
import {
|
|
|
|
|
|
Users, Calendar, Trophy, Play, Settings, Copy, Check, Loader2, Trash2,
|
|
|
|
|
|
Globe, Lock, CalendarCheck, UserPlus, Gamepad2, ArrowLeft, Zap, Flag,
|
|
|
|
|
|
Star, Target, TrendingDown, ChevronDown, ChevronUp, Link2
|
|
|
|
|
|
} from 'lucide-react'
|
2025-12-14 02:38:35 +07:00
|
|
|
|
import { format } from 'date-fns'
|
2025-12-17 02:03:33 +07:00
|
|
|
|
import { ru } from 'date-fns/locale'
|
2025-12-14 02:38:35 +07:00
|
|
|
|
|
|
|
|
|
|
export function MarathonPage() {
|
|
|
|
|
|
const { id } = useParams<{ id: string }>()
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
const user = useAuthStore((state) => state.user)
|
2025-12-16 01:50:40 +07:00
|
|
|
|
const toast = useToast()
|
|
|
|
|
|
const confirm = useConfirm()
|
2025-12-14 02:38:35 +07:00
|
|
|
|
const [marathon, setMarathon] = useState<Marathon | null>(null)
|
2025-12-15 03:22:29 +07:00
|
|
|
|
const [activeEvent, setActiveEvent] = useState<ActiveEvent | null>(null)
|
|
|
|
|
|
const [challenges, setChallenges] = useState<Challenge[]>([])
|
2025-12-14 02:38:35 +07:00
|
|
|
|
const [isLoading, setIsLoading] = useState(true)
|
|
|
|
|
|
const [copied, setCopied] = useState(false)
|
2025-12-14 20:21:56 +07:00
|
|
|
|
const [isDeleting, setIsDeleting] = useState(false)
|
|
|
|
|
|
const [isJoining, setIsJoining] = useState(false)
|
2025-12-16 02:22:12 +07:00
|
|
|
|
const [isFinishing, setIsFinishing] = useState(false)
|
2025-12-15 03:22:29 +07:00
|
|
|
|
const [showEventControl, setShowEventControl] = useState(false)
|
2025-12-15 22:31:42 +07:00
|
|
|
|
const activityFeedRef = useRef<ActivityFeedRef>(null)
|
2025-12-14 02:38:35 +07:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
loadMarathon()
|
|
|
|
|
|
}, [id])
|
|
|
|
|
|
|
|
|
|
|
|
const loadMarathon = async () => {
|
|
|
|
|
|
if (!id) return
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = await marathonsApi.get(parseInt(id))
|
|
|
|
|
|
setMarathon(data)
|
2025-12-15 03:22:29 +07:00
|
|
|
|
|
|
|
|
|
|
if (data.status === 'active' && data.my_participation) {
|
|
|
|
|
|
const eventData = await eventsApi.getActive(parseInt(id))
|
|
|
|
|
|
setActiveEvent(eventData)
|
|
|
|
|
|
|
|
|
|
|
|
if (data.my_participation.role === 'organizer') {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const challengesData = await challengesApi.list(parseInt(id))
|
|
|
|
|
|
setChallenges(challengesData)
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
// Ignore if no challenges
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-14 02:38:35 +07:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Failed to load marathon:', error)
|
|
|
|
|
|
navigate('/marathons')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setIsLoading(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-15 03:22:29 +07:00
|
|
|
|
const refreshEvent = async () => {
|
|
|
|
|
|
if (!id) return
|
|
|
|
|
|
try {
|
|
|
|
|
|
const eventData = await eventsApi.getActive(parseInt(id))
|
|
|
|
|
|
setActiveEvent(eventData)
|
2025-12-15 22:31:42 +07:00
|
|
|
|
activityFeedRef.current?.refresh()
|
2025-12-15 03:22:29 +07:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Failed to refresh event:', error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-14 20:39:26 +07:00
|
|
|
|
const getInviteLink = () => {
|
|
|
|
|
|
if (!marathon) return ''
|
|
|
|
|
|
return `${window.location.origin}/invite/${marathon.invite_code}`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const copyInviteLink = () => {
|
2025-12-14 02:38:35 +07:00
|
|
|
|
if (marathon) {
|
2025-12-14 20:39:26 +07:00
|
|
|
|
navigator.clipboard.writeText(getInviteLink())
|
2025-12-14 02:38:35 +07:00
|
|
|
|
setCopied(true)
|
|
|
|
|
|
setTimeout(() => setCopied(false), 2000)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-14 20:21:56 +07:00
|
|
|
|
const handleDelete = async () => {
|
2025-12-16 01:50:40 +07:00
|
|
|
|
if (!marathon) return
|
|
|
|
|
|
|
|
|
|
|
|
const confirmed = await confirm({
|
|
|
|
|
|
title: 'Удалить марафон?',
|
|
|
|
|
|
message: 'Все данные марафона будут удалены безвозвратно.',
|
|
|
|
|
|
confirmText: 'Удалить',
|
|
|
|
|
|
cancelText: 'Отмена',
|
|
|
|
|
|
variant: 'danger',
|
|
|
|
|
|
})
|
|
|
|
|
|
if (!confirmed) return
|
2025-12-14 20:21:56 +07:00
|
|
|
|
|
|
|
|
|
|
setIsDeleting(true)
|
|
|
|
|
|
try {
|
|
|
|
|
|
await marathonsApi.delete(marathon.id)
|
|
|
|
|
|
navigate('/marathons')
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('Failed to delete marathon:', error)
|
2025-12-16 01:50:40 +07:00
|
|
|
|
toast.error('Не удалось удалить марафон')
|
2025-12-14 20:21:56 +07:00
|
|
|
|
} finally {
|
|
|
|
|
|
setIsDeleting(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleJoinPublic = async () => {
|
|
|
|
|
|
if (!marathon) return
|
|
|
|
|
|
|
|
|
|
|
|
setIsJoining(true)
|
|
|
|
|
|
try {
|
|
|
|
|
|
const updated = await marathonsApi.joinPublic(marathon.id)
|
|
|
|
|
|
setMarathon(updated)
|
|
|
|
|
|
} catch (err: unknown) {
|
|
|
|
|
|
const error = err as { response?: { data?: { detail?: string } } }
|
2025-12-16 01:50:40 +07:00
|
|
|
|
toast.error(error.response?.data?.detail || 'Не удалось присоединиться')
|
2025-12-14 20:21:56 +07:00
|
|
|
|
} finally {
|
|
|
|
|
|
setIsJoining(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-16 02:22:12 +07:00
|
|
|
|
const handleFinish = async () => {
|
|
|
|
|
|
if (!marathon) return
|
|
|
|
|
|
|
|
|
|
|
|
const confirmed = await confirm({
|
|
|
|
|
|
title: 'Завершить марафон?',
|
|
|
|
|
|
message: 'Марафон будет завершён досрочно. Участники больше не смогут выполнять задания.',
|
|
|
|
|
|
confirmText: 'Завершить',
|
|
|
|
|
|
cancelText: 'Отмена',
|
|
|
|
|
|
variant: 'warning',
|
|
|
|
|
|
})
|
|
|
|
|
|
if (!confirmed) return
|
|
|
|
|
|
|
|
|
|
|
|
setIsFinishing(true)
|
|
|
|
|
|
try {
|
|
|
|
|
|
const updated = await marathonsApi.finish(marathon.id)
|
|
|
|
|
|
setMarathon(updated)
|
|
|
|
|
|
toast.success('Марафон завершён')
|
|
|
|
|
|
} catch (err: unknown) {
|
|
|
|
|
|
const error = err as { response?: { data?: { detail?: string } } }
|
|
|
|
|
|
toast.error(error.response?.data?.detail || 'Не удалось завершить марафон')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setIsFinishing(false)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-14 02:38:35 +07:00
|
|
|
|
if (isLoading || !marathon) {
|
|
|
|
|
|
return (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="flex flex-col items-center justify-center py-24">
|
|
|
|
|
|
<Loader2 className="w-12 h-12 animate-spin text-neon-500 mb-4" />
|
|
|
|
|
|
<p className="text-gray-400">Загрузка марафона...</p>
|
2025-12-14 02:38:35 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-14 20:21:56 +07:00
|
|
|
|
const isOrganizer = marathon.my_participation?.role === 'organizer' || user?.role === 'admin'
|
2025-12-14 02:38:35 +07:00
|
|
|
|
const isParticipant = !!marathon.my_participation
|
2025-12-14 20:21:56 +07:00
|
|
|
|
const isCreator = marathon.creator.id === user?.id
|
|
|
|
|
|
const canDelete = isCreator || user?.role === 'admin'
|
2025-12-14 02:38:35 +07:00
|
|
|
|
|
2025-12-17 02:03:33 +07:00
|
|
|
|
const statusConfig = {
|
|
|
|
|
|
active: { color: 'text-neon-400', bg: 'bg-neon-500/20', border: 'border-neon-500/30', label: 'Активен' },
|
|
|
|
|
|
preparing: { color: 'text-yellow-400', bg: 'bg-yellow-500/20', border: 'border-yellow-500/30', label: 'Подготовка' },
|
|
|
|
|
|
finished: { color: 'text-gray-400', bg: 'bg-gray-500/20', border: 'border-gray-500/30', label: 'Завершён' },
|
|
|
|
|
|
}
|
|
|
|
|
|
const status = statusConfig[marathon.status as keyof typeof statusConfig] || statusConfig.finished
|
|
|
|
|
|
|
2025-12-14 02:38:35 +07:00
|
|
|
|
return (
|
2025-12-15 22:31:42 +07:00
|
|
|
|
<div className="max-w-7xl mx-auto">
|
2025-12-14 20:21:56 +07:00
|
|
|
|
{/* Back button */}
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<Link
|
|
|
|
|
|
to="/marathons"
|
|
|
|
|
|
className="inline-flex items-center gap-2 text-gray-400 hover:text-neon-400 mb-6 transition-colors group"
|
|
|
|
|
|
>
|
|
|
|
|
|
<ArrowLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" />
|
2025-12-14 20:21:56 +07:00
|
|
|
|
К списку марафонов
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
2025-12-17 02:03:33 +07:00
|
|
|
|
{/* Hero Banner */}
|
|
|
|
|
|
<div className="relative rounded-2xl overflow-hidden mb-8">
|
|
|
|
|
|
{/* Background */}
|
|
|
|
|
|
<div className="absolute inset-0 bg-gradient-to-br from-neon-500/10 via-dark-800 to-accent-500/10" />
|
|
|
|
|
|
<div className="absolute inset-0 bg-[linear-gradient(rgba(0,240,255,0.03)_1px,transparent_1px),linear-gradient(90deg,rgba(0,240,255,0.03)_1px,transparent_1px)] bg-[size:50px_50px]" />
|
|
|
|
|
|
|
|
|
|
|
|
<div className="relative p-8">
|
|
|
|
|
|
<div className="flex flex-col md:flex-row justify-between items-start gap-6">
|
|
|
|
|
|
{/* Title & Description */}
|
|
|
|
|
|
<div className="flex-1">
|
|
|
|
|
|
<div className="flex flex-wrap items-center gap-3 mb-3">
|
|
|
|
|
|
<h1 className="text-3xl md:text-4xl font-bold text-white">{marathon.title}</h1>
|
|
|
|
|
|
<span className={`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-full border ${
|
2025-12-15 22:31:42 +07:00
|
|
|
|
marathon.is_public
|
2025-12-17 02:03:33 +07:00
|
|
|
|
? 'bg-green-500/20 text-green-400 border-green-500/30'
|
|
|
|
|
|
: 'bg-dark-700 text-gray-300 border-dark-600'
|
2025-12-15 22:31:42 +07:00
|
|
|
|
}`}>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
{marathon.is_public ? <Globe className="w-3 h-3" /> : <Lock className="w-3 h-3" />}
|
|
|
|
|
|
{marathon.is_public ? 'Открытый' : 'Закрытый'}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span className={`flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-full border ${status.bg} ${status.color} ${status.border}`}>
|
|
|
|
|
|
<span className={`w-2 h-2 rounded-full ${marathon.status === 'active' ? 'bg-neon-500 animate-pulse' : marathon.status === 'preparing' ? 'bg-yellow-500' : 'bg-gray-500'}`} />
|
|
|
|
|
|
{status.label}
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{marathon.description && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<p className="text-gray-400 max-w-2xl">{marathon.description}</p>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-12-17 02:03:33 +07:00
|
|
|
|
{/* Action Buttons */}
|
|
|
|
|
|
<div className="flex flex-wrap gap-2">
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{marathon.is_public && !isParticipant && marathon.status !== 'finished' && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton onClick={handleJoinPublic} isLoading={isJoining} icon={<UserPlus className="w-4 h-4" />}>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
Присоединиться
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</NeonButton>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{marathon.status === 'preparing' && isOrganizer && (
|
|
|
|
|
|
<Link to={`/marathons/${id}/lobby`}>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton variant="secondary" icon={<Settings className="w-4 h-4" />}>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
Настройка
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</NeonButton>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</Link>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{marathon.status === 'preparing' && isParticipant && !isOrganizer && marathon.game_proposal_mode === 'all_participants' && (
|
|
|
|
|
|
<Link to={`/marathons/${id}/lobby`}>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton variant="secondary" icon={<Gamepad2 className="w-4 h-4" />}>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
Предложить игру
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</NeonButton>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</Link>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{marathon.status === 'active' && isParticipant && (
|
|
|
|
|
|
<Link to={`/marathons/${id}/play`}>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton icon={<Play className="w-4 h-4" />}>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
Играть
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</NeonButton>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</Link>
|
2025-12-14 20:21:56 +07:00
|
|
|
|
)}
|
2025-12-15 22:31:42 +07:00
|
|
|
|
|
|
|
|
|
|
<Link to={`/marathons/${id}/leaderboard`}>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton variant="outline" icon={<Trophy className="w-4 h-4" />}>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
Рейтинг
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</NeonButton>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</Link>
|
|
|
|
|
|
|
2025-12-16 02:22:12 +07:00
|
|
|
|
{marathon.status === 'active' && isOrganizer && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton
|
2025-12-16 02:22:12 +07:00
|
|
|
|
variant="secondary"
|
|
|
|
|
|
onClick={handleFinish}
|
|
|
|
|
|
isLoading={isFinishing}
|
2025-12-17 02:03:33 +07:00
|
|
|
|
icon={<Flag className="w-4 h-4" />}
|
|
|
|
|
|
className="!text-yellow-400 !border-yellow-500/30 hover:!bg-yellow-500/10"
|
2025-12-16 02:22:12 +07:00
|
|
|
|
>
|
|
|
|
|
|
Завершить
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</NeonButton>
|
2025-12-16 02:22:12 +07:00
|
|
|
|
)}
|
|
|
|
|
|
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{canDelete && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<NeonButton
|
2025-12-15 22:31:42 +07:00
|
|
|
|
variant="ghost"
|
|
|
|
|
|
onClick={handleDelete}
|
|
|
|
|
|
isLoading={isDeleting}
|
2025-12-17 02:03:33 +07:00
|
|
|
|
className="!text-red-400 hover:!bg-red-500/10"
|
|
|
|
|
|
icon={<Trash2 className="w-4 h-4" />}
|
|
|
|
|
|
/>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2025-12-14 20:21:56 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-12-14 02:38:35 +07:00
|
|
|
|
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="flex flex-col lg:flex-row gap-6">
|
|
|
|
|
|
{/* Main content */}
|
|
|
|
|
|
<div className="flex-1 min-w-0 space-y-6">
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{/* Stats */}
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="grid grid-cols-2 md:grid-cols-5 gap-4">
|
|
|
|
|
|
<StatsCard
|
|
|
|
|
|
label="Участников"
|
|
|
|
|
|
value={marathon.participants_count}
|
|
|
|
|
|
icon={<Users className="w-5 h-5" />}
|
|
|
|
|
|
color="neon"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<StatsCard
|
|
|
|
|
|
label="Игр"
|
|
|
|
|
|
value={marathon.games_count}
|
|
|
|
|
|
icon={<Gamepad2 className="w-5 h-5" />}
|
|
|
|
|
|
color="purple"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<StatsCard
|
|
|
|
|
|
label="Начало"
|
|
|
|
|
|
value={marathon.start_date ? format(new Date(marathon.start_date), 'd MMM', { locale: ru }) : '-'}
|
|
|
|
|
|
icon={<Calendar className="w-5 h-5" />}
|
|
|
|
|
|
color="default"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<StatsCard
|
|
|
|
|
|
label="Конец"
|
|
|
|
|
|
value={marathon.end_date ? format(new Date(marathon.end_date), 'd MMM', { locale: ru }) : '-'}
|
|
|
|
|
|
icon={<CalendarCheck className="w-5 h-5" />}
|
|
|
|
|
|
color="default"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<StatsCard
|
|
|
|
|
|
label="Статус"
|
|
|
|
|
|
value={status.label}
|
|
|
|
|
|
icon={<Target className="w-5 h-5" />}
|
|
|
|
|
|
color={marathon.status === 'active' ? 'neon' : marathon.status === 'preparing' ? 'default' : 'default'}
|
|
|
|
|
|
/>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-14 20:21:56 +07:00
|
|
|
|
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{/* Active event banner */}
|
|
|
|
|
|
{marathon.status === 'active' && activeEvent?.event && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<EventBanner activeEvent={activeEvent} onRefresh={refreshEvent} />
|
2025-12-14 02:38:35 +07:00
|
|
|
|
)}
|
|
|
|
|
|
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{/* Event control for organizers */}
|
|
|
|
|
|
{marathon.status === 'active' && isOrganizer && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<GlassCard>
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={() => setShowEventControl(!showEventControl)}
|
|
|
|
|
|
className="w-full flex items-center justify-between"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
|
<div className="w-10 h-10 rounded-xl bg-yellow-500/20 flex items-center justify-center">
|
|
|
|
|
|
<Zap className="w-5 h-5 text-yellow-400" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="text-left">
|
|
|
|
|
|
<h3 className="font-semibold text-white">Управление событиями</h3>
|
|
|
|
|
|
<p className="text-sm text-gray-400">Активируйте бонусы для участников</p>
|
|
|
|
|
|
</div>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
{showEventControl ? (
|
|
|
|
|
|
<ChevronUp className="w-5 h-5 text-gray-400" />
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<ChevronDown className="w-5 h-5 text-gray-400" />
|
|
|
|
|
|
)}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
{showEventControl && activeEvent && (
|
|
|
|
|
|
<div className="mt-6 pt-6 border-t border-dark-600">
|
2025-12-15 22:31:42 +07:00
|
|
|
|
<EventControl
|
|
|
|
|
|
marathonId={marathon.id}
|
|
|
|
|
|
activeEvent={activeEvent}
|
|
|
|
|
|
challenges={challenges}
|
|
|
|
|
|
onEventChange={refreshEvent}
|
|
|
|
|
|
/>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</GlassCard>
|
2025-12-14 20:21:56 +07:00
|
|
|
|
)}
|
|
|
|
|
|
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{/* Invite link */}
|
|
|
|
|
|
{marathon.status !== 'finished' && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<GlassCard>
|
|
|
|
|
|
<div className="flex items-center gap-3 mb-4">
|
|
|
|
|
|
<div className="w-10 h-10 rounded-xl bg-accent-500/20 flex items-center justify-center">
|
|
|
|
|
|
<Link2 className="w-5 h-5 text-accent-400" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<h3 className="font-semibold text-white">Пригласить друзей</h3>
|
|
|
|
|
|
<p className="text-sm text-gray-400">Поделитесь ссылкой</p>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
|
<code className="flex-1 px-4 py-3 bg-dark-700 rounded-xl text-neon-400 font-mono text-sm overflow-hidden text-ellipsis border border-dark-600">
|
|
|
|
|
|
{getInviteLink()}
|
|
|
|
|
|
</code>
|
|
|
|
|
|
<NeonButton variant="secondary" onClick={copyInviteLink} icon={copied ? <Check className="w-4 h-4" /> : <Copy className="w-4 h-4" />}>
|
|
|
|
|
|
{copied ? 'Скопировано!' : 'Копировать'}
|
|
|
|
|
|
</NeonButton>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</GlassCard>
|
2025-12-14 02:38:35 +07:00
|
|
|
|
)}
|
|
|
|
|
|
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{/* My stats */}
|
|
|
|
|
|
{marathon.my_participation && (
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<GlassCard variant="neon">
|
|
|
|
|
|
<h3 className="font-semibold text-white mb-4 flex items-center gap-2">
|
|
|
|
|
|
<Star className="w-5 h-5 text-yellow-500" />
|
|
|
|
|
|
Ваша статистика
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
<div className="grid grid-cols-3 gap-4">
|
|
|
|
|
|
<div className="text-center p-4 bg-dark-700/50 rounded-xl border border-dark-600">
|
|
|
|
|
|
<div className="text-3xl font-bold text-neon-400">
|
|
|
|
|
|
{marathon.my_participation.total_points}
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="text-sm text-gray-400 mt-1">Очков</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="text-center p-4 bg-dark-700/50 rounded-xl border border-dark-600">
|
|
|
|
|
|
<div className="text-3xl font-bold text-yellow-400 flex items-center justify-center gap-1">
|
|
|
|
|
|
{marathon.my_participation.current_streak}
|
|
|
|
|
|
{marathon.my_participation.current_streak > 0 && (
|
|
|
|
|
|
<span className="text-lg">🔥</span>
|
|
|
|
|
|
)}
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="text-sm text-gray-400 mt-1">Серия</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div className="text-center p-4 bg-dark-700/50 rounded-xl border border-dark-600">
|
|
|
|
|
|
<div className="text-3xl font-bold text-gray-400 flex items-center justify-center gap-1">
|
|
|
|
|
|
{marathon.my_participation.drop_count}
|
|
|
|
|
|
<TrendingDown className="w-5 h-5" />
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="text-sm text-gray-400 mt-1">Пропусков</div>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
2025-12-17 02:03:33 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
</GlassCard>
|
2025-12-14 20:21:56 +07:00
|
|
|
|
)}
|
2025-12-14 02:38:35 +07:00
|
|
|
|
</div>
|
2025-12-14 20:21:56 +07:00
|
|
|
|
|
2025-12-15 22:31:42 +07:00
|
|
|
|
{/* Activity Feed - right sidebar */}
|
|
|
|
|
|
{isParticipant && (
|
|
|
|
|
|
<div className="lg:w-96 flex-shrink-0">
|
2025-12-17 02:03:33 +07:00
|
|
|
|
<div className="lg:sticky lg:top-24">
|
2025-12-15 22:31:42 +07:00
|
|
|
|
<ActivityFeed
|
|
|
|
|
|
ref={activityFeedRef}
|
2025-12-15 03:22:29 +07:00
|
|
|
|
marathonId={marathon.id}
|
2025-12-15 22:31:42 +07:00
|
|
|
|
className="lg:max-h-[calc(100vh-8rem)]"
|
2025-12-15 03:22:29 +07:00
|
|
|
|
/>
|
2025-12-14 02:38:35 +07:00
|
|
|
|
</div>
|
2025-12-15 22:31:42 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2025-12-14 02:38:35 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|