diff --git a/contracts/Cargo.lock b/contracts/Cargo.lock index 12c0eb7d..ba023de2 100644 --- a/contracts/Cargo.lock +++ b/contracts/Cargo.lock @@ -14,13 +14,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "analytics" -version = "0.1.0" -dependencies = [ - "soroban-sdk", -] - [[package]] name = "android_system_properties" version = "0.1.5" @@ -364,14 +357,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "cross-game-assets" -version = "0.1.0" -dependencies = [ - "arenax-events", - "soroban-sdk", -] - [[package]] name = "crypto-bigint" version = "0.5.5" diff --git a/frontend/src/app/tournaments/create/page.tsx b/frontend/src/app/tournaments/create/page.tsx deleted file mode 100644 index 72c08018..00000000 --- a/frontend/src/app/tournaments/create/page.tsx +++ /dev/null @@ -1,814 +0,0 @@ -"use client"; - -import { useState, useEffect, useCallback } from "react"; -import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/Card"; -import { Button } from "@/components/ui/Button"; -import { Input } from "@/components/ui/Input"; -import { FormError } from "@/components/ui/FormError"; -import { motion, AnimatePresence } from "framer-motion"; -import { - ChevronRight, - ChevronLeft, - Check, - Save, - Eye, - Share2, - Copy, - Twitter, - Facebook, - Trophy, - Calendar, - Users, - DollarSign, - Gamepad2 -} from "lucide-react"; -import { TournamentType, TournamentVisibility } from "@/types/tournament"; - -type Step = 1 | 2 | 3 | 4 | "preview" | "success"; - -interface TournamentFormData { - // Step 1: Basic Info - name: string; - gameType: string; - description: string; - // Step 2: Format & Rules - tournamentType: TournamentType; - matchFormat: string; - rules: string; - // Step 3: Entry & Prizes - entryFee: number; - prizePool: number; - prizeDistribution: string; - // Step 4: Schedule & Registration - visibility: TournamentVisibility; - maxParticipants: number; - registrationOpenDate: string; - registrationCloseDate: string; - startDate: string; - endDate: string; -} - -const initialFormData: TournamentFormData = { - name: "", - gameType: "", - description: "", - tournamentType: "single_elimination", - matchFormat: "bo3", - rules: "", - entryFee: 0, - prizePool: 0, - prizeDistribution: "", - visibility: "public", - maxParticipants: 16, - registrationOpenDate: "", - registrationCloseDate: "", - startDate: "", - endDate: "", -}; - -const gameTypes = [ - "League of Legends", - "Valorant", - "Counter-Strike 2", - "Dota 2", - "Fortnite", - "Rocket League", - "Apex Legends", - "Overwatch 2", - "Street Fighter 6", - "Super Smash Bros", - "Other", -]; - -const matchFormats = [ - { value: "bo1", label: "Best of 1" }, - { value: "bo3", label: "Best of 3" }, - { value: "bo5", label: "Best of 5" }, - { value: "bo7", label: "Best of 7" }, -]; - -const tournamentTypes: { value: TournamentType; label: string; description: string }[] = [ - { value: "single_elimination", label: "Single Elimination", description: "Lose once and you're out" }, - { value: "double_elimination", label: "Double Elimination", description: "Two chances before elimination" }, - { value: "round_robin", label: "Round Robin", description: "Everyone plays everyone" }, - { value: "swiss", label: "Swiss System", description: "Pairings based on performance" }, -]; - -export default function CreateTournamentPage() { - const [currentStep, setCurrentStep] = useState(1); - const [formData, setFormData] = useState(initialFormData); - const [errors, setErrors] = useState>({}); - const [isSaving, setIsSaving] = useState(false); - const [isSubmitting, setIsSubmitting] = useState(false); - const [draftSaved, setDraftSaved] = useState(false); - const [createdTournamentId, setCreatedTournamentId] = useState(""); - - // Load draft from localStorage on mount - useEffect(() => { - const savedDraft = localStorage.getItem("tournament_draft"); - if (savedDraft) { - try { - const parsed = JSON.parse(savedDraft); - setFormData(parsed); - setDraftSaved(true); - } catch (e) { - console.error("Failed to load draft:", e); - } - } - }, []); - - // Save draft to localStorage - const saveDraft = useCallback(() => { - setIsSaving(true); - localStorage.setItem("tournament_draft", JSON.stringify(formData)); - setTimeout(() => { - setIsSaving(false); - setDraftSaved(true); - setTimeout(() => setDraftSaved(false), 2000); - }, 500); - }, [formData]); - - // Auto-save draft on form changes - useEffect(() => { - const timer = setTimeout(() => { - saveDraft(); - }, 1000); - return () => clearTimeout(timer); - }, [formData, saveDraft]); - - const validateStep = (step: Step): boolean => { - const newErrors: Record = {}; - - if (step === 1) { - if (!formData.name.trim()) newErrors.name = "Tournament name is required"; - if (!formData.gameType) newErrors.gameType = "Game type is required"; - if (!formData.description.trim()) newErrors.description = "Description is required"; - } - - if (step === 2) { - if (!formData.matchFormat) newErrors.matchFormat = "Match format is required"; - if (!formData.rules.trim()) newErrors.rules = "Rules are required"; - } - - if (step === 3) { - if (formData.entryFee < 0) newErrors.entryFee = "Entry fee cannot be negative"; - if (formData.prizePool < 0) newErrors.prizePool = "Prize pool cannot be negative"; - if (formData.prizePool > 0 && !formData.prizeDistribution.trim()) { - newErrors.prizeDistribution = "Prize distribution is required when prize pool is set"; - } - } - - if (step === 4) { - if (!formData.registrationOpenDate) newErrors.registrationOpenDate = "Registration open date is required"; - if (!formData.registrationCloseDate) newErrors.registrationCloseDate = "Registration close date is required"; - if (!formData.startDate) newErrors.startDate = "Start date is required"; - if (formData.maxParticipants < 2) newErrors.maxParticipants = "Minimum 2 participants required"; - - if (formData.registrationOpenDate && formData.registrationCloseDate) { - if (new Date(formData.registrationOpenDate) >= new Date(formData.registrationCloseDate)) { - newErrors.registrationCloseDate = "Registration close date must be after open date"; - } - } - - if (formData.startDate && formData.registrationCloseDate) { - if (new Date(formData.registrationCloseDate) > new Date(formData.startDate)) { - newErrors.startDate = "Start date must be after registration close date"; - } - } - } - - setErrors(newErrors); - return Object.keys(newErrors).length === 0; - }; - - const handleNext = () => { - if (validateStep(currentStep)) { - setCurrentStep((prev) => (prev === 4 ? "preview" : (prev as Step) + 1) as Step); - } - }; - - const handleBack = () => { - setCurrentStep((prev) => (prev === "preview" ? 4 : (prev as Step) - 1) as Step); - }; - - const handleFieldChange = (field: keyof TournamentFormData, value: string | number) => { - setFormData((prev) => ({ ...prev, [field]: value })); - // Clear error for this field - if (errors[field]) { - setErrors((prev) => { - const newErrors = { ...prev }; - delete newErrors[field]; - return newErrors; - }); - } - }; - - const handleSubmit = async () => { - if (!validateStep(4)) return; - - setIsSubmitting(true); - - // Simulate API call - await new Promise((resolve) => setTimeout(resolve, 2000)); - - // Generate mock tournament ID - const tournamentId = `t_${Date.now()}`; - setCreatedTournamentId(tournamentId); - - // Clear draft - localStorage.removeItem("tournament_draft"); - - setCurrentStep("success"); - setIsSubmitting(false); - }; - - const handleCopyLink = () => { - const link = `${window.location.origin}/tournaments/${createdTournamentId}`; - navigator.clipboard.writeText(link); - }; - - const steps = [ - { number: 1, title: "Basic Info", icon: Gamepad2 }, - { number: 2, title: "Format & Rules", icon: Trophy }, - { number: 3, title: "Entry & Prizes", icon: DollarSign }, - { number: 4, title: "Schedule", icon: Calendar }, - ]; - - return ( -
-
- {/* Header */} -
-

- Create Tournament -

-

- Set up your tournament in a few simple steps -

-
- - {/* Progress Indicator */} - {currentStep !== "success" && ( -
-
- {steps.map((step, index) => { - const Icon = step.icon; - const isActive = currentStep === step.number; - const isCompleted = (typeof currentStep === "number" && currentStep > step.number) || currentStep === "preview"; - - return ( -
-
-
- {isCompleted ? ( - - ) : ( - - )} -
- - {step.title} - -
- {index < steps.length - 1 && ( -
- )} -
- ); - })} -
- - {/* Draft saved indicator */} -
-
- - Draft {draftSaved ? "saved" : "auto-saving..."} -
-
-
- )} - - {/* Form Content */} - - {currentStep === 1 && ( - - - - Basic Information - - Tell us about your tournament - - - -
- - handleFieldChange("name", e.target.value)} - error={!!errors.name} - /> - {errors.name &&

{errors.name}

} -
- -
- - - {errors.gameType &&

{errors.gameType}

} -
- -
- -