import { useState } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from './ui/dialog'; import { Button } from './ui/button'; import { Badge } from './ui/badge'; import { Loader2, AlertCircle, Clock, HardDrive } from 'lucide-react'; interface Backup { id: string; timestamp: string; size?: string; } interface BackupRestoreModalProps { isOpen: boolean; onClose: () => void; mode: 'backup' | 'restore'; appName: string; backups?: Backup[]; isLoading?: boolean; onConfirm: (backupId?: string) => void; isPending?: boolean; } export function BackupRestoreModal({ isOpen, onClose, mode, appName, backups = [], isLoading = false, onConfirm, isPending = false, }: BackupRestoreModalProps) { const [selectedBackupId, setSelectedBackupId] = useState(null); const handleConfirm = () => { if (mode === 'backup') { onConfirm(); } else if (mode === 'restore' && selectedBackupId) { onConfirm(selectedBackupId); } onClose(); }; const formatTimestamp = (timestamp: string) => { try { return new Date(timestamp).toLocaleString(); } catch { return timestamp; } }; return ( {mode === 'backup' ? 'Create Backup' : 'Restore from Backup'} {mode === 'backup' ? `Create a backup of the ${appName} application data.` : `Select a backup to restore for the ${appName} application.`}
{mode === 'backup' ? (

This will create a new backup of the current application state. The backup process may take a few minutes depending on the size of the data.

) : (
{isLoading ? (
) : backups.length === 0 ? (

No backups available for this application.

) : (
{backups.map((backup) => ( ))}
)}
)}
); }