diff --git a/package.json b/package.json index 36b72ea5e..90252988d 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "engines": { "node": "~18", - "yarn": "3.5.0" + "yarn": "3.6.0" }, "dependencies": { "@artsy/fresnel": "6.1.0", @@ -114,5 +114,5 @@ "husky": { "pre-commit": "yarn lint" }, - "packageManager": "yarn@3.5.0" + "packageManager": "yarn@3.6.0" } diff --git a/src/components/contextual/contextual-basemaps.tsx b/src/components/contextual/contextual-basemaps.tsx index 7c28b571a..130309fb2 100644 --- a/src/components/contextual/contextual-basemaps.tsx +++ b/src/components/contextual/contextual-basemaps.tsx @@ -16,13 +16,14 @@ import type { ContextualBasemapsId } from 'types/widget'; const BasemapsMapSettings = () => { const [activeLayers, setActiveLayers] = useRecoilState(activeLayersAtom); - const defaultActive = activeLayers.find((layer) => layer.id.includes('planet'))?.id || 'no-layer'; + const defaultActive = + activeLayers?.find((layer) => layer.id.includes('planet'))?.id || 'no-layer'; const [isActive, setIsActive] = useState(defaultActive); const handleClick = useCallback( (id) => { setIsActive(id); - const noPlanetLayers = activeLayers.filter((w) => !w.id.includes('planet_medres')); + const noPlanetLayers = activeLayers?.filter((w) => !w.id.includes('planet_medres')); const layersUpdate = id === 'no-layer' ? noPlanetLayers diff --git a/src/components/contextual/hi-res-extent-basemap.tsx b/src/components/contextual/hi-res-extent-basemap.tsx index 892c201ad..f7f903ec1 100644 --- a/src/components/contextual/hi-res-extent-basemap.tsx +++ b/src/components/contextual/hi-res-extent-basemap.tsx @@ -16,7 +16,7 @@ import type { ContextualBasemapsId } from 'types/widget'; const HighResolutionExtentBasemap = () => { const [activeLayers, setActiveLayers] = useRecoilState(activeLayersAtom); const defaultActive = - activeLayers.find((layer) => layer.id === 'hi-res-extent')?.id || 'no-layer'; + activeLayers?.find((layer) => layer.id === 'hi-res-extent')?.id || 'no-layer'; const [isActive, setIsActive] = useState(defaultActive); const handleClick = useCallback( @@ -24,7 +24,7 @@ const HighResolutionExtentBasemap = () => { setIsActive(id); const layersUpdate = id === 'no-layer' - ? activeLayers.filter((w) => w.id !== 'hi-res-extent') + ? activeLayers?.filter((w) => w.id !== 'hi-res-extent') : ([ ...activeLayers, { diff --git a/src/components/highlighted-places/index.tsx b/src/components/highlighted-places/index.tsx index 49728fd7a..4abf19c50 100644 --- a/src/components/highlighted-places/index.tsx +++ b/src/components/highlighted-places/index.tsx @@ -17,7 +17,7 @@ const HighlightedPlaces = ({ onSelectLocation }: { onSelectLocation: () => void const { query: { params }, } = useRouter(); - const locationType = params?.[0] as LocationTypes; + const locationType = (params?.[0] || 'worldwide') as LocationTypes; const id = params?.[1]; const { diff --git a/src/components/planet-date-select/index.tsx b/src/components/planet-date-select/index.tsx index eda81159c..9ed515101 100644 --- a/src/components/planet-date-select/index.tsx +++ b/src/components/planet-date-select/index.tsx @@ -33,7 +33,7 @@ const DateSelect = ({ const { data: dates } = useMosaicsFromSeriesPlanetSatelliteBasemaps(mosaic_id); const [activeLayers, setActiveLayers] = useRecoilState(activeLayersAtom); const layerToUpdate = useMemo( - () => activeLayers.find((layer) => layer.id === id), + () => activeLayers?.find((layer) => layer.id === id), [activeLayers] ); @@ -49,7 +49,7 @@ const DateSelect = ({ const handleDate = useCallback( (e) => { - const filteredLayers = activeLayers.filter((l) => l.id !== id); + const filteredLayers = activeLayers?.filter((l) => l.id !== id); if (!!layerToUpdate) { setActiveLayers([ { diff --git a/src/components/suggested-layers/index.tsx b/src/components/suggested-layers/index.tsx index f55f7d4fb..16ab8ec19 100644 --- a/src/components/suggested-layers/index.tsx +++ b/src/components/suggested-layers/index.tsx @@ -35,12 +35,12 @@ const SuggestedLayers = ({ }: SuggestionTypes) => { const Info = INFO[id]; const [activeLayers, setActiveLayers] = useRecoilState(activeLayersAtom); - const activeLayersIds = activeLayers.map((l) => l.id); - const isActive = useMemo(() => activeLayersIds.includes(id), [activeLayersIds, id]); + const activeLayersIds = activeLayers?.map((l) => l.id); + const isActive = useMemo(() => activeLayersIds?.includes(id), [activeLayersIds, id]); const handleClick = useCallback(() => { const layersUpdate = isActive - ? activeLayers.filter((w) => w.id !== id) + ? activeLayers?.filter((w) => w.id !== id) : ([{ id, opacity: '1', visibility: 'visible' }, ...activeLayers] as ActiveLayers[]); setActiveLayers(layersUpdate); }, [isActive, activeLayers, setActiveLayers, id]); diff --git a/src/components/widget-controls/index.tsx b/src/components/widget-controls/index.tsx index c35d3e269..a252761d2 100644 --- a/src/components/widget-controls/index.tsx +++ b/src/components/widget-controls/index.tsx @@ -35,11 +35,11 @@ const WidgetControls = ({ id, content }: WidgetControlsType) => { const locationTool = useRecoilValue(locationToolAtom); const [activeLayers, setActiveLayers] = useRecoilState(activeLayersAtom); - const activeLayersIds = activeLayers.map((l) => l.id); + const activeLayersIds = activeLayers?.map((l) => l.id); const isActive = useMemo(() => { // Check if the id is included in activeLayersIds - const isCurrentlyActive = activeLayersIds.includes(id); + const isCurrentlyActive = activeLayersIds?.includes(id); // Check if any id in activeLayersIds starts with 'national_dashboard' const isAnyActiveNationalDashboard = @@ -64,7 +64,7 @@ const WidgetControls = ({ id, content }: WidgetControlsType) => { setActiveLayers(layersUpdate); }, [isActive, activeLayers, setActiveLayers, id]); - const HELPER_ID = id === activeLayers[0]?.id; + const HELPER_ID = id === activeLayers?.[0]?.id; const showDownloadInfoHelpers = !isMapSettingsOpen && HELPER_ID && (locationTool === 'worldwide' || locationTool === 'search'); diff --git a/src/containers/categories-menu/index.tsx b/src/containers/categories-menu/index.tsx index cf458b8fc..90a19f387 100644 --- a/src/containers/categories-menu/index.tsx +++ b/src/containers/categories-menu/index.tsx @@ -34,7 +34,7 @@ const Category = () => { const activeWidgetsIds = widgetsFiltered.map((widget) => widget.slug); const activeLayersIds: ActiveLayers[] = LAYERS_BY_CATEGORY[ event.currentTarget.value as string - ].map((id) => ({ + ]?.map((id) => ({ id: id as WidgetSlugType | ContextualBasemapsId | 'custom-area', opacity: '1', visibility: 'visible', @@ -50,45 +50,48 @@ const Category = () => {
presets
{activeLayers.length}
} + {!mapView &&{activeLayers?.length}
}