From 56376ac0fbca86c8056c12f556446193f1d98a02 Mon Sep 17 00:00:00 2001 From: "Dusan Mijatovic (PC2020)" Date: Tue, 19 Nov 2024 13:36:53 +0100 Subject: [PATCH] feat: remove categories when organisation removed from software or projects --- frontend/components/projects/edit/organisations/index.tsx | 4 ++++ frontend/components/software/edit/organisations/index.tsx | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/components/projects/edit/organisations/index.tsx b/frontend/components/projects/edit/organisations/index.tsx index 91ab12746..4002ebca8 100644 --- a/frontend/components/projects/edit/organisations/index.tsx +++ b/frontend/components/projects/edit/organisations/index.tsx @@ -34,6 +34,7 @@ import useProjectContext from '../useProjectContext' import useParticipatingOrganisations from './useParticipatingOrganisations' import {cfgOrganisations as config} from './config' import ProjectCategoriesDialog from './ProjectCategoriesDialog' +import {removeOrganisationCategoriesFromProject} from './apiProjectOrganisations' export default function ProjectOrganisations() { const {token,user} = useSession() @@ -190,6 +191,9 @@ export default function ProjectOrganisations() { const organisation = organisations[pos] // if it has id if (organisation?.id) { + // remove categories from project - do not wait for result + removeOrganisationCategoriesFromProject(project.id,organisation.id,token) + // remove organisation from project const resp = await deleteOrganisationFromProject({ project: project.id, organisation: organisation.id, diff --git a/frontend/components/software/edit/organisations/index.tsx b/frontend/components/software/edit/organisations/index.tsx index 7ce5db665..6d35f93e2 100644 --- a/frontend/components/software/edit/organisations/index.tsx +++ b/frontend/components/software/edit/organisations/index.tsx @@ -40,6 +40,7 @@ import { deleteOrganisationFromSoftware, patchOrganisationPositions } from './organisationForSoftware' import SoftwareCategoriesDialog from './SoftwareCategoriesDialog' +import {removeOrganisationCategoriesFromSoftware} from './apiSoftwareOrganisations' export type OrganisationModalStates = ModalStates & { categories: T @@ -211,9 +212,12 @@ export default function SoftwareOrganisations() { // get organisation const organisation = organisations[pos] // if it has id - if (organisation?.id) { + if (organisation?.id && software?.id) { + // remove categories from software - do not wait for result + removeOrganisationCategoriesFromSoftware(software?.id, organisation.id, token) + // remove organisation from software const resp = await deleteOrganisationFromSoftware({ - software: software?.id ?? undefined, + software: software?.id, organisation: organisation.id, token })