@@ -7,7 +7,7 @@ import "leaflet/dist/leaflet.css";
77import { useEffect , useMemo , useRef , useState } from "react" ;
88import { GeoJSON , MapContainer } from "react-leaflet" ;
99import { getCountryPopulation } from "@/lib/data" ;
10- import { useCountries , useSubdivisions } from "@/lib/geo" ;
10+ import { useCountries } from "@/lib/geo" ;
1111import { CountryFlag } from "./icons/CountryFlag" ;
1212
1313interface TooltipContent {
@@ -58,39 +58,13 @@ export function MapComponent({
5858 } ;
5959 } , [ locationsData ?. countries ] ) ;
6060
61- const subdivisionData = useMemo ( ( ) => {
62- if ( ! locationsData ?. cities ) return null ;
63-
64- const regions : Record < string , { visitors : number ; pageviews : number } > = { } ;
65-
66- for ( const city of locationsData . cities ) {
67- const regionKey = `${ city . country } -${ city . region } ` ;
68- if ( ! regions [ regionKey ] ) {
69- regions [ regionKey ] = { visitors : 0 , pageviews : 0 } ;
70- }
71- regions [ regionKey ] . visitors += city . visitors ;
72- regions [ regionKey ] . pageviews += city . pageviews ;
73- }
74-
75- return {
76- data : Object . entries ( regions ) . map ( ( [ key , data ] ) => ( {
77- value : key ,
78- count : data . visitors ,
79- percentage :
80- ( data . visitors /
81- ( locationsData . cities . reduce ( ( sum : number , c : any ) => sum + c . visitors , 0 ) || 1 ) ) *
82- 100 ,
83- } ) ) ,
84- } ;
85- } , [ locationsData ?. cities ] ) ;
86-
8761 const [ dataVersion , setDataVersion ] = useState < number > ( 0 ) ;
8862
8963 useEffect ( ( ) => {
90- if ( countryData || subdivisionData ) {
64+ if ( countryData ) {
9165 setDataVersion ( ( prev ) => prev + 1 ) ;
9266 }
93- } , [ countryData , subdivisionData ] ) ;
67+ } , [ countryData ] ) ;
9468
9569 const [ tooltipContent , setTooltipContent ] = useState < TooltipContent | null > ( null ) ;
9670 const [ tooltipPosition , setTooltipPosition ] = useState < TooltipPosition > ( {
@@ -144,7 +118,6 @@ export function MapComponent({
144118 } ;
145119 } , [ processedCountryData , mode ] ) ;
146120
147- const { data : subdivisionsGeoData } = useSubdivisions ( ) ;
148121 const { data : countriesGeoData } = useCountries ( ) ;
149122
150123 const handleStyle = ( feature : Feature < any > ) => {
@@ -252,7 +225,7 @@ export function MapComponent({
252225 </ div >
253226 ) }
254227
255- { ( countriesGeoData || subdivisionsGeoData ) && (
228+ { ( countriesGeoData ) && (
256229 < MapContainer
257230 attributionControl = { false }
258231 center = { [ 40 , 3 ] }
0 commit comments