"use client"; import { useState } from "react"; import Image from "next/image"; import { useRouter } from "next/navigation"; import { useSession } from "../lib/session"; function LoginForm({ next }: { next: string }) { const { login } = useSession(); const router = useRouter(); const [rut, setRut] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const submit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(null); try { await login(rut.trim(), password); router.push(next.startsWith("/") ? next : "/"); router.refresh(); } catch (err) { setError(err instanceof Error ? err.message : "Error al ingresar"); } finally { setLoading(false); } }; return (
SAM

Mis Pruebas

Welcome | Bienvenido/a

Rinde con tu RUT y clave

RUT | CLAVE
{error && (
{error}
)}
setRut(e.target.value)} className="form-control shadow mb-2" required placeholder="RUT (ej. 12345678-9)" autoComplete="username" /> setPassword(e.target.value)} className="form-control shadow mb-2" required placeholder="Clave" autoComplete="current-password" />
); } export default async function Login({ searchParams }: { searchParams: Promise<{ next?: string }>; }) { const sp = await searchParams; return ; }