import React, { useState } from "react";
import { Link } from "react-router-dom";
import { base44 } from "@/api/base44Client";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { LogIn, Mail, Lock, Loader2 } from "lucide-react";
import AuthLayout from "@/components/AuthLayout";
import GoogleIcon from "@/components/GoogleIcon";
export default function Login() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
const handleSubmit = async (e) => {
e.preventDefault();
setError("");
setLoading(true);
try {
await base44.auth.loginViaEmailPassword(email, password);
window.location.href = "/";
} catch (err) {
setError(err.message || "Invalid email or password");
} finally {
setLoading(false);
}
};
const handleGoogle = () => {
base44.auth.loginWithProvider("google", "/");
};
return (
Don't have an account?{" "}
Create one
>
}
>
{error && (
{error}
)}
);
}