'use client'; import { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import { Users, Trophy, Search, Plus, Sparkles, Crown, Star, TrendingUp, Shield, Zap, UserPlus, ChevronRight, Timer, Target, Award, Handshake, MessageCircle, Calendar, } from 'lucide-react'; import TeamCard from '@/components/teams/TeamCard'; import Button from '@/components/ui/Button'; import Card from '@/components/ui/Card'; import Input from '@/components/ui/Input'; import Heading from '@/components/ui/Heading'; import CreateTeamForm from '@/components/teams/CreateTeamForm'; import { getGetAllTeamsQuery, getGetTeamMembersQuery, getDriverStats } from '@/lib/di-container'; import type { Team } from '@gridpilot/racing'; // ============================================================================ // TYPES // ============================================================================ type SkillLevel = 'beginner' | 'intermediate' | 'advanced' | 'pro'; interface TeamDisplayData { id: string; name: string; memberCount: number; rating: number | null; totalWins: number; totalRaces: number; performanceLevel: SkillLevel; isRecruiting: boolean; createdAt: Date; description?: string; specialization?: 'endurance' | 'sprint' | 'mixed'; region?: string; languages?: string[]; } // ============================================================================ // DEMO TEAMS DATA // ============================================================================ const DEMO_TEAMS: TeamDisplayData[] = [ // Pro Teams { id: 'demo-team-1', name: 'Apex Predators Racing', description: 'Elite GT3 team competing at the highest level. Multiple championship winners seeking consistent drivers.', memberCount: 8, rating: 4850, totalWins: 47, totalRaces: 156, performanceLevel: 'pro', isRecruiting: true, createdAt: new Date(Date.now() - 180 * 24 * 60 * 60 * 1000), specialization: 'mixed', region: '🇺🇸 North America', languages: ['English'], }, { id: 'demo-team-2', name: 'Velocity Esports', description: 'Professional sim racing team with sponsors. Competing in major endurance events worldwide.', memberCount: 12, rating: 5200, totalWins: 63, totalRaces: 198, performanceLevel: 'pro', isRecruiting: false, createdAt: new Date(Date.now() - 365 * 24 * 60 * 60 * 1000), specialization: 'endurance', region: '🇬🇧 Europe', languages: ['English', 'German'], }, { id: 'demo-team-3', name: 'Nitro Motorsport', description: 'Championship-winning sprint specialists. Fast, consistent, and always fighting for podiums.', memberCount: 6, rating: 4720, totalWins: 38, totalRaces: 112, performanceLevel: 'pro', isRecruiting: true, createdAt: new Date(Date.now() - 90 * 24 * 60 * 60 * 1000), specialization: 'sprint', region: '🇩🇪 Germany', languages: ['German', 'English'], }, // Advanced Teams { id: 'demo-team-4', name: 'Horizon Racing Collective', description: 'Ambitious team on the rise. Building towards professional competition with dedicated drivers.', memberCount: 10, rating: 3800, totalWins: 24, totalRaces: 89, performanceLevel: 'advanced', isRecruiting: true, createdAt: new Date(Date.now() - 60 * 24 * 60 * 60 * 1000), specialization: 'mixed', region: '🇳🇱 Netherlands', languages: ['Dutch', 'English'], }, { id: 'demo-team-5', name: 'Phoenix Rising eSports', description: 'From the ashes to the podium. A team built on improvement and teamwork.', memberCount: 7, rating: 3650, totalWins: 19, totalRaces: 76, performanceLevel: 'advanced', isRecruiting: true, createdAt: new Date(Date.now() - 45 * 24 * 60 * 60 * 1000), specialization: 'endurance', region: '🇫🇷 France', languages: ['French', 'English'], }, { id: 'demo-team-6', name: 'Thunderbolt Racing', description: 'Fast and furious sprint racing. We live for wheel-to-wheel battles.', memberCount: 5, rating: 3420, totalWins: 15, totalRaces: 54, performanceLevel: 'advanced', isRecruiting: false, createdAt: new Date(Date.now() - 120 * 24 * 60 * 60 * 1000), specialization: 'sprint', region: '🇮🇹 Italy', languages: ['Italian', 'English'], }, // Intermediate Teams { id: 'demo-team-7', name: 'Grid Starters', description: 'Growing together as racers. Friendly competition with a focus on learning and fun.', memberCount: 9, rating: 2800, totalWins: 11, totalRaces: 67, performanceLevel: 'intermediate', isRecruiting: true, createdAt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000), specialization: 'mixed', region: '🇪🇸 Spain', languages: ['Spanish', 'English'], }, { id: 'demo-team-8', name: 'Midnight Racers', description: 'Night owls who love endurance racing. Join us for late-night stints and good vibes.', memberCount: 6, rating: 2650, totalWins: 8, totalRaces: 42, performanceLevel: 'intermediate', isRecruiting: true, createdAt: new Date(Date.now() - 15 * 24 * 60 * 60 * 1000), specialization: 'endurance', region: '🌍 International', languages: ['English'], }, { id: 'demo-team-9', name: 'Casual Speedsters', description: 'Racing for fun, improving together. No pressure, just clean racing.', memberCount: 4, rating: 2400, totalWins: 5, totalRaces: 31, performanceLevel: 'intermediate', isRecruiting: true, createdAt: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), specialization: 'sprint', region: '🇵🇱 Poland', languages: ['Polish', 'English'], }, // Beginner Teams { id: 'demo-team-10', name: 'Fresh Rubber Racing', description: 'New team for new racers! Learn the basics together in a supportive environment.', memberCount: 3, rating: 1800, totalWins: 2, totalRaces: 18, performanceLevel: 'beginner', isRecruiting: true, createdAt: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000), specialization: 'mixed', region: '🇧🇷 Brazil', languages: ['Portuguese', 'English'], }, { id: 'demo-team-11', name: 'Rookie Revolution', description: 'First time racers welcome! We all start somewhere.', memberCount: 5, rating: 1650, totalWins: 1, totalRaces: 12, performanceLevel: 'beginner', isRecruiting: true, createdAt: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000), specialization: 'sprint', region: '🇦🇺 Australia', languages: ['English'], }, { id: 'demo-team-12', name: 'Pit Lane Pioneers', description: 'Learning endurance racing from scratch. Long races, longer friendships.', memberCount: 4, rating: 1500, totalWins: 0, totalRaces: 8, performanceLevel: 'beginner', isRecruiting: true, createdAt: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000), specialization: 'endurance', region: '🇯🇵 Japan', languages: ['Japanese', 'English'], }, // Recently Added { id: 'demo-team-13', name: 'Shadow Squadron', description: 'Elite drivers emerging from the shadows. Watch out for us this season.', memberCount: 6, rating: 4100, totalWins: 12, totalRaces: 34, performanceLevel: 'advanced', isRecruiting: true, createdAt: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000), specialization: 'mixed', region: '🇸🇪 Scandinavia', languages: ['Swedish', 'Norwegian', 'English'], }, { id: 'demo-team-14', name: 'Turbo Collective', description: 'Fast, furious, and friendly. Sprint racing specialists looking for quick racers.', memberCount: 4, rating: 3200, totalWins: 7, totalRaces: 28, performanceLevel: 'intermediate', isRecruiting: true, createdAt: new Date(Date.now() - 12 * 60 * 60 * 1000), specialization: 'sprint', region: '🇨🇦 Canada', languages: ['English', 'French'], }, ]; // ============================================================================ // SKILL LEVEL CONFIG // ============================================================================ const SKILL_LEVELS: { id: SkillLevel; label: string; icon: React.ElementType; color: string; bgColor: string; borderColor: string; description: string; }[] = [ { id: 'pro', label: 'Pro', icon: Crown, color: 'text-yellow-400', bgColor: 'bg-yellow-400/10', borderColor: 'border-yellow-400/30', description: 'Elite competition, sponsored teams', }, { id: 'advanced', label: 'Advanced', icon: Star, color: 'text-purple-400', bgColor: 'bg-purple-400/10', borderColor: 'border-purple-400/30', description: 'Competitive racing, high consistency', }, { id: 'intermediate', label: 'Intermediate', icon: TrendingUp, color: 'text-primary-blue', bgColor: 'bg-primary-blue/10', borderColor: 'border-primary-blue/30', description: 'Growing skills, regular practice', }, { id: 'beginner', label: 'Beginner', icon: Shield, color: 'text-green-400', bgColor: 'bg-green-400/10', borderColor: 'border-green-400/30', description: 'Learning the basics, friendly environment', }, ]; // ============================================================================ // WHY JOIN A TEAM SECTION // ============================================================================ function WhyJoinTeamSection() { const benefits = [ { icon: Handshake, title: 'Shared Strategy', description: 'Develop setups together, share telemetry, and coordinate pit strategies for endurance races.', }, { icon: MessageCircle, title: 'Team Communication', description: 'Discord integration, voice chat during races, and dedicated team channels.', }, { icon: Calendar, title: 'Coordinated Schedule', description: 'Team calendars, practice sessions, and organized race attendance.', }, { icon: Trophy, title: 'Team Championships', description: 'Compete in team-based leagues and build your collective reputation.', }, ]; return (
Racing is better when you have teammates to share the journey
{benefit.description}
{level.description}
Teams actively recruiting new members
Highest rated racing teams
Loading teams...
Solo racing is great. Team racing is unforgettable. Join a team that matches your skill level and ambitions.
{/* Quick Stats */}Find Your Level
Be the first to create a racing team. Gather drivers and compete together in endurance events.
No teams found matching "{searchQuery}"