Files
ColaFlow-Web/components/ui/empty-state.tsx
Yaojia Wang 99ba4c4b1a feat(frontend): improve error handling and UX - Sprint 3 Story 4
Add comprehensive error handling with Error Boundary and improve user feedback.

Changes:
- Created global ErrorBoundary component with fallback UI using react-error-boundary
- Integrated ErrorBoundary in root layout to catch all errors
- Created Loading component with variants (sm, md, lg) for consistent loading states
- Created EmptyState component for better empty data display with CTAs
- Improved form error messages in login and register pages (consistent destructive styling)
- Updated projects page to use EmptyState component
- Added better error handling with retry actions

UX improvements:
- Better error messages and recovery options with clear action buttons
- Consistent loading indicators across all pages
- Helpful empty states with clear descriptions and CTAs
- Graceful error handling without crashes
- Consistent destructive color theme for all error messages

Technical:
- Installed react-error-boundary package (v5)
- All TypeScript types are properly defined
- Build and type checking pass successfully

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 20:04:00 +01:00

45 lines
1015 B
TypeScript

import { LucideIcon } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils';
interface EmptyStateProps {
icon: LucideIcon;
title: string;
description: string;
action?: {
label: string;
onClick: () => void;
variant?: 'default' | 'outline' | 'secondary';
};
className?: string;
}
export function EmptyState({
icon: Icon,
title,
description,
action,
className
}: EmptyStateProps) {
return (
<div className={cn(
'flex flex-col items-center justify-center py-12 px-4',
className
)}>
<Icon className="h-16 w-16 text-muted-foreground/50 mb-4" />
<h3 className="text-lg font-semibold mb-2">{title}</h3>
<p className="text-muted-foreground text-center mb-6 max-w-sm">
{description}
</p>
{action && (
<Button
onClick={action.onClick}
variant={action.variant || 'default'}
>
{action.label}
</Button>
)}
</div>
);
}