import React from 'react'; import { useGame } from '../context/GameContext'; import { GamePhase } from '../types'; import type { Player } from '../types'; import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer, Cell } from 'recharts'; import { Trophy, Zap, Users } from 'lucide-react'; export const SpectatorView: React.FC = () => { const { gameState, questions, teams, players, buzzQueue } = useGame(); const currentQ = questions[gameState.currentQuestionIndex]; // Helper to get formatted leaderboard data const leaderboardData = [...teams].sort((a, b) => b.score - a.score); const COLORS = ['#F59E0B', '#3B82F6', '#10B981', '#EC4899', '#8B5CF6']; // Helper for YouTube ID extraction const getYoutubeId = (url: string) => { const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/; const match = url.match(regExp); return (match && match[2].length === 11) ? match[2] : null; }; const renderContent = () => { switch (gameState.phase) { case GamePhase.LOBBY: return (

JOIN THE QUIZ

QR Code

Scan to Join

{players.filter(p => p.isApproved).map(p => (
{p.name}
))}
); case GamePhase.COUNTDOWN: return (
{gameState.countdownValue}
); case GamePhase.QUESTION_DISPLAY: case GamePhase.BUZZER_OPEN: case GamePhase.ADJUDICATION: return (
{currentQ?.category || 'General'} {currentQ?.points} PTS

{currentQ?.text}

{/* Media Display */} {currentQ?.mediaUrl && (
{currentQ.mediaType === 'video' ? (