'use client';

import { useEffect } from 'react';
import { useTranslations } from 'next-intl';
import * as Sentry from '@sentry/nextjs';
import { Button } from '@/components/ui/shared/Button';

export default function LocaleError({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  const t = useTranslations('common');

  useEffect(() => {
    Sentry.captureException(error);
  }, [error]);

  return (
    <div className="flex min-h-[50vh] flex-col items-center justify-center gap-4 px-4 text-center">
      <h1 className="text-lg font-semibold">{t('pageErrorTitle')}</h1>
      <p className="max-w-md text-sm text-text-secondary">{t('pageErrorBody')}</p>
      <Button type="button" onClick={() => reset()}>
        {t('tryAgain')}
      </Button>
    </div>
  );
}
