-
Notifications
You must be signed in to change notification settings - Fork 5
/
NewTreasuryGeneration.tsx
57 lines (50 loc) · 1.46 KB
/
NewTreasuryGeneration.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
import type { NewTreasuryGenerationInput } from 'types/graphql'
import { useMutation } from '@redwoodjs/web'
import { toast } from '@redwoodjs/web/toast'
import NewTreasuryGenerationForm from 'src/components/TreasuryGeneration/NewTreasuryGenerationForm/NewTreasuryGenerationForm'
const KICK_OFF_TREASURY_REPORT_GENERATION_MUTATION = gql`
mutation KickOffTreasuryReportGeneration(
$input: NewTreasuryGenerationInput!
) {
kickOffTreasuryReportGeneration(input: $input) {
response
}
}
`
const NewTreasuryGeneration = () => {
const [newTreasuryGeneration, { loading, error }] = useMutation(
KICK_OFF_TREASURY_REPORT_GENERATION_MUTATION,
{
onCompleted: (data) => {
toast.success(
`New Treasury Generation Kicked-off with response ${JSON.stringify(
data
)}`
)
},
onError: (error) => {
toast.error(error.message)
},
}
)
const onSave = (input: NewTreasuryGenerationInput) => {
newTreasuryGeneration({ variables: { input } })
}
return (
<div className="rw-segment">
<header className="rw-segment-header">
<h2 className="rw-heading rw-heading-secondary">
Add Treasury Generation
</h2>
</header>
<div className="rw-segment-main">
<NewTreasuryGenerationForm
onSave={onSave}
loading={loading}
error={error}
/>
</div>
</div>
)
}
export default NewTreasuryGeneration