import { Badge } from "@/shared/ui/badge" import type { SelectionPatternScore } from "../api/selection.types" interface PatternScoreProps { score: SelectionPatternScore | null } const breakdownLabels = { trend_structure: "趋势", kdj_state: "KDJ", volume_pattern: "量能", price_shape: "价格形态", } as const export function PatternScoreSummary({ score }: PatternScoreProps) { if (!score) return 未评分 if (score.status === "failed") { return 评分暂不可用 } if (score.status === "below_threshold") { return ( 未匹配到 {formatScore(score.threshold)} 分以上案例 ) } return ( {formatScore(score.value)} 分 {score.case?.name ?? "最佳案例未知"} ) } export function PatternScoreDetails({ score }: PatternScoreProps) { if (!score) { return (

本次运行未执行图形评分。

) } if (score.status === "failed") { return (
评分暂不可用

{score.reason || "案例库或评分计算暂时不可用。"}

) } if (score.status === "below_threshold") { return (
低于匹配阈值

未匹配到 {formatScore(score.threshold)} 分以上案例。

) } return (

{formatScore(score.value)} 分

最佳案例:{score.case?.name ?? "未知"}

已匹配
{score.breakdown ? (
{Object.entries(breakdownLabels).map(([key, label]) => (
{label}
{formatScore( score.breakdown?.[key as keyof typeof breakdownLabels], )}
))}
) : null}
) } function formatScore(value: number | null | undefined) { return value === null || value === undefined ? "—" : value.toFixed(2) }