import { useState } from 'react'; import axios from '../services/api'; function JsonFormatterTool() { const [input, setInput] = useState(''); const [indent, setIndent] = useState(2); const [result, setResult] = useState(''); const [error, setError] = useState(''); const [copied, setCopied] = useState(false); const format = async () => { setError(''); setResult(''); try { const res = await axios.post('/api/json/format', { text: input, indent }); setResult(res.data.result); } catch (err) { setError(err.response?.data?.message || 'Ungültiges JSON'); } }; const copy = () => { navigator.clipboard.writeText(result); setCopied(true); setTimeout(() => setCopied(false), 1500); }; return (