-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuse-add-update-infraction-env.tsx
39 lines (34 loc) · 1.31 KB
/
use-add-update-infraction-env.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
import { gql, MutationTuple, useMutation } from '@apollo/client'
import { GET_MISSION_TIMELINE } from "../timeline/use-mission-timeline.tsx";
import { GET_ACTION_BY_ID } from "../actions/use-action-by-id.tsx";
import { InfractionByTarget } from "../../../types/infraction-types.ts";
import { useParams } from "react-router-dom";
export const MUTATION_ADD_OR_UPDATE_INFRACTION_ENV = gql`
mutation AddOrUpdateInfractionForEnvTarget($infraction: InfractionWithNewTargetInput!) {
addOrUpdateInfractionForEnvTarget(infraction: $infraction) {
id
controlType
infractionType
natinfs
observations
target {
id
identityControlledPerson
vesselIdentifier
vesselSize
vesselType
}
}
}
`
const useAddOrUpdateInfractionEnv = (): MutationTuple<InfractionByTarget, Record<string, any>> => {
const {missionId, actionId} = useParams()
const mutation = useMutation(MUTATION_ADD_OR_UPDATE_INFRACTION_ENV, {
refetchQueries: [
{query: GET_MISSION_TIMELINE, variables: {missionId}},
{query: GET_ACTION_BY_ID, variables: {id: actionId, missionId}},
]
})
return mutation
}
export default useAddOrUpdateInfractionEnv