diff --git a/frontend/src/pages/AdminPromptsPage.jsx b/frontend/src/pages/AdminPromptsPage.jsx index 66b7edf..f364c1b 100644 --- a/frontend/src/pages/AdminPromptsPage.jsx +++ b/frontend/src/pages/AdminPromptsPage.jsx @@ -21,6 +21,7 @@ export default function AdminPromptsPage() { const [showNewPrompt, setShowNewPrompt] = useState(false) const [importing, setImporting] = useState(false) const [importResult, setImportResult] = useState(null) + const [importDialogData, setImportDialogData] = useState(null) // {count, fileData, event} const categories = [ { id: 'all', label: 'Alle Kategorien' }, @@ -194,7 +195,6 @@ export default function AdminPromptsPage() { const file = event.target.files[0] if (!file) return - setImporting(true) setError(null) setImportResult(null) @@ -202,28 +202,34 @@ export default function AdminPromptsPage() { const text = await file.text() const data = JSON.parse(text) - // Two-step confirmation for clarity - // Step 1: Confirm import - const shouldImport = confirm( - `${data.count || 0} Prompts importieren?\n\n` + - 'OK = Fortfahren\n' + - 'Abbrechen = Import abbrechen' - ) + // Show custom 3-button dialog + setImportDialogData({ + count: data.count || 0, + fileData: data, + event: event + }) + } catch (e) { + setError('Import-Fehler: ' + e.message) + event.target.value = '' // Reset file input + } + } - if (!shouldImport) { - setImporting(false) - event.target.value = '' - return - } + const handleImportChoice = async (choice) => { + if (!importDialogData) return - // Step 2: Ask about overwrite - const overwrite = confirm( - 'Existierende Prompts überschreiben?\n\n' + - 'OK = Ja, bestehende Prompts aktualisieren\n' + - 'Abbrechen = Nein, nur neue Prompts erstellen' - ) + const { fileData, event } = importDialogData + setImportDialogData(null) // Close dialog - const result = await api.importPrompts(data, overwrite) + if (choice === 'cancel') { + event.target.value = '' // Reset file input + return + } + + setImporting(true) + + try { + const overwrite = choice === 'yes' // 'yes' = overwrite, 'no' = skip existing + const result = await api.importPrompts(fileData, overwrite) setImportResult(result) await loadPrompts() } catch (e) { @@ -621,6 +627,70 @@ export default function AdminPromptsPage() { }} /> )} + + {/* Import Dialog - 3 Button Choice */} + {importDialogData && ( +
+
+

+ {importDialogData.count} Prompts importieren? +

+

+ Wie sollen existierende Prompts behandelt werden? +

+ +
+ + + + + +
+
+
+ )} ) }