import React, { useEffect } from 'react'; import { Player } from '../types'; import { motion } from 'framer-motion'; import { Trophy, Medal, RotateCcw } from 'lucide-react'; import confetti from 'canvas-confetti'; import { PlayerAvatar } from './PlayerAvatar'; interface PodiumProps { players: Player[]; onRestart: () => void; } export const Podium: React.FC = ({ players, onRestart }) => { const sorted = [...players].sort((a, b) => b.score - a.score); const winner = sorted[0]; const second = sorted[1]; const third = sorted[2]; useEffect(() => { const duration = 3 * 1000; const animationEnd = Date.now() + duration; const defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 }; const randomInRange = (min: number, max: number) => Math.random() * (max - min) + min; const interval: any = setInterval(function() { const timeLeft = animationEnd - Date.now(); if (timeLeft <= 0) return clearInterval(interval); const particleCount = 50 * (timeLeft / duration); confetti({ ...defaults, particleCount, origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 } }); confetti({ ...defaults, particleCount, origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 } }); }, 250); return () => clearInterval(interval); }, []); return (

Podium

{/* Second Place */} {second && (
{second.name}
{second.score}
)} {/* First Place */} {winner && (
{winner.name}
{winner.score}
)} {/* Third Place */} {third && (
{third.name}
{third.score}
)}
); };