Fix remaining undefined array access error on blockchain visualization page.
When blockchainData exists but blocks is undefined, accessing .length would crash:
- "can't access property 'length', e is undefined"
CHANGES:
1. Blockchain page (blockchain/page.tsx):
- Ensure blocks array always exists when API data is fetched
- Provide fallback to empty array with verification object
- Add null check before accessing blocks.length in conditional render
This is the final fix for all frontend undefined array access issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed ElGamal class instantiation in votes.py (ElGamalEncryption instead of ElGamal)
- Fixed public key serialization in admin.py (use public_key_bytes property)
- Implemented database migration with SQL-based key generation
- Added vote deduplication endpoint: GET /api/votes/check
- Protected all array accesses with type validation in frontend
- Fixed vote parameter type handling (string to number conversion)
- Removed all debug console logs for production
- Created missing dynamic route for vote history details
Fixes:
- JavaScript error: "can't access property length, e is undefined"
- Vote deduplication not preventing form display
- Frontend data validation issues
- Missing dynamic routes
The blockchain page was calling /api/elections instead of
/api/elections/active, resulting in 404 Not Found errors.
The API returns an array directly, not wrapped in an object,
so updated response parsing to handle both formats.
This fixes 'Error fetching elections: Impossible de charger
les élections' error on the blockchain dashboard page.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Add next-themes dependency for theme management
- Create ThemeProvider wrapper for app root layout
- Set dark mode as default theme
- Create ThemeToggle component with Sun/Moon icons
- Add theme toggle to home page navigation
- Add theme toggle to dashboard header
- App now starts in dark mode with ability to switch to light mode
Styling uses existing Tailwind dark mode variables configured in
tailwind.config.ts and globals.css. All existing components automatically
support dark theme.
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive blockchain viewer with:
- BlockchainViewer component: Display blocks in expandable cards
- Hash visualization: Show SHA-256 hashes for each block
- Chain verification: Visual integrity status and verification button
- Block details: Expand to see full block information
- Index, timestamp, previous hash, block hash
- Encrypted vote data, transaction ID
- Digital signatures
- Election selector: View blockchain for different elections
- Mock data: Demo blockchain included for testing
- Responsive design: Works on mobile and desktop
UI Features:
✓ Block expansion/collapse with icon indicators
✓ Genesis block highlighted with ⚡ icon
✓ Vote blocks marked with 🔒 icon
✓ Chain link visual indicators
✓ Hash truncation with full display on expand
✓ Status indicators: Chain valid/invalid
✓ Security information panel
✓ Statistics: Total blocks, votes, integrity status
Integration:
✓ Fetch elections list from API
✓ Fetch blockchain state for selected election
✓ Verify blockchain integrity
✓ Handle empty blockchain state
✓ Error handling with user feedback
✓ Loading states during API calls
Routes:
✓ /dashboard/blockchain - Main blockchain viewer
✓ Added to sidebar navigation
✓ 13 total routes now (added 1 new)
Frontend Build:
✓ No TypeScript errors
✓ Zero unused imports
✓ Production build successful
✓ All routes prerendered
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>