Checkpoint: Amélioration de la gestion d'erreur sur la page des notifications - affichage des messages d'erreur au lieu de planter

This commit is contained in:
Manus Sandbox
2025-12-15 16:05:37 -05:00
parent 7950caee1a
commit b0cecb65f6
3 changed files with 133 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
{
"query": "SHOW TABLES LIKE 'logsNotifications';",
"command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute SHOW TABLES LIKE 'logsNotifications';",
"rows": [
{
"Tables_in_7PAT67UmWoxv8vwp8Bbcv6 (logsNotifications)": "logsNotifications"
}
],
"messages": [],
"stdout": "Tables_in_7PAT67UmWoxv8vwp8Bbcv6 (logsNotifications)\nlogsNotifications\n",
"stderr": "",
"execution_time_ms": 76
}

View File

@@ -0,0 +1,106 @@
{
"query": "DESCRIBE logsNotifications;",
"command": "mysql --batch --raw --column-names --default-character-set=utf8mb4 --host gateway02.us-east-1.prod.aws.tidbcloud.com --port 4000 --user 4CrrYuB5tme73Qo.root --database 7PAT67UmWoxv8vwp8Bbcv6 --execute DESCRIBE logsNotifications;",
"rows": [
{
"Field": "id",
"Type": "int(11)",
"Null": "NO",
"Key": "PRI",
"Default": "NULL",
"Extra": "auto_increment"
},
{
"Field": "type",
"Type": "enum('remerciement','notification_formateur_inscription','notification_formateur_annulation','alerte_capacite','notification_liste_attente')",
"Null": "NO",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "sequenceId",
"Type": "int(11)",
"Null": "YES",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "apprenantId",
"Type": "int(11)",
"Null": "YES",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "formateurId",
"Type": "int(11)",
"Null": "YES",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "emailDestinataire",
"Type": "varchar(320)",
"Null": "NO",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "sujet",
"Type": "varchar(500)",
"Null": "NO",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "dateEnvoi",
"Type": "timestamp",
"Null": "NO",
"Key": "",
"Default": "CURRENT_TIMESTAMP",
"Extra": ""
},
{
"Field": "statut",
"Type": "enum('success','failed')",
"Null": "NO",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "messageErreur",
"Type": "text",
"Null": "YES",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "metadata",
"Type": "text",
"Null": "YES",
"Key": "",
"Default": "NULL",
"Extra": ""
},
{
"Field": "createdAt",
"Type": "timestamp",
"Null": "NO",
"Key": "",
"Default": "CURRENT_TIMESTAMP",
"Extra": ""
}
],
"messages": [],
"stdout": "Field\tType\tNull\tKey\tDefault\tExtra\nid\tint(11)\tNO\tPRI\tNULL\tauto_increment\ntype\tenum('remerciement','notification_formateur_inscription','notification_formateur_annulation','alerte_capacite','notification_liste_attente')\tNO\t\tNULL\t\nsequenceId\tint(11)\tYES\t\tNULL\t\napprenantId\tint(11)\tYES\t\tNULL\t\nformateurId\tint(11)\tYES\t\tNULL\t\nemailDestinataire\tvarchar(320)\tNO\t\tNULL\t\nsujet\tvarchar(500)\tNO\t\tNULL\t\ndateEnvoi\ttimestamp\tNO\t\tCURRENT_TIMESTAMP\t\nstatut\tenum('success','failed')\tNO\t\tNULL\t\nmessageErreur\ttext\tYES\t\tNULL\t\nmetadata\ttext\tYES\t\tNULL\t\ncreatedAt\ttimestamp\tNO\t\tCURRENT_TIMESTAMP\t\n",
"stderr": "",
"execution_time_ms": 51
}

View File

@@ -63,7 +63,7 @@ export default function AdminNotifications() {
const [page, setPage] = useState(0); const [page, setPage] = useState(0);
const limit = 20; const limit = 20;
const { data: historiqueData, isLoading: isLoadingHistorique, refetch } = trpc.notifications.historique.useQuery({ const { data: historiqueData, isLoading: isLoadingHistorique, refetch, error: historiqueError } = trpc.notifications.historique.useQuery({
type: filters.type as any || undefined, type: filters.type as any || undefined,
statut: filters.statut as any || undefined, statut: filters.statut as any || undefined,
email: filters.email || undefined, email: filters.email || undefined,
@@ -73,7 +73,7 @@ export default function AdminNotifications() {
offset: page * limit, offset: page * limit,
}); });
const { data: statsData, isLoading: isLoadingStats } = trpc.notifications.statistiques.useQuery({ const { data: statsData, isLoading: isLoadingStats, error: statsError } = trpc.notifications.statistiques.useQuery({
dateDebut: filters.dateDebut || undefined, dateDebut: filters.dateDebut || undefined,
dateFin: filters.dateFin || undefined, dateFin: filters.dateFin || undefined,
}); });
@@ -129,6 +129,12 @@ export default function AdminNotifications() {
<TabsContent value="statistiques" className="space-y-6"> <TabsContent value="statistiques" className="space-y-6">
{isLoadingStats ? ( {isLoadingStats ? (
<div className="text-center py-8 text-muted-foreground">Chargement...</div> <div className="text-center py-8 text-muted-foreground">Chargement...</div>
) : statsError ? (
<div className="text-center py-8 text-red-500">
<AlertCircle className="h-8 w-8 mx-auto mb-2" />
<p>Erreur lors du chargement des statistiques</p>
<p className="text-sm text-muted-foreground mt-1">{statsError.message}</p>
</div>
) : statsData ? ( ) : statsData ? (
<> <>
{/* Cartes de statistiques globales */} {/* Cartes de statistiques globales */}
@@ -378,6 +384,12 @@ export default function AdminNotifications() {
<CardContent> <CardContent>
{isLoadingHistorique ? ( {isLoadingHistorique ? (
<div className="text-center py-8 text-muted-foreground">Chargement...</div> <div className="text-center py-8 text-muted-foreground">Chargement...</div>
) : historiqueError ? (
<div className="text-center py-8 text-red-500">
<AlertCircle className="h-8 w-8 mx-auto mb-2" />
<p>Erreur lors du chargement de l'historique</p>
<p className="text-sm text-muted-foreground mt-1">{historiqueError.message}</p>
</div>
) : historiqueData?.logs.length === 0 ? ( ) : historiqueData?.logs.length === 0 ? (
<div className="text-center py-8 text-muted-foreground"> <div className="text-center py-8 text-muted-foreground">
Aucune notification trouvée Aucune notification trouvée