'use client';

import { useEffect } from 'react';

export default function AdminError({
  error,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    const key = 'gcx_admin_reload_count';
    const count = parseInt(sessionStorage.getItem(key) ?? '0', 10);
    if (count < 3) {
      sessionStorage.setItem(key, String(count + 1));
      window.location.reload();
    }
  }, [error]);

  return null;
}
