Skip to content

Commit 1ef674e

Browse files
committed
Lint fixes
1 parent 93a892d commit 1ef674e

7 files changed

Lines changed: 157 additions & 160 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import Roster from './pages/Roster.tsx';
1010
import Notifications from './pages/Notifications.tsx';
1111
import Profile from './pages/Profile.tsx';
1212
import Settings from './pages/Settings.tsx';
13-
/*@ts-ignore*/
14-
import { AuthProvider } from './context/AuthContext.tsx'
13+
import { AuthProvider } from './context/AuthContext.tsx';
1514
import HelpCenter from './pages/HelpCenter.tsx';
1615

1716
function App() {

src/components/LoginPopup.tsx

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import React, { useEffect } from "react";
2-
import { useAuth } from "../context/AuthContext";
3-
import "../css/login.css";
1+
import React, { useEffect } from 'react';
2+
import { useAuth } from '../context/AuthContext';
3+
import '../css/login.css';
44

55
type Props = {
66
isOpen: boolean;
77
onClose: () => void;
88
};
99

1010
export default function LoginPopup({ isOpen, onClose }: Props) {
11-
1211
const { login, user } = useAuth();
1312

1413
useEffect(() => {
@@ -29,39 +28,21 @@ export default function LoginPopup({ isOpen, onClose }: Props) {
2928

3029
return (
3130
<div className="popup-overlay" onClick={handleOverlayClick}>
32-
33-
<div
34-
className="popup-container"
35-
onClick={handlePopupClick}
36-
>
37-
38-
<button
39-
className="popup-close-x"
40-
onClick={onClose}
41-
>
31+
<div className="popup-container" onClick={handlePopupClick}>
32+
<button className="popup-close-x" onClick={onClose}>
4233
×
4334
</button>
4435

45-
<h2 className="popup-title">
46-
Register or Login
47-
</h2>
36+
<h2 className="popup-title">Register or Login</h2>
4837

49-
<button
50-
className="popup-button"
51-
onClick={() => login("google")}
52-
>
38+
<button className="popup-button" onClick={() => login('google')}>
5339
Continue with Google
5440
</button>
5541

56-
<button
57-
className="popup-button"
58-
onClick={() => login("microsoft")}
59-
>
42+
<button className="popup-button" onClick={() => login('microsoft')}>
6043
Continue with Microsoft
6144
</button>
62-
6345
</div>
64-
6546
</div>
6647
);
67-
}
48+
}

src/components/sidebar/Sidebar.tsx

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SidebarGroup from './SidebarGroup.tsx';
44
import SidebarLink from './SidebarLink.tsx';
55
//import { type useNavigate } from 'react-router-dom';
66
import { useState } from 'react';
7-
import LoginPopup from "../LoginPopup.tsx";
7+
import LoginPopup from '../LoginPopup.tsx';
88
import SidebarProfile from './SidebarProfile.tsx';
99
import SidebarWorkspace from './SidebarWorkspace.tsx';
1010

@@ -29,7 +29,7 @@ type SidebarProps = {
2929

3030
export default function Sidebar({ collapsed, onToggle }: SidebarProps) {
3131
const [showLogin, setShowLogin] = useState(false);
32-
32+
3333
return (
3434
<>
3535
<div className={`sidebar ${collapsed ? 'collapsed' : ''}`}>
@@ -44,43 +44,53 @@ export default function Sidebar({ collapsed, onToggle }: SidebarProps) {
4444
<SidebarLink label="Events" icon={<StarIcon />} nav="/events" />
4545
<SidebarLink label="Calendar" icon={<CalendarDaysIcon />} nav="/calendar" />
4646
<SidebarLink label="Roster" icon={<UserGroupIcon />} nav="/roster" />
47-
<SidebarLink label="Notifications" icon={<BellAlertIcon />} nav="/notifications" />
47+
<SidebarLink
48+
label="Notifications"
49+
icon={<BellAlertIcon />}
50+
nav="/notifications"
51+
/>
4852
</div>
4953
<div className="lower-sidebar-link-container">
5054
<SidebarLink label="My Profile" icon={<UserCircleIcon />} nav="/profile" />
5155
<SidebarLink label="Settings" icon={<Cog8ToothIcon />} nav="/settings" />
5256
</div>
53-
<a className="register-btn" onClick={() => setShowLogin(true)}> Register </a>
54-
<LoginPopup
55-
isOpen={showLogin}
56-
onClose={() => setShowLogin(false)}
57-
/>
57+
<a className="register-btn" onClick={() => setShowLogin(true)}>
58+
{' '}
59+
Register{' '}
60+
</a>
61+
<LoginPopup isOpen={showLogin} onClose={() => setShowLogin(false)} />
5862
<SidebarWorkspace workspace="Overview">
59-
<SidebarLink label="Dashboard" icon={<HomeIcon />} nav="/dashboard" />
60-
<SidebarGroup label="Events" icon={<StarIcon />} collapsed={collapsed}>
61-
<SidebarLink label="Create" icon={<PlusIcon />} nav="/events/create" />
63+
<SidebarLink label="Dashboard" icon={<HomeIcon />} nav="/dashboard" />
64+
<SidebarGroup label="Events" icon={<StarIcon />} collapsed={collapsed}>
65+
<SidebarLink label="Create" icon={<PlusIcon />} nav="/events/create" />
66+
<SidebarLink
67+
label="History"
68+
icon={<ClipboardDocumentCheckIcon />}
69+
nav="/events/history"
70+
/>
71+
</SidebarGroup>
72+
<SidebarLink label="Calendar" icon={<CalendarDaysIcon />} nav="/calendar" />
73+
<SidebarLink label="Roster" icon={<UserGroupIcon />} nav="/roster" />
74+
<SidebarLink
75+
label="Notifications"
76+
icon={<BellAlertIcon />}
77+
nav="/notifications"
78+
/>
79+
</SidebarWorkspace>
80+
<SidebarWorkspace>
6281
<SidebarLink
63-
label="History"
64-
icon={<ClipboardDocumentCheckIcon />}
65-
nav="/events/history"
82+
label="Help Center"
83+
icon={<QuestionMarkCircleIcon />}
84+
nav="/help"
85+
/>
86+
<SidebarLink label="Settings" icon={<Cog8ToothIcon />} nav="/settings" />
87+
<SidebarProfile
88+
icon={<UserCircleIcon />}
89+
name="Kevin Smith"
90+
email="smithk@rpi.edu"
6691
/>
67-
</SidebarGroup>
68-
<SidebarLink label="Calendar" icon={<CalendarDaysIcon />} nav="/calendar" />
69-
<SidebarLink label="Roster" icon={<UserGroupIcon />} nav="/roster" />
70-
<SidebarLink label="Notifications" icon={<BellAlertIcon />} nav="/notifications" />
71-
</SidebarWorkspace>
72-
<SidebarWorkspace>
73-
<SidebarLink label="Help Center" icon={<QuestionMarkCircleIcon />} nav="/help" />
74-
<SidebarLink label="Settings" icon={<Cog8ToothIcon />} nav="/settings" />
75-
<SidebarProfile
76-
icon={<UserCircleIcon />}
77-
name="Kevin Smith"
78-
email="smithk@rpi.edu"
79-
/>
80-
</SidebarWorkspace>
81-
</div>
82-
92+
</SidebarWorkspace>
93+
</div>
8394
</>
84-
8595
);
8696
}

src/context/AuthContext.tsx

Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable react-refresh/only-export-components*/
12
import React, { createContext, useContext, useState, type ReactNode } from 'react';
23

34
type User = {
@@ -10,7 +11,7 @@ type AuthContextType = {
1011
user: User | null;
1112
loading: boolean;
1213
error: string | null;
13-
login: (provider: "google" | "microsoft") => void;
14+
login: (provider: 'google' | 'microsoft') => void;
1415
logout: () => Promise<void>;
1516
refreshUser: () => Promise<void>;
1617
};
@@ -22,7 +23,6 @@ type AuthProviderProps = {
2223
const AuthContext = createContext<AuthContextType | undefined>(undefined);
2324

2425
export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
25-
2626
const [user, setUser] = useState<User | null>(null);
2727
const [loading, setLoading] = useState<boolean>(true);
2828
const [error, setError] = useState<string | null>(null);
@@ -31,22 +31,18 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
3131
try {
3232
setLoading(true);
3333

34-
const response = await fetch(
35-
'https://api.capyrpi.org/v1/auth/me',
36-
{
37-
headers: {
38-
Accept: 'application/json'
39-
}
40-
}
41-
);
34+
const response = await fetch('https://api.capyrpi.org/v1/auth/me', {
35+
headers: {
36+
Accept: 'application/json',
37+
},
38+
});
4239

4340
if (response.ok) {
4441
const data: User = await response.json();
4542
setUser(data);
4643
} else {
4744
setUser(null);
4845
}
49-
5046
} catch (err: unknown) {
5147
if (err instanceof Error) {
5248
console.error('Failed to fetch user:', err);
@@ -57,105 +53,76 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
5753
}
5854

5955
setUser(null);
60-
6156
} finally {
6257
setLoading(false);
6358
}
6459
};
6560

66-
const login = (provider: "google" | "microsoft"): void => {
67-
61+
const login = (provider: 'google' | 'microsoft'): void => {
6862
const url =
69-
provider === "google"
70-
? "https://api.capyrpi.org/v1/auth/google"
71-
: "https://api.capyrpi.org/v1/auth/microsoft";
63+
provider === 'google'
64+
? 'https://api.capyrpi.org/v1/auth/google'
65+
: 'https://api.capyrpi.org/v1/auth/microsoft';
7266

73-
window.open(url, "_blank");
67+
window.open(url, '_blank');
7468

7569
const pollInterval = setInterval(async () => {
76-
7770
try {
78-
79-
const response = await fetch(
80-
'https://api.capyrpi.org/v1/auth/me',
81-
{
82-
headers: {
83-
Accept: 'application/json'
84-
}
85-
}
86-
);
71+
const response = await fetch('https://api.capyrpi.org/v1/auth/me', {
72+
headers: {
73+
Accept: 'application/json',
74+
},
75+
});
8776

8877
if (response.ok) {
89-
9078
const data: User = await response.json();
9179
setUser(data);
9280
clearInterval(pollInterval);
93-
9481
}
95-
9682
} catch (err: unknown) {
97-
9883
if (err instanceof Error) {
9984
console.error('Polling failed:', err.message);
10085
}
101-
10286
}
103-
10487
}, 3000);
10588

10689
setTimeout(() => {
10790
clearInterval(pollInterval);
10891
}, 120000);
10992
};
11093
const logout = async (): Promise<void> => {
111-
11294
try {
113-
114-
await fetch(
115-
'https://api.capyrpi.org/v1/auth/logout',
116-
{
117-
method: 'POST'
118-
}
119-
);
95+
await fetch('https://api.capyrpi.org/v1/auth/logout', {
96+
method: 'POST',
97+
});
12098

12199
setUser(null);
122100

123101
window.location.href = '/app/';
124-
125102
} catch (err: unknown) {
126-
127103
if (err instanceof Error) {
128104
console.error('Logout failed:', err.message);
129105
}
130-
131106
}
132-
133107
};
134108
const value: AuthContextType = {
135109
user,
136110
loading,
137111
error,
138112
login,
139113
logout,
140-
refreshUser: fetchMe
114+
refreshUser: fetchMe,
141115
};
142116

143-
return (
144-
<AuthContext.Provider value={value}>
145-
{children}
146-
</AuthContext.Provider>
147-
);
117+
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
148118
};
149119

150120
export const useAuth = (): AuthContextType => {
151-
152121
const context = useContext(AuthContext);
153122

154123
if (!context) {
155-
throw new Error(
156-
'useAuth must be used within an AuthProvider'
157-
);
124+
throw new Error('useAuth must be used within an AuthProvider');
158125
}
159126

160127
return context;
161-
};
128+
};

src/css/login.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
.popup-overlay {
22
position: fixed;
3-
top: 0;
4-
left: 0;
5-
right: 0;
6-
bottom: 0;
3+
inset: 0;
74
background-color: var(--standard-text);
85
display: flex;
96
justify-content: center;
@@ -34,7 +31,7 @@
3431
.popup-button {
3532
background-color: var(--standard-text);
3633
border: var(--standard-text);
37-
color: var(--standard-white);
34+
color: var(--standard-white);
3835
padding: 10px;
3936
border-radius: 8px;
4037
cursor: pointer;

src/css/sidebar.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,5 +206,4 @@
206206

207207
.register-btn {
208208
color: black;
209-
210209
}

0 commit comments

Comments
 (0)