Skip to content

Commit fe8321c

Browse files
chore: formatting + rm console logs
1 parent 06821e5 commit fe8321c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3192
-3001
lines changed

client/public/manifest.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"short_name": "React App",
3-
"name": "Create React App Sample",
4-
"icons": [
5-
{
6-
"src": "favicon.ico",
7-
"sizes": "64x64 32x32 24x24 16x16",
8-
"type": "image/x-icon"
9-
},
10-
{
11-
"src": "logo192.png",
12-
"type": "image/png",
13-
"sizes": "192x192"
14-
},
15-
{
16-
"src": "logo512.png",
17-
"type": "image/png",
18-
"sizes": "512x512"
19-
}
20-
],
21-
"start_url": ".",
22-
"display": "standalone",
23-
"theme_color": "#000000",
24-
"background_color": "#ffffff"
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
2525
}

client/src/App.css

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
/* This file contains the CSS styles for the React application*/
22
.App {
3-
text-align: center;
3+
text-align: center;
44
}
55

66
/* The logo is imported from the React library */
77
.App-logo {
8-
height: 40vmin;
9-
pointer-events: none;
8+
height: 40vmin;
9+
pointer-events: none;
1010
}
1111

1212
/* The logo is animated to spin */
1313
@media (prefers-reduced-motion: no-preference) {
14-
.App-logo {
15-
animation: App-logo-spin infinite 20s linear;
16-
}
14+
.App-logo {
15+
animation: App-logo-spin infinite 20s linear;
16+
}
1717
}
1818

1919
/* The header section of the application */
2020
.App-header {
21-
background-color: #282c34;
22-
min-height: 100vh;
23-
display: flex;
24-
flex-direction: column;
25-
align-items: center;
26-
justify-content: center;
27-
font-size: calc(10px + 2vmin);
28-
color: white;
21+
background-color: #282c34;
22+
min-height: 100vh;
23+
display: flex;
24+
flex-direction: column;
25+
align-items: center;
26+
justify-content: center;
27+
font-size: calc(10px + 2vmin);
28+
color: white;
2929
}
3030

3131
/* The link section of the application */
3232
.App-link {
33-
color: #61dafb;
33+
color: #61dafb;
3434
}
3535

3636
/* The logo spins infinitely */
3737
@keyframes App-logo-spin {
38-
from {
39-
transform: rotate(0deg);
40-
}
41-
to {
42-
transform: rotate(360deg);
43-
}
38+
from {
39+
transform: rotate(0deg);
40+
}
41+
to {
42+
transform: rotate(360deg);
43+
}
4444
}

client/src/App.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { render, screen } from '@testing-library/react';
2+
23
import App from './App';
34

45
// This is a test suite for the App component
56
// It uses React Testing Library to render the App component and check if it behaves as expected
67
test('renders learn react link', () => {
7-
render(<App />);
8-
const linkElement = screen.getByText(/learn react/i);
9-
expect(linkElement).toBeInTheDocument();
8+
render(<App />);
9+
const linkElement = screen.getByText(/learn react/i);
10+
expect(linkElement).toBeInTheDocument();
1011
});

client/src/App.tsx

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { AbilityContext, AuthProvider } from '@/contexts';
2+
import { useAbility, useAuth } from '@/hooks';
13
import NewUser from '@/pages/AdminDashboard/NewUser';
24
import AdminDashboard from '@/pages/AdminDashboard/StaffDashboard';
35
import QrPage from '@/pages/CompletedSurvey/QrPage';
@@ -13,7 +15,6 @@ import Signup from '@/pages/Signup/Signup';
1315
import SurveyComponent from '@/pages/Survey/SurveyComponent';
1416
import SurveyEntryDashboard from '@/pages/SurveyEntryDashboard/SurveyEntryDashboard';
1517
import CssBaseline from '@mui/material/CssBaseline';
16-
import { ProtectedRoute } from './components/ProtectedRoute';
1718
import { ThemeProvider } from '@mui/material/styles';
1819
import {
1920
Navigate,
@@ -22,9 +23,8 @@ import {
2223
Routes
2324
} from 'react-router-dom';
2425

26+
import { ProtectedRoute } from './components/ProtectedRoute';
2527
import { muiTheme } from './theme/muiTheme';
26-
import { AbilityContext, AuthProvider } from '@/contexts';
27-
import { useAbility, useAuth } from '@/hooks';
2828

2929
function App() {
3030
const { isLoggedIn, handleLogin, handleLogout } = useAuth();
@@ -48,111 +48,122 @@ function App() {
4848
<Route
4949
path="/survey/:id/survey"
5050
element={
51-
<ProtectedRoute
52-
isLoggedIn={isLoggedIn}
53-
children={<SurveyComponent />}
51+
<ProtectedRoute
52+
isLoggedIn={isLoggedIn}
53+
children={<SurveyComponent />}
5454
/>
5555
}
5656
/>
5757
<Route path="/signup" element={<Signup />} />
5858
<Route
5959
path="/dashboard"
6060
element={
61-
<ProtectedRoute
62-
isLoggedIn={isLoggedIn}
63-
children={<LandingPage />}
64-
/>
61+
<ProtectedRoute
62+
isLoggedIn={isLoggedIn}
63+
children={<LandingPage />}
64+
/>
6565
}
6666
/>
6767
<Route
6868
path="/survey"
6969
element={
70-
<ProtectedRoute
71-
isLoggedIn={isLoggedIn}
72-
children={<SurveyComponent />}
70+
<ProtectedRoute
71+
isLoggedIn={isLoggedIn}
72+
children={<SurveyComponent />}
7373
/>
7474
}
7575
/>
7676
<Route
7777
path="/admin-dashboard"
7878
element={
79-
<ProtectedRoute
79+
<ProtectedRoute
8080
isLoggedIn={isLoggedIn}
81-
children={<AdminDashboard />}
81+
children={<AdminDashboard />}
8282
/>
8383
}
8484
/>
8585
<Route
8686
path="/admin-edit-profile/:id"
8787
element={
88-
<ProtectedRoute
88+
<ProtectedRoute
8989
isLoggedIn={isLoggedIn}
90-
children={<AdminEditProfile />}
90+
children={<AdminEditProfile />}
9191
/>
9292
}
9393
/>
9494
<Route
9595
path="/add-new-user"
9696
element={
97-
<ProtectedRoute
97+
<ProtectedRoute
9898
isLoggedIn={isLoggedIn}
99-
children={<NewUser />}
99+
children={<NewUser />}
100100
/>
101101
}
102102
/>
103103
<Route
104104
path="/survey-entries"
105105
element={
106-
<ProtectedRoute isLoggedIn={isLoggedIn}
107-
children={<SurveyEntryDashboard />}
106+
<ProtectedRoute
107+
isLoggedIn={isLoggedIn}
108+
children={<SurveyEntryDashboard />}
108109
/>
109110
}
110111
/>
111112
<Route
112113
path="/qrcode"
113114
element={
114-
<ProtectedRoute isLoggedIn={isLoggedIn}
115-
children={<QrPage />}
115+
<ProtectedRoute
116+
isLoggedIn={isLoggedIn}
117+
children={<QrPage />}
116118
/>
117119
}
118120
/>
119121
<Route
120122
path="/past-entries"
121123
element={
122-
<ProtectedRoute isLoggedIn={isLoggedIn}
123-
children={<PastEntries />}
124+
<ProtectedRoute
125+
isLoggedIn={isLoggedIn}
126+
children={<PastEntries />}
124127
/>
125128
}
126129
/>
127130
<Route
128131
path="/survey/:id"
129132
element={
130-
<ProtectedRoute isLoggedIn={isLoggedIn}
131-
children={<SurveyDetails />}
133+
<ProtectedRoute
134+
isLoggedIn={isLoggedIn}
135+
children={<SurveyDetails />}
132136
/>
133137
}
134138
/>
135139
<Route
136140
path="/survey/:id/edit"
137141
element={
138-
<ProtectedRoute isLoggedIn={isLoggedIn}
139-
children={<SurveyEdit />}
142+
<ProtectedRoute
143+
isLoggedIn={isLoggedIn}
144+
children={<SurveyEdit />}
140145
/>
141146
}
142147
/>
143148
<Route
144149
path="/apply-referral"
145150
element={
146-
<ProtectedRoute isLoggedIn={isLoggedIn}
147-
children={<ApplyReferral />}
151+
<ProtectedRoute
152+
isLoggedIn={isLoggedIn}
153+
children={<ApplyReferral />}
148154
/>
149155
}
150156
/>
151157
<Route
152158
path="/view-profile"
153159
element={
154-
<ProtectedRoute isLoggedIn={isLoggedIn}
155-
children={<ViewProfile onLogout={handleLogout} />} // TODO: rm onLogout when updating API fetching to useApi hook
160+
<ProtectedRoute
161+
isLoggedIn={isLoggedIn}
162+
children={
163+
<ViewProfile
164+
onLogout={handleLogout}
165+
/>
166+
} // TODO: rm onLogout when updating API fetching to useApi hook
156167
/>
157168
}
158169
/>

client/src/components/Header.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import '@/styles/header.css';
22

33
import { useEffect, useRef, useState } from 'react';
44

5-
import { useNavigate } from 'react-router-dom';
6-
75
import { useAuthContext } from '@/contexts';
6+
import { useNavigate } from 'react-router-dom';
87

98
export function Header() {
109
const { onLogout } = useAuthContext();
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import { Navigate } from 'react-router-dom';
21
import { ReactNode } from 'react';
2+
33
import { Header } from '@/components';
4+
import { Navigate } from 'react-router-dom';
45

56
interface ProtectedRouteProps {
6-
isLoggedIn: boolean;
7-
children: ReactNode;
8-
redirectTo?: string;
7+
isLoggedIn: boolean;
8+
children: ReactNode;
9+
redirectTo?: string;
910
}
1011

11-
export const ProtectedRoute = ({
12-
isLoggedIn,
13-
children,
14-
redirectTo = '/login'
12+
export const ProtectedRoute = ({
13+
isLoggedIn,
14+
children,
15+
redirectTo = '/login'
1516
}: ProtectedRouteProps) => {
16-
return isLoggedIn ? <><Header />{children}</> : <Navigate replace to={redirectTo} />;
17+
return isLoggedIn ? (
18+
<>
19+
<Header />
20+
{children}
21+
</>
22+
) : (
23+
<Navigate replace to={redirectTo} />
24+
);
1725
};

client/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { ProtectedRoute } from './ProtectedRoute';
2-
export { Header } from './Header';
2+
export { Header } from './Header';
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { createContext } from 'react';
2-
import { createContextualCan } from '@casl/react';
3-
import { Ability } from '@/permissions/constants';
2+
43
import defineAbilitiesForUser from '@/permissions/abilityBuilder';
4+
import { Ability } from '@/permissions/constants';
5+
import { createContextualCan } from '@casl/react';
56

67
// Default ability will be nonexistent user (i.e. no permissions)
7-
export const AbilityContext = createContext<Ability>(defineAbilitiesForUser('', '', '', []));
8-
export const Can = createContextualCan<Ability>(AbilityContext.Consumer);
8+
export const AbilityContext = createContext<Ability>(
9+
defineAbilitiesForUser('', '', '', [])
10+
);
11+
export const Can = createContextualCan<Ability>(AbilityContext.Consumer);

0 commit comments

Comments
 (0)