-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from DoodleyJC/frontend
feat: navbar
- Loading branch information
Showing
4 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { cookies } from "next/headers"; | ||
|
||
export default function LoginPage() { | ||
async function handleSubmit(formData: FormData) { | ||
"use server"; | ||
|
||
const email = formData.get("email"); | ||
const password = formData.get("password"); | ||
|
||
cookies().set("isLoggedIn", "1", { expires: Date.now() + 1000 * 60 * 60 }); //cookie that expires after 1 hour | ||
} | ||
|
||
return ( | ||
<form action={handleSubmit}> | ||
<input type="text" name="email" placeholder="Email" required /> | ||
<input type="password" name="password" placeholder="Password" required /> | ||
<button type="submit">Login</button> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Link from "next/link"; | ||
|
||
export default function Navbar() { | ||
return ( | ||
<div className="w-full bg-gray-900"> | ||
<nav> | ||
<ul className="text-2x mx-20 flex h-16 items-center justify-between text-blue-500"> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
Home | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
Teams | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
Standings | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
Schedules | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
Games | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
Volunteers | ||
</Link> | ||
</li> | ||
<li> | ||
<Link className="hover:text-blue-800" href="/"> | ||
History | ||
</Link> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { NextResponse } from "next/server"; | ||
import type { NextRequest } from "next/server"; | ||
|
||
export function middleware(request: NextRequest) { | ||
const isLoggedIn = request.cookies.get("isLoggedIn"); | ||
|
||
if (isLoggedIn && isLoggedIn.value == "0") { | ||
return Response.redirect(new URL("/login", request.nextUrl)); | ||
} | ||
} | ||
|
||
export const config = { | ||
matcher: ["/logintest"], | ||
}; |