first commit
This commit is contained in:
82
components/dashboard/real-time-stats.tsx
Normal file
82
components/dashboard/real-time-stats.tsx
Normal file
@@ -0,0 +1,82 @@
|
||||
"use client";
|
||||
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { useStats } from "@/hooks/useStats";
|
||||
import { SimpleStatsChart } from "./charts/simple-stats-chart";
|
||||
import { ModelDistributionChart } from "./charts/model-distribution-chart";
|
||||
import { AlertCircle } from "lucide-react";
|
||||
|
||||
export function RealTimeStats() {
|
||||
const { stats, loading, error } = useStats();
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<div className="h-64 bg-muted animate-pulse rounded-lg" />
|
||||
<div className="h-64 bg-muted animate-pulse rounded-lg" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<Card>
|
||||
<CardContent className="flex items-center justify-center h-64">
|
||||
<div className="text-center">
|
||||
<AlertCircle className="h-8 w-8 text-destructive mx-auto mb-2" />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Erreur lors du chargement des données
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center justify-center h-64">
|
||||
<div className="text-center">
|
||||
<AlertCircle className="h-8 w-8 text-destructive mx-auto mb-2" />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Erreur lors du chargement des données
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!stats) {
|
||||
return (
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<Card>
|
||||
<CardContent className="flex items-center justify-center h-64">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Aucune donnée disponible
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center justify-center h-64">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Aucune donnée disponible
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<SimpleStatsChart
|
||||
title="Tokens consommés par jour"
|
||||
data={stats.dailyTokens}
|
||||
color="hsl(var(--primary))"
|
||||
/>
|
||||
<ModelDistributionChart
|
||||
title="Répartition par modèle"
|
||||
data={stats.modelDistribution}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user