## Profile Display Fix - Fixed profile creator info showing "Anonymous" instead of display name - Updated API routes to use correct `display_name` column instead of `name` - Updated all frontend code (41 replacements across 8 files) to use display_name - Added database migration for foreign key relationship between projects and profiles ## Gallery UI Improvements - Redesigned gallery lightbox to be more compact and elegant - Constrained lightbox images to max-w-5xl and max-h-[85vh] (was full screen) - Improved main gallery thumbnail sizing and aspect ratios - Added proper responsive padding and smoother transitions - Better click handling to prevent accidental closes ## Bitcoin Donations Redesign - Created new compact BitcoinDonationCard component - Created BitcoinWalletStatsCompact component without external links - Removed all mempool.space links per requirements - Made QR codes always visible with improved layout - Added "Send with Wallet" button for one-click Bitcoin URI - Reduced donation section size by ~50% while maintaining functionality - Modular, DRY code structure for better maintainability Files changed: - API: projects/[id]/route.ts, projects/route.ts - Components: 2 new Bitcoin components, updated profile layout - Frontend: 8 files updated with display_name references - Gallery: ProjectMediaGallery.tsx redesigned 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
16 KiB
Dashboard Page - Comprehensive Analysis
Created: 2025-11-02 Last Modified: 2025-01-30 Last Modified Summary: Updated route references to reflect consolidation to /projects/[id]
🔴 CRITICAL ERRORS & ISSUES
1. Type Mismatch: Currency Type Definition ❌ CRITICAL
Location: src/types/funding.ts:23
Problem:
currency?: 'BTC' | 'SATS' // Type only allows BTC/SATS
But dashboard code uses:
currency={project.currency || 'CHF'} // Trying to use CHF
currency={featuredProject.currency || 'CHF'} // Trying to use CHF
Impact:
- TypeScript errors (type mismatch)
- Runtime could fail if currency is 'CHF'/'USD'/'EUR'
- Type system doesn't match actual database schema
- Database schema supports: 'CHF', 'USD', 'EUR', 'BTC', 'SATS'
Fix Required:
// src/types/funding.ts
currency?: 'BTC' | 'SATS' | 'CHF' | 'USD' | 'EUR' | string
2. Missing Currency Field in Project Store ⚠️
Location: src/stores/projectStore.ts:77-90
Problem:
The project store mapping doesn't explicitly preserve the currency field:
const projects: Project[] = (data || []).map((project: any) => ({
...project, // Currency should be here but not guaranteed
total_funding: project.raised_amount ?? project.total_funding ?? 0,
// ... but no explicit currency mapping
}));
Issue:
- Spread operator
...projectshould include currency, but:- Type system doesn't enforce it
- If database field is missing, it won't be in the object
- No default value set
Recommendation:
currency: project.currency || 'CHF', // Explicit default
3. Potential Division by Zero ⚠️
Location: Line 574
Code:
amount={activeProjectsCount > 0 ? totalRaised / activeProjectsCount : 0}
Issue:
- Protected with ternary, but
totalRaisedmight be 0 from wrong currency selection - If
primaryCurrencylogic fails, could show wrong average - No validation that projects in calculation use same currency
4. Empty useEffect Hook 🐛
Location: Line 49-51
Code:
useEffect(() => {
// REMOVED: console.log statement for security
}, [user, profile, session, isLoading, hydrated, authError, localLoading]);
Problem:
- Empty effect with dependencies - does nothing but runs on every change
- Unnecessary re-renders
- Should be removed entirely
Fix:
// DELETE this entire useEffect
5. Multiple Currency Logic Issues ⚠️
Location: Lines 147-157
Current Logic:
const primaryCurrency =
fundingByCurrency['CHF'] !== undefined
? 'CHF'
: fundingByCurrency['BTC'] !== undefined
? 'BTC'
: 'CHF';
Problems:
- Ignores other currencies - If user has only EUR projects, shows CHF (wrong)
- Arbitrary priority - Why CHF > BTC? Should be user preference or most common
- No indication of mixed currencies - User might have CHF + EUR but only sees CHF total
- Total could be misleading - Shows "2,500 CHF" but might have 1,000 EUR + 1,500 CHF
Better Approach:
- Show totals per currency when mixed
- Or convert all to single currency with clear indicator
- Or let user choose display currency
🟡 ENGINEERING ISSUES
6. Large Component (743 lines) ⚠️
Problem: Single file component is too large
Issues:
- Hard to maintain
- Hard to test
- Multiple responsibilities (data fetching, UI rendering, state management)
- Violates Single Responsibility Principle
Recommendation: Extract into smaller components:
DashboardWelcome.tsx- Welcome sectionDashboardFeaturedProject.tsx- Featured project cardDashboardStatsCards.tsx- Stats gridDashboardProjectsList.tsx- Projects listDashboardQuickActions.tsx- Quick actions
7. Business Logic in Component ⚠️
Location: Throughout component
Problems:
- Currency calculation logic (lines 147-157) should be in utility
- Featured project selection logic (lines 174-179) should be in store or utility
- Profile completion calculation (lines 160-167) should be utility/hook
Recommendation:
// src/utils/dashboard.ts
export function calculateTotalRaisedByCurrency(projects: Project[]): {
totals: Record<string, number>;
primaryCurrency: string;
};
export function selectFeaturedProject(projects: Project[]): Project | null;
// src/hooks/useProfileCompletion.ts
export function useProfileCompletion(profile: Profile | null): number;
8. Missing Error Boundaries ⚠️
Problem: No error boundaries to catch component errors
Issues:
- If project data is malformed, entire dashboard crashes
- No graceful degradation
- User sees blank page instead of helpful error
Recommendation:
- Wrap sections in Error Boundaries
- Add try-catch for data processing
- Show fallback UI for missing data
9. Hardcoded Profile Category ⚠️
Location: Line 182
const profileCategory = PROFILE_CATEGORIES.individual;
Problem:
- Always shows "Individual" regardless of actual profile type
- Should read from
profile.categoryor similar - Could be misleading to users
10. No Loading States for Async Operations ⚠️
Location: Various
Issues:
projectLoadingis fetched but never used in render- No loading indicator while projects load
- No skeleton UI for better UX
- Analytics loading state unused
Recommendation:
{projectLoading ? (
<SkeletonLoader count={3} />
) : (
// Render projects
)}
11. Inefficient Re-renders ⚠️
Location: Multiple useEffects, computed values
Issues:
featuredProjectrecalculated on every render (line 175)fundingByCurrencyrecalculated on every render (line 148)- Should use
useMemofor expensive calculations
Recommendation:
const featuredProject = useMemo(() => {
// ... selection logic
}, [safeActiveProjects, safeProjects]);
const fundingByCurrency = useMemo(() => {
// ... calculation
}, [safeProjects]);
12. Route Inconsistency - ACTUAL BUG ⚠️
Location: Lines 285, 668
Problem:
- Dashboard uses
/project/${id}(singular) - Line 285, 668 - But actual route structure:
- Public route:
/projects/[id](plural) ✅ unified route - Old
/project/[id]: Redirects to/projects/[id]✅ backward compatibility
- Public route:
- VERIFIED: Both routes exist, but this is confusing!
Issues:
- Two different routes for same resource
- Users might get 404 if clicking from wrong context
- Codebase inconsistency (plural vs singular)
Root Cause:
- Public pages use
/projects/(plural) - Authenticated pages use
/project/(singular) - No route constants to standardize
Recommendation:
- Create route constants file
- Standardize to one pattern ✅ COMPLETED - All routes now use
/projects/[id](plural) - Update all references
🟢 DESIGN & UX ISSUES
13. Mixed Currency Display Confusion ⚠️
Location: Lines 508, 574
Problem: When projects have different currencies:
- "Total raised: 2,500.00 CHF" might exclude EUR/BTC projects
- User doesn't know if total is complete
- No indication that some projects excluded
Recommendation:
// Show currency breakdown
{Object.keys(fundingByCurrency).length > 1 && (
<div className="text-xs text-gray-500">
Mixed currencies: {Object.keys(fundingByCurrency).join(', ')}
</div>
)}
14. Empty State for "Recent Activity" ⚠️
Location: Lines 720-739
Problem:
- Shows "Activity tracking coming soon" with no action
- Takes up space but provides no value
- Should either: a) Hide when empty b) Show actual activity c) Remove entirely until feature ready
15. Button Accessibility ⚠️
Location: Multiple Button/Link components
Issues:
- Some buttons wrapped in Links (redundant)
- Missing aria-labels on icon-only buttons
- Keyboard navigation might be confusing
Example:
<Link href={`/project/${project.id}`}>
<Button variant="outline" size="sm">
<Eye className="w-4 h-4" /> // No aria-label
</Button>
</Link>
Fix:
<Button asChild variant="outline" size="sm" aria-label="View project">
<Link href={`/project/${project.id}`}>
<Eye className="w-4 h-4" />
</Link>
</Button>
16. Inconsistent Spacing and Layout ⚠️
Location: Throughout
Issues:
- Different padding values (
p-6,p-8,p-4) - Inconsistent gap sizes
- Some sections use
space-y-8, others usespace-y-6 - No consistent design system tokens
Recommendation:
- Use consistent spacing scale
- Create spacing constants
- Use Tailwind's spacing scale consistently
17. Featured Project Selection Logic ⚠️
Location: Lines 174-179
const featuredProject =
safeActiveProjects.length > 0
? safeActiveProjects.sort((a, b) => (b.total_funding || 0) - (a.total_funding || 0))[0]
: safeProjects.find(c => c.title?.toLowerCase().includes('orange cat')) || safeProjects[0];
Problems:
- Sorts array in place - mutates original array (bad practice)
- Hardcoded "orange cat" - magic string, not user-centric
- Falls back to first project - might be draft/inactive
- No user preference - user can't choose featured project
Recommendation:
const featuredProject = useMemo(() => {
// Sort copy, not original
const sorted = [...safeActiveProjects].sort(...);
// Or use user preference
// Or most recent active
return sorted[0] || null;
}, [safeActiveProjects]);
🎨 DESIGN IMPROVEMENTS
18. Visual Hierarchy ✅ Mostly Good
- Welcome section is prominent
- Featured project stands out
- Card grid is organized
Minor Improvements:
- Could add subtle animations on load
- Progress bars could be more prominent
- Empty states could be more engaging
19. Color Consistency ✅ Good
- Bitcoin orange used appropriately
- Status badges are clear
- Error states use red appropriately
20. Responsive Design ✅ Good
- Uses responsive grid classes
- Mobile-first approach visible
- Breakpoints are appropriate
Minor Issue:
- Some text could wrap better on mobile
- Button groups might overflow on small screens
📊 BEST PRACTICES ANALYSIS
✅ GOOD PRACTICES
- Error handling for auth state
- Loading states present
- Safe array checks before reduce
- TypeScript types used
- Modular component structure (uses Card, Button, etc.)
- Accessible HTML structure
- Responsive design
❌ NEEDS IMPROVEMENT
- Type system matches actual data
- Business logic extracted to utilities
- Large component split into smaller ones
- Memoization for expensive calculations
- Error boundaries added
- Loading states for async data
- Consistent route naming
- Accessibility labels on icons
- No empty useEffect hooks
🔧 SPECIFIC FIXES NEEDED
Priority 0 (Critical - Fix Immediately)
-
Fix Currency Type Definition
// src/types/funding.ts currency?: 'BTC' | 'SATS' | 'CHF' | 'USD' | 'EUR' | string; -
Explicit Currency in Project Store
// src/stores/projectStore.ts currency: project.currency || 'CHF', -
Remove Empty useEffect
// DELETE lines 48-51 -
Fix Featured Project Selection
const featuredProject = useMemo(() => { if (safeActiveProjects.length === 0) return null; const sorted = [...safeActiveProjects].sort( (a, b) => (b.total_funding || 0) - (a.total_funding || 0) ); return sorted[0]; }, [safeActiveProjects]);
Priority 1 (High - Fix Soon)
-
Extract Business Logic
- Create
src/utils/dashboard.tsfor calculations - Create
src/hooks/useProfileCompletion.ts
- Create
-
Add Memoization
- Wrap expensive calculations in
useMemo - Optimize re-renders
- Wrap expensive calculations in
-
Add Loading States
- Show skeleton while projects load
- Use
projectLoadingstate
-
Fix Route Consistency
- Verify all routes use same pattern
- Use route constants
Priority 2 (Medium - Nice to Have)
-
Component Extraction
- Split into smaller components
- Better separation of concerns
-
Error Boundaries
- Add React Error Boundaries
- Graceful error handling
-
Accessibility Improvements
- Add aria-labels
- Improve keyboard navigation
- Test with screen readers
-
Mixed Currency Display
- Show currency breakdown
- Or allow user to choose display currency
📈 PERFORMANCE CONSIDERATIONS
Current Issues:
- No memoization - Recalculates on every render
- Array mutations -
.sort()mutates original - Multiple useEffects - Could be consolidated
- Large component - Re-renders entire tree on state change
Recommendations:
- Use
useMemofor derived state - Use
useCallbackfor event handlers - Lazy load heavy sections
- Virtualize long lists if needed
🧪 TESTING SCENARIOS
Critical Test Cases:
-
Type Safety
- Project with CHF currency doesn't cause TypeScript errors
- Currency display works for all supported currencies
-
Empty States
- No projects shows appropriate empty state
- No drafts shows no draft section
- No profile shows profile completion prompt
-
Mixed Currencies
- Projects with CHF + BTC show correctly
- Total calculation doesn't mix currencies incorrectly
-
Error Handling
- Failed project load shows error state
- Malformed project data doesn't crash dashboard
-
Loading States
- Projects loading shows loading indicator
- Analytics loading doesn't block UI
🎯 RECOMMENDED REFACTORING PLAN
Phase 1: Critical Fixes (Do First)
- ✅ Fix currency type definition
- ✅ Fix project store currency mapping
- ✅ Remove empty useEffect
- ✅ Fix featured project selection
- ✅ Add memoization for calculations
Phase 2: Code Quality (Do Next)
- ✅ Extract business logic to utilities
- ✅ Add loading states
- ✅ Fix route consistency
- ✅ Add error boundaries
Phase 3: Architecture (Do Later)
- ✅ Split large component
- ✅ Create custom hooks
- ✅ Add comprehensive tests
📝 SUMMARY
Issues Found:
- 4 Critical Errors (Type mismatch, missing fields, empty hooks, logic bugs)
- 8 Engineering Issues (Large component, logic in component, no memoization, etc.)
- 7 Design/UX Issues (Mixed currencies, empty states, accessibility, etc.)
- 3 Performance Issues (No memoization, array mutations, re-renders)
Total: 22 Issues Identified
Priority Breakdown:
- P0 (Critical): 4 issues - Fix immediately
- P1 (High): 8 issues - Fix soon
- P2 (Medium): 10 issues - Fix when time allows
✅ STRENGTHS TO MAINTAIN
- Good Error Handling - Auth errors handled well
- Safe Array Operations - Prevents runtime errors
- Responsive Design - Works on mobile
- Visual Design - Modern, clean, professional
- Loading States - Basic loading handled
- TypeScript Usage - Types used throughout
🚀 NEXT STEPS
Immediate Actions:
- Fix currency type definition (5 minutes)
- Add explicit currency to project store (2 minutes)
- Remove empty useEffect (1 minute)
- Fix featured project selection with useMemo (5 minutes)
Short-term (This Week): 5. Extract business logic (2-3 hours) 6. Add loading states (1-2 hours) 7. Add memoization (1 hour)
Long-term (This Sprint): 8. Component extraction (4-6 hours) 9. Error boundaries (2-3 hours) 10. Comprehensive testing (4-6 hours)
📚 REFERENCES
- React Best Practices: https://react.dev/learn
- TypeScript Best Practices: Type-safe code
- Accessibility Guidelines: WCAG 2.1
- Performance: React Performance Optimization