Skip to content

Commit 72dfcaf

Browse files
committedFeb 17, 2016
updates to voter store for proper authentication
1 parent 6b573fe commit 72dfcaf

File tree

11 files changed

+412
-368
lines changed

11 files changed

+412
-368
lines changed
 

‎.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
"no-underscore-dangle": [0],
148148
"no-unreachable": [2],
149149
"no-unused-expressions": [1],
150-
"no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
150+
"no-unused-vars": [1],
151151
"no-use-before-define": [1],
152152
"no-void": [0],
153153
"no-warning-comments": [0, {"terms": ["todo", "fixme", "xxx"], "location": "start"}],

‎server.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// start the express server
2-
//
3-
const express = require('express');
2+
const express = require("express");
43
const app = express();
54

65
const port = 3003;
@@ -9,9 +8,9 @@ const opts = {
98
};
109

1110
app
12-
.use( '/', express.static('build', opts))
13-
.all( '*', (req, res) => res.sendFile(__dirname + '/build/index.html'))
11+
.use( "/", express.static("build", opts))
12+
.all( "*", (req, res) => res.sendFile(__dirname + "/build/index.html"))
1413
.listen(port, () =>
15-
console.log('INFO: '.bold + 'express server started', new Date()) ||
16-
console.log('INFO: '.bold + 'Server is at http://localhost:%d', port)
14+
console.log("INFO: " + "express server started", new Date()) ||
15+
console.log("INFO: " + "Server is at http://localhost:%d", port)
1716
);

‎src/js/Application.jsx

+17-31
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
import React, { Component, PropTypes } from "react";
2-
import Navigator from './components/Navigator';
3-
import MoreMenu from './components/MoreMenu';
4-
import Header from './components/Header';
5-
import SubHeader from './components/SubHeader';
6-
import VoterStore from './stores/VoterStore';
2+
import Navigator from "./components/Navigator";
3+
import MoreMenu from "./components/MoreMenu";
4+
import Header from "./components/Header";
5+
import SubHeader from "./components/SubHeader";
76

87
export default class Application extends Component {
98
static propTypes = {
10-
children: PropTypes.object,
11-
voter: PropTypes.object
9+
children: PropTypes.element,
10+
route: PropTypes.object
1211
};
1312

14-
constructor(props) {
13+
constructor (props) {
1514
super(props);
16-
this.state = {
17-
voter: {}
18-
};
15+
this.state = {};
1916
}
2017

21-
componentDidMount() {
22-
console.log("Application: About to initialize VoterStore");
23-
VoterStore.signInStatus((voter) => {
24-
//console.log(voter, 'voter is your object')
25-
this.setState({voter});
26-
});
18+
componentDidMount () {
19+
// TODO: Figure out if voter is actually signed in...
20+
this.setState({ is_signed_in: false });
2721
}
2822

29-
render() {
30-
var { voter } = this.state;
23+
render () {
24+
var {is_signed_in} = this.state;
25+
var {voter} = this.props.route;
3126

32-
return (
33-
<div className="app-base">
27+
return <div className="app-base">
3428
<div className="container-fluid">
3529
<div className="row">
3630
<Header />
@@ -44,22 +38,14 @@ export default class Application extends Component {
4438
<div className="container-fluid">
4539
<div className="row">
4640
<div className="col-xs-4 col-sm-4 col-md-4 no-show">
47-
{
48-
voter ?
49-
<div>
50-
<MoreMenu {...voter} />
51-
</div>
52-
:
53-
<span></span>
54-
}
41+
{ is_signed_in ? <MoreMenu {...voter} /> : <span></span> }
5542
</div>
5643
<div className="col-xs-8 col-sm-8 col-md-8">
5744
{ this.props.children }
5845
</div>
5946
</div>
6047
</div>
6148
<Navigator />
62-
</div>
63-
);
49+
</div>;
6450
}
6551
}

‎src/js/Root.jsx

+89-116
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,102 @@
1-
import React, { Component, PropTypes } from 'react';
2-
import { Router, Route, IndexRoute, IndexRedirect } from 'react-router';
1+
import React from "react";
2+
import { Route, IndexRoute, IndexRedirect } from "react-router";
33

44
// main Application
5-
import Application from './Application';
5+
import Application from "./Application";
66

77
/****************************** ROUTE-COMPONENTS ******************************/
88
/* Intro */
9-
import Intro from './routes/Intro/Intro';
10-
import IntroContests from './routes/Intro/IntroContests';
11-
import IntroOpinions from './routes/Intro/IntroOpinions';
9+
import Intro from "./routes/Intro/Intro";
10+
import IntroContests from "./routes/Intro/IntroContests";
11+
import IntroOpinions from "./routes/Intro/IntroOpinions";
1212

1313
/* Settings */
14-
import SettingsDashboard from './routes/Settings/SettingsDashboard';
15-
import Settings from './routes/Settings/Settings';
16-
import Location from './routes/Settings/Location';
14+
import SettingsDashboard from "./routes/Settings/SettingsDashboard";
15+
import Settings from "./routes/Settings/Settings";
16+
import Location from "./routes/Settings/Location";
1717

1818
/* Pages that use Ballot Navigation */
19-
import BallotIndex from './routes/Ballot/BallotIndex';
20-
import Ballot from './routes/Ballot/Ballot';
21-
import Candidate from './routes/Ballot/Candidate';
19+
import BallotIndex from "./routes/Ballot/BallotIndex";
20+
import Ballot from "./routes/Ballot/Ballot";
21+
import Candidate from "./routes/Ballot/Candidate";
2222

2323
/* Ballot Off-shoot Pages */
24-
import Opinions from './routes/Opinions';
24+
import Opinions from "./routes/Opinions";
2525

2626
/* More */
27-
import More from './routes/More';
28-
import About from './routes/More/About';
29-
import OpinionsFollowed from './routes/More/OpinionsFollowed';
30-
import SignIn from './routes/More/SignIn';
31-
import EmailBallot from './routes/More/EmailBallot';
32-
import Privacy from './routes/More/Privacy';
33-
34-
35-
// import Measure from 'routes/Ballot/Measure';
36-
// import Opinion from 'routes/Ballot/Opinion';
37-
import Requests from './routes/Requests';
38-
import Connect from './routes/Connect';
39-
import Activity from './routes/Activity';
40-
import NotFound from './routes/NotFound';
41-
import AddFriends from './routes/AddFriends';
42-
43-
44-
class Root extends Component {
45-
static propTypes = {
46-
history: PropTypes.object.isRequired,
47-
firstVisit: PropTypes.bool.isRequired,
48-
//voter_object: PropTypes.object
49-
};
50-
51-
constructor(props) {
52-
super(props);
53-
}
54-
55-
render() {
56-
const { history } = this.props;
57-
//var { voter_object } = this.props;
58-
59-
// Add to <Router? voter_object={voter_object}
60-
return (
61-
<Router history={history} >
62-
{
63-
/*
64-
* This is the intro section of the application.
65-
* First time visitors should be directed here.
66-
*/
67-
}
68-
<Route path="/intro" component={Intro}>
69-
<Route path="/intro/opinions" component={IntroOpinions} />
70-
<Route path="/intro/contests" component={IntroContests} />
71-
</Route>
72-
73-
{/* Settings go in this structure... */}
74-
<Route path="/settings" component={SettingsDashboard}>
75-
<IndexRoute component={Settings} />
76-
<Route path="/settings/location" component={Location} /> /* Complete path on one line for searching */
77-
</Route>
78-
79-
{/* Ballot Off-shoot Pages */}
80-
<Route path="/opinions" component={Opinions} />
81-
82-
<Route path="/friends" >
83-
<Route path="add" component={AddFriends} />
84-
<Route path="remove" />
85-
</Route>
86-
87-
{/* More Menu Pages */}
88-
<Route path="/more/sign_in" component={SignIn} />
89-
<Route path="/more/email_ballot" component={EmailBallot} />
90-
<Route path="/more/about" component={About} />
91-
<Route path="/more/opinions/followed" component={OpinionsFollowed} />
92-
<Route path="/more/privacy" component={Privacy} />
93-
94-
<Route path="/" component={Application} >
95-
96-
{
97-
this.props.firstVisit ?
98-
<IndexRoute component={Intro} /> : <IndexRedirect to='ballot' />
99-
}
100-
101-
<Route path="ballot" component={BallotIndex}>
102-
<IndexRoute component={Ballot} />
103-
<Route path="/candidate/:we_vote_id" component={Candidate} />
104-
</Route>
105-
{/*
106-
<Route path="org/:id" component={Organization}/>
107-
<Route path="measure/:id" component={Measure} />
108-
<Route path="org/:id" component={Organization}/>
109-
<Route path="opinion" component={Opinion} />
110-
<Route path="/office/:id" component={Office} />
111-
112-
*/}
113-
114-
<Route path="requests" component={Requests} />
115-
<Route path="connect" component={Connect} />
116-
117-
<Route path="activity" component={Activity} />
118-
<Route path="more" component={More} />
119-
120-
// Any route that is not found -> @return NotFound component
121-
<Route path="*" component={NotFound} />
122-
</Route>
123-
{/* Routes should not be placed down here */}
124-
</Router>
125-
);
126-
}
127-
};
128-
129-
export default Root;
27+
import More from "./routes/More";
28+
import About from "./routes/More/About";
29+
import OpinionsFollowed from "./routes/More/OpinionsFollowed";
30+
import SignIn from "./routes/More/SignIn";
31+
import EmailBallot from "./routes/More/EmailBallot";
32+
import Privacy from "./routes/More/Privacy";
33+
34+
// import Measure from "routes/Ballot/Measure";
35+
// import Opinion from "routes/Ballot/Opinion";
36+
import Requests from "./routes/Requests";
37+
import Connect from "./routes/Connect";
38+
import Activity from "./routes/Activity";
39+
import NotFound from "./routes/NotFound";
40+
import AddFriends from "./routes/AddFriends";
41+
42+
const routes = (firstVisit, voter) =>
43+
<Route path="/" component={Application} voter={voter} firstVisit={firstVisit}>
44+
{
45+
/*
46+
* This is the intro section of the application.
47+
* First time visitors should be directed here.
48+
*/
49+
}
50+
<Route path="/intro" component={Intro}>
51+
<Route path="/intro/opinions" component={IntroOpinions} />
52+
<Route path="/intro/contests" component={IntroContests} />
53+
</Route>
54+
55+
{/* Settings go in this structure... */}
56+
<Route path="/settings" component={SettingsDashboard}>
57+
<IndexRoute component={Settings} />
58+
<Route path="/settings/location" component={Location} /> /* Complete path on one line for searching */
59+
</Route>
60+
61+
{/* Ballot Off-shoot Pages */}
62+
<Route path="/opinions" component={Opinions} />
63+
64+
<Route path="/friends" >
65+
<Route path="add" component={AddFriends} />
66+
<Route path="remove" />
67+
</Route>
68+
69+
{/* More Menu Pages */}
70+
<Route path="/more/sign_in" component={SignIn} />
71+
<Route path="/more/email_ballot" component={EmailBallot} />
72+
<Route path="/more/about" component={About} />
73+
<Route path="/more/opinions/followed" component={OpinionsFollowed} />
74+
<Route path="/more/privacy" component={Privacy} />
75+
76+
{ firstVisit ? <IndexRoute component={Intro} /> : <IndexRedirect to="ballot" /> }
77+
78+
<Route path="ballot" component={BallotIndex}>
79+
<IndexRoute component={Ballot} />
80+
<Route path="/candidate/:we_vote_id" component={Candidate} />
81+
</Route>
82+
{/*
83+
<Route path="org/:id" component={Organization}/>
84+
<Route path="measure/:id" component={Measure} />
85+
<Route path="org/:id" component={Organization}/>
86+
<Route path="opinion" component={Opinion} />
87+
<Route path="/office/:id" component={Office} />
88+
89+
*/}
90+
91+
<Route path="requests" component={Requests} />
92+
<Route path="connect" component={Connect} />
93+
94+
<Route path="activity" component={Activity} />
95+
<Route path="more" component={More} />
96+
97+
// Any route that is not found -> @return NotFound component
98+
<Route path="*" component={NotFound} />
99+
</Route>;
100+
101+
102+
export default routes;
+14-19
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import React from 'react';
2-
import FacebookActionCreators from '../../actions/FacebookActionCreators';
3-
import VoterStore from '../../stores/VoterStore';
4-
5-
const VoterActions = require('../../actions/VoterActions');
1+
import React from "react";
2+
import FacebookActionCreators from "../../actions/FacebookActionCreators";
63

74
class FacebookSignIn extends React.Component {
8-
constructor(props) {
9-
super(props);
10-
}
11-
render() {
12-
return (
13-
<a className="btn btn-social btn-lg btn-facebook" onClick={this.didClickFacebookLoginButton}>
14-
<i className="fa fa-facebook"></i>Sign in with Facebook
15-
</a>
16-
);
17-
}
5+
constructor (props) {
6+
super(props);
7+
}
8+
render () {
9+
return <a className="btn btn-social btn-lg btn-facebook" onClick={this.didClickFacebookLoginButton}>
10+
<i className="fa fa-facebook"></i>Sign in with Facebook
11+
</a>;
12+
}
1813

19-
didClickFacebookLoginButton(e) {
20-
console.log("didClickFacebookLoginButton");
21-
FacebookActionCreators.login();
22-
}
14+
didClickFacebookLoginButton () {
15+
console.log("didClickFacebookLoginButton");
16+
FacebookActionCreators.login();
17+
}
2318
}
2419

2520
export default FacebookSignIn;

0 commit comments

Comments
 (0)