diff --git a/e-voting-system/frontend/app/dashboard/votes/active/[id]/page.tsx b/e-voting-system/frontend/app/dashboard/votes/active/[id]/page.tsx index adbd5c9..ae6d168 100644 --- a/e-voting-system/frontend/app/dashboard/votes/active/[id]/page.tsx +++ b/e-voting-system/frontend/app/dashboard/votes/active/[id]/page.tsx @@ -52,7 +52,12 @@ export default function VoteDetailPage() { } const data = await response.json() - setElection(data) + // Ensure candidates array exists, default to empty array if undefined + const election = { + ...data, + candidates: data.candidates || [] + } + setElection(election) } catch (err) { const message = err instanceof Error ? err.message : "Erreur lors du chargement" setError(message) diff --git a/e-voting-system/frontend/app/dashboard/votes/active/page.tsx b/e-voting-system/frontend/app/dashboard/votes/active/page.tsx index 316bacf..365a374 100644 --- a/e-voting-system/frontend/app/dashboard/votes/active/page.tsx +++ b/e-voting-system/frontend/app/dashboard/votes/active/page.tsx @@ -39,7 +39,12 @@ export default function ActiveVotesPage() { } const data = await response.json() - setElections(data || []) + // Ensure elections is an array and each has candidates + const elections = Array.isArray(data) ? data.map(e => ({ + ...e, + candidates: e.candidates || [] + })) : [] + setElections(elections) } catch (err) { const message = err instanceof Error ? err.message : "Erreur lors du chargement" setError(message) diff --git a/e-voting-system/frontend/components/blockchain-visualizer.tsx b/e-voting-system/frontend/components/blockchain-visualizer.tsx index d79a84c..aca549b 100644 --- a/e-voting-system/frontend/components/blockchain-visualizer.tsx +++ b/e-voting-system/frontend/components/blockchain-visualizer.tsx @@ -54,14 +54,14 @@ export function BlockchainVisualizer({ // Animate blocks on load useEffect(() => { - if (data.blocks.length > 0) { + if (data?.blocks && data.blocks.length > 0) { data.blocks.forEach((_, index) => { setTimeout(() => { setAnimatingBlocks((prev) => [...prev, index]) }, index * 100) }) } - }, [data.blocks]) + }, [data?.blocks]) const toggleBlockExpand = (index: number) => { setExpandedBlocks((prev) =>