2024-07-29 18:41:36 +02:00
|
|
|
import {
|
|
|
|
|
ClockCircleOutlined,
|
|
|
|
|
DeleteOutlined,
|
|
|
|
|
ReloadOutlined,
|
|
|
|
|
ShareAltOutlined,
|
|
|
|
|
SignatureOutlined,
|
|
|
|
|
SyncOutlined
|
|
|
|
|
} from "@ant-design/icons";
|
2024-08-20 15:22:14 +02:00
|
|
|
import {Timeline, Tooltip} from "antd";
|
2024-07-29 18:41:36 +02:00
|
|
|
import React from "react";
|
2024-08-02 17:23:27 +02:00
|
|
|
import {Domain, EventAction} from "../../utils/api";
|
2024-07-30 06:28:00 +02:00
|
|
|
import useBreakpoint from "../../hooks/useBreakpoint";
|
2024-08-20 15:22:14 +02:00
|
|
|
import {rdapEventDetailTranslation, rdapEventNameTranslation} from "./rdapEventActionDetailTranslation";
|
2024-07-29 18:41:36 +02:00
|
|
|
|
2024-08-02 17:23:27 +02:00
|
|
|
export function actionToColor(a: EventAction) {
|
|
|
|
|
return a === 'registration' ? 'green' :
|
|
|
|
|
a === 'reregistration' ? 'cyan' :
|
|
|
|
|
a === 'expiration' ? 'red' :
|
|
|
|
|
a === 'deletion' ? 'magenta' :
|
|
|
|
|
a === 'transfer' ? 'orange' :
|
|
|
|
|
a === 'last changed' ? 'blue' : 'default'
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-03 02:21:11 +02:00
|
|
|
|
2024-07-29 18:41:36 +02:00
|
|
|
export function EventTimeline({domain}: { domain: Domain }) {
|
2024-07-30 06:28:00 +02:00
|
|
|
const sm = useBreakpoint('sm')
|
2024-07-29 18:41:36 +02:00
|
|
|
|
|
|
|
|
const locale = navigator.language.split('-')[0]
|
2024-08-20 15:22:14 +02:00
|
|
|
const rdapEventNameTranslated = rdapEventNameTranslation()
|
|
|
|
|
const rdapEventDetailTranslated = rdapEventDetailTranslation()
|
2024-07-29 18:41:36 +02:00
|
|
|
|
2024-08-18 18:13:23 +02:00
|
|
|
const domainEvents = domain.events.sort((e1, e2) => new Date(e2.date).getTime() - new Date(e1.date).getTime())
|
|
|
|
|
const expirationEvents = domainEvents.filter(e => e.action === 'expiration')
|
|
|
|
|
|
2024-07-29 18:41:36 +02:00
|
|
|
return <Timeline
|
2024-07-30 06:28:00 +02:00
|
|
|
mode={sm ? "left" : "right"}
|
2024-08-18 18:13:23 +02:00
|
|
|
items={domainEvents.map(({action, date}) => {
|
|
|
|
|
let dot
|
|
|
|
|
if (action === 'registration') {
|
|
|
|
|
dot = <SignatureOutlined style={{fontSize: '16px'}}/>
|
|
|
|
|
} else if (action === 'expiration') {
|
|
|
|
|
dot = <ClockCircleOutlined style={{fontSize: '16px'}}/>
|
|
|
|
|
} else if (action === 'transfer') {
|
|
|
|
|
dot = <ShareAltOutlined style={{fontSize: '16px'}}/>
|
|
|
|
|
} else if (action === 'last changed') {
|
|
|
|
|
dot = <SyncOutlined style={{fontSize: '16px'}}/>
|
|
|
|
|
} else if (action === 'deletion') {
|
|
|
|
|
dot = <DeleteOutlined style={{fontSize: '16px'}}/>
|
|
|
|
|
} else if (action === 'reregistration') {
|
|
|
|
|
dot = <ReloadOutlined style={{fontSize: '16px'}}/>
|
|
|
|
|
}
|
2024-07-29 18:41:36 +02:00
|
|
|
|
2024-08-20 15:22:14 +02:00
|
|
|
const eventName = Object.keys(rdapEventNameTranslated).includes(action) ? rdapEventNameTranslated[action as keyof typeof rdapEventNameTranslated] : action
|
2024-08-18 18:13:23 +02:00
|
|
|
const dateStr = new Date(date).toLocaleString(locale)
|
2024-08-20 15:22:14 +02:00
|
|
|
const eventDetail = action in rdapEventDetailTranslated ? rdapEventDetailTranslated[action as keyof typeof rdapEventDetailTranslated] : undefined
|
2024-07-30 06:28:00 +02:00
|
|
|
|
2024-08-18 18:13:23 +02:00
|
|
|
const text = sm ? {
|
2024-08-20 15:22:14 +02:00
|
|
|
children: <Tooltip placement='bottom' title={eventDetail}>
|
|
|
|
|
{eventName} {dateStr}
|
|
|
|
|
</Tooltip>
|
2024-08-18 18:13:23 +02:00
|
|
|
} : {
|
|
|
|
|
label: dateStr,
|
2024-08-20 15:22:14 +02:00
|
|
|
children: <Tooltip placement='left' title={eventDetail}>{eventName}</Tooltip>,
|
2024-08-18 18:13:23 +02:00
|
|
|
}
|
2024-07-30 06:28:00 +02:00
|
|
|
|
2024-08-18 18:13:23 +02:00
|
|
|
return {
|
|
|
|
|
color: (action === 'expiration' ? (expirationEvents.length > 0 && domainEvents[0].date === date) : true) ? actionToColor(action) : 'grey',
|
|
|
|
|
dot,
|
|
|
|
|
pending: new Date(date).getTime() > new Date().getTime(),
|
|
|
|
|
...text
|
2024-07-29 18:41:36 +02:00
|
|
|
}
|
2024-08-18 18:13:23 +02:00
|
|
|
}
|
|
|
|
|
)
|
2024-07-29 18:41:36 +02:00
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
}
|