mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Fixed realtime page.
This commit is contained in:
parent
65ebd736b9
commit
c1d301ffdc
12 changed files with 83 additions and 450 deletions
28
src/components/common/DateDisplay.tsx
Normal file
28
src/components/common/DateDisplay.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { useState } from 'react';
|
||||
import { ToggleGroup, ToggleGroupItem } from '@umami/react-zen';
|
||||
import { ToggleGroup, ToggleGroupItem, Box } from '@umami/react-zen';
|
||||
|
||||
export interface FilterButtonsProps {
|
||||
items: { id: string; label: string }[];
|
||||
|
|
@ -16,12 +16,18 @@ export function FilterButtons({ items, value, onChange }: FilterButtonsProps) {
|
|||
};
|
||||
|
||||
return (
|
||||
<ToggleGroup value={[selected]} onChange={e => handleChange(e[0])}>
|
||||
{items.map(({ id, label }) => (
|
||||
<ToggleGroupItem key={id} id={id}>
|
||||
{label}
|
||||
</ToggleGroupItem>
|
||||
))}
|
||||
</ToggleGroup>
|
||||
<Box>
|
||||
<ToggleGroup
|
||||
value={[selected]}
|
||||
onChange={e => handleChange(e[0])}
|
||||
disallowEmptySelection={true}
|
||||
>
|
||||
{items.map(({ id, label }) => (
|
||||
<ToggleGroupItem key={id} id={id}>
|
||||
{label}
|
||||
</ToggleGroupItem>
|
||||
))}
|
||||
</ToggleGroup>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue