Adapt frontend to SAM API: RUT auth, new types, helpdesk endpoints

- 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)
This commit is contained in:
Nurfog committed 2026-09-10 11:27:35 -03:00
1 parent 0cca57f21e
commit f56f6365d2
11 files changed
+285 -718

No files matched your search

+7 -17
View File
@@ -2,11 +2,10 @@
import { useState } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { useAuth } from "@/lib/auth";
export default function LoginPage() {
const [email, setEmail] = useState("");
const [rut, setRut] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
@@ -18,7 +17,7 @@ export default function LoginPage() {
setError("");
setLoading(true);
try {
await login(email, password);
await login(rut, password);
router.push("/");
} catch (err: any) {
setError(err.message || "Credenciales inválidas");
@@ -75,13 +74,13 @@ export default function LoginPage() {
<form onSubmit={handleSubmit}>
<div className="mb-3">
<label className="form-label">Correo Electrónico</label>
<label className="form-label">RUT</label>
<input
type="email"
type="text"
className="form-control"
placeholder="tu@email.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="12.345.678-9"
value={rut}
onChange={(e) => setRut(e.target.value)}
required
autoFocus
/>
@@ -117,15 +116,6 @@ export default function LoginPage() {
)}
</button>
</form>
<div className="text-center mt-4">
<span className="text-muted" style={{ fontSize: "0.9rem" }}>
¿No tienes cuenta?{" "}
<Link href="/register" style={{ color: "var(--primary)", fontWeight: 500 }}>
Regístrate aquí
</Link>
</span>
</div>
</div>
</div>
</div>