umami/components/pages/realtime/RealtimeCountries.js

26 lines
748 B
JavaScript
Raw Normal View History

2023-02-18 06:42:42 +01:00
import { useCallback } from 'react';
import DataTable from 'components/metrics/DataTable';
import useLocale from 'hooks/useLocale';
import useCountryNames from 'hooks/useCountryNames';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
2023-02-18 06:42:42 +01:00
export default function RealtimeCountries({ data }) {
2023-03-22 22:05:55 +01:00
const { formatMessage, labels } = useMessages();
2023-02-18 06:42:42 +01:00
const { locale } = useLocale();
const countryNames = useCountryNames(locale);
const renderCountryName = useCallback(
({ x }) => <span className={locale}>{countryNames[x]}</span>,
[countryNames, locale],
);
return (
<DataTable
title={formatMessage(labels.countries)}
metric={formatMessage(labels.visitors)}
data={data}
renderLabel={renderCountryName}
/>
);
}