Rev 447 | Rev 457 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from "react";
const Option = (props) => {
// get props
const { question, handleAnswer } = props;
return (
<div>
{question.options.map((opt, key) => {
return (
<div className="checkbox"
key={key}>
{question.type == 'multiple' &&
<input
type="checkbox"
name={`${opt.slug_option}[]`}
value={opt.slug_option}
checked={question.answer.includes(opt.slug_option)}
onChange={() => handleAnswer(question.slug_section, question.slug_question, opt.slug_option)}
/>
}
{question.type != 'multiple' &&
<input
type="radio"
name={`${opt.slug_question}`}
value={opt.slug_option}
checked={question.answer == opt.slug_option}
onChange={() => handleAnswer(question.slug_section, question.slug_question, opt.slug_option)}
/>
}
<div
dangerouslySetInnerHTML={{ __html: opt.text }}
className="option"
/>
</div>
)
})}
</div>
)
}
export default Option;