import { Link2, ShieldCheck } from 'lucide-react' import { useTranslation } from 'react-i18next' import type { ChainEntry } from '../api/certificates' interface CertificateChainViewerProps { chain: ChainEntry[] } function getChainLabel(index: number, total: number, t: (key: string) => string): string { if (index === 0) return t('certificates.chainLeaf') if (index === total - 1 && total > 1) return t('certificates.chainRoot') return t('certificates.chainIntermediate') } export default function CertificateChainViewer({ chain }: CertificateChainViewerProps) { const { t } = useTranslation() if (!chain || chain.length === 0) { return (

{t('certificates.noChainData')}

) } return (
{chain.map((entry, index) => { const label = getChainLabel(index, chain.length, t) const isLast = index === chain.length - 1 return (
{index === 0 ? (
{!isLast && (
{label}

{entry.subject}

{t('certificates.issuerOrg')}: {entry.issuer}

{t('certificates.expiresAt')}: {new Date(entry.expires_at).toLocaleDateString()}

) })}
) }