-
Notifications
You must be signed in to change notification settings - Fork 5
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
22bc82d
commit a6803f3
Showing
5 changed files
with
120 additions
and
72 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
...tics-admin/src/pages/release/datablocks/components/chart/ChartBoundaryLevelsModalForm.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,57 @@ | ||
import Button from '@common/components/Button'; | ||
import ButtonGroup from '@common/components/ButtonGroup'; | ||
import FormFieldSelect from '@common/components/form/FormFieldSelect'; | ||
import Modal from '@common/components/Modal'; | ||
import React from 'react'; | ||
import FormProvider from '@common/components/form/FormProvider'; | ||
import { Form } from '@common/components/form'; | ||
import { SelectOption } from '@common/components/form/FormSelect'; | ||
|
||
const formId = 'boundaryLevelPerDataSetForm'; | ||
|
||
interface FormValues { | ||
dataSetBoundaryLevel?: number; | ||
} | ||
|
||
interface Props { | ||
initialValue: FormValues['dataSetBoundaryLevel']; | ||
options: SelectOption[]; | ||
onClose: () => void; | ||
onSubmit: (values: FormValues) => void; | ||
} | ||
|
||
export default function ChartBoundaryLevelModalForm({ | ||
initialValue, | ||
options, | ||
onClose, | ||
onSubmit, | ||
}: Props) { | ||
return ( | ||
<Modal open title="Edit boundary" onExit={onClose}> | ||
<FormProvider | ||
enableReinitialize | ||
initialValues={{ | ||
dataSetBoundaryLevel: initialValue, | ||
}} | ||
> | ||
{() => ( | ||
<Form id={formId} onSubmit={values => onSubmit(values)}> | ||
<FormFieldSelect | ||
label="Boundary level" | ||
hint="Select a version of geographical data to use for this dataset" | ||
name="dataSetBoundaryLevel" | ||
order={[]} | ||
options={options} | ||
/> | ||
<ButtonGroup> | ||
<Button type="submit">Done</Button> | ||
<Button onClick={onClose} variant="secondary"> | ||
Cancel | ||
</Button> | ||
</ButtonGroup> | ||
</Form> | ||
)} | ||
</FormProvider> | ||
</Modal> | ||
); | ||
} |
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