Component.tsx
1.62 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
import * as R from "ramda";
import * as React from "react";
import { Link } from "react-router-dom";
import DropDownMenu from "material-ui/DropDownMenu";
import MenuItem from "material-ui/MenuItem";
import TextField from "material-ui/TextField";
import RaisedButton from "material-ui/RaisedButton";
require("./styles.scss");
interface State {
modelId: string;
name: string;
}
interface Props {
models: Array<any>;
registerDrone(input: any): void;
}
const style = {
width: "100%"
};
class DronePage extends React.Component<Props, State> {
state = {
modelId: "",
name: ""
};
handleChangeModel = (event, index, modelId) => this.setState({ modelId });
handleChangeName = event => this.setState({ name: event.target.value });
public render() {
const { props, state } = this;
return (
<div className="drone-page">
<h2>드론등록</h2>
<TextField
hintText="이름"
type="text"
value={state.name}
onChange={this.handleChangeName}
style={style}
/>
<h3>모델</h3>
<DropDownMenu
maxHeight={300}
value={state.modelId}
onChange={this.handleChangeModel}
>
{props.models.map(model => (
<MenuItem
key={model.id}
value={model.id}
primaryText={`${model.name}`}
/>
))}
</DropDownMenu>
<RaisedButton
label="등록하기"
primary={true}
style={style}
onClick={() => props.registerDrone(state)}
/>
</div>
);
}
}
export default DronePage;