-
- {r.region}
- {r.count}
-
- {r.cities.map((c) => (
-
- {c.city}
- {c.count}
-
- ))}
+
+ );
+}
+
+function CountryDetail({ country }: { country: CountryData }) {
+ return (
+
+
+ {countryCodeToFlag(country.code)}
+ {country.code}
+ {country.count} hits
+
+ {country.regions.map((r) => (
+
+
+ {r.region}
+ {r.count}
+
+ {r.cities.map((c) => (
+
+ {c.city}
+ {c.count}
))}
- )}
+ ))}
);
}
@@ -72,6 +80,7 @@ export function GlobeCard() {
countries: [],
});
const [grabbing, setGrabbing] = useState(false);
+ const [selectedCountry, setSelectedCountry] = useState
(null);
useEffect(() => {
async function fetchVisitors() {
@@ -190,9 +199,18 @@ export function GlobeCard() {
{visitorStats.countries.length > 0 && (
+ {selectedCountry && (() => {
+ const country = visitorStats.countries.find(c => c.code === selectedCountry);
+ return country ?
: null;
+ })()}
{visitorStats.countries.map((country) => (
-
+
))}