-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b24e87
commit e5c4f66
Showing
8 changed files
with
160 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Button, Row } from "@amsterdam/design-system-react" | ||
import SubtaskDialog from "./SubtaskDialog/SubtaskDialog" | ||
import { useDialog } from "app/hooks" | ||
|
||
|
||
const AddSubtask: React.FC = () => { | ||
const dialogId = "ams-dialog-add-subtask" | ||
const { openDialog } = useDialog(dialogId) | ||
return ( | ||
<Row align="end"> | ||
<Button | ||
key="id-subtask-add" | ||
onClick={ openDialog } | ||
> | ||
Taak opvoeren | ||
</Button> | ||
<SubtaskDialog id={ dialogId }/> | ||
</Row> | ||
) | ||
} | ||
|
||
export default AddSubtask |
63 changes: 63 additions & 0 deletions
63
src/app/pages/CaseDetailsPage/AddSubtask/SubtaskDialog/SubtaskDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Dialog } from "@amsterdam/design-system-react" | ||
import { useParams } from "react-router-dom" | ||
import { Form, FormActionButtons, SelectField } from "app/components/forms" | ||
import { useCaseProcesses, useCaseProcessesStart } from "app/state/rest" | ||
import { useMemo } from "react" | ||
|
||
type Props = { | ||
id: string | ||
} | ||
|
||
type Value = boolean | string | object | ||
type FormData = Record<string, Value> | ||
|
||
type Option = { | ||
value: string, | ||
label: string | ||
} | ||
|
||
const DEFAULT_OPTION_VALUE = "default_option" | ||
|
||
export const SubtaskDialog: React.FC<Props> = ({ id }) => { | ||
const { caseId } = useParams() | ||
const [data] = useCaseProcesses() | ||
const [, { execPost }] = useCaseProcessesStart(Number(caseId)) | ||
|
||
|
||
const options: Option[] = useMemo(() => { | ||
if (!data) return [] | ||
return data.map(({ id, name }) => ({ value: `${ id }`, label: name })) | ||
}, [data]) | ||
|
||
|
||
const onSubmit = (variables: FormData) => { | ||
if (variables.workflow_option_id === DEFAULT_OPTION_VALUE) { | ||
// No valid option selected. | ||
return | ||
} | ||
|
||
execPost(variables) | ||
.then((resp) => { | ||
console.log("Succes:", resp) | ||
}).catch((err) => { | ||
console.log("Error creating case:", err) | ||
}) | ||
} | ||
|
||
return ( | ||
<Dialog heading="Taak opvoeren" id={ id } > | ||
<Form onSubmit={ onSubmit } formGrid={{ narrow: 4, medium: 6, wide: 10 }}> | ||
<SelectField | ||
name="workflow_option_id" | ||
label="Selecteer een taak" | ||
options={ options } | ||
defaultOption | ||
validation={{ required: true }} | ||
/> | ||
<FormActionButtons okText="Taak opvoeren" onCancel={ Dialog.close } /> | ||
</Form> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export default SubtaskDialog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters