Add an about page

This commit is contained in:
Gabriel Augendre 2016-04-23 16:18:41 +02:00
parent c64d91d0cc
commit 50d3359e23
No known key found for this signature in database
GPG key ID: D2B6A5B41FC438B1
3 changed files with 62 additions and 7 deletions

View file

@ -0,0 +1,15 @@
'use strict';
var React = require('react');
var About = React.createClass({
render: function () {
return (
<div>
<h2>About</h2>
<p>This is an about page.</p>
</div>
);
}
});
module.exports = About;

View file

@ -4,6 +4,7 @@ var $ = require('jquery');
var DuplicateFinderBox = require('./duplicate-finder-box'); var DuplicateFinderBox = require('./duplicate-finder-box');
var Authenticate = require('./authenticate'); var Authenticate = require('./authenticate');
var About = require('./about');
/** /**
* Obtains parameters from the hash of the URL * Obtains parameters from the hash of the URL
@ -29,7 +30,11 @@ var App = React.createClass({
access_token: access_token, access_token: access_token,
refresh_token: refresh_token, refresh_token: refresh_token,
playlists: null, playlists: null,
playlistsLoading: true playlistsLoading: true,
activeTab: {
finder: true,
about: false
}
}; };
}, },
getPlaylists: function () { getPlaylists: function () {
@ -72,22 +77,56 @@ var App = React.createClass({
this.getPlaylists(); this.getPlaylists();
} }
}, },
showFinder: function (e) {
e.preventDefault();
this.setState({
activeTab: {
finder: true,
about: false
}
});
},
showAbout: function (e) {
e.preventDefault();
this.setState({
activeTab: {
finder: false,
about: true
}
});
},
render: function () { render: function () {
var auth = { var auth = {
access_token: this.state.access_token, access_token: this.state.access_token,
refresh_token: this.state.refresh_token refresh_token: this.state.refresh_token
}; };
var content = <p>Please log in with Spotify :)</p>; var content;
if (this.isLoggedIn()) { if (this.state.activeTab.finder) {
var playlistsLoading = this.state.playlistsLoading;
content = ( content = (
<DuplicateFinderBox playlistsLoading={playlistsLoading} auth={auth} playlists={this.state.playlists}/> <div>
<h1>Login</h1>
<p>Please <a href="/login">login with Spotify</a> first :)</p>
</div>
); );
if (this.isLoggedIn()) {
var playlistsLoading = this.state.playlistsLoading;
content = (
<DuplicateFinderBox playlistsLoading={playlistsLoading} auth={auth}
playlists={this.state.playlists}/>
);
}
}
else if (this.state.activeTab.about) {
content = (<About />);
}
else {
content = <p>Error...</p>
} }
return ( return (
<div> <div>
<Authenticate auth={auth} refreshAuth={this.refreshAuth}/> <Authenticate activeTab={this.state.activeTab} showFinder={this.showFinder} showAbout={this.showAbout}
auth={auth} refreshAuth={this.refreshAuth}/>
<div className="container-fluid"> <div className="container-fluid">
{content} {content}
</div> </div>

View file

@ -56,7 +56,8 @@ var Authenticate = React.createClass({
</Navbar.Header> </Navbar.Header>
<Navbar.Collapse> <Navbar.Collapse>
<Nav> <Nav>
<NavItem eventKey={1} href="/" active>Finder</NavItem> <NavItem eventKey={1} href="#" active={this.props.activeTab.finder} onClick={this.props.showFinder}>Finder</NavItem>
<NavItem eventKey={1} href="#" active={this.props.activeTab.about} onClick={this.props.showAbout}>About</NavItem>
</Nav> </Nav>
{auth} {auth}
</Navbar.Collapse> </Navbar.Collapse>