2024-07-29 18:41:36 +02:00
|
|
|
import vCard from "vcf";
|
2024-08-20 15:22:14 +02:00
|
|
|
import {Avatar, List, Tooltip} from "antd";
|
2024-07-29 18:41:36 +02:00
|
|
|
import {BankOutlined, IdcardOutlined, SignatureOutlined, ToolOutlined, UserOutlined} from "@ant-design/icons";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import {Domain} from "../../utils/api";
|
|
|
|
|
import {t} from "ttag";
|
|
|
|
|
|
2024-08-16 13:56:52 +02:00
|
|
|
export function translateRoles() {
|
|
|
|
|
return {
|
2024-07-29 18:41:36 +02:00
|
|
|
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`
|
|
|
|
|
}
|
2024-08-16 13:56:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function EntitiesList({domain}: { domain: Domain }) {
|
|
|
|
|
const domainRole = translateRoles()
|
2024-07-29 18:41:36 +02:00
|
|
|
|
|
|
|
|
return <List
|
|
|
|
|
className="demo-loadmore-list"
|
|
|
|
|
itemLayout="horizontal"
|
|
|
|
|
dataSource={domain.entities.sort((e1, e2) => {
|
|
|
|
|
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 <List.Item>
|
|
|
|
|
<List.Item.Meta
|
|
|
|
|
avatar={<Avatar style={{backgroundColor: '#87d068'}}
|
|
|
|
|
icon={e.roles.includes('registrant') ?
|
|
|
|
|
<SignatureOutlined/> : e.roles.includes('registrar') ?
|
|
|
|
|
<BankOutlined/> :
|
|
|
|
|
e.roles.includes('technical') ?
|
|
|
|
|
<ToolOutlined/> :
|
|
|
|
|
e.roles.includes('administrative') ?
|
|
|
|
|
<IdcardOutlined/> :
|
|
|
|
|
<UserOutlined/>}/>}
|
|
|
|
|
title={e.entity.handle}
|
|
|
|
|
description={name}
|
|
|
|
|
/>
|
|
|
|
|
<div>{e.roles.map((r) => Object.keys(domainRole).includes(r) ? domainRole[r as keyof typeof domainRole] : r).join(', ')}</div>
|
|
|
|
|
</List.Item>
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|