Fixed realtime page.

This commit is contained in:
Mike Cao 2025-05-02 15:20:20 -07:00
parent 65ebd736b9
commit c1d301ffdc
12 changed files with 83 additions and 450 deletions

View file

@ -0,0 +1,28 @@
import { Icon, Row, Text } from '@umami/react-zen';
import { differenceInDays, isSameDay } from 'date-fns';
import { useLocale } from '@/components/hooks';
import { Icons } from '@/components/icons';
import { formatDate } from '@/lib/date';
export function DateDisplay({ startDate, endDate }) {
const { locale } = useLocale();
const isSingleDate = differenceInDays(endDate, startDate) === 0;
return (
<Row gap="3" alignItems="center" wrap="nowrap">
<Icon>
<Icons.Calendar />
</Icon>
<Text wrap="nowrap">
{isSingleDate ? (
<>{formatDate(startDate, 'PP', locale)}</>
) : (
<>
{formatDate(startDate, 'PP', locale)}
{!isSameDay(startDate, endDate) && `${formatDate(endDate, 'PP', locale)}`}
</>
)}
</Text>
</Row>
);
}