diff --git a/src/components/layout/SideNav.js b/src/components/layout/SideNav.js index e7e96b7d..ccb6f360 100644 --- a/src/components/layout/SideNav.js +++ b/src/components/layout/SideNav.js @@ -4,7 +4,13 @@ import { useRouter } from 'next/router'; import Link from 'next/link'; import styles from './SideNav.module.css'; -export function SideNav({ selectedKey, items, shallow, onSelect = () => {} }) { +export function SideNav({ + selectedKey, + items, + shallow = true, + scroll = false, + onSelect = () => {}, +}) { const { asPath } = useRouter(); return ( @@ -13,7 +19,7 @@ export function SideNav({ selectedKey, items, shallow, onSelect = () => {} }) { key={key} className={classNames(styles.item, { [styles.selected]: asPath.startsWith(url) })} > - + {label} diff --git a/src/components/metrics/CitiesTable.js b/src/components/metrics/CitiesTable.js index fcdc8f88..86b7f07a 100644 --- a/src/components/metrics/CitiesTable.js +++ b/src/components/metrics/CitiesTable.js @@ -1,20 +1,36 @@ +import { useRouter } from 'next/router'; import MetricsTable from './MetricsTable'; import { emptyFilter } from 'lib/filters'; import FilterLink from 'components/common/FilterLink'; import useLocale from 'components/hooks/useLocale'; import useMessages from 'components/hooks/useMessages'; +import useCountryNames from 'components/hooks/useCountryNames'; export function CitiesTable({ websiteId, ...props }) { const { locale } = useLocale(); const { formatMessage, labels } = useMessages(); + const { basePath } = useRouter(); + const countryNames = useCountryNames(locale); - function renderLink({ x }) { + const renderLabel = (city, country) => { + const name = countryNames[country]; + return name ? `${city}, ${name}` : city; + }; + + const renderLink = ({ x: city, country }) => { return ( -
- -
+ + {country && ( + {country} + )} + ); - } + }; return ( `${n}%`) }} /> - {props.width.to(n => `${n.toFixed(0)}%`)} + {props.width.to(n => `${n?.toFixed?.(0)}%`)} )} @@ -102,4 +102,4 @@ const AnimatedRow = ({ ); }; -export default DataTable; +export default ListTable; diff --git a/src/components/metrics/MetricsTable.js b/src/components/metrics/MetricsTable.js index 893427a5..39578381 100644 --- a/src/components/metrics/MetricsTable.js +++ b/src/components/metrics/MetricsTable.js @@ -8,7 +8,7 @@ import { percentFilter } from 'lib/filters'; import useDateRange from 'components/hooks/useDateRange'; import usePageQuery from 'components/hooks/usePageQuery'; import ErrorMessage from 'components/common/ErrorMessage'; -import DataTable from './DataTable'; +import ListTable from './ListTable'; import { DEFAULT_ANIMATION_DURATION } from 'lib/constants'; import Icons from 'components/icons'; import useMessages from 'components/hooks/useMessages'; @@ -104,7 +104,7 @@ export function MetricsTable({
{!data && isLoading && !isFetched && } {error && } - {data && !error && } + {data && !error && }
{data && !error && limit && ( diff --git a/src/components/pages/realtime/RealtimeCountries.js b/src/components/pages/realtime/RealtimeCountries.js index 3aecad5f..7a61651a 100644 --- a/src/components/pages/realtime/RealtimeCountries.js +++ b/src/components/pages/realtime/RealtimeCountries.js @@ -1,6 +1,6 @@ import { useCallback } from 'react'; import { useRouter } from 'next/router'; -import DataTable from 'components/metrics/DataTable'; +import ListTable from 'components/metrics/ListTable'; import useLocale from 'components/hooks/useLocale'; import useCountryNames from 'components/hooks/useCountryNames'; import useMessages from 'components/hooks/useMessages'; @@ -24,7 +24,7 @@ export function RealtimeCountries({ data }) { ); return ( - {filter === FILTER_REFERRERS && ( - )} {filter === FILTER_PAGES && ( -