import { useEffect, useState } from 'react' import StyledModal from './StyledModal' import api from '~/lib/api' interface ServiceLogsModalProps { serviceName: string friendlyName: string open: boolean onClose: () => void } /** Shows the tail of a service container's logs with a manual refresh. */ export default function ServiceLogsModal({ serviceName, friendlyName, open, onClose, }: ServiceLogsModalProps) { const [logs, setLogs] = useState('') const [loading, setLoading] = useState(false) async function load() { setLoading(true) const res = await api.getServiceLogs(serviceName, 500) setLogs(res?.success ? res.logs || '' : 'Unable to load logs for this container.') setLoading(false) } useEffect(() => { if (open) load() // eslint-disable-next-line react-hooks/exhaustive-deps }, [open, serviceName]) return (
        {logs || (loading ? 'Loading…' : 'No log output.')}
      
) }