import { Form, Link } from "react-router"; import type { Route } from "./+types/admin.sports-seasons.$id.events.$eventId"; import { loader, action } from "./admin.sports-seasons.$id.events.$eventId.server"; import { Button } from "~/components/ui/button"; import { Input } from "~/components/ui/input"; import { Label } from "~/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "~/components/ui/card"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "~/components/ui/select"; import { Badge } from "~/components/ui/badge"; import { ArrowLeft, Trophy, CheckCircle2, Pencil, Trash2, Brackets } from "lucide-react"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "~/components/ui/table"; export { loader, action }; export default function EventResults({ loaderData, actionData, }: Route.ComponentProps) { const { sportsSeason, event, participants, results } = loaderData; // Create a map of participants with results for easy lookup const participantResultsMap = new Map( results.map((r: { participant: { id: string } }) => [r.participant.id, r]) ); // Get participants without results const participantsWithoutResults = participants.filter( (p: { id: string }) => !participantResultsMap.has(p.id) ); // Sort results by placement const sortedResults = [...results].sort((a, b) => (a.placement || 999) - (b.placement || 999)); const getEventTypeLabel = (type: string) => { switch (type) { case "playoff_game": return "Bracket"; case "major_tournament": return "Major Tournament"; case "final_standings": return "Final Standings"; default: return type; } }; return (
{sportsSeason.sport.name} - {sportsSeason.name} •{" "} {getEventTypeLabel(event.eventType)} {event.playoffRound && ` • ${event.playoffRound}`}
No results added yet. Add results using the form above.
) : (