Skip to content

Commit 9efcf72

Browse files
authored
Merge pull request #13 from DoodleyJC/frontend
feat: navbar
2 parents 43193f7 + 9c1f030 commit 9efcf72

File tree

4 files changed

+86
-1
lines changed

4 files changed

+86
-1
lines changed

frontend/src/app/layout.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import { Inter } from "next/font/google";
33
import "./globals.css";
4+
import Navbar from "@/components/navigationbar";
45

56
const inter = Inter({ subsets: ["latin"] });
67

@@ -16,7 +17,10 @@ export default function RootLayout({
1617
}>) {
1718
return (
1819
<html lang="en">
19-
<body className={inter.className}>{children}</body>
20+
<body className={inter.className}>
21+
<Navbar />
22+
{children}
23+
</body>
2024
</html>
2125
);
2226
}

frontend/src/app/login/page.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { cookies } from "next/headers";
2+
3+
export default function LoginPage() {
4+
async function handleSubmit(formData: FormData) {
5+
"use server";
6+
7+
const email = formData.get("email");
8+
const password = formData.get("password");
9+
10+
cookies().set("isLoggedIn", "1", { expires: Date.now() + 1000 * 60 * 60 }); //cookie that expires after 1 hour
11+
}
12+
13+
return (
14+
<form action={handleSubmit}>
15+
<input type="text" name="email" placeholder="Email" required />
16+
<input type="password" name="password" placeholder="Password" required />
17+
<button type="submit">Login</button>
18+
</form>
19+
);
20+
}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Link from "next/link";
2+
3+
export default function Navbar() {
4+
return (
5+
<div className="w-full bg-gray-900">
6+
<nav>
7+
<ul className="text-2x mx-20 flex h-16 items-center justify-between text-blue-500">
8+
<li>
9+
<Link className="hover:text-blue-800" href="/">
10+
Home
11+
</Link>
12+
</li>
13+
<li>
14+
<Link className="hover:text-blue-800" href="/">
15+
Teams
16+
</Link>
17+
</li>
18+
<li>
19+
<Link className="hover:text-blue-800" href="/">
20+
Standings
21+
</Link>
22+
</li>
23+
<li>
24+
<Link className="hover:text-blue-800" href="/">
25+
Schedules
26+
</Link>
27+
</li>
28+
<li>
29+
<Link className="hover:text-blue-800" href="/">
30+
Games
31+
</Link>
32+
</li>
33+
<li>
34+
<Link className="hover:text-blue-800" href="/">
35+
Volunteers
36+
</Link>
37+
</li>
38+
<li>
39+
<Link className="hover:text-blue-800" href="/">
40+
History
41+
</Link>
42+
</li>
43+
</ul>
44+
</nav>
45+
</div>
46+
);
47+
}

frontend/src/middleware.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NextResponse } from "next/server";
2+
import type { NextRequest } from "next/server";
3+
4+
export function middleware(request: NextRequest) {
5+
const isLoggedIn = request.cookies.get("isLoggedIn");
6+
7+
if (isLoggedIn && isLoggedIn.value == "0") {
8+
return Response.redirect(new URL("/login", request.nextUrl));
9+
}
10+
}
11+
12+
export const config = {
13+
matcher: ["/logintest"],
14+
};

0 commit comments

Comments
 (0)