"use client"; import { useEffect, useRef } from "react"; import KatexRenderer from "@/components/math/KatexRenderer"; import type { VariableTermChoice } from "@/lib/engine/variable-types"; interface VariableChoiceAnswerFormProps { choices: [VariableTermChoice[], VariableTermChoice[]]; selectedChoiceIds: [string | null, string | null]; activeTermIndex: 0 | 1; onSelectChoice: (termIndex: 0 | 1, choiceId: string) => void; onSubmit: () => void; } export default function VariableChoiceAnswerForm({ choices, selectedChoiceIds, activeTermIndex, onSelectChoice, onSubmit, }: VariableChoiceAnswerFormProps) { const firstChoiceRef = useRef(null); const submitButtonRef = useRef(null); const canSubmit = selectedChoiceIds[0] !== null && selectedChoiceIds[1] !== null; const activeChoices = choices[activeTermIndex]; useEffect(() => { firstChoiceRef.current?.focus(); }, [activeTermIndex]); useEffect(() => { if (canSubmit) { submitButtonRef.current?.focus(); } }, [canSubmit]); return (

{activeTermIndex === 0 ? "첫째 항" : "둘째 항"}을 고르세요.

괄호를 풀었을 때의 부호를 선택합니다.

{selectedChoiceIds.map((choiceId, index) => { const selected = activeTermIndex === index; return ( {choiceId ? `${index + 1}항 완료` : `${index + 1}항`} ); })}
{activeChoices.map((choice, index) => { const selected = selectedChoiceIds[activeTermIndex] === choice.id; return ( ); })}
); }