forked from folio-org/ui-organizations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
77 lines (69 loc) · 2 KB
/
index.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
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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Switch from 'react-router-dom/Switch';
import Route from 'react-router-dom/Route';
import { hot } from 'react-hot-loader';
import { ContactsContainer } from './src/contacts';
import InterfaceContainer from './src/interfaces';
import Main from './src/Main';
import Settings from './src/Settings';
class Organizations extends Component {
static propTypes = {
stripes: PropTypes.shape({
connect: PropTypes.func.isRequired,
}).isRequired,
location: PropTypes.object.isRequired,
match: PropTypes.object.isRequired,
showSettings: PropTypes.bool,
}
constructor(props, context) {
super(props, context);
this.connectedApp = props.stripes.connect(Main);
this.connectedContactsContainer = props.stripes.connect(ContactsContainer);
this.connectedInterfaceContainer = props.stripes.connect(InterfaceContainer);
}
goToContacts = (props) => (
<this.connectedContactsContainer
{...props}
stripes={this.props.stripes}
/>
);
goToInterface = (props) => (
<this.connectedInterfaceContainer
{...props}
stripes={this.props.stripes}
/>
);
render() {
if (this.props.showSettings) {
return <Settings {...this.props} />;
}
return (
<div>
<Switch>
<Route
path="/organizations/contacts/"
render={this.goToContacts}
/>
<Route
path="/organizations/interface/"
render={this.goToInterface}
/>
<Route
path="/organizations/:orgId/contacts/"
render={this.goToContacts}
/>
<Route
path="/organizations/:orgId/interface/"
render={this.goToInterface}
/>
<Route
path={`${this.props.match.path}`}
render={() => <this.connectedApp {...this.props} />}
/>
</Switch>
</div>
);
}
}
export default hot(module)(Organizations);