'use client';

import { FoxButton } from '@fox/core/components/fox-button';
import styles from './page-error.module.scss';

interface PageErrorProps {
  onRetry: () => void;
}

/**
 * 라우트 세그먼트 오류 폴백. 화면 다섯 곳의 `error.tsx`가 같은 모양이라 여기 한 번만 둔다
 * (PageLoading과 같은 이유).
 *
 * 원본 메시지·스택은 여기서 받지 않는다 — 진단용 기록은 호출부(`error.tsx`)가 콘솔에만 남기고,
 * 화면에는 일반화된 문구와 재시도만 낸다.
 */
export function PageError({ onRetry }: PageErrorProps) {
  return (
    <section className={styles.root}>
      <h1 className={styles.title}>문제가 발생했습니다.</h1>
      <p className={styles.description}>잠시 후 다시 시도해 주세요.</p>
      <FoxButton
        type="primary"
        size="md"
        label="다시 시도"
        onAction={onRetry}
        className={styles.action}
      />
    </section>
  );
}
