"use client"; import { useEffect, useRef } from "react"; import AnswerResultLine from "@/components/game/AnswerResultLine"; import type { GradeResult, ParenthesisSignProblem } from "@/lib/engine/types"; interface FeedbackPanelProps { result: GradeResult; problem: ParenthesisSignProblem; isLastProblem: boolean; onNext: () => void; } function formatSignedNumber(value: number) { return value < 0 ? `(${value})` : `${value}`; } export default function FeedbackPanel({ result, problem, isLastProblem, onNext, }: FeedbackPanelProps) { const nextButtonRef = useRef(null); const signedTerms = [ problem.a, problem.operator === "-" ? -problem.b : problem.b, ] as const; const feedbackItems = signedTerms.map((term, index) => ({ formulaLatex: `${formatSignedNumber( problem.multiplier, )}\\times ${formatSignedNumber(term)}`, userAnswer: result.userAnswer[index], correctAnswer: result.correctAnswer[index], correct: result.userAnswer[index] === result.correctAnswer[index], })); useEffect(() => { nextButtonRef.current?.focus(); }, []); return (

{result.correct ? "정답입니다." : "오답입니다."}

); }