import { Input, Checkbox, Button, Link } from "@heroui/react"; import { IconMail, IconLock } from "@tabler/icons-react"; import { useState } from "react"; import { toast } from "react-toastify"; import http, { login } from "../http"; export default function LoginView({ onSignup }: { onSignup: () => void }) { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const validateFields = () => { if (!email || !password) { toast.error("Both email and password are required."); return false; } return true; }; const handleLogin = async () => { if (!validateFields()) return; const loginRequest = { email, password, }; try { const response = await http.post("/User/login", loginRequest); if (response.status !== 200) { throw new Error("Login failed"); } const { token } = response.data; login(token); } catch (error) { toast.error( (error as any).response?.data || "Something went wrong! Please try again." ); } }; return (

Welcome back!

Let us know who you are, and we will let you in.

} label="Email" type="email" value={email} onValueChange={setEmail} /> } label="Password" type="password" value={password} onValueChange={setPassword} />
Remember me Forgot password?

Don't have an account?

Sign up
); }