Component.tsx
2.79 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
103
104
105
106
107
108
import * as React from "react";
import { Link } from "react-router-dom";
import TextField from "material-ui/TextField";
import RaisedButton from "material-ui/RaisedButton";
import DatePicker from "material-ui/DatePicker";
import Toggle from "material-ui/Toggle";
import MenuItem from "material-ui/MenuItem";
import DropDownMenu from "material-ui/DropDownMenu";
require("./styles.scss");
const style = {
width: "100%"
};
interface Props {
user: any;
orgs: any;
createContract(input: any): void;
}
interface State {
reason: string;
date: Date;
droneId: string;
area: string;
address: string;
}
class RequestPage extends React.Component<Props, State> {
state = {
reason: "",
date: new Date(),
droneId: "",
area: "지역",
address: ""
};
handleChangeReason = event => this.setState({ reason: event.target.value });
handleChangeDate = (event, date) => this.setState({ date });
handleChangeDrone = (event, index, droneId) => this.setState({ droneId });
handleChangeArea = (event, index, area) => this.setState({ area });
handleChangeAddress = event => this.setState({ address: event.target.value });
public render() {
const { props, state } = this;
const minDate = new Date();
const maxDate = new Date();
maxDate.setDate(maxDate.getDate() + 90);
return (
<div className="request-page">
<h2>허가 신청서 작성</h2>
<TextField
hintText="사유"
type="text"
value={state.reason}
onChange={this.handleChangeReason}
style={style}
/>
<DropDownMenu
maxHeight={300}
value={state.droneId}
onChange={this.handleChangeDrone}
>
{props.user.drones.map(drone => (
<MenuItem
key={drone.id}
value={drone.id}
primaryText={`${drone.name} (${drone.model.name})`}
/>
))}
</DropDownMenu>
<DatePicker
floatingLabelText="날짜"
onChange={this.handleChangeDate}
defaultDate={state.date}
minDate={minDate}
maxDate={maxDate}
/>
<DropDownMenu
maxHeight={300}
value={state.area}
onChange={this.handleChangeArea}
>
{props.orgs.map(org => (
<MenuItem key={org.id} value={org.name} primaryText={org.name} />
))}
</DropDownMenu>
<TextField
hintText="상세주소"
type="text"
value={state.address}
onChange={this.handleChangeAddress}
style={style}
/>
<RaisedButton
label="확인"
primary={true}
style={style}
onClick={() => props.createContract(state)}
/>
</div>
);
}
}
export default RequestPage;