// Error boundary scoped to the /admin subtree. A render error (or a loader
// rejection that ISN'T a RedirectError / NotFoundError) bubbles to here instead
// of the router default. `reset` re-runs the failed segment.
import type { ReactNode } from 'react'
import type { ErrorBoundaryProps } from '@voltro/web'
import { T } from '@voltro/i18n'

export default function AdminError({ error, reset }: ErrorBoundaryProps): ReactNode {
  return (
    <div className="admin">
      <main>
        <h1><T id="error.heading" /></h1>
        <p className="muted">{String(error)}</p>
        <p style={{ marginTop: '1rem' }}>
          <button type="button" className="btn" onClick={reset}><T id="error.retry" /></button>
        </p>
      </main>
    </div>
  )
}
