lunch/js/components/LunchApp.js

99 lines
2.9 KiB
JavaScript
Raw Normal View History

2016-12-22 21:22:47 -05:00
var React = require('react');
var ReactBootstrap = require('react-bootstrap');
var Jumbotron = ReactBootstrap.Jumbotron;
var Tabs = ReactBootstrap.Tabs;
var Tab = ReactBootstrap.Tab;
var Modal = ReactBootstrap.Modal;
var TopBarContainer = require('../containers/TopBarContainer');
var RecordLunchContainer = require('../containers/RecordLunchContainer');
2016-12-22 21:22:47 -05:00
var AccountSettingsModalContainer = require('../containers/AccountSettingsModalContainer');
2017-01-08 09:47:30 -05:00
var LunchStatsContainer = require('../containers/LunchStatsContainer');
2017-01-10 08:08:45 -05:00
var NewUserModalContainer = require('../containers/NewUserModalContainer');
var NewGroupModalContainer = require('../containers/NewGroupModalContainer');
2016-12-22 21:22:47 -05:00
module.exports = React.createClass({
displayName: "LunchApp",
getInitialState: function() {
return {
showNewUserModal: false,
2017-01-10 08:08:45 -05:00
showNewGroupModal: false,
2016-12-22 21:22:47 -05:00
showAccountSettingsModal: false
};
},
componentDidMount: function() {
this.props.tryResumingSession();
2017-01-10 08:08:45 -05:00
this.props.fetchGroups();
2016-12-22 21:22:47 -05:00
},
handleAccountSettings: function() {
this.setState({showAccountSettingsModal: true});
},
handleSettingsSubmitted: function(user) {
this.setState({showAccountSettingsModal: false});
2016-12-22 21:22:47 -05:00
},
handleSettingsCanceled: function() {
this.setState({showAccountSettingsModal: false});
},
handleCreateNewUser: function() {
this.setState({showNewUserModal: true});
},
handleNewUserCreated: function() {
this.setState({showNewUserModal: false});
2016-12-22 21:22:47 -05:00
},
handleNewUserCanceled: function() {
this.setState({showNewUserModal: false});
2016-12-22 21:22:47 -05:00
},
2017-01-10 08:08:45 -05:00
handleCreateNewGroup: function() {
this.setState({showNewGroupModal: true});
},
handleNewGroupCreated: function() {
this.setState({showNewGroupModal: false});
},
handleNewGroupCanceled: function() {
this.setState({showNewGroupModal: false});
},
2016-12-22 21:22:47 -05:00
render: function() {
var mainContent;
if (this.props.user.isUser())
mainContent = (
<Tabs defaultActiveKey={1} id='mainNavigationTabs'>
<Tab title="Record Lunch" eventKey={1} >
<RecordLunchContainer />
</Tab>
<Tab title="Reports" eventKey={2} >
<LunchStatsContainer />
</Tab>
</Tabs>);
else
mainContent = (
<Jumbotron>
<center>
<h1>Lunch App</h1>
</center>
</Jumbotron>);
2016-12-22 21:22:47 -05:00
return (
<div className="fullheight ui">
<TopBarContainer
onCreateNewUser={this.handleCreateNewUser}
2017-01-10 08:08:45 -05:00
onCreateNewGroup={this.handleCreateNewGroup}
2016-12-22 21:22:47 -05:00
onAccountSettings={this.handleAccountSettings} />
{mainContent}
<NewUserModalContainer
show={this.state.showNewUserModal}
onSubmit={this.handleNewUserCreated}
onCancel={this.handleNewUserCanceled}/>
2017-01-10 08:08:45 -05:00
<NewGroupModalContainer
show={this.state.showNewGroupModal}
onSubmit={this.handleNewGroupCreated}
onCancel={this.handleNewGroupCanceled}/>
2016-12-22 21:22:47 -05:00
<AccountSettingsModalContainer
show={this.state.showAccountSettingsModal}
onSubmit={this.handleSettingsSubmitted}
onCancel={this.handleSettingsCanceled}/>
</div>
);
}
});