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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user