mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: translate domain events in watchlistsList
This commit is contained in:
@@ -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 ? {
|
||||
|
||||
@@ -4,7 +4,7 @@ import {deleteWatchlist} from "../../utils/api";
|
||||
import {DeleteFilled} from "@ant-design/icons";
|
||||
import React from "react";
|
||||
import useBreakpoint from "../../hooks/useBreakpoint";
|
||||
import {actionToColor} from "../search/EventTimeline";
|
||||
import {actionToColor, domainEvent} from "../search/EventTimeline";
|
||||
import {Watchlist} from "../../pages/tracking/WatchlistPage";
|
||||
|
||||
const {useToken} = theme;
|
||||
@@ -14,6 +14,8 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
|
||||
const {token} = useToken()
|
||||
const sm = useBreakpoint('sm')
|
||||
|
||||
const domainEventTranslated = domainEvent()
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: t`Domain names`,
|
||||
@@ -49,7 +51,10 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
|
||||
dataSource={[{
|
||||
domains: watchlist.domains.map(d => <Tag>{d.ldhName}</Tag>),
|
||||
events: watchlist.triggers?.filter(t => t.action === 'email')
|
||||
.map(t => <Tag color={actionToColor(t.event)}>{t.event}</Tag>)
|
||||
.map(t => <Tag color={actionToColor(t.event)}>
|
||||
{domainEventTranslated[t.event as keyof typeof domainEventTranslated]}
|
||||
</Tag>
|
||||
)
|
||||
}]}
|
||||
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user