diff --git a/assets/components/search/EventTimeline.tsx b/assets/components/search/EventTimeline.tsx index 21cee37..c2a07c6 100644 --- a/assets/components/search/EventTimeline.tsx +++ b/assets/components/search/EventTimeline.tsx @@ -24,7 +24,7 @@ export function actionToColor(a: EventAction) { export const domainEvent = () => ({ registration: t`Registration`, reregistration: t`Reregistration`, - 'last changed': t`Last changed`, + 'last changed': t`Changed`, expiration: t`Expiration`, deletion: t`Deletion`, reinstantiation: t`Reinstantiation`, @@ -38,48 +38,48 @@ export const domainEvent = () => ({ export function EventTimeline({domain}: { domain: Domain }) { const sm = useBreakpoint('sm') - const locale = navigator.language.split('-')[0] const domainEventTranslated = domainEvent() + 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') + return new Date(e2.date).getTime() - new Date(e1.date).getTime()) - .map(({action, date}) => { - let dot - if (action === 'registration') { - dot = - } else if (action === 'expiration') { - dot = - } else if (action === 'transfer') { - dot = - } else if (action === 'last changed') { - dot = - } else if (action === 'deletion') { - dot = - } else if (action === 'reregistration') { - dot = - } - - const eventName = Object.keys(domainEventTranslated).includes(action) ? domainEventTranslated[action as keyof typeof domainEventTranslated] : action - const dateStr = new Date(date).toLocaleString(locale) - - const text = sm ? { - children: <>{eventName} {dateStr} - } : { - label: dateStr, - children: eventName, - } - - return { - color: actionToColor(action), - dot, - pending: new Date(date).getTime() > new Date().getTime(), - ...text - } + items={domainEvents.map(({action, date}) => { + let dot + if (action === 'registration') { + dot = + } else if (action === 'expiration') { + dot = + } else if (action === 'transfer') { + dot = + } else if (action === 'last changed') { + dot = + } else if (action === 'deletion') { + dot = + } else if (action === 'reregistration') { + dot = } - ) + + const eventName = Object.keys(domainEventTranslated).includes(action) ? domainEventTranslated[action as keyof typeof domainEventTranslated] : action + const dateStr = new Date(date).toLocaleString(locale) + + const text = sm ? { + children: <>{eventName} {dateStr} + } : { + label: dateStr, + children: eventName, + } + + 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 + } + } + ) } /> } \ No newline at end of file diff --git a/translations/translations.pot b/translations/translations.pot index 32a8269..8f6f407 100644 --- a/translations/translations.pot +++ b/translations/translations.pot @@ -49,7 +49,7 @@ msgid "Reregistration" msgstr "" #: assets/components/search/EventTimeline.tsx:27 -msgid "Last changed" +msgid "Changed" msgstr "" #: assets/components/search/EventTimeline.tsx:28