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>
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>
- Migrate from React CRA to Next.js 15 with modern architecture
- Implement comprehensive shadcn/ui component library
- Create complete dashboard system with layouts and navigation
- Build authentication pages (login, register) with proper forms
- Implement vote management pages (active, upcoming, history, archives)
- Add user profile management with security settings
- Configure Tailwind CSS with custom dark theme (accent: #e8704b)
- Setup TypeScript with strict type checking
- Backup old React-based frontend to .backups/frontend-old
- All pages compile successfully and build passes linting
Pages created:
- Home page with hero section and features
- Authentication (login/register)
- Dashboard with stats and vote cards
- Vote management (active, upcoming, history, archives)
- User profile with form validation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>