import { Avatar, Badge, Text, Tooltip } from "@chakra-ui/react";
import { RowAction, RowActionsMenu } from "components";
import { intl } from "locale";
import getNiceDNSProvider from "modules/Acmesh";
function ActionsFormatter(rowActions: RowAction[]) {
const formatCell = (instance: any) => {
return ;
};
return formatCell;
}
function BooleanFormatter() {
const formatCell = ({ value }: any) => {
return (
{value ? "true" : "false"}
);
};
return formatCell;
}
function CapabilitiesFormatter() {
const formatCell = ({ row, value }: any) => {
const style = {} as any;
if (row?.original?.isDisabled) {
style.textDecoration = "line-through";
}
if (row?.original?.isSystem) {
return (
{intl.formatMessage({ id: "capability.system" })}
);
}
if (value?.indexOf("full-admin") !== -1) {
return (
{intl.formatMessage({ id: "capability.full-admin" })}
);
}
if (value?.length) {
const strs: string[] = [];
value.map((c: string) => {
strs.push(intl.formatMessage({ id: `capability.${c}` }));
return null;
});
return (
{intl.formatMessage(
{ id: "capability-count" },
{ count: value.length },
)}
);
}
return null;
};
return formatCell;
}
function CertificateStatusFormatter() {
const formatCell = ({ value }: any) => {
return (
{value
? intl.formatMessage({ id: "ready" })
: intl.formatMessage({ id: "setup-required" })}
);
};
return formatCell;
}
function DisabledFormatter() {
const formatCell = ({ value, row }: any) => {
if (row?.original?.isDisabled) {
return (
{value}
);
}
return value;
};
return formatCell;
}
function DNSProviderFormatter() {
const formatCell = ({ value }: any) => {
return getNiceDNSProvider(value);
};
return formatCell;
}
function DomainsFormatter() {
const formatCell = ({ value }: any) => {
if (value?.length > 0) {
return (
<>
{value.map((dom: string, idx: number) => {
return (
{dom}
);
})}
>
);
}
return No domains!;
};
return formatCell;
}
function GravatarFormatter() {
const formatCell = ({ value }: any) => {
return ;
};
return formatCell;
}
function HostStatusFormatter() {
const formatCell = ({ row }: any) => {
if (row.original.isDisabled) {
return (
{intl.formatMessage({ id: "disabled" })}
);
}
if (row.original.certificateId) {
if (row.original.certificate.status === "provided") {
return (
{row.original.sslForced
? intl.formatMessage({ id: "https-only" })
: intl.formatMessage({ id: "http-https" })}
);
}
if (row.original.certificate.status === "error") {
return (
{intl.formatMessage({ id: "error" })}
);
}
return (
{intl.formatMessage({
id: `certificate.${row.original.certificate.status}`,
})}
);
}
return (
{intl.formatMessage({ id: "http-only" })}
);
};
return formatCell;
}
function HostTypeFormatter() {
const formatCell = ({ value }: any) => {
return intl.formatMessage({ id: `host-type.${value}` });
};
return formatCell;
}
function IDFormatter() {
const formatCell = ({ value }: any) => {
return {value};
};
return formatCell;
}
function SecondsFormatter() {
const formatCell = ({ value }: any) => {
return intl.formatMessage({ id: "seconds" }, { seconds: value });
};
return formatCell;
}
export {
ActionsFormatter,
BooleanFormatter,
CapabilitiesFormatter,
CertificateStatusFormatter,
DisabledFormatter,
DNSProviderFormatter,
DomainsFormatter,
GravatarFormatter,
HostStatusFormatter,
HostTypeFormatter,
IDFormatter,
SecondsFormatter,
};