forked from hull-ships/hull-processor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.jsx
More file actions
73 lines (64 loc) · 1.84 KB
/
app.jsx
File metadata and controls
73 lines (64 loc) · 1.84 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
import React, { Component } from "react";
import { Grid, Col, Row, Button } from "react-bootstrap";
import UserPane from "./user";
import CodePane from "./code";
import ResultsPane from "./results";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentWillMount() {
this.props.engine.addChangeListener(this._onChange);
}
componentWillUnmount() {
this.props.engine.removeChangeListener(this._onChange);
}
_onChange = () => {
const state = this.props.engine.getState();
this.setState(state);
}
handleSearch(userSearch) {
if (userSearch && !this.state.loading) {
this.props.engine.searchUser(userSearch);
}
}
handleCodeUpdate(code) {
this.props.engine.updateCode(code);
}
render() {
const { user, loading, userSearch, initialized, error, ship = {} } = this.state;
const { private_settings = {} } = ship;
const { code = "" } = private_settings;
if (initialized) {
return <Grid fluid={true} className="pt-1">
<Row className="flexRow">
<UserPane
className="flexColumn userPane"
sm={4}
md={4}
loading={loading}
onSearch={this.handleSearch.bind(this)}
value={user}
error={error}
userSearch={userSearch} />
<CodePane
className="flexColumn userPane"
onChange={this.handleCodeUpdate.bind(this)}
value={code}
sm={4}
md={5}
/>
<ResultsPane
className="flexColumn pl-1 resultPane"
sm={4}
md={3}
loading={loading}
error={error}
{...this.state.result} />
</Row>
</Grid>
}
return <div className="text-center pt-2"><h4>Loading...</h4></div>;
}
}