'use client'

import type { BackupFile } from '../page'
import type {
  BackupStatusEnvelope,
  ResticSnapshot,
  ResticStats,
} from '../_lib/types'
import DatabaseBackupsSection from './database-backups-section'
import ServerBackupSection from './server-backup-section'

type Props = {
  backups: BackupFile[]
  listError: string | null
  envelope: BackupStatusEnvelope
  nasSnapshots: ResticSnapshot[]
  b2Snapshots: ResticSnapshot[]
  nasStats: ResticStats | null
  b2Stats: ResticStats | null
  serverBackupErrors: {
    status?: string
    nasSnapshots?: string
    b2Snapshots?: string
    nasStats?: string
    b2Stats?: string
  }
}

export default function BackupsPanel({
  backups,
  listError,
  envelope,
  nasSnapshots,
  b2Snapshots,
  nasStats,
  b2Stats,
  serverBackupErrors,
}: Props) {
  return (
    <div className="space-y-12">
      <DatabaseBackupsSection backups={backups} listError={listError} />
      <div className="h-px bg-border" />
      <ServerBackupSection
        envelope={envelope}
        nasSnapshots={nasSnapshots}
        b2Snapshots={b2Snapshots}
        nasStats={nasStats}
        b2Stats={b2Stats}
        errors={serverBackupErrors}
      />
    </div>
  )
}
