mirror of
https://github.com/umami-software/umami.git
synced 2026-02-19 12:05:41 +01:00
Update SessionStats.tsx
This commit is contained in:
parent
876286ed28
commit
8f08639058
1 changed files with 26 additions and 3 deletions
|
|
@ -2,15 +2,38 @@ import { useMessages } from 'components/hooks';
|
|||
import MetricCard from 'components/metrics/MetricCard';
|
||||
import MetricsBar from 'components/metrics/MetricsBar';
|
||||
import { formatShortTime } from 'lib/format';
|
||||
import { type FormatNumberOptions, useIntl } from 'react-intl';
|
||||
|
||||
export function SessionStats({ data }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const intl = useIntl();
|
||||
|
||||
const optionsNumber: FormatNumberOptions = { notation: 'compact', maximumSignificantDigits: 3 };
|
||||
const optionsSmallNumber: FormatNumberOptions = { notation: 'compact' };
|
||||
|
||||
return (
|
||||
<MetricsBar isFetched={true}>
|
||||
<MetricCard label={formatMessage(labels.visits)} value={data?.visits} />
|
||||
<MetricCard label={formatMessage(labels.views)} value={data?.views} />
|
||||
<MetricCard label={formatMessage(labels.events)} value={data?.events} />
|
||||
<MetricCard
|
||||
label={formatMessage(labels.visits)}
|
||||
value={data?.visits}
|
||||
formatValue={(n: number) =>
|
||||
intl.formatNumber(+n, +n < 100 ? optionsSmallNumber : optionsNumber)
|
||||
}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.views)}
|
||||
value={data?.views}
|
||||
formatValue={(n: number) =>
|
||||
intl.formatNumber(+n, +n < 100 ? optionsSmallNumber : optionsNumber)
|
||||
}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.events)}
|
||||
value={data?.events}
|
||||
formatValue={(n: number) =>
|
||||
intl.formatNumber(+n, +n < 100 ? optionsSmallNumber : optionsNumber)
|
||||
}
|
||||
/>
|
||||
<MetricCard
|
||||
label={formatMessage(labels.visitDuration)}
|
||||
value={data?.totaltime / data?.visits}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue