import { useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Pencil, Trash2 } from 'lucide-react'; import { environments } from '../api'; import type { Environment } from '../api'; import { Breadcrumbs, Button, Card, DescriptionList, Timestamp } from '../ui'; import styles from './Page.module.css'; export function EnvironmentDetailPage() { const { t } = useTranslation(); const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); const [env, setEnv] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!id) return; environments .get(Number(id)) .then(setEnv) .catch((err: Error) => setError(err.message)) .finally(() => setLoading(false)); }, [id]); const handleDelete = async () => { if (!env) return; await environments.remove(env.id); navigate('/environments'); }; return (
navigate('/environments') }, { label: env?.name ?? `#${id}` }, ]} /> {env && (
)}
{error &&

{error}

} {loading &&

{t('environments.loading')}

} {env && ( <>
, }, { term: t('environments.field_updated'), detail: , }, ]} />

{t('environments.section_urls')}

{Object.entries(env.urls).filter(([, v]) => v).length === 0 ? (

{t('environments.no_urls')}

) : ( v) .map(([key, value]) => ({ term: key, detail: ( {value} ), }))} /> )}
)}
); }