Skip to content

Commit

Permalink
clean up selection and onSelectionChange
Browse files Browse the repository at this point in the history
  • Loading branch information
buckhalt committed Dec 17, 2024
1 parent 266def4 commit 5d49cb6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/interviewer/containers/Interfaces/Geospatial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ export default function GeospatialInterface({
tokenId,
getAssetUrl,
initialSelectionValue,
onSelectionChange: (selection: unknown) => {
onSelectionChange: (value: string) => {
if (currentPrompt && stageNodes[navState.activeIndex]) {
updateNode(
stageNodes[navState.activeIndex][entityPrimaryKeyProperty],
{},
{
[currentPrompt.variable]: selection,
[currentPrompt.variable]: value,
},
);
}
Expand Down
12 changes: 7 additions & 5 deletions lib/interviewer/hooks/useMapbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type UseMapboxProps = {
tokenId: string;
getAssetUrl: (url: string) => string;
initialSelectionValue?: string;
onSelectionChange: (value: string | null) => void;
onSelectionChange: (value: string) => void;
};

const useMapboxToken = (tokenId: string) => {
Expand Down Expand Up @@ -206,17 +206,19 @@ export const useMapbox = ({
const feature = e.features[0];
const propToSelect = selectionLayer.filter;

const selected = feature?.properties
? feature.properties[propToSelect]
const selected: string | null = feature?.properties
? (feature.properties[propToSelect] as string)
: null;

onSelectionChange(selected);
if (selected !== null) {
onSelectionChange(selected);
}

if (selectionLayer && mapInstance) {
mapInstance.setFilter(selectionLayer.id, [
'==',
selectionLayer.filter,
selected,
selected ?? '',
]);
}
};
Expand Down

0 comments on commit 5d49cb6

Please sign in to comment.