import React from 'react'; import { normalizeWhois } from './helpers'; import { WHOIS_ICONS } from './constants'; const getFormattedWhois = (whois) => { const whoisInfo = normalizeWhois(whois); return ( Object.keys(whoisInfo) .map((key) => { const icon = WHOIS_ICONS[key]; return ( {icon && ( <>   )}{whoisInfo[key]} ); }) ); }; export const formatClientCell = (row, isDetailed = false, isLogs = true) => { const { value, original: { info } } = row; let whoisContainer = ''; let nameContainer = value; if (info) { const { name, whois_info } = info; const whoisAvailable = whois_info && Object.keys(whois_info).length > 0; if (name) { if (isLogs) { nameContainer = !whoisAvailable && isDetailed ? ( {value} ) : (
{name} {`(${value})`}
); } else { nameContainer = (
{name} {`(${value})`}
); } } if (whoisAvailable && isDetailed) { whoisContainer = (
{getFormattedWhois(whois_info)}
); } } return (
<> {nameContainer} {whoisContainer}
); };