correzione dei dati lato frontend
All checks were successful
Deploy to VPS / build (push) Successful in 22s
Deploy to VPS / deploy (push) Successful in 26s

This commit is contained in:
AV77web 2026-07-14 10:51:04 +02:00
parent 948cdb8765
commit e311d8ace3
5 changed files with 39 additions and 24 deletions

View file

@ -59,7 +59,17 @@ export async function login(email: string, password: string): Promise<void> {
const data = await response.json().catch(() => ({})) as { url?: string };
if (!response.ok || data.url?.includes("error=")) {
throw new Error("Credenziali non valide");
const errorType = data.url?.match(/error=([^&]+)/)?.[1];
if (errorType === "CredentialsSignin") {
throw new Error("Credenziali non valide");
}
if (errorType === "MissingCSRF") {
throw new Error("Sessione scaduta: ricarica la pagina e riprova");
}
if (errorType === "Configuration") {
throw new Error("Errore di configurazione del server (database o auth)");
}
throw new Error("Accesso non riuscito");
}
}

View file

@ -15,7 +15,7 @@ export default function Layout() {
<header className="header">
<div className="header-inner">
<Link to="/dashboard" className="logo">
Esame ITS 24-26
Academy aziendale
</Link>
<nav>
<Link to="/dashboard">Dashboard</Link>

View file

@ -1,3 +1,9 @@
//=======================================
// File: Daschborad.tsx
// Componete Dashborad dell'applicazione
// author: "villari.andrea@libero.it"
// version: "1.0.0 2026-07.14"
//=======================================
import { useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { useAuth } from "../context/AuthContext";
@ -6,7 +12,7 @@ export default function Dashboard() {
const { user } = useAuth();
const location = useLocation();
const navigate = useNavigate();
const isAdmin = user?.ruolo === "Amministratore";
const isReferente = user?.ruolo === "Referente Academy";
const [deniedMessage, setDeniedMessage] = useState<string | null>(null);
useEffect(() => {
@ -24,7 +30,7 @@ export default function Dashboard() {
<p>
Benvenuto, <strong>{user?.nome} {user?.cognome}</strong>
</p>
<p className="muted">Ruolo: {isAdmin ? "Amministratore" : "Operatore"}</p>
<p className="muted">Ruolo: {isReferente ? "Referente Academy" : "Dipendente"}</p>
<p className="muted">Email: {user?.email}</p>
</div>
);

View file

@ -1,5 +1,10 @@
export type Ruolo = "Operatore" | "Amministratore";
//=======================================
// File: index.ts
// Script per la gestione dei tipi utente
// author: "villari.andrea@libero.it"
// version: "1.0.0 2026-07-14"
//=======================================
export type Ruolo = "Dipendente" | "Referente Academy";
export interface Utente {
id: number;

View file

@ -1,8 +1,8 @@
//===================================================
// File: constraints.ts
// Vincoli derivati da initdb/01_schema.sql.
// Vincoli derivati da initdb/01_schema.sql (backend).
// author: "villari.andrea@libero.it"
// version: "1.0.0 2026-06-24"
// version: "1.0.0 2026-07-14"
//===================================================
export const UTENTE_CONSTRAINTS = {
@ -11,29 +11,23 @@ export const UTENTE_CONSTRAINTS = {
email: { maxLength: 255, required: true },
password: { minLength: 8, maxLength: 72, required: true },
ruolo: {
allowedValues: ["Operatore", "Amministratore"],
allowedValues: ["Dipendente", "Referente Academy"] as const,
required: true,
},
} as const;
export const CLIENTE_CONSTRAINTS = {
nome: { maxLength: 100, required: true },
cognome: { maxLength: 100, required: true },
via: { maxLength: 100, required: true },
comune: { maxLength: 100, required: true },
provincia: { maxLength: 2, required: true },
telefono: { maxLength: 30, required: true },
email: { maxLength: 255, required: true },
note: { required: false },
export const CORSO_CONSTRAINTS = {
titolo: { maxLength: 200, required: true },
descrizione: { maxLength: 65535, required: false },
categoria: { maxLength: 100, required: true },
durataOre: { min: 1, max: 65535, required: true },
obbligatorio: { required: false },
attivo: { required: false },
} as const;
export const CONSEGNA_CONSTRAINTS = {
dataRitiro: { required: false },
dataConsegna: { required: false },
export const ASSEGNAZIONE_CONSTRAINTS = {
stato: {
allowedValues: ["da ritirare", "in consegna", "in giacenza", "in deposito"],
allowedValues: ["Assegnato", "Completato", "Scaduto", "Annullato"] as const,
required: true,
},
chiaveConsegna: { maxLength: 8, required: true },
clienteId: { required: true },
} as const;