import cn from "classnames"; import type { ReactNode } from "react"; import { formatDateTime, T } from "src/locale"; interface Props { domains: string[]; createdOn?: string; niceName?: string; provider?: string; color?: string; } const DomainLink = ({ domain, color }: { domain?: string; color?: string }) => { // when domain contains a wildcard, make the link go nowhere. // Apparently the domain can be null or undefined sometimes. // This try is just a safeguard to prevent the whole formatter from breaking. if (!domain) return null; try { let onClick: ((e: React.MouseEvent) => void) | undefined; if (domain.includes("*")) { onClick = (e: React.MouseEvent) => e.preventDefault(); } return ( {domain} ); } catch { return null; } }; export function DomainsFormatter({ domains, createdOn, niceName, provider, color }: Props) { const elms: ReactNode[] = []; if ((!domains || domains.length === 0) && !niceName) { elms.push( Unknown , ); } if (!domains || (niceName && provider !== "letsencrypt")) { elms.push( {niceName} , ); } if (domains) { domains.map((domain: string) => elms.push()); } return (
{...elms}
{createdOn ? (
) : null}
); }