-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathselect-scenario.js
50 lines (45 loc) · 1.27 KB
/
select-scenario.js
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
import React, {Component, PropTypes} from 'react'
import {connect} from 'react-redux'
import {push} from 'react-router-redux'
import Select from 'react-select'
import {Button} from './components/buttons'
import {Group} from './components/input'
import {Body} from './components/panel'
function mapStateToProps ({
scenario
}, {
params
}) {
return {
projectId: params.projectId,
scenarios: scenario.scenarios
}
}
class SelectProject extends Component {
static propTypes = {
projectId: PropTypes.string.isRequired,
push: PropTypes.func.isRequired,
scenarios: PropTypes.array.isRequired
}
render () {
const {projectId, push, scenarios} = this.props
return (
<Body>
<Group>
<Select
options={scenarios.map((scenario) => { return {value: scenario.id, label: scenario.name} })}
onChange={(option) => push(`/projects/${projectId}/scenarios/${option.value}`)}
placeholder='Select a scenario...'
/>
</Group>
<Button
block
onClick={() => push(`/projects/${projectId}/scenarios/create`)}
style='success'
>Create a new scenario
</Button>
</Body>
)
}
}
export default connect(mapStateToProps, {push})(SelectProject)