diff --git a/src/features/projectsV2/ProjectsMap/InterventionDropDown/InterventionList.tsx b/src/features/projectsV2/ProjectsMap/InterventionDropDown/InterventionList.tsx index 51f574316..085baa0c2 100644 --- a/src/features/projectsV2/ProjectsMap/InterventionDropDown/InterventionList.tsx +++ b/src/features/projectsV2/ProjectsMap/InterventionDropDown/InterventionList.tsx @@ -15,13 +15,15 @@ interface InterventionListProps { setIsMenuOpen: SetState; selectedInterventionData: InterventionData | undefined; hasProjectSites?: boolean + existingIntervention: string[] } const InterventionList = ({ interventionList, setSelectedInterventionType, setIsMenuOpen, selectedInterventionData, - hasProjectSites + hasProjectSites, + existingIntervention }: InterventionListProps) => { const tProjectDetails = useTranslations("ProjectDetails.intervention"); const handleFilterSelection = (key: INTERVENTION_TYPE) => { @@ -29,21 +31,35 @@ const InterventionList = ({ setSelectedInterventionType(key); }; + const shouldRenderIntervention = (interventionValue: string) => { + const showAllIntervention = interventionValue === 'all'; + const showExisitingIntervention = existingIntervention.includes(interventionValue); + if (showAllIntervention && existingIntervention.length === 1) { + return false; + } + return showExisitingIntervention || showAllIntervention; + }; + + + return ( -