gemma: generate apps/web/src/pages/Login.tsx

This commit is contained in:
Dennis (via Claude+Gemma) 2026-05-23 04:27:17 +02:00
parent 54b2032348
commit b0d8ed8577

View File

@ -0,0 +1,79 @@
import { useState } from "react"
import { useNavigate } from "@tanstack/react-router"
import { api } from "../lib/api"
export default function Login() {
const navigate = useNavigate()
const [email, setEmail] = useState("admin@emberclone.local")
const [password, setPassword] = useState("emberclone2026")
const [error, setError] = useState<string | null>(null)
const [isLoading, setIsLoading] = useState(false)
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError(null)
setIsLoading(true)
try {
await api.login(email, password)
navigate({ to: "/" })
} catch (err: any) {
setError(err.message || "Login failed")
} finally {
setIsLoading(false)
}
}
return (
<div className="min-h-screen flex items-center justify-center bg-slate-50 px-4">
<div className="w-full max-w-md bg-white rounded-xl shadow-sm border border-slate-200 p-8">
<div className="text-center mb-8">
<h1 className="text-2xl font-bold text-slate-900">EmberClone</h1>
<p className="text-slate-500 mt-2">Sign in to your account</p>
</div>
<form onSubmit={handleSubmit} className="space-y-6">
<div>
<label className="block text-sm font-medium text-slate-700 mb-1">
Email Address
</label>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full px-3 py-2 border border-slate-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all"
required
/>
</div>
<div>
<label className="block text-sm font-medium text-slate-700 mb-1">
Password
</label>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full px-3 py-2 border border-slate-300 rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all"
required
/>
</div>
{error && (
<div className="p-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded-md">
{error}
</div>
)}
<button
type="submit"
disabled={isLoading}
className="w-full py-2 px-4 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
{isLoading ? "Signing in..." : "Sign In"}
</button>
</form>
</div>
</div>
)
}