diff --git a/site/scripts/fetch-stats.js b/site/scripts/fetch-stats.js index a547df5d9..d6ce9ee37 100644 --- a/site/scripts/fetch-stats.js +++ b/site/scripts/fetch-stats.js @@ -275,11 +275,6 @@ async function main() { // token isn't valid) we fallback to some fake data -- it would be better to // have a static ressource accessible without authentification. writeInDataDir('stats.json', { - visitesJours: [], - visitesMois: { - pages: [], - }, - satisfaction: [], retoursUtilisateurs: { open: [], closed: [], diff --git a/site/source/components/search/SearchRulesAndSimulators.tsx b/site/source/components/search/SearchRulesAndSimulators.tsx index 380750064..9b5d0c2dc 100644 --- a/site/source/components/search/SearchRulesAndSimulators.tsx +++ b/site/source/components/search/SearchRulesAndSimulators.tsx @@ -2,11 +2,11 @@ import algoliasearch from 'algoliasearch/lite' import { Spacing } from '@/design-system/layout' import { useEffect } from 'react' import { Configure, Index } from 'react-instantsearch-dom' -import { useHistory } from 'react-router' import { RulesInfiniteHits } from './RulesInfiniteHits' import { SearchBox } from './SearchBox' import { SearchRoot } from './SearchRoot' import { SimulatorHits } from './SimulatorHits' +import { useLocation } from 'react-router-dom-v5-compat' const ALGOLIA_APP_ID = import.meta.env.VITE_ALGOLIA_APP_ID || '' const ALGOLIA_SEARCH_KEY = import.meta.env.VITE_ALGOLIA_SEARCH_KEY || '' @@ -19,13 +19,8 @@ interface Props { } export default function SearchRulesAndSimulators({ closePopover }: Props) { - const history = useHistory() - - useEffect(() => { - const unlisten = history.listen(closePopover) - - return unlisten - }, [closePopover, history]) + const location = useLocation() + useEffect(() => closePopover(), [location]) return ( - - - {' '} - - } - footnote={`${currentMonthSatisfaction.total} avis ce mois ci`} - /> - + {currentMonthSatisfaction.total > 0 && ( + + + {' '} + + } + footnote={`${currentMonthSatisfaction.total} avis ce mois ci`} + /> + + )} diff --git a/site/source/pages/Stats/Stats.tsx b/site/source/pages/Stats/Stats.tsx index 9a1bd0029..114e6abcc 100644 --- a/site/source/pages/Stats/Stats.tsx +++ b/site/source/pages/Stats/Stats.tsx @@ -29,7 +29,7 @@ type Period = 'mois' | 'jours' type Chapter2 = PageChapter2 | 'PAM' const chapters2: Chapter2[] = [ - ...new Set(stats.visitesMois.pages.map((p) => p.page_chapter2)), + ...new Set(stats.visitesMois?.pages.map((p) => p.page_chapter2)), 'PAM', ] @@ -301,10 +301,18 @@ const Indicators = styled.div` ` export default function Stats() { + const statsAvailable = stats.visitesMois !== undefined + return ( <> - - + {statsAvailable ? ( + <> + + + + ) : ( +

Statistiques indisponibles.

+ )} diff --git a/site/source/pages/integration/Iframe.tsx b/site/source/pages/integration/Iframe.tsx index 46534a04b..575d049e7 100644 --- a/site/source/pages/integration/Iframe.tsx +++ b/site/source/pages/integration/Iframe.tsx @@ -14,7 +14,7 @@ import urssafLogo from '@/images/Urssaf.svg' import { lazy, Suspense, useContext, useEffect, useRef, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { Route } from 'react-router' -import { MemoryRouter } from 'react-router-dom' +import { MemoryRouter, useSearchParams } from 'react-router-dom-v5-compat' import styled from 'styled-components' import { TrackingContext, TrackPage } from '../../ATInternetTracking' import { hexToHSL } from '../../hexToHSL' @@ -28,7 +28,6 @@ import './iframe.css' import cciLogo from './images/cci.png' import minTraLogo from './images/min-tra.jpg' import poleEmploiLogo from './images/pole-emploi.png' -import { useSearchParams } from 'react-router-dom-v5-compat' const LazyColorPicker = lazy(() => import('../Dev/ColorPicker'))