|
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"; |
3 | 3 |
|
4 | 4 | // main Application
|
5 |
| -import Application from './Application'; |
| 5 | +import Application from "./Application"; |
6 | 6 |
|
7 | 7 | /****************************** ROUTE-COMPONENTS ******************************/
|
8 | 8 | /* 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"; |
12 | 12 |
|
13 | 13 | /* 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"; |
17 | 17 |
|
18 | 18 | /* 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"; |
22 | 22 |
|
23 | 23 | /* Ballot Off-shoot Pages */
|
24 |
| -import Opinions from './routes/Opinions'; |
| 24 | +import Opinions from "./routes/Opinions"; |
25 | 25 |
|
26 | 26 | /* 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; |
0 commit comments