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');
|
2016-12-28 09:25:20 -05:00
|
|
|
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-08 20:51:58 -05:00
|
|
|
var NewUserModalContainer = require('../containers//NewUserModalContainer');
|
2016-12-22 21:22:47 -05:00
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
displayName: "LunchApp",
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2017-01-08 20:51:58 -05:00
|
|
|
showNewUserModal: false,
|
2016-12-22 21:22:47 -05:00
|
|
|
showAccountSettingsModal: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
|
|
this.props.tryResumingSession();
|
|
|
|
},
|
|
|
|
handleAccountSettings: function() {
|
|
|
|
this.setState({showAccountSettingsModal: true});
|
|
|
|
},
|
|
|
|
handleSettingsSubmitted: function(user) {
|
2017-01-08 20:51:58 -05:00
|
|
|
this.setState({showAccountSettingsModal: false});
|
2016-12-22 21:22:47 -05:00
|
|
|
},
|
|
|
|
handleSettingsCanceled: function() {
|
|
|
|
this.setState({showAccountSettingsModal: false});
|
|
|
|
},
|
|
|
|
handleCreateNewUser: function() {
|
2017-01-08 20:51:58 -05:00
|
|
|
this.setState({showNewUserModal: true});
|
|
|
|
},
|
|
|
|
handleNewUserCreated: function() {
|
|
|
|
this.setState({showNewUserModal: false});
|
2016-12-22 21:22:47 -05:00
|
|
|
},
|
2017-01-08 20:51:58 -05:00
|
|
|
handleNewUserCanceled: function() {
|
|
|
|
this.setState({showNewUserModal: false});
|
2016-12-22 21:22:47 -05:00
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
var mainContent;
|
2017-01-08 20:51:58 -05:00
|
|
|
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}
|
|
|
|
onAccountSettings={this.handleAccountSettings} />
|
|
|
|
{mainContent}
|
2017-01-08 20:51:58 -05:00
|
|
|
<NewUserModalContainer
|
|
|
|
show={this.state.showNewUserModal}
|
|
|
|
onSubmit={this.handleNewUserCreated}
|
|
|
|
onCancel={this.handleNewUserCanceled}/>
|
2016-12-22 21:22:47 -05:00
|
|
|
<AccountSettingsModalContainer
|
|
|
|
show={this.state.showAccountSettingsModal}
|
|
|
|
onSubmit={this.handleSettingsSubmitted}
|
|
|
|
onCancel={this.handleSettingsCanceled}/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|