mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Export and use formatCity.
This commit is contained in:
parent
fe9db71ba8
commit
53449d65bb
@ -53,7 +53,7 @@ export function useFormat() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return { formatOS, formatBrowser, formatDevice, formatCountry, formatRegion, formatValue };
|
return { formatOS, formatBrowser, formatDevice, formatCountry, formatRegion, formatCity, formatValue };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default useFormat;
|
export default useFormat;
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
import MetricsTable, { MetricsTableProps } from './MetricsTable';
|
import MetricsTable, { MetricsTableProps } from './MetricsTable';
|
||||||
import { emptyFilter } from 'lib/filters';
|
import { emptyFilter } from 'lib/filters';
|
||||||
import FilterLink from 'components/common/FilterLink';
|
import FilterLink from 'components/common/FilterLink';
|
||||||
import { useLocale } from 'components/hooks';
|
|
||||||
import { useMessages } from 'components/hooks';
|
import { useMessages } from 'components/hooks';
|
||||||
import { useCountryNames } from 'components/hooks';
|
import { useFormat } from 'components/hooks';
|
||||||
|
|
||||||
export function CitiesTable(props: MetricsTableProps) {
|
export function CitiesTable(props: MetricsTableProps) {
|
||||||
const { locale } = useLocale();
|
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const countryNames = useCountryNames(locale);
|
const { formatCity } = useFormat();
|
||||||
|
|
||||||
const renderLabel = (city: string, country: string) => {
|
|
||||||
const countryName = countryNames[country];
|
|
||||||
return countryName ? `${city}, ${countryName}` : city;
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderLink = ({ x: city, country }) => {
|
const renderLink = ({ x: city, country }) => {
|
||||||
return (
|
return (
|
||||||
<FilterLink id="city" value={city} label={renderLabel(city, country)}>
|
<FilterLink id="city" value={city} label={formatCity(city, country)}>
|
||||||
{country && (
|
{country && (
|
||||||
<img
|
<img
|
||||||
src={`${process.env.basePath}/images/flags/${country?.toLowerCase() || 'xx'}.png`}
|
src={`${process.env.basePath}/images/flags/${country?.toLowerCase() || 'xx'}.png`}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user