import { useState } from 'react'; import { api } from '@/pages/investment/shared'; export type ParkInstallationPlan = { installed: boolean; ready: boolean; hash: string; migration: string; reasons: string[]; target: { database: string; port: number }; }; export default function InvestmentZoneInstallation({ initial, endpoint = '/management/investment/zones/profile-install', title = 'Preparação privada da ficha de parques', summary = 'Uma coluna privada; sem importação ou publicação de dados.', }: { initial: ParkInstallationPlan; endpoint?: string; title?: string; summary?: string; }) { const [plan, setPlan] = useState(initial); const [busy, setBusy] = useState(false); const [message, setMessage] = useState(''); async function refresh() { const response = await fetch(endpoint, { headers: { Accept: 'application/json' }, }); if (!response.ok) throw new Error( 'Não foi possível carregar a prévia da instalação.', ); const value = await response.json(); setPlan(value.plan); return value.plan as ParkInstallationPlan; } return (

{title}

{plan.installed ? 'Esquema instalado. Não importa nem publica fichas.' : summary}

Alvo: {plan.target.database}:{plan.target.port} ·{' '} {plan.migration}

{plan.reasons.map((reason) => (

{reason}

))} {message &&

{message}

}
); }