feat: translate domain events in watchlistsList

This commit is contained in:
Maël Gangloff
2024-08-03 02:21:11 +02:00
parent ee47f9aac6
commit 9afaf11476
3 changed files with 42 additions and 35 deletions

View File

@@ -21,31 +21,33 @@ export function actionToColor(a: EventAction) {
a === 'last changed' ? 'blue' : 'default'
}
export 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`
})
export function EventTimeline({domain}: { domain: Domain }) {
const sm = useBreakpoint('sm')
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]
const domainEventTranslated = domainEvent()
return <Timeline
mode={sm ? "left" : "right"}
items={domain.events
.sort((e1, e2) => new Date(e2.date).getTime() - new Date(e1.date).getTime())
.map(({action, date}) => {
let dot
if (action === 'registration') {
dot = <SignatureOutlined style={{fontSize: '16px'}}/>
@@ -61,7 +63,7 @@ export function EventTimeline({domain}: { domain: Domain }) {
dot = <ReloadOutlined style={{fontSize: '16px'}}/>
}
const eventName = Object.keys(domainEvent).includes(action) ? domainEvent[action as keyof typeof domainEvent] : action
const eventName = Object.keys(domainEventTranslated).includes(action) ? domainEventTranslated[action as keyof typeof domainEventTranslated] : action
const dateStr = new Date(date).toLocaleString(locale)
const text = sm ? {