Rev 308 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React from "react";
import Option from "../option/Option";
const Question = (props) => {
// get props
const { question } = props;
return (
<div className="form-group" >
<label>{question.text}</label>
{question.type == 'open' &&
<div>
{question.multiline == 1 ? (
<textarea
className="form-control"
rows="5"
maxLength={question.maxlength}
name={question.slug_question}
id={question.slug_question}
></textarea>
) : (
<input
type="text"
className="form-control"
maxLength={question.maxlength}
name={question.slug_question}
id={question.slug_question} />
)}
</div>
}
{question.type == 'rating-range' &&
<div>
{Array.apply(0, Array(question.range)).map((_, i) => {
return (
<div className="radio radio-inline">
<input
key={i}
type="radio"
name={question.slug_question}
id={question.slug_question}
value={i} />
{i}
</div>
)
})}
</div>
}
{question.type == 'simple' || question.type == 'rating-open' || question.type=='multiple' &&
<div>
{question.options.length <= 0 &&
<Option question={question} />
}
</div>
}
</div>
)
}
export default Question;