"use client"; import { useState } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; import { gameData } from "@/lib/game-data"; import { Clock, ArrowRight, Zap } from "lucide-react"; import Image from "next/image"; export function ProgressTimeline() { const [selectedRound, setSelectedRound] = useState(null); const formatTime = (timestamp: string) => { return new Date(timestamp).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true }); }; const getWordChanges = (roundIndex: number) => { if (roundIndex === 0) return null; const prevWords = new Set(gameData.rounds[roundIndex - 1].words); const currWords = new Set(gameData.rounds[roundIndex].words); const added = Array.from(currWords).filter(word => !prevWords.has(word)); const removed = Array.from(prevWords).filter(word => !currWords.has(word)); return { added, removed }; }; const selectedRoundData = gameData.rounds.find(round => round.id === selectedRound); return ( Game Progress Timeline
{gameData.rounds.map((round, index) => { const changes = getWordChanges(index); const isSignificantChange = changes && (changes.added.length > 0 || changes.removed.length > 0); return (
{round.roundNumber}

Round {round.roundNumber} {isSignificantChange && ( )}

{formatTime(round.timestamp)}
{round.words.slice(0, 5).map((word) => ( {word} ))} {round.words.length > 5 && ( +{round.words.length - 5} more )}
{changes && (changes.added.length > 0 || changes.removed.length > 0) && (
{changes.added.length > 0 && ( +{changes.added.length} added )} {changes.removed.length > 0 && ( -{changes.removed.length} removed )}
)}
Round {round.roundNumber} - {formatTime(round.timestamp)}
{`Screenshot

Words in this round:

{round.words.map((word) => ( {word} ))}
{changes && (changes.added.length > 0 || changes.removed.length > 0) && (
{changes.added.length > 0 && (
Added words:
{changes.added.map((word) => ( +{word} ))}
)} {changes.removed.length > 0 && (
Removed words:
{changes.removed.map((word) => ( -{word} ))}
)}
)}
); })}
); }