Skip to content

Commit

Permalink
Added country to regions display.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Apr 21, 2023
1 parent 69b9458 commit e6c5a9b
Show file tree
Hide file tree
Showing 2 changed files with 3,625 additions and 3,552 deletions.
12 changes: 9 additions & 3 deletions components/metrics/RegionsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ import { emptyFilter } from 'lib/filters';
import FilterLink from 'components/common/FilterLink';
import useLocale from 'hooks/useLocale';
import useMessages from 'hooks/useMessages';
import useCountryNames from 'hooks/useCountryNames';
import regions from 'public/iso-3166-2.json';

export function RegionsTable({ websiteId, ...props }) {
const { locale } = useLocale();
const { formatMessage, labels } = useMessages();
const countryNames = useCountryNames(locale);

function renderLink({ x }) {
const renderLabel = x => {
return regions[x] ? `${regions[x]}, ${countryNames[x.split('-')[0]]}` : x;
};

const renderLink = ({ x }) => {
return (
<div className={locale}>
<FilterLink id="region" value={x} label={regions[x] || x} />
<FilterLink id="region" value={x} label={renderLabel(x)} />
</div>
);
}
};

return (
<MetricsTable
Expand Down
Loading

0 comments on commit e6c5a9b

Please sign in to comment.