Skip to content

Commit 0402507

Browse files
Merge main
2 parents b8346c5 + e8a5bd7 commit 0402507

9 files changed

+229
-217
lines changed

app/login/page.jsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use client";
2+
import { Suspense } from "react";
3+
import LoginPage from "../../components/LoginPage/LoginPage";
4+
5+
export default function Page() {
6+
return (
7+
<Suspense>
8+
<LoginPage />
9+
</Suspense>
10+
);
11+
}

app/login/page.tsx

-117
This file was deleted.

components/LoginPage/LoginForm.jsx

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
export default function LoginForm() {
2+
<form onSubmit={handleSubmit}>
3+
<div className="relative mt-6">
4+
<input
5+
type="email"
6+
name="email"
7+
id="email"
8+
placeholder="Email Address"
9+
className="peer mt-1 w-full border-b-2 border-gray-300 px-0 py-1 placeholder:text-transparent focus:border-gray-500 focus:outline-none"
10+
autoComplete="email"
11+
/>
12+
<label
13+
htmlFor="email"
14+
className="pointer-events-none absolute top-0 left-0 origin-left -translate-y-1/2 transform text-sm text-gray-800 opacity-75 transition-all duration-100 ease-in-out peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-base peer-placeholder-shown:text-gray-500 peer-focus:top-0 peer-focus:pl-0 peer-focus:text-sm peer-focus:text-gray-800"
15+
>
16+
Email Address
17+
</label>
18+
</div>
19+
<div className="relative mt-6">
20+
<input
21+
type="password"
22+
name="password"
23+
id="password"
24+
required
25+
autoComplete="current-password"
26+
placeholder="Password"
27+
className="peer peer mt-1 w-full border-b-2 border-gray-300 px-0 py-1 placeholder:text-transparent focus:border-gray-500 focus:outline-none"
28+
/>
29+
<label
30+
htmlFor="password"
31+
className="pointer-events-none absolute top-0 left-0 origin-left -translate-y-1/2 transform text-sm text-gray-800 opacity-75 transition-all duration-100 ease-in-out peer-placeholder-shown:top-1/2 peer-placeholder-shown:text-base peer-placeholder-shown:text-gray-500 peer-focus:top-0 peer-focus:pl-0 peer-focus:text-sm peer-focus:text-gray-800"
32+
>
33+
Password
34+
</label>
35+
</div>
36+
<div className="text-sm my-12 font-semibold text-gray-700 hover:text-black underline">
37+
<a href="/#">Forgot password?</a>
38+
</div>
39+
<div className="flex items-center justify-between">
40+
<label htmlFor="remember_me" className="block text-sm text-gray-900">
41+
Remember me
42+
</label>
43+
<input
44+
id="rememberMe"
45+
name="rememberMe"
46+
type="checkbox"
47+
className="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded"
48+
/>
49+
</div>
50+
<div className="my-12 flex justify-center">
51+
<button
52+
type="submit"
53+
className="w-11/12 bg-blue-800 rounded-full p-1.5 text-white hover:bg-blue-900"
54+
>
55+
Sign in
56+
</button>
57+
</div>
58+
<div className="flex text-center text-sm text-gray-500">
59+
<p>Don't have an account yet?</p>
60+
<a
61+
href="/signup"
62+
className="ml-1 font-semibold text-gray-600 hover:underline focus:text-gray-800 focus:outline-none"
63+
>
64+
Create Account
65+
</a>
66+
.
67+
</div>
68+
</form>;
69+
}

components/LoginPage/LoginPage.jsx

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"use client";
2+
3+
import { useRouter, useSearchParams } from "next/navigation";
4+
import { SECRET_ROUTE } from "lib/routes";
5+
import { signIn, useUser } from "lib/auth";
6+
import LoginForm from "./LoginForm";
7+
8+
export default function LoginPage() {
9+
const router = useRouter();
10+
const searchParams = useSearchParams();
11+
const user = useUser();
12+
13+
const continueTo = searchParams?.get("continueTo") ?? SECRET_ROUTE;
14+
15+
async function handleSubmit(event) {
16+
event.preventDefault();
17+
const form = event.currentTarget;
18+
const email = form.email.value;
19+
const password = form.password.value;
20+
const rememberMe = form.rememberMe.checked;
21+
22+
try {
23+
await signIn(email, password, rememberMe);
24+
router.replace(continueTo);
25+
} catch (error) {
26+
window.alert(error);
27+
}
28+
}
29+
30+
if (user) {
31+
router.replace(continueTo);
32+
return null;
33+
}
34+
35+
return (
36+
<main className="flex">
37+
<section className="flex flex-col py-12 px-16">
38+
<div className="text-xl tracking-wide mb-10">Sign In</div>
39+
40+
<div className="mt-5 mx-5"></div>
41+
<LoginForm />
42+
</section>
43+
</main>
44+
);
45+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use client";
2+
3+
export default function LoginSeparator() {
4+
return (
5+
<div className="between m-auto mx-20 flex flex-col">
6+
<div className="relative left-[50%] m-[-1.5px] h-[110px] w-px border-l-[1px] bg-[#aaa]"></div>
7+
<div className="m-0 h-[60px] w-[60px] rounded-full border-[1px] border-[#aaa] p-0 text-center leading-[60px]">
8+
<span>OR</span>
9+
</div>
10+
<div className="relative left-[50%] m-[-1.5px] mt-0 h-[110px] w-px border-l-[1px] bg-[#aaa]"></div>
11+
</div>
12+
);
13+
}

components/LoginPage/ManualLogin.jsx

-100
This file was deleted.

0 commit comments

Comments
 (0)