Skip to content

Commit

Permalink
unused code refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
shyambhongle committed Dec 27, 2024
1 parent 43d3856 commit 9f9021c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion public/assets/images/icons/InterventionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import React from 'react';
import { IconProps } from '../../../../src/features/common/types/common';

function InterventionIcon() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const OtherInterventionInfo = ({
plantLocationInfo.plantedSpecies &&
plantLocationInfo.plantedSpecies.length > 0
? plantLocationInfo.plantedSpecies.reduce(
(sum: any, species: { treeCount: any; }) => sum + species.treeCount,
(sum, species: { treeCount: number }) => sum + species.treeCount,
0
)
: 0;
Expand All @@ -64,7 +64,7 @@ const OtherInterventionInfo = ({
}, [plantLocationInfo?.geometry, plantLocationInfo?.type]);

const sampleInterventionSpeciesImages = useMemo(() => {
if (plantLocationInfo && plantLocationInfo.sampleInterventions.length>0) {
if (plantLocationInfo && plantLocationInfo.sampleInterventions.length > 0) {
const result = plantLocationInfo.sampleInterventions && plantLocationInfo.sampleInterventions.map((item) => {
return {
id: item.coordinates[0].id,
Expand Down
18 changes: 15 additions & 3 deletions src/features/projectsV2/ProjectDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,21 @@ const ProjectDetails = ({
(hoveredPlantLocation?.type === 'multi-tree-registration' ||
selectedPlantLocation?.type === 'multi-tree-registration') &&
!isMobile;
const PLANTATION_TYPES = ['multi-tree-registration', 'single-tree-registration']
const shouldShowOtherIntervention = (hoveredPlantLocation !== null && !PLANTATION_TYPES.includes(hoveredPlantLocation.type)) || (selectedPlantLocation !== null && !PLANTATION_TYPES.includes(selectedPlantLocation.type)) &&
!isMobile;

const PLANTATION_TYPES = ['multi-tree-registration', 'single-tree-registration'] as const;

// Helper function with proper type checking
const isNonPlantationType = (location: PlantLocation | null): boolean => {
return location !== null && !PLANTATION_TYPES.includes(location.type);
};


const shouldShowOtherIntervention = (
isNonPlantationType(hoveredPlantLocation) ||
(isNonPlantationType(selectedPlantLocation) && !isMobile)
);


const shouldShowSinglePlantInfo =
(hoveredPlantLocation?.type === 'single-tree-registration' ||
selectedPlantLocation?.type === 'single-tree-registration' ||
Expand Down

0 comments on commit 9f9021c

Please sign in to comment.