Spaces:
Sleeping
Sleeping
Download src/components/RegistrationView.tsx from Musabek/NOVAESPORT: direct link, hf CLI and curl.
- Browser
- Download file 18.5 kB
-
https://huggingface.co/spaces/Musabek/NOVAESPORT/resolve/main/src/components/RegistrationView.tsx
- Command line
-
hf download hf://spaces/Musabek/NOVAESPORT/src/components/RegistrationView.tsx
-
curl -L -o RegistrationView.tsx https://huggingface.co/spaces/Musabek/NOVAESPORT/resolve/main/src/components/RegistrationView.tsx
18.5 kB
| import React, { useState } from 'react'; | |
| import { Tournament, User } from '../types'; | |
| import { Info, ShieldAlert, CheckCircle2, UserCheck, Users, HelpCircle, Calendar, Trophy, ChevronRight } from 'lucide-react'; | |
| import { PrizePoolBadge } from './PrizePoolBadge'; | |
| import { Language } from '../translations'; | |
| interface RegistrationViewProps { | |
| tournaments: Tournament[]; | |
| currentUser: User; | |
| onRegisterTournament: (tournamentId: string, playerDetails: { gamerTag: string; extraInfo?: string }) => void; | |
| selectedTournamentId: string; | |
| onSelectTournamentId: (id: string) => void; | |
| currentLanguage: Language; | |
| } | |
| export const RegistrationView: React.FC<RegistrationViewProps> = ({ | |
| tournaments, | |
| currentUser, | |
| onRegisterTournament, | |
| selectedTournamentId, | |
| onSelectTournamentId, | |
| currentLanguage, | |
| }) => { | |
| const [filterCategory, setFilterCategory] = useState<'all' | 'solo' | 'team'>('all'); | |
| // Registration Form state | |
| const [gamerTag, setGamerTag] = useState(currentUser.username || ''); | |
| const [gameCoordId, setGameCoordId] = useState(currentUser.gameID || ''); | |
| const [platform, setPlatform] = useState('Mobile'); | |
| const [teamName, setTeamName] = useState(''); | |
| const [rosters, setRosters] = useState<string[]>(['', '', '', '']); // 4 extra members | |
| const [acceptedTerms, setAcceptedTerms] = useState(false); | |
| const [formSuccess, setFormSuccess] = useState(false); | |
| const [errorMsg, setErrorMsg] = useState(''); | |
| // Active tourney logic | |
| const selectedTourney = tournaments.find((t) => t.id === selectedTournamentId) || tournaments[0]; | |
| const filteredTourneys = tournaments.filter((t) => { | |
| if (filterCategory === 'all') return true; | |
| return t.category === filterCategory; | |
| }); | |
| const isAlreadyRegistered = currentUser.registeredTournaments.includes(selectedTourney?.id); | |
| const handleSubmit = (e: React.FormEvent) => { | |
| e.preventDefault(); | |
| setErrorMsg(''); | |
| if (!acceptedTerms) { | |
| setErrorMsg('You must accept the terms of fair play before submitting registration.'); | |
| return; | |
| } | |
| // Construct extra details based on Solo / Team | |
| const extraInfo = selectedTourney.category === 'team' | |
| ? `Team: ${teamName} | Rosters: [${gamerTag}, ${rosters.filter(r => r).join(', ')}]` | |
| : `Game ID: ${gameCoordId} | Platform: ${platform}`; | |
| onRegisterTournament(selectedTourney.id, { | |
| gamerTag: gamerTag, | |
| extraInfo, | |
| }); | |
| setFormSuccess(true); | |
| setTimeout(() => { | |
| setFormSuccess(false); | |
| }, 5000); | |
| }; | |
| const handleRosterChange = (index: number, val: string) => { | |
| const updated = [...rosters]; | |
| updated[index] = val; | |
| setRosters(updated); | |
| }; | |
| return ( | |
| <div className="max-w-7xl mx-auto px-4 py-8 space-y-12 animate-in fade-in duration-300 font-sans" id="registration-dashboard-view"> | |
| {/* Title */} | |
| <div className="border-b border-cyan-500/20 pb-4"> | |
| <h1 className="text-3xl font-black text-white uppercase tracking-wider font-mono"> | |
| π Esports Registry Chamber | |
| </h1> | |
| <p className="text-slate-400 text-sm mt-1"> | |
| Secure your team slot, read regulatory provisions, and lock configurations for active matches. | |
| </p> | |
| </div> | |
| {/* Grid: Left - Tourneys column, Right - Registration Form details */} | |
| <div className="grid grid-cols-1 lg:grid-cols-12 gap-8"> | |
| {/* Left column (Col 1-5): Tournament picker list */} | |
| <div className="lg:col-span-5 space-y-6"> | |
| <div className="flex justify-between items-center bg-white/5 p-3 rounded-lg border border-white/10 backdrop-blur-sm"> | |
| <span className="text-xs font-bold text-slate-300 font-mono uppercase">Category Filter</span> | |
| <div className="flex gap-1"> | |
| {(['all', 'solo', 'team'] as const).map((cat) => ( | |
| <button | |
| key={cat} | |
| onClick={() => setFilterCategory(cat)} | |
| className={`px-3 py-1 text-[10px] font-mono font-bold capitalize rounded-md transition-all cursor-pointer ${ | |
| filterCategory === cat | |
| ? 'bg-cyan-500 text-white' | |
| : 'text-slate-400 hover:text-white bg-slate-950/50 border border-white/5' | |
| }`} | |
| > | |
| {cat} | |
| </button> | |
| ))} | |
| </div> | |
| </div> | |
| <div className="space-y-3.5 max-h-[600px] overflow-y-auto pr-1.5 custom-scrollbar"> | |
| {filteredTourneys.map((tour) => { | |
| const isSelected = tour.id === selectedTourney?.id; | |
| const belongsUser = currentUser.registeredTournaments.includes(tour.id); | |
| return ( | |
| <div | |
| key={tour.id} | |
| onClick={() => { | |
| onSelectTournamentId(tour.id); | |
| setFormSuccess(false); | |
| }} | |
| className={`p-4 rounded-xl border transition-all cursor-pointer text-left relative backdrop-blur-sm ${ | |
| isSelected | |
| ? 'bg-white/10 border-cyan-500/80 shadow-md shadow-cyan-950/20' | |
| : 'bg-white/5 border-white/10 hover:border-cyan-500/20' | |
| }`} | |
| > | |
| {belongsUser && ( | |
| <span className="absolute top-3 right-3 bg-emerald-950 border border-emerald-500/30 font-bold font-mono text-[9px] px-2 py-0.5 rounded uppercase text-emerald-400"> | |
| β Registered | |
| </span> | |
| )} | |
| <span className="text-[10px] text-slate-400 uppercase tracking-widest font-bold font-mono"> | |
| {tour.gameTitle} | |
| </span> | |
| <h3 className="text-sm font-semibold text-white tracking-wide uppercase mt-1"> | |
| {tour.title} | |
| </h3> | |
| <div className="mt-3 space-y-2.5"> | |
| <PrizePoolBadge | |
| prizePool={tour.prizePool} | |
| prizeDistribution={tour.prizeDistribution} | |
| currentLanguage={currentLanguage} | |
| size="sm" | |
| /> | |
| <div className="flex items-center justify-between text-[11px] text-slate-400 font-mono"> | |
| <span>Fee: <strong className="text-cyan-400">{tour.entryFee}</strong></span> | |
| <span>Slots: <strong>{tour.slotsFilled}/{tour.slotsTotal}</strong></span> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| </div> | |
| {/* Right column (Col 6-12): Selected Tournament details & Form */} | |
| <div className="lg:col-span-7 space-y-6"> | |
| {selectedTourney && ( | |
| <> | |
| {/* Selected Tourney Card */} | |
| <div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-2xl overflow-hidden relative p-6 space-y-4"> | |
| <div className="absolute top-0 right-0 w-32 h-32 bg-cyan-500/5 rounded-full blur-2xl" /> | |
| <div className="flex flex-col md:flex-row md:items-center justify-between gap-2 border-b border-white/10 pb-4"> | |
| <div> | |
| <span className="text-xs bg-white/5 text-cyan-400 border border-white/10 px-3 py-1 rounded font-bold uppercase font-mono tracking-wider"> | |
| {selectedTourney.category} Tournament | |
| </span> | |
| <h2 className="text-xl font-bold text-white uppercase tracking-wider font-mono mt-2.5"> | |
| {selectedTourney.title} | |
| </h2> | |
| </div> | |
| <div className="text-right text-xs"> | |
| <span className="block text-slate-400 font-mono">START DATE</span> | |
| <span className="text-white font-mono font-bold">{selectedTourney.startDate} @ {selectedTourney.startTime}</span> | |
| </div> | |
| </div> | |
| {/* Large Dynamic Prize Pool Component */} | |
| <PrizePoolBadge | |
| prizePool={selectedTourney.prizePool} | |
| prizeDistribution={selectedTourney.prizeDistribution} | |
| currentLanguage={currentLanguage} | |
| /> | |
| {/* Regulations & Core terms */} | |
| <div className="grid grid-cols-1 md:grid-cols-2 gap-6 pt-2"> | |
| <div className="space-y-2.5"> | |
| <h4 className="text-xs font-bold text-slate-300 uppercase tracking-widest font-mono flex items-center gap-1.5"> | |
| <ShieldAlert className="w-4 h-4 text-cyan-400" /> Ground Rules | |
| </h4> | |
| <ul className="space-y-1.5 text-[11px] text-slate-400 leading-relaxed list-disc list-inside"> | |
| {selectedTourney.rules.map((rule, idx) => ( | |
| <li key={idx}>{rule}</li> | |
| ))} | |
| </ul> | |
| </div> | |
| <div className="space-y-2.5"> | |
| <h4 className="text-xs font-bold text-slate-300 uppercase tracking-widest font-mono flex items-center gap-1.5"> | |
| <Info className="w-4 h-4 text-purple-400" /> Gamer Requirements | |
| </h4> | |
| <ul className="space-y-1.5 text-[11px] text-slate-400 leading-relaxed list-inside list-disc"> | |
| {selectedTourney.requirements.map((req, idx) => ( | |
| <li key={idx}>{req}</li> | |
| ))} | |
| </ul> | |
| </div> | |
| </div> | |
| {/* Dynamic Register/Status panel */} | |
| <div className="border-t border-white/10 pt-6"> | |
| {isAlreadyRegistered ? ( | |
| <div className="bg-emerald-950/40 border border-green-500/20 backdrop-blur-sm rounded-xl p-5 flex items-center gap-4 animate-in zoom-in-95"> | |
| <div className="w-10 h-10 rounded-full bg-emerald-500/10 border border-emerald-500/30 flex items-center justify-center text-emerald-400"> | |
| <CheckCircle2 className="w-6 h-6" /> | |
| </div> | |
| <div className="text-left font-sans"> | |
| <h4 className="text-xs font-bold text-white uppercase tracking-wide">Registration is Active</h4> | |
| <p className="text-[11px] text-slate-400 mt-0.5">Your squad slots are secure. Be inside the Arena chat lobby 15 minutes before setup start.</p> | |
| </div> | |
| </div> | |
| ) : selectedTourney.status === 'completed' ? ( | |
| <div className="bg-[#020205]/40 border border-white/10 backdrop-blur-sm rounded-xl p-5 text-center text-slate-500 text-xs"> | |
| This tournament has completed. Registration is closed. | |
| </div> | |
| ) : ( | |
| <div> | |
| {formSuccess ? ( | |
| <div className="bg-emerald-950/40 border border-emerald-500/30 rounded-xl p-4 text-center text-emerald-300 text-xs font-bold mb-4 animate-in fade-in"> | |
| π Registration Successful! Code telemetry assigned to {currentUser.username}. | |
| </div> | |
| ) : ( | |
| <form onSubmit={handleSubmit} className="space-y-4"> | |
| <h3 className="text-sm font-bold text-white uppercase tracking-wider font-mono"> | |
| βοΈ Secure Your Contest Entry Slot | |
| </h3> | |
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label className="block text-[10px] font-bold text-slate-400 uppercase mb-1">Gamer Tag Identity</label> | |
| <input | |
| type="text" | |
| value={gamerTag} | |
| onChange={(e) => setGamerTag(e.target.value)} | |
| className="w-full bg-[#020205]/40 text-white rounded-lg border border-white/10 focus:border-cyan-500 p-2.5 text-xs outline-none backdrop-blur-sm" | |
| required | |
| /> | |
| </div> | |
| {selectedTourney.category === 'solo' ? ( | |
| <div> | |
| <label className="block text-[10px] font-bold text-slate-400 uppercase mb-1">Account ID coordinate</label> | |
| <input | |
| type="text" | |
| value={gameCoordId} | |
| onChange={(e) => setGameCoordId(e.target.value)} | |
| placeholder="e.g. 58390142" | |
| className="w-full bg-[#020205]/40 text-white rounded-lg border border-white/10 focus:border-cyan-500 p-2.5 text-xs outline-none backdrop-blur-sm" | |
| required | |
| /> | |
| </div> | |
| ) : ( | |
| <div> | |
| <label className="block text-[10px] font-bold text-slate-400 uppercase mb-1">Squad Team Name</label> | |
| <input | |
| type="text" | |
| value={teamName} | |
| onChange={(e) => setTeamName(e.target.value)} | |
| placeholder="e.g. Apex Predators" | |
| className="w-full bg-[#020205]/40 text-white rounded-lg border border-white/10 focus:border-cyan-500 p-2.5 text-xs outline-none backdrop-blur-sm" | |
| required | |
| /> | |
| </div> | |
| )} | |
| </div> | |
| {selectedTourney.category === 'solo' ? ( | |
| <div> | |
| <label className="block text-[10px] font-bold text-slate-400 uppercase mb-1">Operational Platform</label> | |
| <select | |
| value={platform} | |
| onChange={(e) => setPlatform(e.target.value)} | |
| className="w-full bg-[#020205]/40 text-white rounded-lg border border-white/10 p-2.5 text-xs outline-none backdrop-blur-sm" | |
| > | |
| <option value="Mobile" className="bg-[#020205] text-white">Mobile Smartphone</option> | |
| <option value="PC" className="bg-[#020205] text-white">PC Desktop Systems</option> | |
| <option value="Console" className="bg-[#020205] text-white">Console (Playstation/Xbox)</option> | |
| </select> | |
| </div> | |
| ) : ( | |
| <div className="space-y-2"> | |
| <label className="block text-[10px] font-bold text-slate-400 uppercase">Input Squad Rosters Members (Gamer Tags)</label> | |
| <div className="grid grid-cols-2 gap-2"> | |
| {rosters.map((roster, idx) => ( | |
| <input | |
| key={idx} | |
| type="text" | |
| value={roster} | |
| onChange={(e) => handleRosterChange(idx, e.target.value)} | |
| placeholder={`Roster Player #${idx + 2} nickname`} | |
| className="w-full bg-[#020205]/40 text-white rounded-lg border border-white/10 focus:border-cyan-500 p-2 text-xs outline-none backdrop-blur-sm" | |
| required | |
| /> | |
| ))} | |
| </div> | |
| </div> | |
| )} | |
| <div className="bg-[#020205]/40 p-3 rounded-lg border border-white/10 flex items-start gap-2 text-[10px] text-slate-400 backdrop-blur-sm"> | |
| <input | |
| type="checkbox" | |
| id="terms" | |
| checked={acceptedTerms} | |
| onChange={(e) => { | |
| setAcceptedTerms(e.target.checked); | |
| if (e.target.checked) setErrorMsg(''); | |
| }} | |
| className="w-4 h-4 rounded text-cyan-600 bg-slate-950 border-slate-750 focus:ring-cyan-500 mt-0.5" | |
| required | |
| /> | |
| <label htmlFor="terms" className="leading-snug cursor-pointer font-sans select-none"> | |
| I certify that our rosters conform to the guidelines, the Level 4 Anti-Cheat tracking rules, and we will avoid exploit setups under pain of forfeiture. | |
| </label> | |
| </div> | |
| {errorMsg && ( | |
| <div className="p-3 bg-red-950/40 border border-red-500/20 text-red-400 text-xs rounded-lg flex items-center gap-2 font-mono"> | |
| <span>β {errorMsg}</span> | |
| </div> | |
| )} | |
| <button | |
| type="submit" | |
| className="w-full bg-gradient-to-r from-cyan-500 to-purple-600 hover:from-cyan-400 hover:to-purple-500 text-white font-bold py-3 px-4 rounded-xl text-xs uppercase tracking-wider animation-all active:scale-[98%] cursor-pointer" | |
| > | |
| Lock Squad Registry Slot | |
| </button> | |
| </form> | |
| )} | |
| </div> | |
| )} | |
| </div> | |
| </div> | |
| </> | |
| )} | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| }; | |