import BackupSettingsPageClient from '@/components/settings/BackupSettingsPageClient';
import { backupService } from '@/services/data-management/backup';
import { backupScheduler } from '@/services/data-management/backup-scheduler';

// Force dynamic rendering pour les données en temps réel
export const dynamic = 'force-dynamic';

export default async function BackupSettingsPage() {
  // Fetch data server-side
  const backups = await backupService.listBackups();
  const schedulerStatus = backupScheduler.getStatus();
  const config = await backupService.getConfig();
  const backupStats = await backupService.getBackupStats(30);

  const initialData = {
    backups,
    scheduler: {
      ...schedulerStatus,
      nextBackup: schedulerStatus.nextBackup
        ? schedulerStatus.nextBackup.toISOString()
        : null,
    },
    config,
    backupStats,
  };

  return <BackupSettingsPageClient initialData={initialData} />;
}
