-
Notifications
You must be signed in to change notification settings - Fork 5
/
NewTreasuryGenerationForm.tsx
65 lines (57 loc) · 1.69 KB
/
NewTreasuryGenerationForm.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Button } from 'react-bootstrap'
import { useForm, UseFormReturn } from 'react-hook-form'
import { Form, Label, TextAreaField, Submit } from '@redwoodjs/forms'
import type { RWGqlError } from '@redwoodjs/forms'
interface CreateNewTreasuryGenerationInput {
payload: string
}
interface NewOrganizationFormProps {
onSave: (data: CreateNewTreasuryGenerationInput) => void
error: RWGqlError
loading: boolean
}
/*
This form collects any payload information to kick-off a lambda function to generate a treasury file.
*/
const NewTreasuryGenerationForm = (props: NewOrganizationFormProps) => {
const { onSave, error, loading } = props
const formMethods: UseFormReturn = useForm()
const hasErrors = Object.keys(formMethods.formState.errors).length > 0
const onReset = () => {
formMethods.reset()
}
return (
<Form
onSubmit={({ payload }) => onSave({ payload })}
formMethods={formMethods}
error={error}
className={hasErrors ? 'was-validated' : ''}
>
<Label
name="payload"
className="rw-label"
errorClassName="rw-label rw-label-error"
>
Generation Payload
</Label>
<TextAreaField
name="payload"
className="rw-input"
errorClassName="rw-input rw-input-error"
rows={5}
/>
<br />
<div className="row">
<div className="offset-3 col-sm-6">
<Submit disabled={loading} className="btn btn-primary me-2">
Kick-off File Generation
</Submit>
<Button onClick={onReset} className="btn btn-secondary">
Reset
</Button>
</div>
</div>
</Form>
)
}
export default NewTreasuryGenerationForm