mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import MetricsTable from './MetricsTable';
|
|
import { percentFilter } from 'lib/filters';
|
|
import FilterLink from 'components/common/FilterLink';
|
|
import useCountryNames from 'hooks/useCountryNames';
|
|
import useLocale from 'hooks/useLocale';
|
|
import useMessages from 'hooks/useMessages';
|
|
|
|
export default function CountriesTable({ websiteId, onDataLoad, ...props }) {
|
|
const { locale } = useLocale();
|
|
const countryNames = useCountryNames(locale);
|
|
const { formatMessage, labels } = useMessages();
|
|
|
|
function renderLink({ x: code }) {
|
|
return (
|
|
<div className={locale}>
|
|
<FilterLink
|
|
id="country"
|
|
value={code}
|
|
label={countryNames[code] ?? formatMessage(labels.unknown)}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<MetricsTable
|
|
{...props}
|
|
title={formatMessage(labels.countries)}
|
|
type="country"
|
|
metric={formatMessage(labels.visitors)}
|
|
websiteId={websiteId}
|
|
onDataLoad={data => onDataLoad?.(percentFilter(data))}
|
|
renderLabel={renderLink}
|
|
/>
|
|
);
|
|
}
|