2024-07-29 18:41:36 +02:00
|
|
|
import {
|
|
|
|
|
ClockCircleOutlined,
|
|
|
|
|
DeleteOutlined,
|
|
|
|
|
ReloadOutlined,
|
|
|
|
|
ShareAltOutlined,
|
|
|
|
|
SignatureOutlined,
|
|
|
|
|
SyncOutlined
|
|
|
|
|
} from "@ant-design/icons";
|
|
|
|
|
import {Timeline} from "antd";
|
|
|
|
|
import React from "react";
|
2024-08-02 17:23:27 +02:00
|
|
|
import {Domain, EventAction} from "../../utils/api";
|
2024-07-29 18:41:36 +02:00
|
|
|
import {t} from "ttag";
|
2024-07-30 06:28:00 +02:00
|
|
|
import useBreakpoint from "../../hooks/useBreakpoint";
|
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-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 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 locale = navigator.language.split('-')[0]
|
|
|
|
|
|
|
|
|
|
return <Timeline
|
2024-07-30 06:28:00 +02:00
|
|
|
mode={sm ? "left" : "right"}
|
2024-07-29 18:41:36 +02:00
|
|
|
items={domain.events
|
|
|
|
|
.sort((e1, e2) => new Date(e2.date).getTime() - new Date(e1.date).getTime())
|
|
|
|
|
.map(({action, date}) => {
|
|
|
|
|
|
2024-08-02 17:23:27 +02:00
|
|
|
let dot
|
2024-07-29 18:41:36 +02:00
|
|
|
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-30 06:28:00 +02:00
|
|
|
const eventName = Object.keys(domainEvent).includes(action) ? domainEvent[action as keyof typeof domainEvent] : action
|
|
|
|
|
const dateStr = new Date(date).toLocaleString(locale)
|
|
|
|
|
|
|
|
|
|
const text = sm ? {
|
|
|
|
|
children: <>{eventName} {dateStr}</>
|
|
|
|
|
} : {
|
|
|
|
|
label: dateStr,
|
|
|
|
|
children: eventName,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 18:41:36 +02:00
|
|
|
return {
|
2024-08-02 17:23:27 +02:00
|
|
|
color: actionToColor(action),
|
2024-07-29 18:41:36 +02:00
|
|
|
dot,
|
2024-07-30 06:28:00 +02:00
|
|
|
pending: new Date(date).getTime() > new Date().getTime(),
|
|
|
|
|
...text
|
2024-07-29 18:41:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
}
|