diff --git a/frontend/tet/youth/src/components/cookieConsent/CookieConsent.tsx b/frontend/tet/youth/src/components/cookieConsent/CookieConsent.tsx index c87ee32cc0..4205af42ca 100644 --- a/frontend/tet/youth/src/components/cookieConsent/CookieConsent.tsx +++ b/frontend/tet/youth/src/components/cookieConsent/CookieConsent.tsx @@ -47,23 +47,26 @@ const CookieConsent: React.FC<{ asPage?: boolean }> = ({ asPage = false }) => { ], }, language: { onLanguageChange }, - onAllConsentsGiven: (consents) => { + onAllConsentsGiven: (consents: { matomo: boolean }) => { if (consents.matomo) { // start tracking + // eslint-disable-next-line no-underscore-dangle, unicorn/no-array-push-push window._paq.push(['setConsentGiven']); + // eslint-disable-next-line no-underscore-dangle, unicorn/no-array-push-push window._paq.push(['setCookieConsentGiven']); } }, - onConsentsParsed: (consents) => { + onConsentsParsed: (consents: { matomo: boolean }) => { if (consents.matomo === undefined) { // tell matomo to wait for consent: + // eslint-disable-next-line no-underscore-dangle, unicorn/no-array-push-push window._paq.push(['requireConsent']); + // eslint-disable-next-line no-underscore-dangle, unicorn/no-array-push-push window._paq.push(['requireCookieConsent']); } else if (consents.matomo === false) { // tell matomo to forget conset - if (window && window._paq) { - window._paq.push(['forgetConsentGiven']); - } + // eslint-disable-next-line no-underscore-dangle, unicorn/no-array-push-push + window._paq.push(['forgetConsentGiven']); } }, focusTargetSelector: '#main_content', diff --git a/frontend/tet/youth/src/pages/_app.tsx b/frontend/tet/youth/src/pages/_app.tsx index a445cea65c..a1b72368fc 100644 --- a/frontend/tet/youth/src/pages/_app.tsx +++ b/frontend/tet/youth/src/pages/_app.tsx @@ -1,6 +1,8 @@ import 'hds-design-tokens'; +import init from '@socialgouv/matomo-next'; import { AppProps } from 'next/app'; +import dynamic from 'next/dynamic'; import { appWithTranslation } from 'next-i18next'; import React, { useEffect } from 'react'; import { QueryClientProvider } from 'react-query'; @@ -8,8 +10,6 @@ import BaseApp from 'shared/components/app/BaseApp'; // import Footer from 'tet/youth/components/footer/Footer'; import Header from 'tet/youth/components/header/Header'; import createQueryClient from 'tet/youth/query-client/create-query-client'; -import init from '@socialgouv/matomo-next'; -import dynamic from 'next/dynamic'; const CookieConsent = dynamic(() => import('../components/cookieConsent/CookieConsent'), { ssr: false }); // Need to import Footer dynamically because currently HDS has issues with SSR diff --git a/frontend/tet/youth/src/pages/cookie-settings.tsx b/frontend/tet/youth/src/pages/cookie-settings.tsx index ba951c77ec..97bc1b4b1d 100644 --- a/frontend/tet/youth/src/pages/cookie-settings.tsx +++ b/frontend/tet/youth/src/pages/cookie-settings.tsx @@ -2,15 +2,14 @@ import { GetStaticProps, NextPage } from 'next'; import * as React from 'react'; import Container from 'shared/components/container/Container'; import getServerSideTranslations from 'shared/i18n/get-server-side-translations'; + import CookieConsent from '../components/cookieConsent/CookieConsent'; -const CookieSettings: NextPage = () => { - return ( - - - - ); -}; +const CookieSettings: NextPage = () => ( + + + +); export const getStaticProps: GetStaticProps = getServerSideTranslations('common');