Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 336 | Rev 342 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
306 geraldo 1
import React from "react";
2
import Option from "../option/Option";
3
 
4
const Question = (props) => {
310 geraldo 5
 
306 geraldo 6
    // get props
340 geraldo 7
    const { question, backendVars, handleAnswer } = props;
306 geraldo 8
 
9
    return (
313 geraldo 10
        <div className="col-md-12 col-sm-12 col-xs-12 np-padding">
310 geraldo 11
            <div className="form-group" >
333 geraldo 12
                <h6>{backendVars.LBL_QUESTION} #{question.position + 1}</h6>
310 geraldo 13
                <div
14
                    dangerouslySetInnerHTML={{ __html: question.text }}
15
                    className="title"
16
                />
17
            </div>
306 geraldo 18
            {question.type == 'open' &&
310 geraldo 19
                <div className="form-group">
306 geraldo 20
                    {question.multiline == 1 ? (
21
                        <textarea
22
                            className="form-control"
23
                            rows="5"
24
                            maxLength={question.maxlength}
25
                            name={question.slug_question}
340 geraldo 26
                            onChange={e => handleAnswer(
27
                                question.slug_section,
28
                                question.slug_question,
29
                                e.target.value)}
306 geraldo 30
                        ></textarea>
31
                    ) : (
32
                        <input
33
                            type="text"
34
                            className="form-control"
35
                            maxLength={question.maxlength}
340 geraldo 36
                            name={question.slug_question}
37
                            onChange={e => handleAnswer(
38
                                question.slug_section,
39
                                question.slug_question,
40
                                e.target.value)} />
306 geraldo 41
                    )}
42
                </div>
43
            }
44
            {question.type == 'rating-range' &&
310 geraldo 45
                <div className="form-group">
334 geraldo 46
                    {[...Array(parseInt(question.range))].map((x, i) => {
306 geraldo 47
                        return (
333 geraldo 48
                            <div className="checkbox"
49
                                key={i}>
306 geraldo 50
                                <input
51
                                    type="radio"
52
                                    name={question.slug_question}
340 geraldo 53
                                    onChange={e => handleAnswer(
54
                                        question.slug_section,
55
                                        question.slug_question,
56
                                        e.target.value)}
336 geraldo 57
                                    value={i + 1} />
333 geraldo 58
                                <div className="option">
336 geraldo 59
                                    {i + 1}
333 geraldo 60
                                </div>
306 geraldo 61
                            </div>
62
                        )
63
                    })}
64
                </div>
65
            }
333 geraldo 66
            {(question.type == 'simple' || question.type == 'rating-open' || question.type == 'multiple') &&
310 geraldo 67
                <div className="form-group">
323 geraldo 68
                    {question.options.length > 0 &&
340 geraldo 69
                        <Option
70
                            question={question}
71
                            handleAnswer={handleAnswer} />
306 geraldo 72
                    }
73
                </div>
74
            }
75
        </div>
76
    )
77
}
78
 
79
export default Question;