2021-10-20 15:42:40 +00:00
|
|
|
import { ReactNode } from "react";
|
|
|
|
|
2022-11-04 15:40:46 +00:00
|
|
|
import { Badge } from "@calcom/ui/components/badge";
|
2021-10-20 15:42:40 +00:00
|
|
|
|
|
|
|
function pluralize(opts: { num: number; plural: string; singular: string }) {
|
|
|
|
if (opts.num === 0) {
|
|
|
|
return opts.singular;
|
|
|
|
}
|
|
|
|
return opts.singular;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function SubHeadingTitleWithConnections(props: { title: ReactNode; numConnections?: number }) {
|
|
|
|
const num = props.numConnections;
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<span>{props.title}</span>
|
|
|
|
{num ? (
|
|
|
|
<Badge variant="success">
|
|
|
|
{num}{" "}
|
|
|
|
{pluralize({
|
|
|
|
num,
|
|
|
|
singular: "connection",
|
|
|
|
plural: "connections",
|
|
|
|
})}
|
|
|
|
</Badge>
|
|
|
|
) : null}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|