From 27e08df2e83073a4c2adcf4598a224aeb775734e Mon Sep 17 00:00:00 2001 From: Brianna Cerkiewicz Date: Thu, 5 May 2022 12:59:07 -0600 Subject: [PATCH] feat: make addReportingRequirementToRevision mutation --- .../addReportingRequirementToRevision.ts.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/mutations/ProjectReportingRequirement/addReportingRequirementToRevision.ts.ts diff --git a/app/mutations/ProjectReportingRequirement/addReportingRequirementToRevision.ts.ts b/app/mutations/ProjectReportingRequirement/addReportingRequirementToRevision.ts.ts new file mode 100644 index 0000000000..435ab8b5f1 --- /dev/null +++ b/app/mutations/ProjectReportingRequirement/addReportingRequirementToRevision.ts.ts @@ -0,0 +1,40 @@ +import { graphql } from "react-relay"; +import useMutationWithErrorMessage from "mutations/useMutationWithErrorMessage"; +import { addReportingRequirementToRevisionMutation } from "__generated__/addReportingRequirementToRevisionMutation.graphql"; + +export const mutation = graphql` + mutation addReportingRequirementToRevisionMutation( + $connections: [ID!]! + $projectRevisionId: Int! + $newFormData: JSON! + ) { + createFormChange( + input: { + formDataSchemaName: "cif" + formDataTableName: "reporting_requirement" + jsonSchemaName: "reporting_requirement" + operation: CREATE + projectRevisionId: $projectRevisionId + newFormData: $newFormData + } + ) { + formChangeEdge @appendEdge(connections: $connections) { + cursor + node { + id + newFormData + projectRevisionByProjectRevisionId { + ...ProjectQuarterlyReportsForm_projectRevision + ...TaskList_projectRevision + } + } + } + } + } +`; + +export const useAddReportingRequirementToRevision = () => + useMutationWithErrorMessage( + mutation, + () => "An error occurred while attempting to create the project revision." + );