committing summative
This commit is contained in:
1 parent
73ac8e85be
commit
95b138f29e
44 files changed
+5319
-755
No files matched your search
@@ -0,0 +1,60 @@
|
||||
"use client";
|
||||
|
||||
import { Suspense, useState, useEffect } from "react";
|
||||
import AuthLoginForm from "./AuthLoginForm"
|
||||
import SigninButton from "./SigninButton";
|
||||
import { handleGoogleLogin } from "@/app/actions/GoogleAction";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
|
||||
function LoginContent() {
|
||||
const [elogin, setElogin] = useState(false);
|
||||
const showEmailLogin = () => { // lets you toggle on and off showEmailLogin which is used to decide if the authloginform is shown
|
||||
setElogin(!elogin);
|
||||
};
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const isJustRegisted = searchParams.get("registered") === "true"; // if redirected with reigstered = true
|
||||
|
||||
useEffect(() => {
|
||||
if (isJustRegisted) {
|
||||
setElogin(true);
|
||||
}
|
||||
}, [isJustRegisted]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="card-title text-2xl justify-center">Please Sign In</h2>
|
||||
<form className="mt-4">
|
||||
{isJustRegisted && ( // display if redirect with search param
|
||||
<div className="p-10 bg-emerald-1001 text-emerald-700 mb-15 rounded-md">
|
||||
Account created successfully. You can now sign in.
|
||||
</div>
|
||||
)}
|
||||
<SigninButton
|
||||
text="Google"
|
||||
style="btn btn-primary w-full"
|
||||
formAction={handleGoogleLogin}
|
||||
/>
|
||||
</form>
|
||||
<div className="mt-4">
|
||||
<SigninButton
|
||||
text="Email"
|
||||
style="btn btn-primary w-full"
|
||||
callback={showEmailLogin}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-4">{elogin ? <AuthLoginForm /> : ""}</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default function LoginPage() { // displays fallback while url dependent content loads (searchparams), errors if it tries to prepare page in advance
|
||||
return (
|
||||
<>
|
||||
<Suspense fallback={<p>Loading login..</p>}>
|
||||
<LoginContent />
|
||||
</Suspense>
|
||||
</>
|
||||
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user