import { useState } from 'react' import { uploadCaddyfilesMulti } from '../api/import' type Props = { visible: boolean onClose: () => void onUploaded?: () => void } export default function ImportSitesModal({ visible, onClose, onUploaded }: Props) { const [sites, setSites] = useState(['']) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) if (!visible) return null const setSite = (index: number, value: string) => { const s = [...sites] s[index] = value setSites(s) } const addSite = () => setSites(prev => [...prev, '']) const removeSite = (index: number) => setSites(prev => prev.filter((_, i) => i !== index)) const handleSubmit = async () => { setError(null) setLoading(true) try { const cleaned = sites.map(s => s || '') await uploadCaddyfilesMulti(cleaned) setLoading(false) onUploaded && onUploaded() onClose() } catch (err: any) { setError(err?.message || 'Upload failed') setLoading(false) } } return (

Multi-site Import

Add each site's Caddyfile content separately, then parse them together.

{sites.map((s, idx) => (
Site {idx + 1}
{sites.length > 1 && ( )}