mirror of
https://github.com/umami-software/umami.git
synced 2026-02-21 04:55:36 +01:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { useMessages } from 'components/hooks';
|
|
import MetricCard from 'components/metrics/MetricCard';
|
|
import MetricsBar from 'components/metrics/MetricsBar';
|
|
import { formatLongNumberOptions, formatShortTime } from 'lib/format';
|
|
import { useIntl } from 'react-intl';
|
|
|
|
export function SessionStats({ data }) {
|
|
const { formatMessage, labels } = useMessages();
|
|
const intl = useIntl();
|
|
|
|
return (
|
|
<MetricsBar isFetched={true}>
|
|
<MetricCard
|
|
label={formatMessage(labels.visits)}
|
|
value={data?.visits}
|
|
formatValue={(n: number) => intl.formatNumber(+n, formatLongNumberOptions(+n))}
|
|
/>
|
|
<MetricCard
|
|
label={formatMessage(labels.views)}
|
|
value={data?.views}
|
|
formatValue={(n: number) => intl.formatNumber(+n, formatLongNumberOptions(+n))}
|
|
/>
|
|
<MetricCard
|
|
label={formatMessage(labels.events)}
|
|
value={data?.events}
|
|
formatValue={(n: number) => intl.formatNumber(+n, formatLongNumberOptions(+n))}
|
|
/>
|
|
<MetricCard
|
|
label={formatMessage(labels.visitDuration)}
|
|
value={data?.totaltime / data?.visits}
|
|
formatValue={n => `${+n < 0 ? '-' : ''}${formatShortTime(Math.abs(~~n), ['m', 's'], ' ')}`}
|
|
/>
|
|
</MetricsBar>
|
|
);
|
|
}
|