Skip to content

Commit

Permalink
passes filters to plot geometries hook
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez authored and davidsingal committed Mar 18, 2024
1 parent 12f570c commit 2342765
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
22 changes: 18 additions & 4 deletions client/src/containers/analysis-eudr/map/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Map from 'react-map-gl/maplibre';
import { MapView } from '@deck.gl/core/typed';
import { TileLayer } from '@deck.gl/geo-layers/typed';
import { CartoLayer, setDefaultCredentials, MAP_TYPES, API_VERSIONS } from '@deck.gl/carto/typed';
import { useParams } from 'next/navigation';

import ZoomControl from './zoom';
import LegendControl from './legend';
Expand Down Expand Up @@ -32,14 +33,27 @@ setDefaultCredentials({
});

const EUDRMap = () => {
const { basemap, planetCompare, supplierLayer, contextualLayers } = useAppSelector(
(state) => state.eudr,
);
const {
basemap,
planetCompare,
supplierLayer,
contextualLayers,
filters: { suppliers, materials, origins, plots },
} = useAppSelector((state) => state.eudr);

const [hoverInfo, setHoverInfo] = useState<PickingInfo>(null);
const [viewState, setViewState] = useState<MapViewState>(DEFAULT_VIEW_STATE);

const plotGeometries = usePlotGeometries();
const params = useParams();

const plotGeometries = usePlotGeometries({
producerIds: params?.supplierId
? [params.supplierId as string]
: suppliers?.map(({ value }) => value),
materialIds: materials?.map(({ value }) => value),
originIds: origins?.map(({ value }) => value),
geoRegionIds: plots?.map(({ value }) => value),
});

// Supplier plot layer
const layer: GeoJsonLayer = new GeoJsonLayer({
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/eudr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const useEUDRSuppliers = <T = Supplier[]>(

export const usePlotGeometries = <T = Supplier[]>(
params?: {
producersIds: string[];
originsId: string[];
materialsId: string[];
producerIds: string[];
originIds: string[];
materialIds: string[];
geoRegionIds: string[];
},
options: UseQueryOptions<Supplier[], unknown, T> = {},
Expand Down

0 comments on commit 2342765

Please sign in to comment.