Alexis Bruneteau 0dd0f100f5 fix: Prevent frontend TypeError from undefined array access
Fix undefined variable crashes when accessing property 'length' on undefined:
- "can't access property 'length', e is undefined"

CHANGES:
1. Election detail page ([id]/page.tsx):
   - Ensure candidates array exists when fetching election data
   - Default to empty array if API returns undefined candidates

2. Active elections list page (active/page.tsx):
   - Validate API response is an array before processing
   - Ensure each election has candidates array with fallback

3. Blockchain visualizer (blockchain-visualizer.tsx):
   - Add optional chaining check before accessing data.blocks
   - Prevent crashes when data prop is undefined

All changes follow defensive programming practices:
- No more direct property access without null checks
- Array fallbacks ensure predictable behavior
- Optional chaining used consistently

This fixes the error that occurred when navigating to election pages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 19:18:42 +01:00
Description
No description provided
2.6 MiB
Languages
JavaScript 37.7%
Python 28.6%
CSS 26%
Typst 4.1%
Shell 2.4%
Other 1.2%