"use client" import { COLORS } from "./logic" interface ResultPanelProps { groups: { numbers: number[]; colorIndex: number }[] hasResult: boolean placeholder?: string } export function ResultPanel({ groups, hasResult, placeholder }: ResultPanelProps) { if (!hasResult || groups.length === 0) { return (
— AWAITING INPUT —
{placeholder && (
{placeholder}
)}
) } // 将groups分成pairs,每组人数>=15时单独一行 const rows: { numbers: number[]; colorIndex: number }[][] = [] let currentRow: { numbers: number[]; colorIndex: number }[] = [] for (const group of groups) { if (group.numbers.length >= 15) { // 单独一行 if (currentRow.length > 0) { rows.push(currentRow) currentRow = [] } rows.push([group]) } else { // 尝试凑成一行两组 currentRow.push(group) if (currentRow.length === 2) { rows.push(currentRow) currentRow = [] } } } // 处理剩余的组 if (currentRow.length > 0) { rows.push(currentRow) } return (
{rows.map((row, rowIdx) => (
{row.map((group, idx) => { const sorted = [...group.numbers].sort((a, b) => a - b) const color = COLORS[group.colorIndex] const globalIdx = groups.indexOf(group) return (
{/* Group label with color */}
G{String(globalIdx + 1).padStart(2, "0")} {String(group.numbers.length).padStart(2, "0")} P
{/* Numbers with color */}
{sorted.map((num) => ( {String(num).padStart(2, "0")} ))}
) })}
))}
) }