-
Notifications
You must be signed in to change notification settings - Fork 17
/
RoutesContainer.jsx
173 lines (169 loc) · 6.16 KB
/
RoutesContainer.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import React from "react";
import { useNavigate, useLocation } from "react-router-dom";
import { Routes, Route } from "react-router-dom";
import Home from "./Pages/Home/Home";
import Login from "./Pages/Login/Login";
import Register from "./Pages/Register/Register";
import ErrorPage from "./Pages/ErrorPage/ErrorPage";
import AllArticlesPage from "./Pages/AllArticlesPage/AllArticlesPage";
import Communities from "./Pages/Communities/Communities";
import SubmitArticle from "./Pages/SubmitArticle/SubmitArticle";
import SuccessfulSubmission from "./Components/SuccessfulSubmission";
import SuccessfulRegistration from "./Components/SuccessfulRegistration";
import CommunityCreation from "./Components/CommunityCreation";
import CreateCommunity from "./Pages/CreateCommunity/CreateCommunity";
import Notifications from "./Pages/Notifications/Notifications";
import Feed from "./Pages/Feed/Feed";
import CommunityPage from "./Pages/CommunityPage/CommunityPage";
import JoinRequest from "./Pages/JoinRequest/JoinRequest";
import SinglePost from "./Pages/SinglePost/SinglePost";
import CommunityAdminPage from "./Pages/CommunityAdminPage/CommunityAdminPage";
import Profile from "./Pages/Profile/Profile";
import Timeline from "./Pages/Timeline/Timeline";
import BookMarks from "./Pages/Bookmarks/Bookmarks";
import ArticlePage from "./Pages/ArticlePage/ArticlePage";
import FavouritePage from "./Pages/FavouritePage/FavouritePage";
import MyPostsPage from "./Pages/MyPostsPage/MyPostsPage";
import MyArticlesPage from "./Pages/MyArticlesPage/MyArticlesPage";
import AuthorArticlePage from "./Pages/AuthorArticlePage/AuthorArticlePage";
import CommunityArticlePage from "./Pages/CommunityArticlePage/CommunityArticlePage";
import MyProfile from "./Pages/MyProfile/MyProfile";
import ForgotPassword from "./Pages/ForgotPassword/ForgotPassword";
import Verify from "./Pages/Verify/Verify";
import PrivateRoute from "./Pages/PrivateRoute/PrivateRoute";
import ChatPage from "./Pages/ChatPage/ChatPage";
import { getContainerStyles } from "./Utils/Constants/Globals";
import useWindowSize from "./Utils/Hooks/useWindowSize";
function RoutesContainer() {
const location = useLocation();
const windowSize = useWindowSize();
const loadContainerStyles = location.pathname !== "/login" && location.pathname !== "/register";
return (
<div className="flex-grow" style={loadContainerStyles ? getContainerStyles(windowSize.width) : {}}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/login" element={<Login />} />
<Route path="/register" element={<Register />} />
<Route path="/articles" element={<AllArticlesPage />} />
<Route path="/communities" element={<Communities />} />
<Route
path="/submitarticle"
element={
<PrivateRoute redirectTo="/login" component={<SubmitArticle />} />
}
/>
<Route
path="/articlesuccessfulsubmission"
element={
<PrivateRoute
redirectTo="/login"
component={<SuccessfulSubmission />}
/>
}
/>
<Route
path="/registersuccessful"
element={
<PrivateRoute
redirectTo="/login"
component={<SuccessfulRegistration />}
/>
}
/>
<Route
path="/createcommunity"
element={
<PrivateRoute redirectTo="/login" component={<CreateCommunity />} />
}
/>
<Route
path="/communitysuccessfulcreated"
element={
<PrivateRoute redirectTo="/login" component={<CommunityCreation />} />
}
/>
<Route
path="/notifications"
element={
<PrivateRoute redirectTo="/login" component={<Notifications />} />
}
/>
<Route path="/explore" element={<Feed />} />
<Route
path="/mytimeline"
element={<PrivateRoute redirectTo="/login" component={<Timeline />} />}
/>
<Route
path="/bookmarks"
element={<PrivateRoute redirectTo="/login" component={<BookMarks />} />}
/>
<Route path="/community/:communityName" element={<CommunityPage />} />
<Route
path="/join-community/:communityName"
element={
<PrivateRoute redirectTo="/login" component={<JoinRequest />} />
}
/>
<Route
path="/mycommunity"
element={
<PrivateRoute
redirectTo="/login"
component={<CommunityAdminPage />}
/>
}
/>
<Route path="/post/:postId" element={<SinglePost />} />
<Route path="/profile/:username" element={<Profile />} />
<Route path="/article/:articleId" element={<ArticlePage />} />
<Route
path="/favourites"
element={
<PrivateRoute redirectTo="/login" component={<FavouritePage />} />
}
/>
<Route
path="/myposts"
element={
<PrivateRoute redirectTo="/login" component={<MyPostsPage />} />
}
/>
<Route
path="/myarticles"
element={
<PrivateRoute redirectTo="/login" component={<MyArticlesPage />} />
}
/>
<Route
path="/myarticles/:articleId"
element={
<PrivateRoute redirectTo="/login" component={<AuthorArticlePage />} />
}
/>
{/* <Route path="/myactivity" element={<PrivateRoute redirectTo="/login" component={<UserActivity/>}/>}/> */}
<Route
path="/community/:communityName/:articleId"
element={
<PrivateRoute
redirectTo="/login"
component={<CommunityArticlePage />}
/>
}
/>
<Route
path="/chat/:id"
element={<PrivateRoute redirectTo="/login" component={<ChatPage />} />}
/>
{/* <Route path="/messages" element={<PrivateRoute redirectTo="/login" component={<AllMessages/>}/>}/> */}
<Route
path="/myprofile"
element={<PrivateRoute redirectTo="/login" component={<MyProfile />} />}
/>
<Route path="/forgotpassword" element={<ForgotPassword />} />
<Route path="/verify" element={<Verify />} />
<Route path="*" element={<ErrorPage />} />
</Routes>
</div>
);
}
export default RoutesContainer;