Skip to content

Commit

Permalink
add correct check for circle type
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Apr 11, 2024
1 parent b641a83 commit b34455c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ConfirmationModal: FC<ConfirmationModalProps> = (props) => {
const { isOpen, onClose, governanceId } = props;
const { notify } = useNotification();
const {
values: { advancedSettings },
values: { advancedSettings, initialAdvancedSettings },
} = useFormikContext<IntermediateCreateProjectPayload>();
const [isUpdatePreviewLoading, setIsUpdatePreviewLoading] = useState(true);
const [isCirclesUpdateLoading, setIsCirclesUpdateLoading] = useState(false);
Expand All @@ -40,7 +40,12 @@ const ConfirmationModal: FC<ConfirmationModalProps> = (props) => {
try {
setIsCirclesUpdateLoading(true);
await GovernanceService.updateCircles(
generatePreviewPayload(governanceId, permissionGovernanceId, circles),
generatePreviewPayload(
governanceId,
permissionGovernanceId,
circles,
initialAdvancedSettings?.circles,
),
);
notify("Changes are successfully applied");
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const generatePreviewPayload = (
governanceId: string,
permissionGovernanceId: string,
circles: InheritedCircleIntermediate[],
initialCircles: InheritedCircleIntermediate[] = [],
): PreviewCirclesUpdatePayload => {
const circlesForPayload: PreviewCirclesUpdateCircles[] = circles
.filter((circle) => circle.selected)
Expand All @@ -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 &&
Expand Down

0 comments on commit b34455c

Please sign in to comment.