"use client" import { FormError } from "@/components/forms/error" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" import { useDownload } from "@/hooks/use-download" import { useProgress } from "@/hooks/use-progress" import { Download, Loader2 } from "lucide-react" import { useActionState } from "react" import { restoreBackupAction } from "./actions" export default function BackupSettingsPage() { const [restoreState, restoreBackup, restorePending] = useActionState(restoreBackupAction, null) const { isLoading, startProgress, progress } = useProgress({ onError: (error) => { console.error("Backup progress error:", error) }, }) const { download, isDownloading } = useDownload({ onError: (error) => { console.error("Download error:", error) }, }) const handleDownload = async () => { try { const progressId = await startProgress("backup") const downloadUrl = `/settings/backups/data?progressId=${progressId || ""}` await download(downloadUrl, "taxhacker-backup.zip") } catch (error) { console.error("Failed to start backup:", error) } } return (
⚠️ This action is irreversible. Restoring from a backup will delete all existing data from your current database and remove all uploaded files. Be careful and make a backup first!
{restoreState?.error &&You can now continue using the app. Import stats: