// src/components/match/MatchCard.tsx import Image from "next/image" import { Card, CardContent } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { PredictionBadge } from "./PredictionBadge" import { OddsRow } from "./OddsRow" // ← new import import { cn } from "@/lib/utils" import { EVTable } from "./EVTable" import type { NormalizedFixture, PredictionResponse, Outcome, EVAnalysis } from "@/types" // ← added EVAnalysis // ── Props ──────────────────────────────────────────────────────────────── interface Props { fixture: NormalizedFixture & { prediction?: PredictionResponse | null actual_result?: Outcome | null b365?: { h: number; d: number; a: number } | null // ← new ev_analysis?: EVAnalysis | null // ← new } } // ── Helpers ─────────────────────────────────────────────────────────────── function resultBadge(predicted?: Outcome, actual?: Outcome | null) { if (!predicted || !actual) return null const correct = predicted === actual return ( {correct ? "✓ Correct" : "✗ Incorrect"} ) } const OUTCOME_LABEL: Record = { H: "Home Win", D: "Draw", A: "Away Win" } const OUTCOME_COLOR: Record = { H: "bg-blue-100 text-blue-700 border-blue-300", D: "bg-yellow-100 text-yellow-700 border-yellow-300", A: "bg-red-100 text-red-700 border-red-300", } // ── Component ───────────────────────────────────────────────────────────── export function MatchCard({ fixture }: Props) { const { home_team, away_team, home_logo, away_logo, date, status, home_score, away_score, prediction, actual_result, b365, // ← destructure new props ev_analysis, // ← destructure new props } = fixture const isFinished = status === "post" const formatted = new Date(date).toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit", }) // Use card-level ev_analysis if prediction doesn't carry its own const activeEV = ev_analysis ?? prediction?.ev_analysis ?? null // Resolve the outcome label for the value bet banner const bestBetLabel = activeEV?.best_bet?.outcome === "H" ? home_team : activeEV?.best_bet?.outcome === "A" ? away_team : "Draw" return ( {/* ── Teams row ────────────────────────────────────────────── */}
{/* Home */}
{home_logo && ( {home_team} )} {home_team}
{/* Score or date */}
{isFinished && home_score !== undefined ? ( {home_score} – {away_score} ) : ( {formatted} )} {isFinished && ( Full Time )}
{/* Away */}
{away_logo && ( {away_team} )} {away_team}
{/* ── Prediction section ───────────────────────────────────── */} {prediction && (
{OUTCOME_LABEL[prediction.predicted]} = 0.50 ? "font-bold text-green-700" : prediction.confidence >= 0.40 ? "font-bold text-amber-600" : "text-muted-foreground" )}> {Math.round(prediction.confidence * 100)}% confidence {resultBadge(prediction.predicted, actual_result)}
{prediction.ev_analysis?.all_outcomes && ( )}
)} {/* ── B365 odds row (new in v2) ────────────────────────────── */} {b365 && ( )} {/* ── Value bet banner (updated in v2) ────────────────────── */} {activeEV?.has_value && activeEV.best_bet && (
🟢 VALUE BET → {bestBetLabel} @ {activeEV.best_bet.decimal_odd}
EV +{(activeEV.best_bet.ev * 100).toFixed(1)}% Kelly {Math.min(activeEV.best_bet.kelly_pct, 15).toFixed(1)}%
)}
) }