"use client" import Link from "next/link" import { useState, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { BarChart3, CheckCircle, Clock, Archive } from "lucide-react" import { electionsApi, Election } from "@/lib/api" export default function DashboardPage() { const [activeVotes, setActiveVotes] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { const fetchData = async () => { try { setLoading(true) const response = await electionsApi.getActive() if (response.data) { setActiveVotes(response.data) } else if (response.error) { setError(response.error) } } catch (err) { setError("Erreur lors du chargement des données") } finally { setLoading(false) } } fetchData() }, []) // Mock data for stats const stats = [ { title: "Votes Actifs", value: "3", icon: CheckCircle, color: "text-accent", href: "/dashboard/votes/active", }, { title: "À Venir", value: "5", icon: Clock, color: "text-blue-500", href: "/dashboard/votes/upcoming", }, { title: "Votes Passés", value: "12", icon: BarChart3, color: "text-green-500", href: "/dashboard/votes/history", }, { title: "Archives", value: "8", icon: Archive, color: "text-gray-500", href: "/dashboard/votes/archives", }, ] return (
{/* Header */}

Tableau de Bord

Gérez et participez à vos élections en toute sécurité

{/* Stats Grid */}
{stats.map((stat) => { const Icon = stat.icon return (
{stat.title} {stat.value}
) })}
{/* Active Votes Section */}

Votes Actifs

{error && (

{error}

)} {loading && (
)} {!loading && activeVotes.length === 0 && (

Aucun vote actif en ce moment

)}
{activeVotes.slice(0, 3).map((vote) => (
{vote.name} {vote.description}
{/* Footer Info */}
Candidates: {vote.candidates?.length || 0}
))}
{/* Quick Actions */}

Actions Rapides

) }