import { Form, Link } from "react-router"; import type { Route } from "./+types/admin.sports-seasons.$id.expected-values"; import { loader, action } from "./admin.sports-seasons.$id.expected-values.server"; import { Button } from "~/components/ui/button"; import { Input } from "~/components/ui/input"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "~/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "~/components/ui/table"; import { ArrowLeft, Save, Calculator } from "lucide-react"; export { loader, action }; export default function ExpectedValuesPage({ loaderData, actionData }: Route.ComponentProps) { const { sportsSeason, participants, existingEVs } = loaderData; const totalEV = Array.from(existingEVs.values()).reduce( (sum, ev) => sum + parseFloat(ev.expectedValue), 0 ); return (
Expected Values: {sportsSeason.sport.name} {sportsSeason.year} Manage probability distributions and expected values for participants {actionData?.error && (
{actionData.error}
)} {actionData?.success && (
All participants saved successfully!
)}

Default Scoring Rules (for EV calculation):

1st: 100 pts 2nd: 70 pts 3rd: 50 pts 4th: 40 pts 5th: 25 pts 6th: 25 pts 7th: 15 pts 8th: 15 pts

Note: EVs will be recalculated with actual league scoring rules when used in fantasy leagues.

Participant 1st % 2nd % 3rd % 4th % 5th % 6th % 7th % 8th % EV {participants.map((participant: { id: string; name: string }) => { const existingEV = existingEVs.get(participant.id); const id = participant.id; return ( {participant.name} {existingEV ? parseFloat(existingEV.expectedValue).toFixed(2) : "-"} ); })} {existingEVs.size > 0 && ( Total EV {totalEV.toFixed(2)} )}
{participants.length === 0 ? (

No participants found. Please add participants to this sports season first.

) : (
)}
); }