fix(settings): восстанавливать базу транзакционно и сохранять результат операции
This commit is contained in:
1 parent
ff8b04bddf
commit
af5dbb0519
12 files changed
+86
-40
No files matched your search
@@ -22,6 +22,8 @@ interface FileImportDialogProps {
|
||||
description?: string
|
||||
accept?: string
|
||||
multiple?: boolean
|
||||
successMessage?: string | null
|
||||
actionLabel?: string
|
||||
onImport: (files: File[]) => void | Promise<void>
|
||||
}
|
||||
|
||||
@@ -33,6 +35,8 @@ function FileImportDialog({
|
||||
accept = "*",
|
||||
multiple = false,
|
||||
onImport,
|
||||
successMessage = "Импорт выполнен",
|
||||
actionLabel = "Импортировать",
|
||||
}: FileImportDialogProps) {
|
||||
const [importing, setImporting] = useState(false)
|
||||
|
||||
@@ -58,13 +62,13 @@ function FileImportDialog({
|
||||
await onImport(rawFiles)
|
||||
actions.clearFiles()
|
||||
onOpenChange(false)
|
||||
toast.success("Импорт выполнен")
|
||||
if (successMessage) toast.success(successMessage)
|
||||
} catch (err) {
|
||||
toast.error(err instanceof Error ? err.message : "Ошибка импорта")
|
||||
} finally {
|
||||
setImporting(false)
|
||||
}
|
||||
}, [actions, files, onImport, onOpenChange])
|
||||
}, [actions, files, onImport, onOpenChange, successMessage])
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
@@ -109,7 +113,7 @@ function FileImportDialog({
|
||||
Отмена
|
||||
</Button>
|
||||
<Button type="button" onClick={handleImport} disabled={importing || files.length === 0}>
|
||||
{importing ? "Импорт…" : "Импортировать"}
|
||||
{importing ? "Импорт…" : actionLabel}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
Reference in new issue
Block a user