mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 01:55:36 +01:00
UTM report.
This commit is contained in:
parent
e602aedd21
commit
bca9c87021
25 changed files with 379 additions and 39 deletions
43
src/app/(main)/reports/utm/UTMView.tsx
Normal file
43
src/app/(main)/reports/utm/UTMView.tsx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { useContext } from 'react';
|
||||
import { firstBy } from 'thenby';
|
||||
import { ReportContext } from '../[reportId]/Report';
|
||||
import styles from './UTMView.module.css';
|
||||
|
||||
function toArray(data: { [key: string]: number }) {
|
||||
return Object.keys(data)
|
||||
.map(key => {
|
||||
return { name: key, value: data[key] };
|
||||
})
|
||||
.sort(firstBy('value', -1));
|
||||
}
|
||||
|
||||
export default function UTMView() {
|
||||
const { report } = useContext(ReportContext);
|
||||
const { data } = report || {};
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{Object.keys(data).map(key => {
|
||||
return (
|
||||
<div key={key}>
|
||||
<div className={styles.title}>{key}</div>
|
||||
<div className={styles.params}>
|
||||
{toArray(data[key]).map(({ name, value }) => {
|
||||
return (
|
||||
<div key={name} className={styles.row}>
|
||||
<div className={styles.label}>{name}</div>
|
||||
<div className={styles.value}>{value}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue