Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 340 | Rev 431 | 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}
342 geraldo 26
                            onChange={e =>
27
                                handleAnswer(question.slug_section, question.slug_question, e.target.value)
28
                            }
29
                        />
306 geraldo 30
                    ) : (
31
                        <input
32
                            type="text"
33
                            className="form-control"
34
                            maxLength={question.maxlength}
340 geraldo 35
                            name={question.slug_question}
342 geraldo 36
                            onChange={e =>
37
                                handleAnswer(question.slug_section, question.slug_question, e.target.value)
38
                            }
39
                        />
306 geraldo 40
                    )}
41
                </div>
42
            }
43
            {question.type == 'rating-range' &&
310 geraldo 44
                <div className="form-group">
334 geraldo 45
                    {[...Array(parseInt(question.range))].map((x, i) => {
306 geraldo 46
                        return (
333 geraldo 47
                            <div className="checkbox"
48
                                key={i}>
306 geraldo 49
                                <input
50
                                    type="radio"
51
                                    name={question.slug_question}
342 geraldo 52
                                    value={i + 1}
53
                                    onChange={() =>
54
                                        handleAnswer(question.slug_section, question.slug_question, i + 1)
55
                                    }
56
                                />
333 geraldo 57
                                <div className="option">
336 geraldo 58
                                    {i + 1}
333 geraldo 59
                                </div>
306 geraldo 60
                            </div>
61
                        )
62
                    })}
63
                </div>
64
            }
333 geraldo 65
            {(question.type == 'simple' || question.type == 'rating-open' || question.type == 'multiple') &&
310 geraldo 66
                <div className="form-group">
323 geraldo 67
                    {question.options.length > 0 &&
340 geraldo 68
                        <Option
69
                            question={question}
70
                            handleAnswer={handleAnswer} />
306 geraldo 71
                    }
72
                </div>
73
            }
74
        </div>
75
    )
76
}
77
 
78
export default Question;