import OverlayTrigger from "react-bootstrap/OverlayTrigger";
import Popover from "react-bootstrap/Popover";
import type { DeadHost, ProxyHost, RedirectionHost, Stream } from "src/api/backend";
import { TrueFalseFormatter } from "src/components";
import { T } from "src/locale";
const getSection = (title: string, items: ProxyHost[] | RedirectionHost[] | DeadHost[]) => {
if (items.length === 0) {
return null;
}
return (
<>
{items.map((host) => (
{host.domainNames.join(", ")}
))}
>
);
};
const getSectionStream = (items: Stream[]) => {
if (items.length === 0) {
return null;
}
return (
<>
{items.map((stream) => (
{stream.forwardingHost}:{stream.forwardingPort}
))}
>
);
};
interface Props {
proxyHosts: ProxyHost[];
redirectionHosts: RedirectionHost[];
deadHosts: DeadHost[];
streams: Stream[];
}
export function CertificateInUseFormatter({ proxyHosts, redirectionHosts, deadHosts, streams }: Props) {
const totalCount = proxyHosts?.length + redirectionHosts?.length + deadHosts?.length + streams?.length;
if (totalCount === 0) {
return ;
}
proxyHosts.sort();
redirectionHosts.sort();
deadHosts.sort();
streams.sort();
const popover = (
{getSection("proxy-hosts", proxyHosts)}
{getSection("redirection-hosts", redirectionHosts)}
{getSection("dead-hosts", deadHosts)}
{getSectionStream(streams)}
);
return (
);
}