- Login: RUT-based (SAM auth) instead of email - API client: updated all endpoints to /api/helpdesk/* - Types: match SAM response format (nombre, apPaterno, perfil) - Dashboard: uses new DashboardStats with dailyCounts - Tickets: title instead of subject, requesterName/assigneeName - KB: categoryName/authorName instead of nested objects - Removed register page (SAM manages users)
124 lines
3.9 KiB
TypeScript
124 lines
3.9 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
import { useAuth } from "@/lib/auth";
|
|
|
|
export default function LoginPage() {
|
|
const [rut, setRut] = useState("");
|
|
const [password, setPassword] = useState("");
|
|
const [error, setError] = useState("");
|
|
const [loading, setLoading] = useState(false);
|
|
const { login } = useAuth();
|
|
const router = useRouter();
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
setError("");
|
|
setLoading(true);
|
|
try {
|
|
await login(rut, password);
|
|
router.push("/");
|
|
} catch (err: any) {
|
|
setError(err.message || "Credenciales inválidas");
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="auth-page d-flex">
|
|
{/* Left Panel */}
|
|
<div className="auth-panel-left d-none d-md-flex col-md-5">
|
|
<div>
|
|
<i className="bi bi-headset display-1 mb-3"></i>
|
|
<h2>HelpDesk ICHN</h2>
|
|
<p>
|
|
Sistema de gestión de tickets de soporte técnico. Gestiona incidencias,
|
|
solicitudes y consultas de manera eficiente.
|
|
</p>
|
|
<div className="mt-4">
|
|
<div className="d-flex align-items-center gap-2 mb-3">
|
|
<i className="bi bi-check-circle-fill"></i>
|
|
<span>Gestión centralizada de tickets</span>
|
|
</div>
|
|
<div className="d-flex align-items-center gap-2 mb-3">
|
|
<i className="bi bi-check-circle-fill"></i>
|
|
<span>Base de conocimiento integrada</span>
|
|
</div>
|
|
<div className="d-flex align-items-center gap-2 mb-3">
|
|
<i className="bi bi-check-circle-fill"></i>
|
|
<span>SLA y métricas de rendimiento</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Right Panel - Form */}
|
|
<div className="auth-panel-right col-md-7 col-12">
|
|
<div className="auth-form">
|
|
<div className="d-md-none text-center mb-4">
|
|
<i className="bi bi-headset display-4" style={{ color: "var(--primary)" }}></i>
|
|
<h4 className="mt-2" style={{ color: "var(--primary)" }}>HelpDesk ICHN</h4>
|
|
</div>
|
|
|
|
<h3>Iniciar Sesión</h3>
|
|
<p className="subtitle">Ingresa tus credenciales para acceder al sistema</p>
|
|
|
|
{error && (
|
|
<div className="alert alert-danger py-2" role="alert">
|
|
<i className="bi bi-exclamation-circle me-2"></i>
|
|
{error}
|
|
</div>
|
|
)}
|
|
|
|
<form onSubmit={handleSubmit}>
|
|
<div className="mb-3">
|
|
<label className="form-label">RUT</label>
|
|
<input
|
|
type="text"
|
|
className="form-control"
|
|
placeholder="12.345.678-9"
|
|
value={rut}
|
|
onChange={(e) => setRut(e.target.value)}
|
|
required
|
|
autoFocus
|
|
/>
|
|
</div>
|
|
|
|
<div className="mb-4">
|
|
<label className="form-label">Contraseña</label>
|
|
<input
|
|
type="password"
|
|
className="form-control"
|
|
placeholder="••••••••"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
required
|
|
/>
|
|
</div>
|
|
|
|
<button
|
|
type="submit"
|
|
className="btn btn-primary w-100 py-2"
|
|
disabled={loading}
|
|
>
|
|
{loading ? (
|
|
<>
|
|
<span className="spinner-border spinner-border-sm me-2" role="status"></span>
|
|
Ingresando...
|
|
</>
|
|
) : (
|
|
<>
|
|
<i className="bi bi-box-arrow-in-right me-2"></i>
|
|
Iniciar Sesión
|
|
</>
|
|
)}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|