'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { routes } from '@/lib/routing/RouteConfig';
import { ErrorScreen } from '@/components/errors/ErrorScreen';

export default function ErrorPage({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  const router = useRouter();

  useEffect(() => {
    // Log the error to an error reporting service
    console.error('Route Error Boundary:', error);
  }, [error]);

  return (
    <ErrorScreen
      error={error}
      reset={reset}
      onHome={() => router.push(routes.public.home)}
    />
  );
}
