From e193300b739e4f04c5a5764b098bac0a51846ce3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Prod=27homme?= Date: Fri, 18 Oct 2024 10:16:22 +0200 Subject: [PATCH] SKY30-495 - Info about terrestrial protected area --- .../terrestrial-data-disclaimer-dialog.tsx | 13 ++++++--- .../src/containers/homepage/intro/index.tsx | 15 ++++++++++- .../homepage/intro/sidebar-item/index.tsx | 27 ++++++++++++++++--- frontend/translations/en.json | 3 ++- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/terrestrial-data-disclaimer-dialog.tsx b/frontend/src/components/terrestrial-data-disclaimer-dialog.tsx index 34125427..be4c8564 100644 --- a/frontend/src/components/terrestrial-data-disclaimer-dialog.tsx +++ b/frontend/src/components/terrestrial-data-disclaimer-dialog.tsx @@ -13,10 +13,15 @@ import { import Icon from '@/components/ui/icon'; import { terrestrialDataDisclaimerDialogAtom } from '@/containers/map/store'; import Notification from '@/styles/icons/notification.svg'; +import { FCWithMessages } from '@/types'; -interface TerrestrialDataDisclaimerDialogProps {} +interface TerrestrialDataDisclaimerDialogProps { + onClose?: () => void; +} -const TerrestrialDataDisclaimerDialog = ({}: TerrestrialDataDisclaimerDialogProps) => { +const TerrestrialDataDisclaimerDialog: FCWithMessages = ({ + onClose, +}) => { const t = useTranslations('pages.progress-tracker'); const [, setOpen] = useAtom(terrestrialDataDisclaimerDialogAtom); @@ -39,7 +44,7 @@ const TerrestrialDataDisclaimerDialog = ({}: TerrestrialDataDisclaimerDialogProp @@ -49,4 +54,6 @@ const TerrestrialDataDisclaimerDialog = ({}: TerrestrialDataDisclaimerDialogProp ); }; +TerrestrialDataDisclaimerDialog.messages = ['pages.progress-tracker']; + export default TerrestrialDataDisclaimerDialog; diff --git a/frontend/src/containers/homepage/intro/index.tsx b/frontend/src/containers/homepage/intro/index.tsx index bc897779..f785aca2 100644 --- a/frontend/src/containers/homepage/intro/index.tsx +++ b/frontend/src/containers/homepage/intro/index.tsx @@ -1,7 +1,10 @@ +import { useState } from 'react'; + import Image from 'next/image'; import { useLocale, useTranslations } from 'next-intl'; +import TerrestrialDataDisclaimerDialog from '@/components/terrestrial-data-disclaimer-dialog'; import Icon from '@/components/ui/icon'; import SidebarItem from '@/containers/homepage/intro/sidebar-item'; import { formatPercentage } from '@/lib/utils/formats'; @@ -17,6 +20,8 @@ const Intro: FCWithMessages = ({ onScrollClick }) => { const t = useTranslations('containers.homepage-intro'); const locale = useLocale(); + const [openDisclaimer, setOpenDisclaimer] = useState(false); + const { data: protectionStatsData } = useGetProtectionCoverageStats<{ marine?: string; terrestrial?: string; @@ -117,7 +122,11 @@ const Intro: FCWithMessages = ({ onScrollClick }) => { percentage={protectionStatsData.terrestrial} text={t('current-total-protected-area')} icon="icon2" + onClickInfoButton={() => setOpenDisclaimer(true)} /> + {openDisclaimer && ( + setOpenDisclaimer(false)} /> + )}
+ )} +