-
Notifications
You must be signed in to change notification settings - Fork 41
/
main.jsx
120 lines (110 loc) · 3.59 KB
/
main.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import React from "react";
import { withRouter } from "react-router";
import { Switch, Route, Redirect } from "react-router-dom";
import { Helmet } from "react-helmet";
import ProjectLoader from "./components/project-loader/project-loader.jsx";
import Bookmarks from "./pages/bookmarks.jsx";
import Issues from "./pages/issues/issues.jsx";
import Issue from "./pages/issue.jsx";
import Entry from "./pages/entry.jsx";
import SingleFilterCriteriaPage from "./pages/single-filter-criteria-page.jsx";
import Add from "./pages/add/add.jsx";
import Submitted from "./pages/add/submitted.jsx";
import Search from "./pages/search/search.jsx";
import Moderation from "./pages/moderation.jsx";
import Profile from "./pages/profile.jsx";
import ProfileEdit from "./pages/profile-edit/profile-edit.jsx";
import NotFound from "./pages/not-found.jsx";
import JoinUsModal from "./components/join-us-modal/join-us-modal.jsx";
import Navbar from "./components/navbar/navbar.jsx";
import Footer from "./components/footer/footer.jsx";
const Latest = () => {
return (
<div className="container mt-5">
<Helmet>
<title>Latest</title>
</Helmet>
<ProjectLoader />
</div>
);
};
const Help = (router) => {
let searchParam = {
key: `help_type`,
value: decodeURIComponent(router.match.params.helpType),
};
return (
<SingleFilterCriteriaPage searchParam={searchParam} headerLabel="Help" />
);
};
const Tag = (router) => {
let searchParam = {
key: `tag`,
value: decodeURIComponent(router.match.params.tag),
};
return (
<SingleFilterCriteriaPage searchParam={searchParam} headerLabel="Tag" />
);
};
const Routes = () => (
<Switch>
<Route exact path="/" component={Search} />
<Route
path="/search/:tab"
render={(props) => (
<Redirect to={`/${props.match.params.tab}${props.location.search}`} />
)}
/>
<Route
exact
path="/search"
render={(props) => <Redirect to={`/projects${props.location.search}`} />}
/>
<Route path="/:tab(people|projects)" component={Search} />
<Redirect exact path="/featured" to="/" />
<Route path="/latest" component={Latest} />
<Route path="/favs" component={Bookmarks} />
<Route exact path="/issues" component={Issues} />
<Route path="/issues/:issue" component={Issue} />
<Route path="/entry/:entryId" component={Entry} />
<Route path="/add" component={Add} />
<Route path="/submitted" component={Submitted} />
<Route exact path="/tags" render={() => <Redirect to="/latest" />} />
<Route path="/tags/:tag" component={Tag} />
<Route exact path="/help" render={() => <Redirect to="/latest" />} />
<Route path="/help/:helpType" component={Help} />
<Route path="/moderation" component={Moderation} />
<Route exact path="/profile/:id" component={Profile} />
<Route path="/profile/:id/:tab" component={Profile} />
<Route path="/myprofile" component={ProfileEdit} />
<Route path="*" component={NotFound} />
</Switch>
);
const JoinUsModalWithRouter = withRouter(JoinUsModal);
const NavbarWithRouter = withRouter(Navbar);
class Main extends React.Component {
constructor(props) {
super(props);
this.pageTitle = `Mozilla Network Pulse`;
}
componentDidUpdate() {
window.scrollTo(0, 0);
}
render() {
return (
<div>
<Helmet
titleTemplate={`%s - ${this.pageTitle}`}
defaultTitle={this.pageTitle}
/>
<JoinUsModalWithRouter />
<NavbarWithRouter />
<div id="main" className="mb-5">
<Routes />
</div>
<Footer />
</div>
);
}
}
export default Main;