Skip to content

Commit cc5ad20

Browse files
committed
Render stop matching button on all matching pages
1 parent f2beb46 commit cc5ad20

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

frontend/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ function App() {
4141
</ProfileContextProvider>
4242
}
4343
/>
44-
<Route path="match" element={<ProtectedRoutes />}>
44+
<Route path="matching" element={<ProtectedRoutes />}>
4545
<Route index element={<Matching />} />
46+
<Route path="matched" element={<div>Matched</div>} />
47+
<Route path="timeout" element={<div>Timeout</div>} />
4648
</Route>
4749
<Route path="*" element={<PageNotFound />} />
4850
</Route>

frontend/src/components/Navbar/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useNavigate, useLocation } from "react-router-dom";
1818
import { useAuth } from "../../contexts/AuthContext";
1919
import { useState } from "react";
2020
import { USE_AUTH_ERROR_MESSAGE } from "../../utils/constants";
21+
import { isMatchingPage } from "../../utils/url";
2122

2223
type NavbarItem = { label: string; link: string; needsLogin: boolean };
2324

@@ -35,8 +36,6 @@ const Navbar: React.FC<NavbarProps> = (props) => {
3536
const location = useLocation();
3637
const path = location.pathname;
3738

38-
console.log(path);
39-
4039
const auth = useAuth();
4140
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
4241

@@ -73,7 +72,7 @@ const Navbar: React.FC<NavbarProps> = (props) => {
7372
>
7473
PeerPrep
7574
</Typography>
76-
{path !== "/match" ? (
75+
{!isMatchingPage(path) ? (
7776
<Stack direction={"row"} alignItems={"center"} spacing={2}>
7877
{navbarItems
7978
.filter((item) => !item.needsLogin || (item.needsLogin && user))

frontend/src/utils/url.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const isMatchingPage = (path: string) => {
2+
const pattern = /^(?<prefix>\/matching)(?<ignore>\/.*)*$/;
3+
return pattern.test(path);
4+
};

0 commit comments

Comments
 (0)