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

@@ -63,7 +63,7 @@ export default function AdminNotifications() {
const [page, setPage] = useState(0);
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,
statut: filters.statut as any || undefined,
email: filters.email || undefined,
@@ -73,7 +73,7 @@ export default function AdminNotifications() {
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,
dateFin: filters.dateFin || undefined,
});
@@ -129,6 +129,12 @@ export default function AdminNotifications() {
<TabsContent value="statistiques" className="space-y-6">
{isLoadingStats ? (
<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 ? (
<>
{/* Cartes de statistiques globales */}
@@ -378,6 +384,12 @@ export default function AdminNotifications() {
<CardContent>
{isLoadingHistorique ? (
<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 ? (
<div className="text-center py-8 text-muted-foreground">
Aucune notification trouvée