Skip to content

Commit

Permalink
non split other features
Browse files Browse the repository at this point in the history
  • Loading branch information
anamontiaga committed Dec 12, 2023
1 parent 8728555 commit 7c102fc
Showing 1 changed file with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback, useRef, useState } from 'react';

import { Form as FormRFF, Field as FieldRFF, FormProps } from 'react-final-form';
import { QueryClient, useQueryClient } from 'react-query';

import { useRouter } from 'next/router';

Expand Down Expand Up @@ -33,6 +34,7 @@ const SplitModal = ({
handleModal: (modalKey: 'edit' | 'split', isVisible: boolean) => void;
onSplitFeature?: (featureId: Feature['id']) => void;
}): JSX.Element => {
const queryClient = useQueryClient();
const { query } = useRouter();
const { pid, sid } = query as { pid: string; sid: string };

Expand Down Expand Up @@ -90,30 +92,50 @@ const SplitModal = ({
data: {
status: 'draft',
features: selectedFeaturesQuery.data.map((sf) => {
return {
featureId: sf.id,
kind: 'withGeoprocessing',
geoprocessingOperations: [
{
kind: 'split/v1',
splitByProperty: splitOption,
splits: splitFeaturesSelected.map((fts) => {
return {
value: fts.id,
marxanSettings: {
fpf: 1,
prop: 0.5,
},
};
}),
},
],
};
if (sf.id === featureId) {
return {
featureId: sf.id,
kind: 'withGeoprocessing',
geoprocessingOperations: [
{
kind: 'split/v1',
splitByProperty: splitOption,
splits: splitFeaturesSelected.map((fts) => {
return {
value: fts.id,
marxanSettings: {
fpf: 1,
prop: 0.5,
},
};
}),
},
],
};
}
if (sf.id !== featureId) {
const {
metadata,
id,
name,
description,
amountRange,
color,
splitOptions,
splitSelected,
splitFeaturesSelected,
splitFeaturesOptions,
intersectFeaturesSelected,
...sfRest
} = sf;
return sfRest;
}
}),
},
},
{
onSuccess: () => {
queryClient.invalidateQueries(['selected-features', sid]);
handleModal('split', false);
},
onError: () => {},
Expand Down

0 comments on commit 7c102fc

Please sign in to comment.