diff --git a/app/components/standings/PointsDisplay.tsx b/app/components/standings/PointsDisplay.tsx new file mode 100644 index 0000000..ee26457 --- /dev/null +++ b/app/components/standings/PointsDisplay.tsx @@ -0,0 +1,37 @@ +/** + * Reusable component for displaying actual / projected points in a stacked format. + * Used in standings tables and anywhere else points need to be shown with projections. + */ +interface PointsDisplayProps { + actualPoints: number | null | undefined; + projectedPoints: number | null | undefined; + totalPoints: number; + participantsRemaining?: number; +} + +export function PointsDisplay({ + actualPoints, + projectedPoints, + totalPoints, + participantsRemaining, +}: PointsDisplayProps) { + const displayed = actualPoints !== null && actualPoints !== undefined ? actualPoints : totalPoints; + const hasProjection = + projectedPoints !== null && + projectedPoints !== undefined && + participantsRemaining !== undefined && + participantsRemaining > 0; + + if (!hasProjection) { + return {displayed.toFixed(2)}; + } + + return ( +