import { players } from '@/app/(home)/major-league-balatro/_constants/players' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Card } from '@/components/ui/card' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { cn } from '@/lib/utils' import { SiTwitch, SiYoutube } from '@icons-pack/react-simple-icons' import { Calendar, Camera, Clock, TvMinimalPlay, Twitch, Youtube, } from 'lucide-react' import Link from 'next/link' import { useMemo } from 'react' import type { BadgeProps, Match, WeekConfig } from '../types' import { PlayerAvatar } from './player-avatar' const WEEK_CONFIG: Record = { 1: { label: 'Week 1: April 6-12, 2025', badgeProps: { variant: 'outline', className: 'border-green-500 bg-green-500/10 text-green-500', text: 'Completed', }, }, 2: { label: 'Week 2: April 13-19, 2025', badgeProps: { variant: 'outline', className: 'border-blue-500 bg-blue-500/10 text-blue-500', text: 'Current Week', }, }, 3: { label: 'Week 3: April 20-26, 2025', }, 4: { label: 'Week 4: April 27-May 3, 2025', }, // 5: { // label: 'Week 5: May 4-10, 2025', // }, // 'Play-in': { // label: 'Play-in Week: May 11-16, 2025', // status: 'playoff', // badgeProps: { // variant: 'outline', // className: 'border-purple-500 bg-purple-500/10 text-purple-500', // text: 'Playoff', // }, // }, // Finals: { // label: 'League Finals: May 17, 2025', // status: 'finals', // badgeProps: { // variant: 'outline', // className: 'border-red-500 bg-red-500/10 text-red-500', // text: 'Championship', // }, // }, } const DEFAULT_BADGE_PROPS: BadgeProps = { variant: 'outline', className: 'bg-muted text-muted-foreground', text: 'Upcoming', } type StatusBadgeProps = { status: 'completed' | 'current' | 'upcoming' } const StatusBadge = ({ status }: StatusBadgeProps) => { const { variant, className } = WEEK_CONFIG[status]?.badgeProps || DEFAULT_BADGE_PROPS const text = status === 'completed' ? 'Completed' : status === 'current' ? 'Current Week' : 'Upcoming' return ( {text} ) } type MatchDivisionProps = { division: 'Blue' | 'Red' } const MatchDivision = ({ division }: MatchDivisionProps) => { const bgColor = division === 'Blue' ? 'bg-blue-950/20' : 'bg-red-950/20' const textColor = division === 'Blue' ? 'border-blue-500 text-blue-500' : 'border-red-500 text-red-500' return (
{division} Division
) } type MatchDateTimeProps = { date: string time: string } const MatchDateTime = ({ date, time }: MatchDateTimeProps) => (
{date} {time}
) type VodButtonProps = { url: string player: string } const VodButton = ({ url, player }: VodButtonProps) => ( ) type LiveButtonProps = { username: string } const LiveButton = ({ username }: LiveButtonProps) => ( ) type MatchCardProps = { match: Match } const MatchCard = ({ match }: MatchCardProps) => { const { player1Id, player2Id, date, time, completed, vod1, vod2 } = match const player1 = players[player1Id] const player2 = players[player2Id] if (!player1) { throw new Error(`Player ${player1Id} not found`) } if (!player2) { throw new Error(`Player ${player2Id} not found`) } return (
{date} • {time}

{player1.name} vs {player2.name}

{completed ? ( <> {vod1 && ( {player1.name} )} {vod2 && ( {player2.name} )} ) : ( {player1.name} {player2.name} )}
) } type WeekTabProps = { week: string | number matches: Match[] status: 'current' | 'completed' | 'upcoming' } const WeekTab = ({ week, matches, status }: WeekTabProps) => { const weekConfig = WEEK_CONFIG[week] if (!weekConfig) { throw new Error(`Week ${week} not found in WEEK_CONFIG`) } const filteredMatches = useMemo( () => matches.filter( (m) => m.week === week || m.week === Number.parseInt(String(week)) ), [matches, week] ) return (

{weekConfig.label}

{filteredMatches.map((match, index) => ( ))}
) } type MlbScheduleProps = { matches: Match[] } export function MlbSchedule({ matches }: MlbScheduleProps) { const sortedMatches = useMemo( () => [...matches].sort((a, b) => { if (typeof a.week === 'string' || typeof b.week === 'string') { return String(a.week).localeCompare(String(b.week)) } return a.week - b.week }), [matches] ) const currentWeek = useMemo(() => { const now = new Date() return ( sortedMatches.find((match) => new Date(match.datetime) > now)?.week || 1 ) }, [sortedMatches]) console.log(currentWeek) return (

Tournament Schedule

All matches from April to May 2025

{Object.keys(WEEK_CONFIG).map((week) => ( Week {week} ))} {Object.keys(WEEK_CONFIG).map((week) => { const weekNumber = Number.parseInt(week) const status = !Number.isNaN(weekNumber) && weekNumber === currentWeek ? 'current' : // @ts-ignore weekNumber > currentWeek ? 'upcoming' : 'completed' return ( ) })}
) }