2024-12-20 19:41:48 +01:00
import { Badge , Card , Col , Divider , Flex , Row , Space , Tag , Tooltip , Typography } from "antd" ;
2024-08-20 15:22:14 +02:00
import { t } from "ttag" ;
import { EventTimeline } from "./EventTimeline" ;
import { EntitiesList } from "./EntitiesList" ;
import { DomainDiagram } from "./DomainDiagram" ;
import React from "react" ;
import { Domain } from "../../utils/api" ;
2024-08-23 21:19:34 +02:00
import { rdapStatusCodeDetailTranslation } from "../../utils/functions/rdapTranslation" ;
2024-08-22 01:44:50 +02:00
import { regionNames } from "../../i18n" ;
import { getCountryCode } from "../../utils/functions/getCountryCode" ;
2024-08-23 21:19:34 +02:00
import { eppStatusCodeToColor } from "../../utils/functions/eppStatusCodeToColor" ;
import { DomainLifecycleSteps } from "./DomainLifecycleSteps" ;
2024-12-30 14:31:31 +01:00
import { BankOutlined , KeyOutlined , SafetyCertificateOutlined } from '@ant-design/icons'
2024-08-20 15:22:14 +02:00
export function DomainResult ( { domain } : { domain : Domain } ) {
const rdapStatusCodeDetailTranslated = rdapStatusCodeDetailTranslation ( )
2024-08-23 21:19:34 +02:00
const { tld , events } = domain
const domainEvents = events . sort ( ( e1 , e2 ) = > new Date ( e2 . date ) . getTime ( ) - new Date ( e1 . date ) . getTime ( ) )
2024-12-29 22:31:40 +01:00
const clientStatus = domain . status . filter ( s = > s . startsWith ( 'client' ) )
const serverStatus = domain . status . filter ( s = > ! clientStatus . includes ( s ) )
const isLocked = ( type : 'client' | 'server' ) : boolean = >
( domain . status . includes ( type + ' update prohibited' ) && domain . status . includes ( type + ' delete prohibited' ) )
|| domain . status . includes ( type + ' transfer prohibited' )
const statusToTag = ( s : string ) = > < Tooltip
placement = 'bottomLeft'
title = { rdapStatusCodeDetailTranslated [ s as keyof typeof rdapStatusCodeDetailTranslated ] || undefined } >
< Tag color = { eppStatusCodeToColor ( s ) } > { s } < / Tag >
< / Tooltip >
2024-08-20 15:22:14 +02:00
return < Space direction = "vertical" size = "middle" style = { { width : '100%' } } >
2024-08-22 01:44:50 +02:00
< Badge.Ribbon text = {
< Tooltip
title = { tld . type === 'ccTLD' ? regionNames . of ( getCountryCode ( tld . tld ) ) : tld . type === 'gTLD' ? tld?.registryOperator : undefined } >
2024-12-29 22:31:40 +01:00
{ ` ${ domain . tld . tld . toUpperCase ( ) } ( ${ tld . type } ) ` }
2024-08-22 01:44:50 +02:00
< / Tooltip >
}
2024-08-20 15:22:14 +02:00
color = {
2024-08-22 01:44:50 +02:00
tld . type === 'ccTLD' ? 'purple' :
( tld . type === 'gTLD' && tld . specification13 ) ? "volcano" :
tld . type === 'gTLD' ? "green"
2024-08-20 15:22:14 +02:00
: "cyan"
} >
2024-08-22 01:44:50 +02:00
2024-08-21 02:01:20 +02:00
< Card title = { < Space >
2024-08-20 15:22:14 +02:00
{ domain . ldhName } { domain . handle && < Typography.Text code > { domain . handle } < / Typography.Text > }
2024-08-21 02:01:20 +02:00
< / Space > }
2024-08-20 15:22:14 +02:00
size = "small" >
2024-08-23 21:19:34 +02:00
{
domain . events . length > 0 && < DomainLifecycleSteps status = { domain . status } / >
}
2024-12-20 19:41:48 +01:00
< Row gutter = { 8 } >
2024-12-29 22:31:40 +01:00
< Col span = { 24 } xl = { 12 } xxl = { 12 } >
2024-12-30 00:19:42 +01:00
< Flex justify = 'center' align = 'center' style = { { margin : 10 } } wrap gap = "4px 0" >
2024-12-29 22:31:40 +01:00
< Tooltip
title = { t ` Registry-level protection, ensuring the highest level of security by preventing unauthorized, unwanted, or accidental changes to the domain name at the registry level ` } >
< Tag bordered = { false } color = { isLocked ( 'server' ) ? 'green' : 'default' }
icon = { < SafetyCertificateOutlined
style = { { fontSize : '16px' } } / > } > { t ` Registry Lock ` } < / Tag >
< / Tooltip >
< Tooltip
title = { t ` Registrar-level protection, safeguarding the domain from unauthorized, unwanted, or accidental changes through registrar controls ` } >
< Tag bordered = { false } color = { isLocked ( 'client' ) ? 'green' : 'default' }
icon = { < BankOutlined
style = { { fontSize : '16px' } } / > } > { t ` Registrar Lock ` } < / Tag >
< / Tooltip >
2024-12-30 14:31:31 +01:00
< Tooltip
title = { t ` DNSSEC secures DNS by adding cryptographic signatures to DNS records, ensuring authenticity and integrity of responses ` } >
< Tag bordered = { false } color = { domain . delegationSigned ? 'green' : 'default' }
icon = { < KeyOutlined style = { { fontSize : '16px' } } / > } > { t ` DNSSEC ` } < / Tag >
< / Tooltip >
2024-12-29 22:31:40 +01:00
< / Flex >
2024-12-20 19:41:48 +01:00
{ domain . status . length > 0 &&
< >
< Divider orientation = "left" > { t ` EPP Status Codes ` } < / Divider >
2024-12-29 23:19:47 +01:00
< Flex gap = "4px 0" wrap >
{ serverStatus . map ( statusToTag ) }
{ clientStatus . map ( statusToTag ) }
< / Flex >
2024-12-20 19:41:48 +01:00
< / >
}
{
domain . events . length > 0 && < >
< Divider orientation = "left" > { t ` Timeline ` } < / Divider >
< EventTimeline events = { domainEvents } / >
< / >
}
{
domain . entities . length > 0 &&
< >
< Divider orientation = "left" > { t ` Entities ` } < / Divider >
< EntitiesList domain = { domain } / >
< / >
}
< / Col >
2024-12-29 22:31:40 +01:00
< Col span = { 24 } xl = { 12 } xxl = { 12 } >
< DomainDiagram domain = { domain } / >
< / Col >
2024-12-20 19:41:48 +01:00
< / Row >
2024-08-20 15:22:14 +02:00
< / Card >
< / Badge.Ribbon >
< / Space >
}