veza/apps/web/src/features/error/pages/ServerErrorPage.tsx

141 lines
5.1 KiB
TypeScript
Raw Normal View History

import { useNavigate } from 'react-router-dom';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import {
Home,
RefreshCw,
AlertTriangle,
Mail,
Clock,
CheckCircle,
} from 'lucide-react';
import { useState } from 'react';
/**
* FE-PAGE-018: Improved 500 error page with helpful messages and recovery actions
*/
function ServerErrorPage() {
const navigate = useNavigate();
const [isRetrying, setIsRetrying] = useState(false);
const handleRefresh = async () => {
setIsRetrying(true);
// Wait a bit before reloading to show feedback
setTimeout(() => {
window.location.reload();
}, 500);
};
const handleGoHome = () => {
navigate('/dashboard');
};
return (
<div className="min-h-screen flex items-center justify-center bg-background p-4">
<div className="w-full max-w-2xl">
<Card className="text-center">
<CardHeader>
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-destructive/10">
<AlertTriangle className="h-8 w-8 text-destructive dark:text-destructive" />
</div>
<CardTitle className="text-2xl">Erreur serveur</CardTitle>
<CardDescription>
Une erreur interne s'est produite. Notre équipe a é notifiée.
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
<div className="text-6xl font-bold text-foreground">
500
</div>
<p className="text-muted-foreground dark:text-muted-foreground">
Nous nous excusons pour la gêne occasionnée. Notre équipe
technique a é automatiquement notifiée et travaille à résoudre
le problème.
</p>
{/* Status Info */}
fix: stabilize builds, tests, and lint across all stacks Complete stabilization pass bringing all 3 stacks to green: Frontend (apps/web/): - Fix TypeScript nullability in useSeason.ts, useTimeOfDay.ts hooks - Disable no-undef in ESLint config (TypeScript handles it; JSX misidentified) - Rename 306 story imports from @storybook/react to @storybook/react-vite - Fix conditional hook call in useMediaQuery.ts useIsTablet - Move useQuery to top of LoginPage.tsx component - Remove useless try/catch in GearFormModal.tsx - Fix stale closure in ResetPasswordPage.tsx handleChange - Make Storybook decorators (withRouter, withQueryClient, withToast, withAudio) no-ops since global StorybookDecorator already provides these — prevents nested Router / duplicate provider crashes in vitest-browser - Fix nested MemoryRouter in 3 page stories (TrackDetail, PlaylistDetail, UserProfile) - Update i18n initialization in test setup (await init before changeLanguage) - Update ~30 test assertions from English to French to match i18n translations - Update test assertions to match SUMI V3 design changes (shadow vs border) - Fix remaining story type errors (PlayerError, PlaylistBatchActions, TrackFilters, VirtualizedChatMessages) Backend (veza-backend-api/): - Fix response_test.go RespondWithAppError signature (2 args, not 3) - Fix TestErrorContractAuthEndpoints expected error codes (ErrCodeUnauthorized vs ErrCodeInvalidCredentials) - Fix TestTrackHandler_GetTrackLikes_Success missing auth middleware setup - Fix TestPlaybackAnalyticsService_GetTrackStats k-anonymity threshold (needs 5 unique users, not 1) - Replace NOW() PostgreSQL function with time.Now() parameter in marketplace service for SQLite test compatibility - Add missing AutoMigrate entries in marketplace_test.go (ProductImage, ProductPreview, ProductLicense, ProductReview) Results: - Frontend TypeCheck: 617 errors -> 0 errors - Frontend ESLint: 349 errors -> 0 errors - Frontend Vitest: 196 failing tests -> 1 skipped (3396/3397 passing) - Backend go vet: 1 error -> 0 errors - Backend tests: 5 failing -> all 13 packages passing - Rust: 150/150 tests passing (unchanged) - Storybook audit: 0 errors across 1244 stories Triage report: docs/TRIAGE_REPORT.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 14:48:07 +00:00
<div className="bg-muted/50 shadow-[0_0_8px_rgba(26,26,30,0.05)] rounded-lg p-4">
<div className="flex items-start gap-4 text-left">
<Clock className="h-5 w-5 text-muted-foreground mt-0.5" />
<div>
<p className="text-sm font-medium text-muted-foreground">
Que faire maintenant ?
</p>
<ul className="text-sm text-muted-foreground mt-2 space-y-1 list-disc list-inside">
<li>Attendez quelques instants et réessayez</li>
<li>Vérifiez votre connexion internet</li>
<li>Si le problème persiste, contactez le support</li>
</ul>
</div>
</div>
</div>
{/* Actions */}
<div className="flex flex-col sm:flex-row gap-2">
<Button
onClick={handleRefresh}
disabled={isRetrying}
className="flex-1"
>
<RefreshCw
className={`mr-2 h-4 w-4 ${isRetrying ? 'animate-spin' : ''}`}
/>
{isRetrying ? 'Réessai...' : 'Réessayer'}
</Button>
<Button
onClick={handleGoHome}
variant="outline"
className="flex-1"
>
2025-12-13 02:34:34 +00:00
<Home className="mr-2 h-4 w-4" />
Retour au dashboard
</Button>
</div>
{/* Help Section */}
<div className="border-t pt-4 text-left">
<p className="text-sm font-medium text-foreground mb-3">
Besoin d'aide ?
</p>
<div className="space-y-2">
<div className="flex items-center gap-2 text-sm text-muted-foreground dark:text-muted-foreground">
<CheckCircle className="h-4 w-4 text-success" />
<span>
L'erreur a é automatiquement signalée à notre équipe
</span>
</div>
<div className="flex items-center gap-2 text-sm text-muted-foreground dark:text-muted-foreground">
<Mail className="h-4 w-4 text-muted-foreground" />
<span>
Contactez le support si le problème persiste après plusieurs
tentatives
</span>
</div>
</div>
</div>
{/* Technical Details (Collapsible) */}
<details className="border-t pt-4 text-left">
<summary className="text-sm font-medium text-foreground cursor-pointer hover:text-foreground dark:hover:text-foreground">
Détails techniques
</summary>
<div className="mt-2 p-4 bg-muted rounded text-xs font-mono text-muted-foreground dark:text-muted-foreground">
<p>Code d'erreur: 500 Internal Server Error</p>
<p>Timestamp: {new Date().toISOString()}</p>
<p>User Agent: {navigator.userAgent}</p>
</div>
</details>
</CardContent>
</Card>
</div>
</div>
);
}
export default ServerErrorPage;