Skip to content

Commit f2beb46

Browse files
committed
Add stop matching button
1 parent f63c967 commit f2beb46

File tree

3 files changed

+66
-52
lines changed

3 files changed

+66
-52
lines changed

frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function App() {
4141
</ProfileContextProvider>
4242
}
4343
/>
44-
<Route path="match">
44+
<Route path="match" element={<ProtectedRoutes />}>
4545
<Route index element={<Matching />} />
4646
</Route>
4747
<Route path="*" element={<PageNotFound />} />

frontend/src/components/Navbar/index.tsx

Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ const Navbar: React.FC<NavbarProps> = (props) => {
3535
const location = useLocation();
3636
const path = location.pathname;
3737

38+
console.log(path);
39+
3840
const auth = useAuth();
3941
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
4042

@@ -62,63 +64,76 @@ const Navbar: React.FC<NavbarProps> = (props) => {
6264
}}
6365
>
6466
<AppMargin>
65-
<Toolbar sx={{ padding: 0 }}>
67+
<Toolbar sx={{ padding: 0, justifyContent: "space-between" }}>
6668
<Typography
6769
component={Box}
6870
variant="h5"
69-
sx={[{ flexGrow: 1, "&:hover": { cursor: "pointer" } }]}
71+
sx={{ "&:hover": { cursor: "pointer" } }}
7072
onClick={() => navigate("/")}
7173
>
7274
PeerPrep
7375
</Typography>
74-
<Stack direction={"row"} alignItems={"center"} spacing={2}>
75-
{navbarItems
76-
.filter((item) => !item.needsLogin || (item.needsLogin && user))
77-
.map((item) => (
78-
<Link
79-
key={item.label}
80-
href={item.link}
81-
underline="none"
82-
sx={{ color: "common.black" }}
83-
>
84-
{path == item.link ? <b>{item.label}</b> : item.label}
85-
</Link>
86-
))}
87-
{user ? (
88-
<>
89-
<Tooltip title={"Account settings"}>
90-
<IconButton onClick={handleClick} data-testid="profile">
91-
<Avatar src={user.profilePictureUrl}/>
92-
</IconButton>
93-
</Tooltip>
94-
<Menu
95-
anchorEl={anchorEl}
96-
open={!!anchorEl}
97-
onClose={handleClose}
98-
onClick={handleClose}
99-
>
100-
<MenuItem
101-
onClick={() => {
102-
handleClose();
103-
navigate(`/profile/${user.id}`);
104-
}}
76+
{path !== "/match" ? (
77+
<Stack direction={"row"} alignItems={"center"} spacing={2}>
78+
{navbarItems
79+
.filter((item) => !item.needsLogin || (item.needsLogin && user))
80+
.map((item) => (
81+
<Link
82+
key={item.label}
83+
href={item.link}
84+
underline="none"
85+
sx={{ color: "common.black" }}
86+
>
87+
{path == item.link ? <b>{item.label}</b> : item.label}
88+
</Link>
89+
))}
90+
{user ? (
91+
<>
92+
<Tooltip title={"Account settings"}>
93+
<IconButton onClick={handleClick} data-testid="profile">
94+
<Avatar src={user.profilePictureUrl} />
95+
</IconButton>
96+
</Tooltip>
97+
<Menu
98+
anchorEl={anchorEl}
99+
open={!!anchorEl}
100+
onClose={handleClose}
101+
onClick={handleClose}
102+
>
103+
<MenuItem
104+
onClick={() => {
105+
handleClose();
106+
navigate(`/profile/${user.id}`);
107+
}}
108+
>
109+
Profile
110+
</MenuItem>
111+
<MenuItem onClick={logout}>Logout</MenuItem>
112+
</Menu>
113+
</>
114+
) : (
115+
<>
116+
<Button
117+
variant="contained"
118+
onClick={() => navigate("/signup")}
105119
>
106-
Profile
107-
</MenuItem>
108-
<MenuItem onClick={logout}>Logout</MenuItem>
109-
</Menu>
110-
</>
111-
) : (
112-
<>
113-
<Button variant="contained" onClick={() => navigate("/signup")}>
114-
Sign up
115-
</Button>
116-
<Button variant="outlined" onClick={() => navigate("/login")}>
117-
Log in
118-
</Button>
119-
</>
120-
)}
121-
</Stack>
120+
Sign up
121+
</Button>
122+
<Button variant="outlined" onClick={() => navigate("/login")}>
123+
Log in
124+
</Button>
125+
</>
126+
)}
127+
</Stack>
128+
) : (
129+
<Button
130+
variant="outlined"
131+
color="error"
132+
onClick={() => navigate("/home")}
133+
>
134+
Stop matching
135+
</Button>
136+
)}
122137
</Toolbar>
123138
</AppMargin>
124139
</AppBar>

frontend/src/components/Timer/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type TimerProps = { totalTime: number; timeLeft: number };
99

1010
const Timer: React.FC<CircularProgressProps & TimerProps> = (props) => {
11-
const { totalTime, timeLeft, thickness, size } = props;
11+
const { totalTime, timeLeft, thickness, size, ...rest } = props;
1212
const percentage = (timeLeft / totalTime) * 100;
1313
const minutes = Math.floor(timeLeft / 60);
1414
const seconds = timeLeft % 60;
@@ -29,7 +29,6 @@ const Timer: React.FC<CircularProgressProps & TimerProps> = (props) => {
2929
size={size}
3030
sx={{ position: "absolute" }}
3131
thickness={thickness}
32-
{...props}
3332
/>
3433
<Box
3534
sx={{

0 commit comments

Comments
 (0)