-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAnsweredQuestionItem.js
More file actions
102 lines (78 loc) · 3.54 KB
/
AnsweredQuestionItem.js
File metadata and controls
102 lines (78 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import {Segment } from 'semantic-ui-react';
//Application
import Nadia from 'src/Application/Nadia';
//component
import AnsweredQuestionIntType from './QuestionItems/QuestionIntType/AnsweredQuestionIntType';
import AnsweredQuestionBoolType from './QuestionItems/QuestionBoolType/AnsweredQuestionBoolType';
import AnsweredQuestionDateType from './QuestionItems/QuestionDateType/AnsweredQuestionDateType';
import AnsweredQuestionStringType from './QuestionItems/QuestionStringType/AnsweredQuestionStringType';
import AnsweredQuestionDoubleType from './QuestionItems/QuestionDoubleType/AnsweredQuestionDoubleType';
import AnsweredQuestionHashType from './QuestionItems/QuestionHashType/AnsweredQuestionHashType';
import AnsweredQuestionUrlType from './QuestionItems/QuestionUrlType/AnsweredQuestionUrlType';
import AnsweredQuestionUuidType from './QuestionItems/QuestionUuidType/AnsweredQuestionUuidType';
export default class AnsweredQuestionItem extends React.Component {
constructor(props) {
super(props);
// initialise component state
this.state = {
}
}
componentDidMount = () => {
this.setState({questionData: this.props.questionData});
}
// prop types and default values
static propTypes = {
questionData: PropTypes.object,
enditAnswer: PropTypes.func,
}
_onEditAnswer=(question)=>{
if(this.props.editAnswer){
this.props.editAnswer(question)
}
}
_createQuestionItem=()=>{
let questionItem;
let questionText = this.props.questionData.questionText;
let answer = this.props.questionData.answer;
switch(this.props.questionData.answerValueType)
{
case 'integer':
questionItem = <AnsweredQuestionIntType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'boolean':
questionItem = <AnsweredQuestionBoolType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'date':
questionItem = <AnsweredQuestionDateType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'defistring':
case 'string':
questionItem = <AnsweredQuestionStringType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'double':
questionItem = <AnsweredQuestionDoubleType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'hash':
questionItem = <AnsweredQuestionHashType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'url':
questionItem = <AnsweredQuestionUrlType question = {questionText} answer ={answer} onEditAnswer={this._onEditAnswer}/>
break;
case 'uuid':
questionItem = <AnsweredQuestionUuidType question = {questionText} answer={answer} onEditAnswer={this._onEditAnswer}/>
break;
}
return questionItem;
}
// component render method
render() {
return (
<Segment className='questionItem'>
{this._createQuestionItem()}
</Segment>
);
}
}