mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Added useFormat hook to format special values.
This commit is contained in:
parent
a71cf675ae
commit
2eee9c23c3
9 changed files with 68 additions and 19 deletions
|
|
@ -1,20 +1,29 @@
|
|||
import { useContext } from 'react';
|
||||
import { GridTable, GridColumn } from 'react-basics';
|
||||
import { useMessages } from 'hooks';
|
||||
import { useFormat, useMessages } from 'hooks';
|
||||
import { ReportContext } from '../Report';
|
||||
|
||||
export function InsightsTable() {
|
||||
const { report } = useContext(ReportContext);
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { groups = [] } = report?.parameters || {};
|
||||
const { formatValue } = useFormat();
|
||||
|
||||
return (
|
||||
<GridTable data={report?.data || []}>
|
||||
{groups.map(({ name, label }) => {
|
||||
return <GridColumn key={name} name={name} label={label} />;
|
||||
return (
|
||||
<GridColumn key={name} name={name} label={label}>
|
||||
{row => formatValue(row[name], name)}
|
||||
</GridColumn>
|
||||
);
|
||||
})}
|
||||
<GridColumn name="views" label={formatMessage(labels.views)} width="100px" />
|
||||
<GridColumn name="visitors" label={formatMessage(labels.visitors)} width="100px" />
|
||||
<GridColumn name="views" label={formatMessage(labels.views)} width="100px">
|
||||
{row => row.views.toLocaleString()}
|
||||
</GridColumn>
|
||||
<GridColumn name="visitors" label={formatMessage(labels.visitors)} width="100px">
|
||||
{row => row.views.toLocaleString()}
|
||||
</GridColumn>
|
||||
</GridTable>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue