Skip to content

Commit

Permalink
Merge pull request #727 from ShivanshPlays/main
Browse files Browse the repository at this point in the history
User signup and fixed deployment issue
  • Loading branch information
mdazfar2 authored Oct 17, 2024
2 parents 529f664 + ceb89fc commit 9a295a3
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 236 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
211 changes: 0 additions & 211 deletions app/(auth)/login/page.tsx

This file was deleted.

145 changes: 145 additions & 0 deletions app/(authFE)/components/loginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Spinner } from "@/components/ui/spinner";
import { Eye, EyeOff, Mail, User } from "lucide-react";
import { signIn, useSession } from "next-auth/react";
import { useState } from "react";
import toast from "react-hot-toast";

interface LoginPageProps {
switchCss: boolean;
setSwitchCss: (value: boolean) => void;
isResetOpen: boolean;
setIsResetOpen: (value: boolean) => void;
loading: boolean;
setError: (value: string) => void;
setloading: (value: boolean) => void;
}

const LoginPage: React.FC<LoginPageProps> = ({
switchCss,
setSwitchCss,
isResetOpen,
setIsResetOpen,
loading,
setloading,
setError,
}) => {
const session = useSession();

const [email, setEmail] = useState("");
const [password, setPassword] = useState("");

const [showPassword, setShowPassword] = useState(false);

const handleSubmit = async (e: React.FormEvent) => {
setloading(true);
e.preventDefault();

const result = await signIn("credentials", {
email,
password,
redirect: false,
});
console.log(result);
if (result?.error) setError("Invalid email or password");
else {
toast.success(`Welcome ${session.data?.user?.name}`);
window.location.href = "/"; // Redirect on success
}
setloading(false);
};

return (
<>
{switchCss && !isResetOpen && (
<div className="flex flex-col z-10 items-center justify-start pt-24 pr-14 gap-4 w-2/4">
<div className="font-nunito text-4xl text-customTeal dark:text-Green font-extrabold">
Login
</div>
<form
// closed login button
onSubmit={handleSubmit}
className="w-full flex dark:text-gray-200 flex-col items-center gap-4"
>
<div className="flex items-center w-4/5 justify-center">
<Input
className="rounded-full"
type="email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<User className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<div className="flex items-center w-4/5 justify-center">
<Input
className="rounded-full"
type={showPassword ? "text" : "password"}
placeholder="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<div
className=" cursor-pointer"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? (
<EyeOff className="h-7 w-7 text-customTeal dark:text-Yellow" />
) : (
<Eye className="h-7 w-7 text-customTeal dark:text-Yellow" />
)}
</div>
</div>
<Button
type="submit"
disabled
// disabled={loading}
className="rounded-full bg-customTeal dark:bg-Green font-bold h-10 w-4/5 disabled"
>
{loading ? <Spinner /> : "Login"}
</Button>
</form>
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setIsResetOpen(!isResetOpen)}
>
Forgot Password?
</div>
<div className="flex items-center dark:text-gray-500 justify-center gap-2">
Don&apos;t have an account?
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setSwitchCss(!switchCss)}
>
{" "}
Sign Up
</div>
</div>
</div>
)}
{switchCss && isResetOpen && (
<div className="flex flex-col z-10 items-center justify-start pt-32 pr-14 gap-4 w-2/4">
<div className="font-nunito text-4xl text-customTeal dark:text-Green font-extrabold">
Forgot Password
</div>
<div className="flex items-center gap-2 w-4/5 justify-center">
<Input className="rounded-full" type="text" placeholder="Email" />
<Mail className="h-7 w-7 text-customTeal dark:text-Yellow" />
</div>
<Button className="rounded-full font-bold h-10 w-4/5 bg-customTeal dark:bg-Green">
Send reset link
</Button>
<div
className="text-customTeal dark:text-Green cursor-pointer"
onClick={() => setIsResetOpen(!isResetOpen)}
>
Back to Login
</div>
</div>
)}
</>
);
};

export default LoginPage;
Loading

0 comments on commit 9a295a3

Please sign in to comment.