diff --git a/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/ConfirmationModal.tsx b/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/ConfirmationModal.tsx index c82da38f9..2d4e77d1b 100644 --- a/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/ConfirmationModal.tsx +++ b/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/ConfirmationModal.tsx @@ -21,7 +21,7 @@ const ConfirmationModal: FC = (props) => { const { isOpen, onClose, governanceId } = props; const { notify } = useNotification(); const { - values: { advancedSettings }, + values: { advancedSettings, initialAdvancedSettings }, } = useFormikContext(); const [isUpdatePreviewLoading, setIsUpdatePreviewLoading] = useState(true); const [isCirclesUpdateLoading, setIsCirclesUpdateLoading] = useState(false); @@ -40,7 +40,12 @@ const ConfirmationModal: FC = (props) => { try { setIsCirclesUpdateLoading(true); await GovernanceService.updateCircles( - generatePreviewPayload(governanceId, permissionGovernanceId, circles), + generatePreviewPayload( + governanceId, + permissionGovernanceId, + circles, + initialAdvancedSettings?.circles, + ), ); notify("Changes are successfully applied"); } catch (err) { diff --git a/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/utils/generatePreviewPayload.ts b/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/utils/generatePreviewPayload.ts index 4fe8eb843..3cc7d9cff 100644 --- a/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/utils/generatePreviewPayload.ts +++ b/src/shared/components/Form/Formik/AdvancedSettings/components/ConfirmationModal/utils/generatePreviewPayload.ts @@ -8,6 +8,7 @@ export const generatePreviewPayload = ( governanceId: string, permissionGovernanceId: string, circles: InheritedCircleIntermediate[], + initialCircles: InheritedCircleIntermediate[] = [], ): PreviewCirclesUpdatePayload => { const circlesForPayload: PreviewCirclesUpdateCircles[] = circles .filter((circle) => circle.selected) @@ -17,9 +18,12 @@ export const generatePreviewPayload = ( } const { inheritFrom } = circle; + const isExistingCircle = initialCircles.some( + (initialCircle) => initialCircle.circleId === circle.circleId, + ); return { - type: "existing", + type: isExistingCircle ? "existing" : "new", circleId: circle.circleId, ...(circle.synced && inheritFrom?.governanceId &&