Skip to content

Commit 768b2e3

Browse files
Fix merge conflicts
2 parents 80bb5c3 + c2e56c6 commit 768b2e3

File tree

3 files changed

+103
-186
lines changed

3 files changed

+103
-186
lines changed

frontend/src/App.tsx

Lines changed: 95 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
import "bootstrap/dist/css/bootstrap.min.css";
2-
import React, { useState, useReducer } from "react";
2+
import React, { useState } from "react";
33
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
44
import TeamMembersPage from "./components/pages/TeamMembersPage";
55

66
import Default from "./pages/Default";
77
import LoginPage from "./pages/LoginPage";
8-
import Signup from "./components/auth/Signup";
98
import ForgotPasswordPage from "./pages/ForgotPasswordPage";
109
import ResetPasswordPage from "./pages/ResetPasswordPage";
1110
import PrivateRoute from "./components/auth/PrivateRoute";
12-
import CreatePage from "./pages/CreatePage";
1311
import PetListPage from "./pages/PetListPage";
14-
import DisplayPage from "./pages/DisplayPage";
15-
import SimpleEntityCreatePage from "./pages/SimpleEntityCreatePage";
16-
import SimpleEntityDisplayPage from "./pages/SimpleEntityDisplayPage";
1712
import TaskManagementPage from "./pages/TaskManagementPage";
1813
import AddTaskTemplatePage from "./pages/AddTaskTemplatePage";
1914
import NotFoundPage from "./pages/NotFoundPage";
20-
import UpdatePage from "./pages/UpdatePage";
21-
import SimpleEntityUpdatePage from "./pages/SimpleEntityUpdatePage";
2215
import CreatePasswordPage from "./pages/CreatePasswordPage";
2316
import * as Routes from "./constants/Routes";
2417
import * as AuthConstants from "./constants/AuthConstants";
2518
import AUTHENTICATED_USER_KEY from "./constants/AuthConstants";
2619
import AuthContext from "./contexts/AuthContext";
2720
import { getLocalStorageObj } from "./utils/LocalStorageUtils";
28-
import SampleContext, {
29-
DEFAULT_SAMPLE_CONTEXT,
30-
} from "./contexts/SampleContext";
31-
import sampleContextReducer from "./reducers/SampleContextReducer";
32-
import SampleContextDispatcherContext from "./contexts/SampleContextDispatcherContext";
33-
import EditTeamInfoPage from "./pages/EditTeamPage";
34-
import HooksDemo from "./pages/HooksDemo";
3521
import InteractionLogPage from "./pages/InteractionLogPage";
3622
import ProfilePage from "./pages/ProfilePage";
3723
import PetProfilePage from "./pages/PetProfilePage";
@@ -42,7 +28,6 @@ import Layout from "./Layout";
4228
import PageTitleUpdater from "./components/common/PageTitleUpdater";
4329

4430
import { AuthenticatedUser } from "./types/AuthTypes";
45-
import DevFileStorageUpload from "./pages/DevFileStorageUpload";
4631

4732
import VolunteerViewEditUserProfilePage from "./pages/VolunteerViewEditUserProfilePage";
4833

@@ -54,181 +39,111 @@ const App = (): React.ReactElement => {
5439
const [authenticatedUser, setAuthenticatedUser] =
5540
useState<AuthenticatedUser>(currentUser);
5641

57-
// Some sort of global state. Context API replaces redux.
58-
// Split related states into different contexts as necessary.
59-
// Split dispatcher and state into separate contexts as necessary.
60-
const [sampleContext, dispatchSampleContextUpdate] = useReducer(
61-
sampleContextReducer,
62-
DEFAULT_SAMPLE_CONTEXT,
63-
);
64-
6542
return (
66-
<SampleContext.Provider value={sampleContext}>
67-
<SampleContextDispatcherContext.Provider
68-
value={dispatchSampleContextUpdate}
69-
>
70-
<AuthContext.Provider
71-
value={{ authenticatedUser, setAuthenticatedUser }}
72-
>
73-
<Router>
74-
<PageTitleUpdater />
43+
<AuthContext.Provider value={{ authenticatedUser, setAuthenticatedUser }}>
44+
<Router>
45+
<PageTitleUpdater />
46+
<Switch>
47+
<Route exact path={Routes.LOGIN_PAGE} component={LoginPage} />
48+
<Route
49+
exact
50+
path={Routes.FORGOT_PASSWORD_PAGE}
51+
component={ForgotPasswordPage}
52+
/>
53+
<Route
54+
exact
55+
path={Routes.RESET_PASSWORD_PAGE}
56+
component={ResetPasswordPage}
57+
/>
58+
<PrivateRoute
59+
exact
60+
path={Routes.CREATE_PASSWORD_PAGE}
61+
component={CreatePasswordPage}
62+
allowedRoles={AuthConstants.ALL_ROLES}
63+
/>
64+
{/* Protected Routes Wrapped in Layout */}
65+
<Layout>
7566
<Switch>
76-
<Route exact path={Routes.LOGIN_PAGE} component={LoginPage} />
77-
<Route exact path={Routes.SIGNUP_PAGE} component={Signup} />
78-
<Route
67+
<PrivateRoute
68+
exact
69+
path={Routes.HOME_PAGE}
70+
component={PetListPage}
71+
allowedRoles={AuthConstants.ALL_ROLES}
72+
/>
73+
{/* Starter Code Route */}
74+
<PrivateRoute
75+
exact
76+
path={Routes.DEV_UTILITY_PAGE}
77+
component={Default}
78+
allowedRoles={AuthConstants.ALL_ROLES}
79+
/>
80+
<PrivateRoute
81+
exact
82+
path={Routes.INTERACTION_LOG_PAGE}
83+
component={InteractionLogPage}
84+
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
85+
/>
86+
<PrivateRoute
87+
exact
88+
path={`${Routes.PROFILE_PAGE}/:id`}
89+
component={ProfilePage}
90+
allowedRoles={AuthConstants.ALL_ROLES}
91+
/>
92+
<PrivateRoute
7993
exact
80-
path={Routes.FORGOT_PASSWORD_PAGE}
81-
component={ForgotPasswordPage}
94+
path={`${Routes.PET_PROFILE_PAGE}/:id`}
95+
component={PetProfilePage}
96+
allowedRoles={AuthConstants.ALL_ROLES}
97+
/>
98+
<PrivateRoute
99+
exact
100+
path={Routes.ADMIN_PAGE}
101+
component={AdminPage}
102+
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
103+
/>
104+
<PrivateRoute
105+
exact
106+
path={Routes.USER_MANAGEMENT_PAGE}
107+
component={UserManagementPage}
108+
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
109+
/>
110+
<PrivateRoute
111+
exact
112+
path={`${Routes.ADMIN_EDIT_USER_PROFILE_PAGE}/:userId`}
113+
component={AdminViewEditUserProfilePage}
114+
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
82115
/>
83-
<Route
116+
<PrivateRoute
117+
exact
118+
path={Routes.TASK_MANAGEMENT_PAGE}
119+
component={TaskManagementPage}
120+
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
121+
/>
122+
<PrivateRoute
84123
exact
85-
path={Routes.RESET_PASSWORD_PAGE}
86-
component={ResetPasswordPage}
124+
path={Routes.ADD_TASK_TEMPLATE_PAGE}
125+
component={AddTaskTemplatePage}
126+
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
127+
/>
128+
<PrivateRoute
129+
exact
130+
path={`${Routes.VOLUNTEER_EDIT_USER_PROFILE_PAGE}/:userId`}
131+
component={VolunteerViewEditUserProfilePage}
132+
allowedRoles={AuthConstants.ALL_ROLES}
87133
/>
88134
<PrivateRoute
89135
exact
90-
path={Routes.CREATE_PASSWORD_PAGE}
91-
component={CreatePasswordPage}
136+
path={Routes.TEAM_MEMBERS}
137+
component={TeamMembersPage}
92138
allowedRoles={AuthConstants.ALL_ROLES}
93139
/>
94-
{/* Protected Routes Wrapped in Layout */}
95-
<Layout>
96-
<Switch>
97-
<PrivateRoute
98-
exact
99-
path={Routes.HOME_PAGE}
100-
component={PetListPage}
101-
allowedRoles={AuthConstants.ALL_ROLES}
102-
/>
103-
<PrivateRoute
104-
exact
105-
path={Routes.CREATE_ENTITY_PAGE}
106-
component={CreatePage}
107-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
108-
/>
109-
<PrivateRoute
110-
exact
111-
path={Routes.UPDATE_ENTITY_PAGE}
112-
component={UpdatePage}
113-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
114-
/>
115-
<PrivateRoute
116-
exact
117-
path={Routes.DISPLAY_ENTITY_PAGE}
118-
component={DisplayPage}
119-
allowedRoles={AuthConstants.ALL_ROLES}
120-
/>
121-
<PrivateRoute
122-
exact
123-
path={Routes.CREATE_SIMPLE_ENTITY_PAGE}
124-
component={SimpleEntityCreatePage}
125-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
126-
/>
127-
<PrivateRoute
128-
exact
129-
path={Routes.UPDATE_SIMPLE_ENTITY_PAGE}
130-
component={SimpleEntityUpdatePage}
131-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
132-
/>
133-
<PrivateRoute
134-
exact
135-
path={Routes.DISPLAY_SIMPLE_ENTITY_PAGE}
136-
component={SimpleEntityDisplayPage}
137-
allowedRoles={AuthConstants.ALL_ROLES}
138-
/>
139-
<PrivateRoute
140-
exact
141-
path={Routes.EDIT_TEAM_PAGE}
142-
component={EditTeamInfoPage}
143-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
144-
/>
145-
<PrivateRoute
146-
exact
147-
path={Routes.HOOKS_PAGE}
148-
component={HooksDemo}
149-
allowedRoles={AuthConstants.ALL_ROLES}
150-
/>
151-
<PrivateRoute
152-
exact
153-
path={Routes.DEV_UTILITY_PAGE}
154-
component={Default}
155-
allowedRoles={AuthConstants.ALL_ROLES}
156-
/>
157-
<PrivateRoute
158-
exact
159-
path={Routes.DEV_FILE_STORAGE_UPLOAD_PAGE}
160-
component={DevFileStorageUpload}
161-
allowedRoles={AuthConstants.ALL_ROLES}
162-
/>
163-
<PrivateRoute
164-
exact
165-
path={Routes.INTERACTION_LOG_PAGE}
166-
component={InteractionLogPage}
167-
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
168-
/>
169-
<PrivateRoute
170-
exact
171-
path={`${Routes.PROFILE_PAGE}/:id`}
172-
component={ProfilePage}
173-
allowedRoles={AuthConstants.ALL_ROLES}
174-
/>
175-
<PrivateRoute
176-
exact
177-
path={`${Routes.PET_PROFILE_PAGE}/:id`}
178-
component={PetProfilePage}
179-
allowedRoles={AuthConstants.ALL_ROLES}
180-
/>
181-
<PrivateRoute
182-
exact
183-
path={Routes.ADMIN_PAGE}
184-
component={AdminPage}
185-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
186-
/>
187-
<PrivateRoute
188-
exact
189-
path={Routes.USER_MANAGEMENT_PAGE}
190-
component={UserManagementPage}
191-
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
192-
/>
193-
<PrivateRoute
194-
exact
195-
path={`${Routes.ADMIN_EDIT_USER_PROFILE_PAGE}/:userId`}
196-
component={AdminViewEditUserProfilePage}
197-
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
198-
/>
199-
<PrivateRoute
200-
exact
201-
path={Routes.TASK_MANAGEMENT_PAGE}
202-
component={TaskManagementPage}
203-
allowedRoles={AuthConstants.STAFF_BEHAVIOURISTS_ADMIN}
204-
/>
205-
<PrivateRoute
206-
exact
207-
path={Routes.ADD_TASK_TEMPLATE_PAGE}
208-
component={AddTaskTemplatePage}
209-
allowedRoles={AuthConstants.ADMIN_AND_BEHAVIOURISTS}
210-
/>
211-
<PrivateRoute
212-
exact
213-
path={`${Routes.VOLUNTEER_EDIT_USER_PROFILE_PAGE}/:userId`}
214-
component={VolunteerViewEditUserProfilePage}
215-
allowedRoles={AuthConstants.ALL_ROLES}
216-
/>
217-
<PrivateRoute
218-
exact
219-
path={Routes.TEAM_MEMBERS}
220-
component={TeamMembersPage}
221-
allowedRoles={AuthConstants.ALL_ROLES}
222-
/>
223-
{/* Fallback Route */}
224-
<Route path="*" component={NotFoundPage} />
225-
</Switch>
226-
</Layout>
140+
{/* Fallback Route */}
141+
<Route path="*" component={NotFoundPage} />
227142
</Switch>
228-
</Router>
229-
</AuthContext.Provider>
230-
</SampleContextDispatcherContext.Provider>
231-
</SampleContext.Provider>
143+
</Layout>
144+
</Switch>
145+
</Router>
146+
</AuthContext.Provider>
232147
);
233148
};
234149

frontend/src/constants/Routes.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export const PROFILE_PAGE = "/profile";
1212

1313
export const PET_PROFILE_PAGE = "/pet-profile";
1414

15-
export const DEV_UTILITY_PAGE = "/dev-utility"; // TODO: This is only here for development purposes
16-
1715
export const USER_MANAGEMENT_PAGE = "/admin/users";
1816

1917
export const ADMIN_EDIT_USER_PROFILE_PAGE = "/admin/edit-user-profile";
@@ -26,7 +24,11 @@ export const ADMIN_PAGE = "/admin";
2624

2725
export const CREATE_PASSWORD_PAGE = "/create-password";
2826

29-
// STARTER CODE ROUTES
27+
export const VOLUNTEER_EDIT_USER_PROFILE_PAGE = "/edit-user-profile";
28+
29+
export const DEV_UTILITY_PAGE = "/dev-utility"; // This starter code route is still available for development purposes
30+
31+
// STARTER CODE ROUTES (DEPRECATED)
3032
export const SIGNUP_PAGE = "/signup";
3133

3234
export const EDIT_TEAM_PAGE = "/edit-team";
@@ -47,6 +49,6 @@ export const HOOKS_PAGE = "/hooks";
4749

4850
export const DEV_FILE_STORAGE_UPLOAD_PAGE = "/dev-file-upload";
4951

50-
export const VOLUNTEER_EDIT_USER_PROFILE_PAGE = "/edit-user-profile";
51-
5252
export const TEAM_MEMBERS = "/team-members";
53+
54+
// END OF STARTER CODE ROUTES (DEPRECATED)

frontend/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3880,7 +3880,7 @@ axe-core@^4.10.0:
38803880
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.10.3.tgz#04145965ac7894faddbac30861e5d8f11bfd14fc"
38813881
integrity sha512-Xm7bpRXnDSX2YE2YFfBk2FnF0ep6tmG7xPh8iHee8MIcrgq762Nkce856dYtJYLkuIoYZvGfTs/PbZhideTcEg==
38823882

3883-
axios@^0.30.0:
3883+
axios@^0.30.2:
38843884
version "0.30.2"
38853885
resolved "https://registry.yarnpkg.com/axios/-/axios-0.30.2.tgz#256d3a8ee765cc27188d08b8b545a5f5a0c77dad"
38863886
integrity sha512-0pE4RQ4UQi1jKY6p7u6i1Tkzqmu+d+/tHS7Q7rKunWLB9WyilBTpHHpXzPNMDj5hTbK0B0PTLSz07yqMBiF6xg==

0 commit comments

Comments
 (0)