mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
fix: handle new getSessionMetrics format in WorldMap
WorldMap now correctly extracts data and total from the new
{ data, total } response format for accurate percentage calculation.
This commit is contained in:
parent
63c562a5fe
commit
11142d401d
1 changed files with 10 additions and 4 deletions
|
|
@ -32,10 +32,16 @@ export function WorldMap({ websiteId, data, ...props }: WorldMapProps) {
|
||||||
type: 'country',
|
type: 'country',
|
||||||
});
|
});
|
||||||
|
|
||||||
const metrics = useMemo(
|
const metrics = useMemo(() => {
|
||||||
() => (data || mapData ? percentFilter((data || mapData) as any[]) : []),
|
const source = data || mapData;
|
||||||
[data, mapData],
|
if (!source) return [];
|
||||||
);
|
|
||||||
|
// Handle both old format (array) and new format ({ data, total })
|
||||||
|
const items = Array.isArray(source) ? source : source.data;
|
||||||
|
const total = Array.isArray(source) ? undefined : source.total;
|
||||||
|
|
||||||
|
return percentFilter(items, total);
|
||||||
|
}, [data, mapData]);
|
||||||
|
|
||||||
const getFillColor = (code: string) => {
|
const getFillColor = (code: string) => {
|
||||||
if (code === 'AQ') return;
|
if (code === 'AQ') return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue