MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / OverviewMap

Function OverviewMap

apps/start/src/components/overview/overview-map.tsx:14–90  ·  view source on GitHub ↗
({ projectId, shareId }: OverviewMapProps)

Source from the content-addressed store, hash-verified

12}
13
14export function OverviewMap({ projectId, shareId }: OverviewMapProps) {
15 const { range, startDate, endDate } = useOverviewOptions();
16 const [filters, setFilter] = useEventQueryFilters();
17 const trpc = useTRPC();
18
19 const query = useQuery(
20 trpc.overview.map.queryOptions({
21 projectId,
22 shareId,
23 range,
24 filters,
25 startDate,
26 endDate,
27 }),
28 );
29
30 const mapData = useMemo(() => {
31 if (!query.data) return [];
32
33 // Aggregate by country (sum counts for same country)
34 const countryMap = new Map<string, number>();
35 query.data.forEach((item) => {
36 const country = item.country.toLowerCase();
37 const current = countryMap.get(country) ?? 0;
38 countryMap.set(country, current + item.count);
39 });
40
41 return Array.from(countryMap.entries()).map(([country, value]) => ({
42 country,
43 value,
44 }));
45 }, [query.data]);
46
47 if (query.isLoading) {
48 return (
49 <div className="h-full w-full flex items-center justify-center">
50 <div className="text-muted-foreground">Loading map...</div>
51 </div>
52 );
53 }
54
55 if (query.isError) {
56 return (
57 <div className="h-full w-full flex items-center justify-center">
58 <div className="text-muted-foreground">Error loading map</div>
59 </div>
60 );
61 }
62
63 if (!query.data || mapData.length === 0) {
64 return (
65 <div className="h-full w-full flex items-center justify-center">
66 <div className="text-muted-foreground">No data available</div>
67 </div>
68 );
69 }
70
71 return (

Callers

nothing calls this directly

Calls 7

useOverviewOptionsFunction · 0.90
useEventQueryFiltersFunction · 0.90
setFilterFunction · 0.50
getMethod · 0.45
setMethod · 0.45
mapMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected