'use client'; import React, { useEffect, useState } from 'react'; import { BarChart3, Clock, Mic, Users, History, Play } from 'lucide-react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; interface Recording { filename: string; text: string; duration: number; timestamp: string; emotion: string; rating: number; } interface Stats { total_recordings: number; total_duration: number; speakers: number; recent_recordings: Recording[]; } export default function DatasetStats() { const [stats, setStats] = useState({ total_recordings: 0, total_duration: 0, speakers: 0, recent_recordings: [] }); const fetchStats = () => { fetch('/api/dataset-stats') .then(res => res.json()) .then(data => setStats(data)) .catch(err => console.error('Error fetching stats:', err)); }; useEffect(() => { fetchStats(); const interval = setInterval(fetchStats, 5000); // Refresh every 5s return () => clearInterval(interval); }, []); return (
Session Stats
Recordings
{stats.total_recordings}
Duration
{(stats.total_duration / 60).toFixed(1)}m
Speakers
{stats.speakers}
Recent History {stats.recent_recordings.length === 0 ? (

No recordings yet

) : ( stats.recent_recordings.map((rec, i) => (
{rec.filename} {rec.emotion}

{rec.text}

{rec.duration.toFixed(1)}s
{[...Array(rec.rating)].map((_, i) => ( ))}
)) )}
); }