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>
This commit is contained in:
@@ -56,9 +56,9 @@ function LoginContent() {
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<div className="rounded bg-red-50 p-3 text-sm text-red-600">
|
||||
<div className="rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm text-destructive">
|
||||
{(error as { response?: { data?: { message?: string } } })
|
||||
?.response?.data?.message || 'Login failed. Please try again.'}
|
||||
?.response?.data?.message || 'Login failed. Please check your credentials and try again.'}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -72,7 +72,7 @@ function LoginContent() {
|
||||
placeholder="your-company"
|
||||
/>
|
||||
{errors.tenantSlug && (
|
||||
<p className="mt-1 text-sm text-red-600">{errors.tenantSlug.message}</p>
|
||||
<p className="mt-1 text-sm text-destructive">{errors.tenantSlug.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -86,7 +86,7 @@ function LoginContent() {
|
||||
placeholder="you@example.com"
|
||||
/>
|
||||
{errors.email && (
|
||||
<p className="mt-1 text-sm text-red-600">{errors.email.message}</p>
|
||||
<p className="mt-1 text-sm text-destructive">{errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -100,7 +100,7 @@ function LoginContent() {
|
||||
placeholder="••••••••"
|
||||
/>
|
||||
{errors.password && (
|
||||
<p className="mt-1 text-sm text-red-600">
|
||||
<p className="mt-1 text-sm text-destructive">
|
||||
{errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -54,10 +54,10 @@ export default function RegisterPage() {
|
||||
className="mt-8 space-y-6 rounded-lg bg-white p-8 shadow"
|
||||
>
|
||||
{error && (
|
||||
<div className="rounded bg-red-50 p-3 text-sm text-red-600">
|
||||
<div className="rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm text-destructive">
|
||||
{(error as { response?: { data?: { message?: string } } })
|
||||
?.response?.data?.message ||
|
||||
'Registration failed. Please try again.'}
|
||||
'Registration failed. Please check your information and try again.'}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -71,7 +71,7 @@ export default function RegisterPage() {
|
||||
placeholder="John Doe"
|
||||
/>
|
||||
{errors.fullName && (
|
||||
<p className="mt-1 text-sm text-red-600">
|
||||
<p className="mt-1 text-sm text-destructive">
|
||||
{errors.fullName.message}
|
||||
</p>
|
||||
)}
|
||||
@@ -87,7 +87,7 @@ export default function RegisterPage() {
|
||||
placeholder="you@example.com"
|
||||
/>
|
||||
{errors.email && (
|
||||
<p className="mt-1 text-sm text-red-600">{errors.email.message}</p>
|
||||
<p className="mt-1 text-sm text-destructive">{errors.email.message}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -101,7 +101,7 @@ export default function RegisterPage() {
|
||||
placeholder="••••••••"
|
||||
/>
|
||||
{errors.password && (
|
||||
<p className="mt-1 text-sm text-red-600">
|
||||
<p className="mt-1 text-sm text-destructive">
|
||||
{errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
@@ -120,7 +120,7 @@ export default function RegisterPage() {
|
||||
placeholder="Acme Inc."
|
||||
/>
|
||||
{errors.tenantName && (
|
||||
<p className="mt-1 text-sm text-red-600">
|
||||
<p className="mt-1 text-sm text-destructive">
|
||||
{errors.tenantName.message}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
import { useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Plus, FolderKanban, Calendar } from 'lucide-react';
|
||||
import { Plus, FolderKanban, Calendar, AlertCircle } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import {
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import { useProjects } from '@/lib/hooks/use-projects';
|
||||
import { ProjectForm } from '@/components/projects/project-form';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { EmptyState } from '@/components/ui/empty-state';
|
||||
|
||||
export default function ProjectsPage() {
|
||||
const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);
|
||||
@@ -52,19 +53,15 @@ export default function ProjectsPage() {
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-destructive">Error Loading Projects</CardTitle>
|
||||
<CardDescription>
|
||||
{error instanceof Error ? error.message : 'Failed to load projects'}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button onClick={() => window.location.reload()}>Retry</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
<EmptyState
|
||||
icon={AlertCircle}
|
||||
title="Failed to load projects"
|
||||
description={error instanceof Error ? error.message : 'An error occurred while loading projects. Please try again.'}
|
||||
action={{
|
||||
label: 'Retry',
|
||||
onClick: () => window.location.reload(),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,17 +118,15 @@ export default function ProjectsPage() {
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Card className="flex flex-col items-center justify-center py-16">
|
||||
<FolderKanban className="h-12 w-12 text-muted-foreground mb-4" />
|
||||
<CardTitle className="mb-2">No projects yet</CardTitle>
|
||||
<CardDescription className="mb-4">
|
||||
Get started by creating your first project
|
||||
</CardDescription>
|
||||
<Button onClick={() => setIsCreateDialogOpen(true)}>
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Create Project
|
||||
</Button>
|
||||
</Card>
|
||||
<EmptyState
|
||||
icon={FolderKanban}
|
||||
title="No projects yet"
|
||||
description="Get started by creating your first project to organize your work and track progress."
|
||||
action={{
|
||||
label: 'Create Project',
|
||||
onClick: () => setIsCreateDialogOpen(true),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Create Project Dialog */}
|
||||
|
||||
@@ -4,6 +4,7 @@ import "./globals.css";
|
||||
import { QueryProvider } from "@/lib/providers/query-provider";
|
||||
import { SignalRProvider } from "@/lib/signalr/SignalRContext";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import { ErrorBoundary } from "@/components/ErrorBoundary";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -30,12 +31,14 @@ export default function RootLayout({
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
<QueryProvider>
|
||||
<SignalRProvider>
|
||||
{children}
|
||||
<Toaster position="top-right" />
|
||||
</SignalRProvider>
|
||||
</QueryProvider>
|
||||
<ErrorBoundary>
|
||||
<QueryProvider>
|
||||
<SignalRProvider>
|
||||
{children}
|
||||
<Toaster position="top-right" />
|
||||
</SignalRProvider>
|
||||
</QueryProvider>
|
||||
</ErrorBoundary>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user