import React, {useState} from "react"; import { Avatar, Badge, Card, Divider, Empty, Flex, Form, FormProps, Input, List, message, Skeleton, Space, Tag, Timeline, Typography } from "antd"; import { BankOutlined, ClockCircleOutlined, DeleteOutlined, IdcardOutlined, ReloadOutlined, SearchOutlined, ShareAltOutlined, SignatureOutlined, SyncOutlined, ToolOutlined, UserOutlined } from "@ant-design/icons"; import {Domain, getDomain} from "../../utils/api"; import {AxiosError} from "axios" import vCard from 'vcf' import {t} from 'ttag' type FieldType = { ldhName: string } const locale = navigator.language.split('-')[0] export default function DomainSearchPage() { const domainRole = { registrant: t`Registrant`, technical: t`Technical`, administrative: t`Administrative`, abuse: t`Abuse`, billing: t`Billing`, registrar: t`Registrar`, reseller: t`Reseller`, sponsor: t`Sponsor`, proxy: t`Proxy`, notifications: t`Notifications`, noc: t`Noc` } const domainEvent = { registration: t`Registration`, reregistration: t`Reregistration`, 'last changed': t`Last changed`, expiration: t`Expiration`, deletion: t`Deletion`, reinstantiation: t`Reinstantiation`, transfer: t`Transfer`, locked: t`Locked`, unlocked: t`Unlocked`, 'registrar expiration': t`Registrar expiration`, 'enum validation expiration': t`ENUM validation expiration` } const [domain, setDomain] = useState() const [messageApi, contextHolder] = message.useMessage() const onFinish: FormProps['onFinish'] = (values) => { setDomain(null) getDomain(values.ldhName).then(d => { setDomain(d) messageApi.success(t`Found !`) }).catch((e: AxiosError) => { const data = e?.response?.data as { detail: string } setDomain(undefined) messageApi.error(data.detail ?? t`An error occurred`) }) } return {contextHolder}
name="ldhName" rules={[{ required: true, message: t`Required` }, { pattern: /^(?=.*\.)\S*[^.\s]$/, message: t`This domain name does not appear to be valid`, max: 63, min: 2 }]} > } placeholder="example.com" autoFocus={true} autoComplete='off'/> { domain && (!domain.deleted ? {domain.status.length > 0 && <> {t`EPP Status Codes`} { domain.status.map(s => {s} ) } } {t`Timeline`} new Date(e2.date).getTime() - new Date(e1.date).getTime()) .map(({action, date}) => { let color, dot if (action === 'registration') { color = 'green' dot = } else if (action === 'expiration') { color = 'red' dot = } else if (action === 'transfer') { color = 'orange' dot = } else if (action === 'last changed') { color = 'blue' dot = } else if (action === 'deletion') { color = 'red' dot = } else if (action === 'reregistration') { color = 'green' dot = } return { label: new Date(date).toLocaleString(locale), children: Object.keys(domainEvent).includes(action) ? domainEvent[action as keyof typeof domainEvent] : action, color, dot, pending: new Date(date).getTime() > new Date().getTime() } } ) } /> { domain.entities.length > 0 && <> {t`Entities`} { const p = (r: string[]) => r.includes('registrant') ? 4 : r.includes('administrative') ? 3 : r.includes('billing') ? 2 : 1 return p(e2.roles) - p(e1.roles) })} renderItem={(e) => { const jCard = vCard.fromJSON(e.entity.jCard) let name = '' if (jCard.data.fn !== undefined && !Array.isArray(jCard.data.fn)) name = jCard.data.fn.valueOf() return : e.roles.includes('registrar') ? : e.roles.includes('technical') ? : e.roles.includes('administrative') ? : }/>} title={e.entity.handle} description={name} />
{e.roles.map((r) => Object.keys(domainRole).includes(r) ? domainRole[r as keyof typeof domainRole] : r).join(', ')}
}} /> }
: {t`Although the domain exists in my database, it has been deleted from the WHOIS by its registrar.`} }/>) }
}