Skip to content

Commit

Permalink
feat: remove categories when organisation removed from software or pr…
Browse files Browse the repository at this point in the history
…ojects
  • Loading branch information
dmijatovic committed Nov 19, 2024
1 parent 5682177 commit 56376ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/components/projects/edit/organisations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions frontend/components/software/edit/organisations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
deleteOrganisationFromSoftware, patchOrganisationPositions
} from './organisationForSoftware'
import SoftwareCategoriesDialog from './SoftwareCategoriesDialog'
import {removeOrganisationCategoriesFromSoftware} from './apiSoftwareOrganisations'

export type OrganisationModalStates<T> = ModalStates<T> & {
categories: T
Expand Down Expand Up @@ -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
})
Expand Down

0 comments on commit 56376ac

Please sign in to comment.