import { useState } from 'react' interface HostPreview { domain_names: string [key: string]: unknown } interface Props { hosts: HostPreview[] conflicts: string[] errors: string[] caddyfileContent?: string onCommit: (resolutions: Record) => Promise onCancel: () => void } export default function ImportReviewTable({ hosts, conflicts, errors, caddyfileContent, onCommit, onCancel }: Props) { const [resolutions, setResolutions] = useState>(() => { const init: Record = {} conflicts.forEach((d: string) => { init[d] = 'keep' }) return init }) const [submitting, setSubmitting] = useState(false) const [error, setError] = useState(null) const [showSource, setShowSource] = useState(false) const handleCommit = async () => { setSubmitting(true) setError(null) try { await onCommit(resolutions) } catch (err) { setError(err instanceof Error ? err.message : 'Failed to commit import') } finally { setSubmitting(false) } } return (
{caddyfileContent && (
setShowSource(!showSource)}>

Source Caddyfile Content

{showSource ? 'Hide' : 'Show'}
{showSource && (
{caddyfileContent}
)}
)}

Review Imported Hosts

{error && (
{error}
)} {errors?.length > 0 && (
Issues found during parsing
    {errors.map((e, i) => (
  • {e}
  • ))}
)}
{hosts.map((h, idx) => { const domain = h.domain_names const hasConflict = conflicts.includes(domain) return ( ) })}
Domain Names Conflict Resolution
{domain}
{hasConflict ? ( ) : ( No conflict )}
) }