Files
old-tellall/web/src/components/IntentList.js

55 lines
2.2 KiB
JavaScript
Raw Normal View History

2017-11-30 17:43:24 +01:00
import React, { Component } from 'react';
2017-12-01 11:03:48 +01:00
import {Button} from 'react-md';
import IntentItem from './IntentItem';
2018-01-14 01:00:35 +01:00
import '../css/components/IntentList.css';
2018-01-11 04:24:16 +01:00
import {
LAUNCH_REQUEST_SELECTED_INDEX,
2018-01-12 01:56:17 +01:00
CONTACT_SELECTED_INDEX} from '../config/constants'
2017-11-30 17:43:24 +01:00
class IntentList extends Component {
constructor (props){
super(props);
2017-12-01 11:03:48 +01:00
this.state = {intents: props.allIntents, selectedIndex:props.selectedIndex, onIntentClick:props.onIntentClick};
2017-11-30 17:43:24 +01:00
}
componentWillReceiveProps(props){
2017-12-01 11:03:48 +01:00
this.setState({intents: props.allIntents, selectedIndex: props.selectedIndex, onIntentClick: props.onIntentClick});
2017-11-30 17:43:24 +01:00
}
render() {
return (
<div className="IntentList">
2018-01-14 01:00:35 +01:00
<Button className={this.props.selectedIndex===LAUNCH_REQUEST_SELECTED_INDEX ? "LaunchRequestButton-selected" : "LaunchRequestButton"} flat primary
onClick={this.props.onLaunchRequestClick}
disabled={this.props.waiting} >Launch request</Button>
2018-01-11 04:24:16 +01:00
2018-01-14 01:00:35 +01:00
<Button className={this.props.selectedIndex===CONTACT_SELECTED_INDEX ? "ContactButton-selected" : "ContactButton"} flat primary
2018-01-11 04:24:16 +01:00
onClick={this.props.onContactClick}
disabled={this.props.waiting} >Contact</Button>
2017-11-30 17:43:24 +01:00
<div className="IntentList-title">
2018-01-16 13:38:05 +01:00
<h3>Questions</h3>
2017-11-30 17:43:24 +01:00
</div>
{
this.state.intents.map((intent,index)=>{
2017-12-01 11:03:48 +01:00
return <IntentItem
key={intent.intentName} intent={intent} index={index}
2017-12-01 11:03:48 +01:00
selectedIndex={this.props.selectedIndex}
onClick={this.state.onIntentClick}
waiting={this.props.waiting}>
2017-12-01 11:03:48 +01:00
</IntentItem>
2017-11-30 17:43:24 +01:00
})
}
<br></br>
2018-01-14 01:00:35 +01:00
<Button className="AddIntent" flat primary swapTheming
onClick={this.props.onAddIntentClick}
2018-01-16 13:38:05 +01:00
disabled={this.props.waiting}>Add question</Button>
2017-11-30 17:43:24 +01:00
</div>
);
}
}
export default IntentList;