import { useTranslation } from 'react-i18next'; import { Modal } from '@/components/ui/Modal'; import { Button } from '@/components/ui/Button'; import { LoadingSpinner } from '@/components/ui/LoadingSpinner'; import { Input } from '@/components/ui/Input'; import type { PrefixProxyEditorField, PrefixProxyEditorFieldValue, PrefixProxyEditorState, } from '@/features/authFiles/hooks/useAuthFilesPrefixProxyEditor'; import styles from '@/pages/AuthFilesPage.module.scss'; export type AuthFilesPrefixProxyEditorModalProps = { disableControls: boolean; editor: PrefixProxyEditorState | null; updatedText: string; dirty: boolean; onClose: () => void; onCopyText: (text: string) => void | Promise; onSave: () => void; onChange: (field: PrefixProxyEditorField, value: PrefixProxyEditorFieldValue) => void; }; export function AuthFilesPrefixProxyEditorModal(props: AuthFilesPrefixProxyEditorModalProps) { const { t } = useTranslation(); const { disableControls, editor, updatedText, dirty, onClose, onCopyText, onSave, onChange } = props; const formatJsonText = (text: string) => { if (!text) return ''; try { return JSON.stringify(JSON.parse(text), null, 2); } catch { return text; } }; const previewText = formatJsonText(updatedText); const invalidContentPreview = editor?.invalidContentPreview ?? ''; return ( } > {editor && (
{editor.loading ? (
{t('auth_files.prefix_proxy_loading')}
) : ( <> {editor.error &&
{editor.error}
}