Skip to content

Commit

Permalink
86833
Browse files Browse the repository at this point in the history
  • Loading branch information
remyvdwereld committed Jul 12, 2023
1 parent fd8142a commit 5dce2ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/app/components/case/forms/SummonForm/SummonForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { FormTitle } from "@amsterdam/asc-ui"

import { useCase, useSummons, useSummonTypes } from "app/state/rest/"
import { useSummons, useSummonTypesByTaskId } from "app/state/rest/"
import WorkflowForm from "app/components/case/WorkflowForm/WorkflowForm"
import scaffold from "app/components/case/forms/SummonForm/scaffold"
import useScaffoldedFields from "app/components/shared/ConfirmScaffoldForm/hooks/useScaffoldedFields"
Expand Down Expand Up @@ -52,12 +52,9 @@ const mapData = (data: SummonData) => {
}

const SummonForm: React.FC<Props> = ({ id, caseUserTaskId }) => {

const themeId = useCase(id)[0]?.theme.id
const [data] = useSummonTypes(themeId)
const [data] = useSummonTypesByTaskId(caseUserTaskId)
const summonTypes = data?.results
const summonTypesWithoutBoete = summonTypes?.filter((summonType) => summonType.workflow_option !== "besluit")
const fields = useScaffoldedFields(scaffold, id, summonTypesWithoutBoete)
const fields = useScaffoldedFields(scaffold, id, summonTypes)
const [, { execPost }] = useSummons({ lazy: true })

return (
Expand Down
12 changes: 12 additions & 0 deletions src/app/state/rest/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,15 @@ export const useTaskNames = (role: string) => {
isProtected: true
})
}

// useSummonTypes for getting the available summonTypes for a specific task
export const useSummonTypesByTaskId = (id: number | string, options?: Options) => {
const handleError = useErrorHandler()
return useApiRequest<Components.Schemas.PaginatedSummonTypeList>({
...options,
url: makeApiUrl("tasks", id, "summon-types"),
groupName: "task",
handleError,
isProtected: true
})
}

0 comments on commit 5dce2ec

Please sign in to comment.