'use client' import { useState } from "react" import { SurveyDetailRequest } from "@/types/Survey" interface EtcCheckboxProps { formName: keyof SurveyDetailRequest label: string detailInfoForm: SurveyDetailRequest setDetailInfoForm: (form: SurveyDetailRequest) => void } export default function EtcCheckbox({ formName, label, detailInfoForm, setDetailInfoForm }: EtcCheckboxProps) { const [showEtcInput, setShowEtcInput] = useState(false) const etcFieldName = `${formName}_etc` as keyof SurveyDetailRequest return (
setDetailInfoForm({ ...detailInfoForm, [formName]: e.target.checked ? 1 : 0 })} />
{ setShowEtcInput(e.target.checked) if (!e.target.checked) { setDetailInfoForm({ ...detailInfoForm, [etcFieldName]: '' }) } }} /> {showEtcInput && ( setDetailInfoForm({ ...detailInfoForm, [etcFieldName]: e.target.value })} className="border rounded px-2 py-1 ml-2" /> )}
) }