dashboard: add retention and quick fix loading states

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-05-01 14:15:31 +02:00
parent c3815bf6ab
commit 5e743a3502
52 changed files with 1324 additions and 205 deletions

View File

@@ -1,3 +1,4 @@
import { isSameYear } from 'date-fns';
import type { FormatStyleName } from 'javascript-time-ago';
import TimeAgo from 'javascript-time-ago';
import en from 'javascript-time-ago/locale/en';
@@ -16,7 +17,16 @@ export function getLocale() {
}
export function formatDate(date: Date) {
return new Intl.DateTimeFormat(getLocale()).format(date);
const options: Intl.DateTimeFormatOptions = {
day: 'numeric',
month: 'numeric',
};
if (!isSameYear(date, new Date())) {
options.year = 'numeric';
}
return new Intl.DateTimeFormat(getLocale(), options).format(date);
}
export function formatDateTime(date: Date) {