mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
ui: improve auth UI
This commit is contained in:
parent
0dddff308e
commit
08f852a397
@ -18,21 +18,21 @@ export default function ForgotPasswordModal() {
|
|||||||
<div>
|
<div>
|
||||||
<Dialog>
|
<Dialog>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button className=" whitespace-nowrap flex bg-transparent border-none hover:bg-transparent shadow-none">
|
<Button className="whitespace-nowrap flex bg-transparent border-none hover:bg-transparent shadow-none">
|
||||||
<h1 className="text-green-600 underline">Forgot password?</h1>
|
<h1 className="text-green-600 underline">Forgot password?</h1>
|
||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="sm:max-w-md">
|
<DialogContent className="sm:max-w-md dark:bg-slate-800">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>What's your email?</DialogTitle>
|
<DialogTitle>What's your email?</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Please verify your email for us. Once you do, we'll send instructions to reset your password
|
Please verify your email for us. Once you do, we'll send instructions to reset your password.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<div className="grid flex-1 gap-2">
|
<div className="grid flex-1 gap-2">
|
||||||
<Label htmlFor="link" className="sr-only">
|
<Label htmlFor="link" className="sr-only">
|
||||||
Link
|
Email
|
||||||
</Label>
|
</Label>
|
||||||
<Input id="email" type="email" placeholder="your.email@gmail.com" />
|
<Input id="email" type="email" placeholder="your.email@gmail.com" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,8 +2,9 @@ import Image from "next/image";
|
|||||||
|
|
||||||
export function GoogleSigninButton() {
|
export function GoogleSigninButton() {
|
||||||
return (
|
return (
|
||||||
<div className="flex w-1/3 justify-center rounded-full border-2 border-border bg-gray-100 hover:bg-gray-300 duration-300 cursor-pointer ">
|
<div className="flex items-center justify-center gap-3 w-full py-2 px-4 rounded-full border border-border bg-gray-100 dark:bg-slate-700 hover:bg-gray-200 dark:hover:bg-slate-600 transition-colors cursor-pointer">
|
||||||
<Image src="/google-logo.png" alt="Google Logo" width={35} height={35} className="object-contain" />
|
<Image src="/google-logo.png" alt="Google Logo" width={35} height={35} className="object-contain" />
|
||||||
|
<span className="font-medium text-gray-800 dark:text-gray-100">Sign in with Google</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,35 +2,35 @@
|
|||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
import { signInSchema } from "@/schemas/auth.schema";
|
import { signInSchema } from "@/schemas/auth.schema";
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import ForgotPasswordModal from "./forgot-password-modal";
|
import ForgotPasswordModal from "./forgot-password-modal";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { GoogleSigninButton } from "./google-oauth";
|
import { GoogleSigninButton } from "./google-oauth";
|
||||||
import { z } from "zod";
|
import type { z } from "zod";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { loginUser } from "@/api/authentication";
|
import { loginUser } from "@/api/authentication";
|
||||||
import { SessionContext } from "@/context/SessionContext";
|
import { SessionContext } from "@/context/SessionContext";
|
||||||
|
import { Eye, EyeOff, Leaf, ArrowRight, AlertCircle, Loader2 } from "lucide-react";
|
||||||
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { ThemeToggle } from "@/components/theme-toggle";
|
||||||
|
|
||||||
export default function SigninPage() {
|
export default function SigninPage() {
|
||||||
const [serverError, setServerError] = useState<string | null>(null);
|
const [serverError, setServerError] = useState<string | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const session = useContext(SessionContext);
|
const session = useContext(SessionContext);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors, isSubmitting },
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: zodResolver(signInSchema),
|
resolver: zodResolver(signInSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@ -56,68 +56,188 @@ export default function SigninPage() {
|
|||||||
router.push("/setup");
|
router.push("/setup");
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Error logging in:", error);
|
console.error("Error logging in:", error);
|
||||||
setServerError(error.message);
|
setServerError(error.message || "Invalid email or password. Please try again.");
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className="min-h-screen bg-gradient-to-br from-green-50 dark:from-gray-900 to-white dark:to-gray-800">
|
||||||
|
<div className="grid lg:grid-cols-[1fr_1.2fr] h-screen overflow-hidden">
|
||||||
|
{/* Left side - Image */}
|
||||||
|
<div className="hidden lg:block relative">
|
||||||
|
<div className="absolute inset-0 bg-[url('/plant-background.jpeg')] bg-cover bg-center">
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-br from-green-900/70 to-green-800/40 flex flex-col justify-between p-10">
|
||||||
<div>
|
<div>
|
||||||
<div className="grid grid-cols-[0.7fr_1.2fr] h-screen overflow-hidden">
|
<Link href="/" className="flex items-center gap-2 text-white">
|
||||||
<div className="flex bg-[url('/plant-background.jpeg')] bg-cover bg-center"></div>
|
<Leaf className="h-6 w-6" />
|
||||||
|
<span className="font-bold text-xl">ForFarm</span>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center items-center">
|
<div className="max-w-md">
|
||||||
<div className="container px-[25%]">
|
<h2 className="text-3xl font-bold text-white mb-4">Grow smarter with ForFarm</h2>
|
||||||
<div className="flex flex-col justify-center items-center">
|
<p className="text-green-100 mb-6">
|
||||||
<span>
|
Join thousands of farmers using our platform to optimize their agricultural operations and increase
|
||||||
<Image src="/forfarm-logo.png" alt="Forfarm" width={150} height={150} />
|
yields.
|
||||||
</span>
|
</p>
|
||||||
<h1 className="text-3xl font-semibold">Welcome back.</h1>
|
<div className="flex items-center gap-4">
|
||||||
<div className="flex whitespace-nowrap gap-x-2 mt-2">
|
<div className="flex -space-x-2">
|
||||||
<span className="text-md">New to Forfarm?</span>
|
{[1, 2, 3].map((i) => (
|
||||||
<span className="text-green-600">
|
<div key={i} className="w-8 h-8 rounded-full border-2 border-green-600 overflow-hidden">
|
||||||
<Link href="signup" className="underline">
|
<Image
|
||||||
|
src={`/placeholder.svg?height=32&width=32`}
|
||||||
|
alt="User"
|
||||||
|
width={32}
|
||||||
|
height={32}
|
||||||
|
className="bg-green-200"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="text-sm text-green-100">
|
||||||
|
<span className="font-bold">500+</span> farmers already using ForFarm
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right side - Form */}
|
||||||
|
<div className="flex justify-center items-center p-6">
|
||||||
|
<div className="w-full max-w-md">
|
||||||
|
<div className="lg:hidden flex justify-center mb-8">
|
||||||
|
<Link href="/" className="flex items-center gap-2">
|
||||||
|
<Image src="/forfarm-logo.png" alt="Forfarm" width={80} height={80} />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-center mb-8">
|
||||||
|
<h1 className="text-3xl font-bold mb-2">Welcome back</h1>
|
||||||
|
<p className="text-gray-500 dark:text-gray-400">
|
||||||
|
New to Forfarm?{" "}
|
||||||
|
<Link href="/auth/signup" className="text-green-600 hover:text-green-700 font-medium">
|
||||||
Sign up
|
Sign up
|
||||||
</Link>
|
</Link>
|
||||||
</span>
|
</p>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{serverError && (
|
||||||
|
<Alert variant="destructive" className="mb-6 animate-fadeIn">
|
||||||
|
<AlertCircle className="h-4 w-4" />
|
||||||
|
<AlertDescription>{serverError}</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Sign in form */}
|
{/* Sign in form */}
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-col mt-4">
|
<form onSubmit={handleSubmit(onSubmit)} className="space-y-5">
|
||||||
<div>
|
<div className="space-y-2">
|
||||||
<Label htmlFor="email">Email</Label>
|
<Label htmlFor="email" className="text-sm font-medium dark:text-gray-300">
|
||||||
<Input type="email" id="email" placeholder="Email" {...register("email")} />
|
Email
|
||||||
{errors.email && <p className="text-red-600 text-sm">{errors.email.message}</p>}
|
</Label>
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
type="email"
|
||||||
|
id="email"
|
||||||
|
placeholder="name@example.com"
|
||||||
|
className={`h-12 px-4 ${errors.email ? "border-red-500 focus-visible:ring-red-500" : ""}`}
|
||||||
|
{...register("email")}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-5">
|
{errors.email && (
|
||||||
<Label htmlFor="password">Password</Label>
|
<p className="text-red-500 text-sm mt-1 flex items-center gap-1">
|
||||||
<Input type="password" id="password" placeholder="Password" {...register("password")} />
|
<AlertCircle className="h-3 w-3" />
|
||||||
{errors.password && <p className="text-red-600 text-sm">{errors.password.message}</p>}
|
{errors.email.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button type="submit" className="mt-5 rounded-full" disabled={isLoading}>
|
<div className="space-y-2">
|
||||||
{isLoading ? "Logging in..." : "Log in"}
|
<div className="flex justify-between">
|
||||||
|
<Label htmlFor="password" className="text-sm font-medium dark:text-gray-300">
|
||||||
|
Password
|
||||||
|
</Label>
|
||||||
|
<ForgotPasswordModal />
|
||||||
|
</div>
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
type={showPassword ? "text" : "password"}
|
||||||
|
id="password"
|
||||||
|
placeholder="••••••••"
|
||||||
|
className={`h-12 px-4 ${errors.password ? "border-red-500 focus-visible:ring-red-500" : ""}`}
|
||||||
|
{...register("password")}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700"
|
||||||
|
onClick={() => setShowPassword(!showPassword)}>
|
||||||
|
{showPassword ? <EyeOff className="h-5 w-5" /> : <Eye className="h-5 w-5" />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{errors.password && (
|
||||||
|
<p className="text-red-500 text-sm mt-1 flex items-center gap-1">
|
||||||
|
<AlertCircle className="h-3 w-3" />
|
||||||
|
{errors.password.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<Checkbox id="remember" />
|
||||||
|
<label
|
||||||
|
htmlFor="remember"
|
||||||
|
className="text-sm text-gray-500 dark:text-gray-400 cursor-pointer select-none">
|
||||||
|
Remember me for 30 days
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="w-full h-12 rounded-full font-medium text-base bg-green-600 hover:bg-green-700 transition-all"
|
||||||
|
disabled={isLoading}>
|
||||||
|
{isLoading ? (
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
|
Logging in...
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="flex items-center justify-center gap-2">
|
||||||
|
Log in
|
||||||
|
<ArrowRight className="h-4 w-4" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div id="signin-footer" className="flex justify-between mt-5">
|
<div className="mt-8">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="relative">
|
||||||
<Checkbox id="terms" />
|
<div className="absolute inset-0 flex items-center">
|
||||||
<label htmlFor="terms" className="text-sm font-medium leading-none">
|
<div className="w-full border-t border-gray-200 dark:border-gray-700"></div>
|
||||||
Remember me
|
</div>
|
||||||
</label>
|
<div className="relative flex justify-center text-sm">
|
||||||
|
<span className="px-2 bg-gradient-to-br from-green-50 to-white dark:from-gray-900 dark:to-gray-800 text-gray-500">
|
||||||
|
Or continue with
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<ForgotPasswordModal />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="my-5">
|
<div className="mt-6">
|
||||||
<p className="text-sm">Or log in with</p>
|
|
||||||
<div className="flex flex-col gap-x-5 mt-3">
|
|
||||||
<GoogleSigninButton />
|
<GoogleSigninButton />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p className="text-center text-sm text-gray-500 dark:text-gray-400 mt-8">
|
||||||
|
By signing in, you agree to our{" "}
|
||||||
|
<Link href="/terms" className="text-green-600 hover:text-green-700">
|
||||||
|
Terms of Service
|
||||||
|
</Link>{" "}
|
||||||
|
and{" "}
|
||||||
|
<Link href="/privacy" className="text-green-600 hover:text-green-700">
|
||||||
|
Privacy Policy
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
const WaterDrop = () => {
|
|
||||||
return (
|
|
||||||
<div className="relative w-6 h-[400px] overflow-hidden">
|
|
||||||
{/* Water Drop animation */}
|
|
||||||
<div className="absolute w-6 h-6 bg-blue-500 rounded-full animate-drop overflow-hidden"></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default WaterDrop;
|
|
||||||
@ -1,28 +1,30 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import type React from "react";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
import { signUpSchema } from "@/schemas/auth.schema";
|
import { signUpSchema } from "@/schemas/auth.schema";
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { z } from "zod";
|
import type { z } from "zod";
|
||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { registerUser } from "@/api/authentication";
|
import { registerUser } from "@/api/authentication";
|
||||||
import { SessionContext } from "@/context/SessionContext";
|
import { SessionContext } from "@/context/SessionContext";
|
||||||
|
import { Eye, EyeOff, Leaf, ArrowRight, AlertCircle, Loader2, Check } from "lucide-react";
|
||||||
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
|
import { Progress } from "@/components/ui/progress";
|
||||||
|
|
||||||
export default function SignupPage() {
|
export default function SignupPage() {
|
||||||
const [serverError, setServerError] = useState<string | null>(null);
|
const [serverError, setServerError] = useState<string | null>(null);
|
||||||
const [successMessage, setSuccessMessage] = useState<string | null>(null);
|
const [successMessage, setSuccessMessage] = useState<string | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||||
|
const [passwordStrength, setPasswordStrength] = useState(0);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const session = useContext(SessionContext);
|
const session = useContext(SessionContext);
|
||||||
@ -30,7 +32,8 @@ export default function SignupPage() {
|
|||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
watch,
|
||||||
|
formState: { errors, isSubmitting },
|
||||||
} = useForm<z.infer<typeof signUpSchema>>({
|
} = useForm<z.infer<typeof signUpSchema>>({
|
||||||
resolver: zodResolver(signUpSchema),
|
resolver: zodResolver(signUpSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@ -40,6 +43,29 @@ export default function SignupPage() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const password = watch("password");
|
||||||
|
|
||||||
|
// Calculate password strength based on several criteria
|
||||||
|
const calculatePasswordStrength = (password: string) => {
|
||||||
|
if (!password) return 0;
|
||||||
|
let strength = 0;
|
||||||
|
|
||||||
|
// Length check
|
||||||
|
if (password.length >= 8) strength += 25;
|
||||||
|
// Contains lowercase
|
||||||
|
if (/[a-z]/.test(password)) strength += 25;
|
||||||
|
// Contains uppercase
|
||||||
|
if (/[A-Z]/.test(password)) strength += 25;
|
||||||
|
// Contains number or special char
|
||||||
|
if (/[0-9!@#$%^&*(),.?":{}|<>]/.test(password)) strength += 25;
|
||||||
|
return strength;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPasswordChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const newStrength = calculatePasswordStrength(e.target.value);
|
||||||
|
setPasswordStrength(newStrength);
|
||||||
|
};
|
||||||
|
|
||||||
const onSubmit = async (values: z.infer<typeof signUpSchema>) => {
|
const onSubmit = async (values: z.infer<typeof signUpSchema>) => {
|
||||||
setServerError(null);
|
setServerError(null);
|
||||||
setSuccessMessage(null);
|
setSuccessMessage(null);
|
||||||
@ -52,82 +78,264 @@ export default function SignupPage() {
|
|||||||
setServerError("An error occurred while registering. Please try again.");
|
setServerError("An error occurred while registering. Please try again.");
|
||||||
throw new Error("No data received from the server.");
|
throw new Error("No data received from the server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
session!.setToken(data.token);
|
session!.setToken(data.token);
|
||||||
session!.setUser(values.email);
|
session!.setUser(values.email);
|
||||||
|
|
||||||
setSuccessMessage("Registration successful! You can now sign in.");
|
setSuccessMessage("Registration successful! You can now sign in.");
|
||||||
router.push("/setup");
|
router.push("/setup");
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Error during registration:", error);
|
console.error("Error during registration:", error);
|
||||||
setServerError(error.message);
|
setServerError(error.message || "Registration failed. Please try again.");
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
const getPasswordStrengthText = () => {
|
||||||
<div>
|
if (passwordStrength === 0) return "";
|
||||||
<div className="grid grid-cols-[0.7fr_1.2fr] h-screen overflow-hidden">
|
if (passwordStrength <= 25) return "Weak";
|
||||||
<div className="flex bg-[url('/plant-background.jpeg')] bg-cover bg-center"></div>
|
if (passwordStrength <= 50) return "Fair";
|
||||||
|
if (passwordStrength <= 75) return "Good";
|
||||||
|
return "Strong";
|
||||||
|
};
|
||||||
|
|
||||||
<div className="flex justify-center items-center">
|
const getPasswordStrengthColor = () => {
|
||||||
<div className="container px-[25%]">
|
if (passwordStrength <= 25) return "bg-red-500";
|
||||||
<div className="flex flex-col justify-center items-center">
|
if (passwordStrength <= 50) return "bg-yellow-500";
|
||||||
<span>
|
if (passwordStrength <= 75) return "bg-blue-500";
|
||||||
<Image src="/forfarm-logo.png" alt="Forfarm" width={150} height={150} />
|
return "bg-green-500";
|
||||||
</span>
|
};
|
||||||
<h1 className="text-3xl font-semibold">Hi! Welcome</h1>
|
|
||||||
<div className="flex whitespace-nowrap gap-x-2 mt-2">
|
return (
|
||||||
<span className="text-md">Already have an account?</span>
|
<div className="min-h-screen bg-gradient-to-br from-green-50 dark:from-gray-900 to-white dark:to-gray-800">
|
||||||
<span className="text-green-600">
|
<div className="grid lg:grid-cols-[1fr_1.2fr] h-screen overflow-hidden">
|
||||||
<Link href="/auth/signin" className="underline">
|
{/* Left Side - Image */}
|
||||||
|
<div className="hidden lg:block relative">
|
||||||
|
<div className="absolute inset-0 bg-[url('/plant-background.jpeg')] bg-cover bg-center">
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-br from-green-900/70 to-green-800/40 flex flex-col justify-between p-10">
|
||||||
|
<div>
|
||||||
|
<Link href="/" className="flex items-center gap-2 text-white">
|
||||||
|
<Leaf className="h-6 w-6" />
|
||||||
|
<span className="font-bold text-xl">ForFarm</span>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className="max-w-md">
|
||||||
|
<h2 className="text-3xl font-bold text-white mb-4">Join the farming revolution</h2>
|
||||||
|
<p className="text-green-100 mb-6">
|
||||||
|
Create your account today and discover how ForFarm can help you optimize your agricultural operations.
|
||||||
|
</p>
|
||||||
|
<div className="space-y-4">
|
||||||
|
{[
|
||||||
|
"Real-time monitoring of your crops",
|
||||||
|
"Smart resource management",
|
||||||
|
"Data-driven insights for better yields",
|
||||||
|
"Connect with other farmers in your area",
|
||||||
|
].map((feature, index) => (
|
||||||
|
<div key={index} className="flex items-start gap-2">
|
||||||
|
<div className="rounded-full bg-green-500 p-1 mt-0.5">
|
||||||
|
<Check className="h-3 w-3 text-white" />
|
||||||
|
</div>
|
||||||
|
<span className="text-green-100 text-sm">{feature}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right Side - Form */}
|
||||||
|
<div className="flex justify-center items-center p-6">
|
||||||
|
<div className="w-full max-w-md">
|
||||||
|
{/* Theme Selector Placeholder */}
|
||||||
|
<div className="mb-4 text-center text-sm text-gray-500 dark:text-gray-400">Theme Selector Placeholder</div>
|
||||||
|
|
||||||
|
<div className="lg:hidden flex justify-center mb-8">
|
||||||
|
<Link href="/" className="flex items-center gap-2">
|
||||||
|
<Image src="/forfarm-logo.png" alt="Forfarm" width={80} height={80} />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-center mb-8">
|
||||||
|
<h1 className="text-3xl font-bold mb-2">Create your account</h1>
|
||||||
|
<p className="text-gray-500 dark:text-gray-400">
|
||||||
|
Already have an account?{" "}
|
||||||
|
<Link href="/auth/signin" className="text-green-600 hover:text-green-700 font-medium">
|
||||||
Sign in
|
Sign in
|
||||||
</Link>
|
</Link>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{serverError && (
|
||||||
|
<Alert variant="destructive" className="mb-6 animate-fadeIn">
|
||||||
|
<AlertCircle className="h-4 w-4" />
|
||||||
|
<AlertDescription>{serverError}</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{successMessage && (
|
||||||
|
<Alert className="mb-6 bg-green-50 text-green-800 border-green-200 animate-fadeIn">
|
||||||
|
<Check className="h-4 w-4" />
|
||||||
|
<AlertDescription>{successMessage}</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Sign Up Form */}
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="space-y-5">
|
||||||
|
{/* Email */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="email" className="text-sm font-medium dark:text-gray-300">
|
||||||
|
Email
|
||||||
|
</Label>
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
type="email"
|
||||||
|
id="email"
|
||||||
|
placeholder="name@example.com"
|
||||||
|
className={`h-12 px-4 ${errors.email ? "border-red-500 focus-visible:ring-red-500" : ""}`}
|
||||||
|
{...register("email")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{errors.email && (
|
||||||
|
<p className="text-red-500 text-sm mt-1 flex items-center gap-1">
|
||||||
|
<AlertCircle className="h-3 w-3" />
|
||||||
|
{errors.email.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Password */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="password" className="text-sm font-medium dark:text-gray-300">
|
||||||
|
Password
|
||||||
|
</Label>
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
type={showPassword ? "text" : "password"}
|
||||||
|
id="password"
|
||||||
|
placeholder="••••••••"
|
||||||
|
className={`h-12 px-4 ${errors.password ? "border-red-500 focus-visible:ring-red-500" : ""}`}
|
||||||
|
{...register("password", { onChange: onPasswordChange })}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={showPassword ? "Hide password" : "Show password"}
|
||||||
|
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700"
|
||||||
|
onClick={() => setShowPassword(!showPassword)}>
|
||||||
|
{showPassword ? <EyeOff className="h-5 w-5" /> : <Eye className="h-5 w-5" />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Password Strength Indicator */}
|
||||||
|
{password && (
|
||||||
|
<div className="mt-2 space-y-1">
|
||||||
|
<div className="flex justify-between items-center">
|
||||||
|
<span className="text-xs text-gray-500 dark:text-gray-400">Password strength</span>
|
||||||
|
<span
|
||||||
|
className={`text-xs font-medium ${
|
||||||
|
passwordStrength <= 25
|
||||||
|
? "text-red-500"
|
||||||
|
: passwordStrength <= 50
|
||||||
|
? "text-yellow-500"
|
||||||
|
: passwordStrength <= 75
|
||||||
|
? "text-blue-500"
|
||||||
|
: "text-green-500"
|
||||||
|
}`}>
|
||||||
|
{getPasswordStrengthText()}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<Progress value={passwordStrength} className={`${getPasswordStrengthColor()} h-1`} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{errors.password && (
|
||||||
|
<p className="text-red-500 text-sm mt-1 flex items-center gap-1">
|
||||||
|
<AlertCircle className="h-3 w-3" />
|
||||||
|
{errors.password.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Signup form */}
|
{/* Confirm Password */}
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="flex flex-col mt-4">
|
<div className="space-y-2">
|
||||||
<div>
|
<Label htmlFor="confirmPassword" className="text-sm font-medium dark:text-gray-300">
|
||||||
<Label htmlFor="email">Email</Label>
|
Confirm Password
|
||||||
<Input type="email" id="email" placeholder="Email" {...register("email")} />
|
</Label>
|
||||||
{errors.email && <p className="text-red-600 text-sm">{errors.email.message}</p>}
|
<div className="relative">
|
||||||
</div>
|
|
||||||
<div className="mt-5">
|
|
||||||
<Label htmlFor="password">Password</Label>
|
|
||||||
<Input type="password" id="password" placeholder="Password" {...register("password")} />
|
|
||||||
{errors.password && <p className="text-red-600 text-sm">{errors.password.message}</p>}
|
|
||||||
</div>
|
|
||||||
<div className="mt-5">
|
|
||||||
<Label htmlFor="confirmPassword">Confirm Password</Label>
|
|
||||||
<Input
|
<Input
|
||||||
type="password"
|
type={showConfirmPassword ? "text" : "password"}
|
||||||
id="confirmPassword"
|
id="confirmPassword"
|
||||||
placeholder="Confirm Password"
|
placeholder="••••••••"
|
||||||
|
className={`h-12 px-4 ${errors.confirmPassword ? "border-red-500 focus-visible:ring-red-500" : ""}`}
|
||||||
{...register("confirmPassword")}
|
{...register("confirmPassword")}
|
||||||
/>
|
/>
|
||||||
{errors.confirmPassword && <p className="text-red-600 text-sm">{errors.confirmPassword.message}</p>}
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={showConfirmPassword ? "Hide password" : "Show password"}
|
||||||
|
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700"
|
||||||
|
onClick={() => setShowConfirmPassword(!showConfirmPassword)}>
|
||||||
|
{showConfirmPassword ? <EyeOff className="h-5 w-5" /> : <Eye className="h-5 w-5" />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{errors.confirmPassword && (
|
||||||
|
<p className="text-red-500 text-sm mt-1 flex items-center gap-1">
|
||||||
|
<AlertCircle className="h-3 w-3" />
|
||||||
|
{errors.confirmPassword.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{serverError && <p className="text-red-600 mt-2 text-sm">{serverError}</p>}
|
<Button
|
||||||
{successMessage && <p className="text-green-600 mt-2 text-sm">{successMessage}</p>}
|
type="submit"
|
||||||
|
className="w-full h-12 rounded-full font-medium text-base bg-green-600 hover:bg-green-700 transition-all"
|
||||||
<Button type="submit" className="mt-5 rounded-full" disabled={isLoading}>
|
disabled={isLoading}>
|
||||||
{isLoading ? "Signing up..." : "Sign up"}
|
{isLoading ? (
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<Loader2 className="h-4 w-4 animate-spin" />
|
||||||
|
Creating account...
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="flex items-center justify-center gap-2">
|
||||||
|
Create account
|
||||||
|
<ArrowRight className="h-4 w-4" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div className="my-5">
|
<div className="mt-8">
|
||||||
<p className="text-sm">Or sign up with</p>
|
<div className="relative">
|
||||||
<div className="flex flex-col gap-x-5 mt-3">
|
<div className="absolute inset-0 flex items-center">
|
||||||
{/* Google OAuth button or additional providers */}
|
<div className="w-full border-t border-gray-200 dark:border-gray-700"></div>
|
||||||
<div className="flex w-1/3 justify-center rounded-full border-2 border-border bg-gray-100 hover:bg-gray-300 duration-300 cursor-pointer">
|
</div>
|
||||||
<Image src="/google-logo.png" alt="Google Logo" width={35} height={35} className="object-contain" />
|
<div className="relative flex justify-center text-sm">
|
||||||
|
<span className="px-2 bg-gradient-to-br from-green-50 to-white dark:from-gray-900 dark:to-gray-800 text-gray-500">
|
||||||
|
Or sign up with
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-6">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
className="w-full h-12 rounded-full border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors">
|
||||||
|
<Image src="/google-logo.png" alt="Google Logo" width={20} height={20} className="mr-2" />
|
||||||
|
Sign up with Google
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p className="text-center text-sm text-gray-500 dark:text-gray-400 mt-8">
|
||||||
|
By signing up, you agree to our{" "}
|
||||||
|
<Link href="/terms" className="text-green-600 hover:text-green-700">
|
||||||
|
Terms of Service
|
||||||
|
</Link>{" "}
|
||||||
|
and{" "}
|
||||||
|
<Link href="/privacy" className="text-green-600 hover:text-green-700">
|
||||||
|
Privacy Policy
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -93,7 +93,7 @@ export default function Home() {
|
|||||||
<Link href="/demo">
|
<Link href="/demo">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="border-white text-white text-md font-bold px-6 py-6 rounded-full hover:bg-white/10 transition-colors w-full sm:w-auto">
|
className="border-white dark:border-white text-black dark:text-white text-md font-bold px-6 py-6 rounded-full hover:bg-white/10 transition-colors w-full sm:w-auto">
|
||||||
Watch demo
|
Watch demo
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user