457db923d2
Deploy / deploy (push) Successful in 4m35s
- Background fijo con tallermg.jpeg + overlay rgba(0,0,0,0.35) en globals.css - Favicon actualizado usando src/app/icon.jpeg (convención Next.js App Router) - Eliminado bg-gray-50 de layouts para que el fondo sea visible - Título del sitio actualizado a "Taller MG" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
"use client";
|
|
import { useState } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
import Button from "@/components/ui/Button";
|
|
import Input from "@/components/ui/Input";
|
|
import Card from "@/components/ui/Card";
|
|
|
|
export default function AdminLoginPage() {
|
|
const router = useRouter();
|
|
const [form, setForm] = useState({ email: "", password: "" });
|
|
const [loading, setLoading] = useState(false);
|
|
const [error, setError] = useState("");
|
|
|
|
function set(f: string) {
|
|
return (e: React.ChangeEvent<HTMLInputElement>) => setForm((v) => ({ ...v, [f]: e.target.value }));
|
|
}
|
|
|
|
async function handleSubmit(e: React.FormEvent) {
|
|
e.preventDefault();
|
|
setLoading(true);
|
|
setError("");
|
|
const res = await fetch("/api/auth/admin-login", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(form),
|
|
});
|
|
const data = await res.json();
|
|
setLoading(false);
|
|
if (!res.ok) { setError(data.error || "Credenciales incorrectas"); return; }
|
|
router.push("/admin/dashboard");
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col items-center justify-center min-h-screen">
|
|
<Card className="w-full max-w-sm mx-4">
|
|
<div className="text-center mb-6">
|
|
<div className="text-4xl mb-2">🔧</div>
|
|
<h1 className="text-xl font-bold text-gray-800">Panel del taller</h1>
|
|
<p className="text-sm text-gray-500 mt-1">Solo para jefes mecánicos</p>
|
|
</div>
|
|
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
|
|
<Input id="email" type="email" label="Email" placeholder="jefe@taller.com" value={form.email} onChange={set("email")} required />
|
|
<Input id="password" type="password" label="Contraseña" placeholder="••••••••" value={form.password} onChange={set("password")} required />
|
|
{error && <p className="text-sm text-red-500 text-center">{error}</p>}
|
|
<Button type="submit" loading={loading} className="w-full">Ingresar</Button>
|
|
</form>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|