diff --git a/components/country/CountryDetails.js b/components/country/CountryDetails.js index 2bb401bd..0403932c 100644 --- a/components/country/CountryDetails.js +++ b/components/country/CountryDetails.js @@ -1,4 +1,3 @@ -import axios from 'axios' import Flag from 'components/Flag' import { StyledStickySubMenu } from 'components/SharedStyledComponents' import ThirdPartyDataChart from 'components/ThirdPartyDataChart' @@ -10,7 +9,7 @@ import Overview from 'components/country/Overview' import PageNavMenu from 'components/country/PageNavMenu' import WebsitesSection from 'components/country/Websites' import { useRouter } from 'next/router' -import { useCallback, useEffect, useMemo, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' import { useIntl } from 'react-intl' import dayjs from 'services/dayjs' import useScrollPosition from '/hooks/useScrollPosition' @@ -37,15 +36,9 @@ const Header = ({ countryCode, countryName }) => { ) } -const CountryDetails = ({ - countryCode, - overviewStats, - reports, - coverageDataSSR, -}) => { +const CountryDetails = ({ countryCode, overviewStats, reports }) => { const intl = useIntl() const countryName = getLocalisedRegionName(countryCode, intl.locale) - const [newData, setNewData] = useState(false) const router = useRouter() const { query } = router @@ -77,29 +70,6 @@ const CountryDetails = ({ } }, []) - const fetchTestCoverageData = useCallback( - (testGroupList) => { - const fetcher = async (testGroupList) => { - const client = axios.create({ - baseURL: process.env.NEXT_PUBLIC_OONI_API, - }) // eslint-disable-line - const result = await client.get('/api/_/test_coverage', { - params: { - probe_cc: countryCode, - test_groups: testGroupList, - }, - }) - // TODO: Use React.createContext to pass along data and methods - setNewData({ - networkCoverage: result.data.network_coverage, - testCoverage: result.data.test_coverage, - }) - } - fetcher(testGroupList) - }, - [countryCode, setNewData], - ) - // Sync page URL params with changes from form values const onSubmit = ({ since, until }) => { const params = { @@ -117,9 +87,6 @@ const CountryDetails = ({ } } - const { testCoverage, networkCoverage } = - newData !== false ? newData : coverageDataSSR - return ( <>
diff --git a/pages/country/[countryCode].js b/pages/country/[countryCode].js index 8eab14a0..6233993c 100644 --- a/pages/country/[countryCode].js +++ b/pages/country/[countryCode].js @@ -35,22 +35,17 @@ export async function getServerSideProps({ res, query }) { try { const client = axios.create({ baseURL: process.env.NEXT_PUBLIC_OONI_API }) // eslint-disable-line const results = await Promise.all([ - // XXX cc @darkk we should ideally have better dedicated daily dumps for this view - client.get('/api/_/test_coverage', { params: { probe_cc: countryCode } }), client.get('/api/_/country_overview', { params: { probe_cc: countryCode }, }), client.get('https://ooni.org/pageindex.json'), ]) - const testCoverage = results[0].data.test_coverage - const networkCoverage = results[0].data.network_coverage - const overviewStats = results[1].data - const reports = getCountryReports(countryCode, results[2].data) + + const overviewStats = results[0].data + const reports = getCountryReports(countryCode, results[1].data) return { props: { - testCoverage, - networkCoverage, overviewStats, reports, countryCode, @@ -65,13 +60,7 @@ export async function getServerSideProps({ res, query }) { } } -const Country = ({ - countryCode, - overviewStats, - reports, - error, - ...coverageDataSSR -}) => { +const Country = ({ countryCode, overviewStats, reports, error }) => { return ( <> {error ? ( @@ -81,7 +70,6 @@ const Country = ({ countryCode={countryCode} overviewStats={overviewStats} reports={reports} - coverageDataSSR={coverageDataSSR} /> )}