"use client"; import type { QuestionField } from "@/lib/schema-adapter"; import { useQuestionAnswers } from "./question-answer-storage"; import QuestionTitle from "./question-title"; type QuestionCheckboxProps = { question: QuestionField; disabled?: boolean; }; export function QuestionCheckbox({ question, disabled, }: QuestionCheckboxProps) { const options = question.options || []; const { getAnswerValue, setAnswerValue } = useQuestionAnswers(); const rawValue = getAnswerValue(question); const value = Array.isArray(rawValue) ? rawValue : rawValue ? [String(rawValue)] : []; const isSingleCheckbox = options.length === 0; if (isSingleCheckbox) { const isChecked = Boolean( rawValue === true || rawValue === "true" || rawValue === "confirmed" || (Array.isArray(rawValue) && rawValue.length > 0), ); const toggleSingle = () => { setAnswerValue(question, isChecked ? null : ["confirmed"]); }; const labelText = question.description || question.title || "تأیید میکنم که نام، سن، تصویر و اطلاعات هویتی من با مدارک بارگذاریشده مطابقت دارد."; return (