'use client'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { Icons } from '@/components/icons'; import { useRouter } from 'next/navigation'; import { useEffect, useTransition } from 'react'; import * as Sentry from '@sentry/nextjs'; interface StatsErrorProps { error: Error; reset: () => void; // Add reset function from error boundary } export default function StatsError({ error, reset }: StatsErrorProps) { const router = useRouter(); const [isPending, startTransition] = useTransition(); useEffect(() => { Sentry.captureException(error); }, [error]); // the reload fn ensures the refresh is deffered until the next render phase allowing react to handle any pending states before processing const reload = () => { startTransition(() => { router.refresh(); reset(); }); }; return (
Error Failed to load statistics: {error.message}

Unable to display statistics at this time

); }