diff --git a/src/data/mock/readonly.ts b/src/data/mock/readonly.ts index aa0f3892ca..e22a8c1ac9 100644 --- a/src/data/mock/readonly.ts +++ b/src/data/mock/readonly.ts @@ -35,6 +35,7 @@ import { GetAllParticipantsAndProvidersQuery, GetAllPaymentsDocument, GetAllPaymentsQuery, + GetModelCollaboratorsDocument, KeyCharacteristic, ModelCategory, ModelLearningSystemType, @@ -66,9 +67,8 @@ import { YesNoOtherType, YesNoType } from 'gql/gen/graphql'; +import { GetModelCollaborators_modelPlan_collaborators as GetModelCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; -import GetModelPlanCollaborators from 'queries/Collaborators/GetModelCollaborators'; -import { GetModelCollaborators_modelPlan_collaborators as GetModelCollaboratorsType } from 'queries/Collaborators/types/GetModelCollaborators'; import GetOperationalNeeds from 'queries/ITSolutions/GetOperationalNeeds'; import { GetOperationalNeeds as GetOperationalNeedsType } from 'queries/ITSolutions/types/GetOperationalNeeds'; import GetModelSummary from 'queries/ReadOnly/GetModelSummary'; @@ -753,7 +753,7 @@ const collaboratorsData: GetModelCollaboratorsType[] = [ export const collaboratorsMocks = [ { request: { - query: GetModelPlanCollaborators, + query: GetModelCollaboratorsDocument, variables: { id: modelID } }, result: { diff --git a/src/queries/Collaborators/CreateModelPlanCollaborator.ts b/src/gql/apolloGQL/Collaborators/CreateModelPlanCollaborator.ts similarity index 88% rename from src/queries/Collaborators/CreateModelPlanCollaborator.ts rename to src/gql/apolloGQL/Collaborators/CreateModelPlanCollaborator.ts index ca03013976..2bfc39420c 100644 --- a/src/queries/Collaborators/CreateModelPlanCollaborator.ts +++ b/src/gql/apolloGQL/Collaborators/CreateModelPlanCollaborator.ts @@ -1,6 +1,6 @@ import { gql } from '@apollo/client'; -export default gql` +export default gql(/* GraphQL */ ` mutation CreateModelPlanCollaborator($input: PlanCollaboratorCreateInput!) { createPlanCollaborator(input: $input) { teamRoles @@ -13,4 +13,4 @@ export default gql` modelPlanID } } -`; +`); diff --git a/src/queries/Collaborators/DeleteModelPlanCollaborator.ts b/src/gql/apolloGQL/Collaborators/DeleteModelPlanCollaborator.ts similarity index 87% rename from src/queries/Collaborators/DeleteModelPlanCollaborator.ts rename to src/gql/apolloGQL/Collaborators/DeleteModelPlanCollaborator.ts index 43e3dcfabc..4d6ead1333 100644 --- a/src/queries/Collaborators/DeleteModelPlanCollaborator.ts +++ b/src/gql/apolloGQL/Collaborators/DeleteModelPlanCollaborator.ts @@ -1,6 +1,6 @@ import { gql } from '@apollo/client'; -export default gql` +export default gql(/* GraphQL */ ` mutation DeleteModelPlanCollaborator($id: UUID!) { deletePlanCollaborator(id: $id) { id @@ -15,4 +15,4 @@ export default gql` modelPlanID } } -`; +`); diff --git a/src/queries/Collaborators/GetModelPlanCollaborator.ts b/src/gql/apolloGQL/Collaborators/GetIndividualModelPlanCollaborator.ts similarity index 68% rename from src/queries/Collaborators/GetModelPlanCollaborator.ts rename to src/gql/apolloGQL/Collaborators/GetIndividualModelPlanCollaborator.ts index fc1d3f836b..c721ee436f 100644 --- a/src/queries/Collaborators/GetModelPlanCollaborator.ts +++ b/src/gql/apolloGQL/Collaborators/GetIndividualModelPlanCollaborator.ts @@ -1,7 +1,7 @@ import { gql } from '@apollo/client'; -export default gql` - query GetModelCollaborator($id: UUID!) { +export default gql(/* GraphQL */ ` + query GetIndividualModelPlanCollaborator($id: UUID!) { planCollaboratorByID(id: $id) { id userAccount { @@ -14,4 +14,4 @@ export default gql` teamRoles } } -`; +`); diff --git a/src/queries/Collaborators/GetIsCollaborator.ts b/src/gql/apolloGQL/Collaborators/GetIsCollaborator.ts similarity index 78% rename from src/queries/Collaborators/GetIsCollaborator.ts rename to src/gql/apolloGQL/Collaborators/GetIsCollaborator.ts index 9e5ea72829..e81b1f9013 100644 --- a/src/queries/Collaborators/GetIsCollaborator.ts +++ b/src/gql/apolloGQL/Collaborators/GetIsCollaborator.ts @@ -1,10 +1,10 @@ import { gql } from '@apollo/client'; -export default gql` +export default gql(/* GraphQL */ ` query GetIsCollaborator($id: UUID!) { modelPlan(id: $id) { id isCollaborator } } -`; +`); diff --git a/src/queries/Collaborators/GetModelCollaborators.ts b/src/gql/apolloGQL/Collaborators/GetModelCollaborators.ts similarity index 90% rename from src/queries/Collaborators/GetModelCollaborators.ts rename to src/gql/apolloGQL/Collaborators/GetModelCollaborators.ts index 2e4ab3f166..c116237775 100644 --- a/src/queries/Collaborators/GetModelCollaborators.ts +++ b/src/gql/apolloGQL/Collaborators/GetModelCollaborators.ts @@ -1,6 +1,6 @@ import { gql } from '@apollo/client'; -export default gql` +export default gql(/* GraphQL */ ` query GetModelCollaborators($id: UUID!) { modelPlan(id: $id) { id @@ -20,4 +20,4 @@ export default gql` } } } -`; +`); diff --git a/src/queries/Collaborators/UpdateModelPlanCollaborator.ts b/src/gql/apolloGQL/Collaborators/UpdateModelPlanCollaborator.ts similarity index 88% rename from src/queries/Collaborators/UpdateModelPlanCollaborator.ts rename to src/gql/apolloGQL/Collaborators/UpdateModelPlanCollaborator.ts index cc1f47ee9b..3f53be3ba0 100644 --- a/src/queries/Collaborators/UpdateModelPlanCollaborator.ts +++ b/src/gql/apolloGQL/Collaborators/UpdateModelPlanCollaborator.ts @@ -1,6 +1,6 @@ import { gql } from '@apollo/client'; -export default gql` +export default gql(/* GraphQL */ ` mutation UpdateModelPlanCollaborator($id: UUID!, $newRole: [TeamRole!]!) { updatePlanCollaborator(id: $id, newRoles: $newRole) { teamRoles @@ -13,4 +13,4 @@ export default gql` modelPlanID } } -`; +`); diff --git a/src/queries/NDA/UpdateNDA.ts b/src/gql/apolloGQL/NDA/UpdateNDA.ts similarity index 77% rename from src/queries/NDA/UpdateNDA.ts rename to src/gql/apolloGQL/NDA/UpdateNDA.ts index 2a22c9bd58..a9b9c635e4 100644 --- a/src/queries/NDA/UpdateNDA.ts +++ b/src/gql/apolloGQL/NDA/UpdateNDA.ts @@ -1,10 +1,10 @@ import { gql } from '@apollo/client'; -export default gql` +export default gql(/* GraphQL */ ` mutation UpdateNDA { agreeToNDA(agree: true) { agreed agreedDts } } -`; +`); diff --git a/src/gql/gen/graphql.ts b/src/gql/gen/graphql.ts index 7192e85bcb..440a8ddbd6 100644 --- a/src/gql/gen/graphql.ts +++ b/src/gql/gen/graphql.ts @@ -2990,6 +2990,49 @@ export type UpdateTdlMutationVariables = Exact<{ export type UpdateTdlMutation = { __typename: 'Mutation', updatePlanTDL: { __typename: 'PlanTDL', id: UUID, modelPlanID: UUID, idNumber: string, dateInitiated: Time, title: string, note?: string | null } }; +export type CreateModelPlanCollaboratorMutationVariables = Exact<{ + input: PlanCollaboratorCreateInput; +}>; + + +export type CreateModelPlanCollaboratorMutation = { __typename: 'Mutation', createPlanCollaborator: { __typename: 'PlanCollaborator', teamRoles: Array, userID: UUID, modelPlanID: UUID, userAccount: { __typename: 'UserAccount', id: UUID, commonName: string, email: string } } }; + +export type DeleteModelPlanCollaboratorMutationVariables = Exact<{ + id: Scalars['UUID']['input']; +}>; + + +export type DeleteModelPlanCollaboratorMutation = { __typename: 'Mutation', deletePlanCollaborator: { __typename: 'PlanCollaborator', id: UUID, teamRoles: Array, userID: UUID, modelPlanID: UUID, userAccount: { __typename: 'UserAccount', id: UUID, commonName: string, email: string, username: string } } }; + +export type GetIndividualModelPlanCollaboratorQueryVariables = Exact<{ + id: Scalars['UUID']['input']; +}>; + + +export type GetIndividualModelPlanCollaboratorQuery = { __typename: 'Query', planCollaboratorByID: { __typename: 'PlanCollaborator', id: UUID, userID: UUID, teamRoles: Array, userAccount: { __typename: 'UserAccount', id: UUID, commonName: string, email: string, username: string } } }; + +export type GetIsCollaboratorQueryVariables = Exact<{ + id: Scalars['UUID']['input']; +}>; + + +export type GetIsCollaboratorQuery = { __typename: 'Query', modelPlan: { __typename: 'ModelPlan', id: UUID, isCollaborator: boolean } }; + +export type GetModelCollaboratorsQueryVariables = Exact<{ + id: Scalars['UUID']['input']; +}>; + + +export type GetModelCollaboratorsQuery = { __typename: 'Query', modelPlan: { __typename: 'ModelPlan', id: UUID, modelName: string, collaborators: Array<{ __typename: 'PlanCollaborator', id: UUID, userID: UUID, teamRoles: Array, modelPlanID: UUID, createdDts: Time, userAccount: { __typename: 'UserAccount', id: UUID, commonName: string, email: string, username: string } }> } }; + +export type UpdateModelPlanCollaboratorMutationVariables = Exact<{ + id: Scalars['UUID']['input']; + newRole: Array | TeamRole; +}>; + + +export type UpdateModelPlanCollaboratorMutation = { __typename: 'Mutation', updatePlanCollaborator: { __typename: 'PlanCollaborator', teamRoles: Array, userID: UUID, modelPlanID: UUID, userAccount: { __typename: 'UserAccount', commonName: string, email: string, username: string } } }; + export type CreateModelPlanDiscussionMutationVariables = Exact<{ input: PlanDiscussionCreateInput; }>; @@ -3109,6 +3152,11 @@ export type GetNdaQueryVariables = Exact<{ [key: string]: never; }>; export type GetNdaQuery = { __typename: 'Query', ndaInfo: { __typename: 'NDAInfo', agreed: boolean, agreedDts?: Time | null } }; +export type UpdateNdaMutationVariables = Exact<{ [key: string]: never; }>; + + +export type UpdateNdaMutation = { __typename: 'Mutation', agreeToNDA: { __typename: 'NDAInfo', agreed: boolean, agreedDts?: Time | null } }; + export type GetNotificationSettingsQueryVariables = Exact<{ [key: string]: never; }>; @@ -4322,6 +4370,272 @@ export function useUpdateTdlMutation(baseOptions?: Apollo.MutationHookOptions; export type UpdateTdlMutationResult = Apollo.MutationResult; export type UpdateTdlMutationOptions = Apollo.BaseMutationOptions; +export const CreateModelPlanCollaboratorDocument = gql` + mutation CreateModelPlanCollaborator($input: PlanCollaboratorCreateInput!) { + createPlanCollaborator(input: $input) { + teamRoles + userAccount { + id + commonName + email + } + userID + modelPlanID + } +} + `; +export type CreateModelPlanCollaboratorMutationFn = Apollo.MutationFunction; + +/** + * __useCreateModelPlanCollaboratorMutation__ + * + * To run a mutation, you first call `useCreateModelPlanCollaboratorMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useCreateModelPlanCollaboratorMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [createModelPlanCollaboratorMutation, { data, loading, error }] = useCreateModelPlanCollaboratorMutation({ + * variables: { + * input: // value for 'input' + * }, + * }); + */ +export function useCreateModelPlanCollaboratorMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(CreateModelPlanCollaboratorDocument, options); + } +export type CreateModelPlanCollaboratorMutationHookResult = ReturnType; +export type CreateModelPlanCollaboratorMutationResult = Apollo.MutationResult; +export type CreateModelPlanCollaboratorMutationOptions = Apollo.BaseMutationOptions; +export const DeleteModelPlanCollaboratorDocument = gql` + mutation DeleteModelPlanCollaborator($id: UUID!) { + deletePlanCollaborator(id: $id) { + id + teamRoles + userAccount { + id + commonName + email + username + } + userID + modelPlanID + } +} + `; +export type DeleteModelPlanCollaboratorMutationFn = Apollo.MutationFunction; + +/** + * __useDeleteModelPlanCollaboratorMutation__ + * + * To run a mutation, you first call `useDeleteModelPlanCollaboratorMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useDeleteModelPlanCollaboratorMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [deleteModelPlanCollaboratorMutation, { data, loading, error }] = useDeleteModelPlanCollaboratorMutation({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useDeleteModelPlanCollaboratorMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(DeleteModelPlanCollaboratorDocument, options); + } +export type DeleteModelPlanCollaboratorMutationHookResult = ReturnType; +export type DeleteModelPlanCollaboratorMutationResult = Apollo.MutationResult; +export type DeleteModelPlanCollaboratorMutationOptions = Apollo.BaseMutationOptions; +export const GetIndividualModelPlanCollaboratorDocument = gql` + query GetIndividualModelPlanCollaborator($id: UUID!) { + planCollaboratorByID(id: $id) { + id + userAccount { + id + commonName + email + username + } + userID + teamRoles + } +} + `; + +/** + * __useGetIndividualModelPlanCollaboratorQuery__ + * + * To run a query within a React component, call `useGetIndividualModelPlanCollaboratorQuery` and pass it any options that fit your needs. + * When your component renders, `useGetIndividualModelPlanCollaboratorQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetIndividualModelPlanCollaboratorQuery({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useGetIndividualModelPlanCollaboratorQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(GetIndividualModelPlanCollaboratorDocument, options); + } +export function useGetIndividualModelPlanCollaboratorLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(GetIndividualModelPlanCollaboratorDocument, options); + } +export function useGetIndividualModelPlanCollaboratorSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSuspenseQuery(GetIndividualModelPlanCollaboratorDocument, options); + } +export type GetIndividualModelPlanCollaboratorQueryHookResult = ReturnType; +export type GetIndividualModelPlanCollaboratorLazyQueryHookResult = ReturnType; +export type GetIndividualModelPlanCollaboratorSuspenseQueryHookResult = ReturnType; +export type GetIndividualModelPlanCollaboratorQueryResult = Apollo.QueryResult; +export const GetIsCollaboratorDocument = gql` + query GetIsCollaborator($id: UUID!) { + modelPlan(id: $id) { + id + isCollaborator + } +} + `; + +/** + * __useGetIsCollaboratorQuery__ + * + * To run a query within a React component, call `useGetIsCollaboratorQuery` and pass it any options that fit your needs. + * When your component renders, `useGetIsCollaboratorQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetIsCollaboratorQuery({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useGetIsCollaboratorQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(GetIsCollaboratorDocument, options); + } +export function useGetIsCollaboratorLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(GetIsCollaboratorDocument, options); + } +export function useGetIsCollaboratorSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSuspenseQuery(GetIsCollaboratorDocument, options); + } +export type GetIsCollaboratorQueryHookResult = ReturnType; +export type GetIsCollaboratorLazyQueryHookResult = ReturnType; +export type GetIsCollaboratorSuspenseQueryHookResult = ReturnType; +export type GetIsCollaboratorQueryResult = Apollo.QueryResult; +export const GetModelCollaboratorsDocument = gql` + query GetModelCollaborators($id: UUID!) { + modelPlan(id: $id) { + id + modelName + collaborators { + id + userAccount { + id + commonName + email + username + } + userID + teamRoles + modelPlanID + createdDts + } + } +} + `; + +/** + * __useGetModelCollaboratorsQuery__ + * + * To run a query within a React component, call `useGetModelCollaboratorsQuery` and pass it any options that fit your needs. + * When your component renders, `useGetModelCollaboratorsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetModelCollaboratorsQuery({ + * variables: { + * id: // value for 'id' + * }, + * }); + */ +export function useGetModelCollaboratorsQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(GetModelCollaboratorsDocument, options); + } +export function useGetModelCollaboratorsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(GetModelCollaboratorsDocument, options); + } +export function useGetModelCollaboratorsSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSuspenseQuery(GetModelCollaboratorsDocument, options); + } +export type GetModelCollaboratorsQueryHookResult = ReturnType; +export type GetModelCollaboratorsLazyQueryHookResult = ReturnType; +export type GetModelCollaboratorsSuspenseQueryHookResult = ReturnType; +export type GetModelCollaboratorsQueryResult = Apollo.QueryResult; +export const UpdateModelPlanCollaboratorDocument = gql` + mutation UpdateModelPlanCollaborator($id: UUID!, $newRole: [TeamRole!]!) { + updatePlanCollaborator(id: $id, newRoles: $newRole) { + teamRoles + userAccount { + commonName + email + username + } + userID + modelPlanID + } +} + `; +export type UpdateModelPlanCollaboratorMutationFn = Apollo.MutationFunction; + +/** + * __useUpdateModelPlanCollaboratorMutation__ + * + * To run a mutation, you first call `useUpdateModelPlanCollaboratorMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateModelPlanCollaboratorMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [updateModelPlanCollaboratorMutation, { data, loading, error }] = useUpdateModelPlanCollaboratorMutation({ + * variables: { + * id: // value for 'id' + * newRole: // value for 'newRole' + * }, + * }); + */ +export function useUpdateModelPlanCollaboratorMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(UpdateModelPlanCollaboratorDocument, options); + } +export type UpdateModelPlanCollaboratorMutationHookResult = ReturnType; +export type UpdateModelPlanCollaboratorMutationResult = Apollo.MutationResult; +export type UpdateModelPlanCollaboratorMutationOptions = Apollo.BaseMutationOptions; export const CreateModelPlanDiscussionDocument = gql` mutation CreateModelPlanDiscussion($input: PlanDiscussionCreateInput!) { createPlanDiscussion(input: $input) { @@ -5203,6 +5517,39 @@ export type GetNdaQueryHookResult = ReturnType; export type GetNdaLazyQueryHookResult = ReturnType; export type GetNdaSuspenseQueryHookResult = ReturnType; export type GetNdaQueryResult = Apollo.QueryResult; +export const UpdateNdaDocument = gql` + mutation UpdateNDA { + agreeToNDA(agree: true) { + agreed + agreedDts + } +} + `; +export type UpdateNdaMutationFn = Apollo.MutationFunction; + +/** + * __useUpdateNdaMutation__ + * + * To run a mutation, you first call `useUpdateNdaMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateNdaMutation` returns a tuple that includes: + * - A mutate function that you can call at any time to execute the mutation + * - An object with fields that represent the current status of the mutation's execution + * + * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; + * + * @example + * const [updateNdaMutation, { data, loading, error }] = useUpdateNdaMutation({ + * variables: { + * }, + * }); + */ +export function useUpdateNdaMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(UpdateNdaDocument, options); + } +export type UpdateNdaMutationHookResult = ReturnType; +export type UpdateNdaMutationResult = Apollo.MutationResult; +export type UpdateNdaMutationOptions = Apollo.BaseMutationOptions; export const GetNotificationSettingsDocument = gql` query GetNotificationSettings { currentUser { diff --git a/src/queries/Collaborators/types/CreateModelPlanCollaborator.ts b/src/gql/gen/types/CreateModelPlanCollaborator.ts similarity index 100% rename from src/queries/Collaborators/types/CreateModelPlanCollaborator.ts rename to src/gql/gen/types/CreateModelPlanCollaborator.ts diff --git a/src/queries/Collaborators/types/DeleteModelPlanCollaborator.ts b/src/gql/gen/types/DeleteModelPlanCollaborator.ts similarity index 100% rename from src/queries/Collaborators/types/DeleteModelPlanCollaborator.ts rename to src/gql/gen/types/DeleteModelPlanCollaborator.ts diff --git a/src/queries/Collaborators/types/GetModelCollaborator.ts b/src/gql/gen/types/GetIndividualModelPlanCollaborator.ts similarity index 50% rename from src/queries/Collaborators/types/GetModelCollaborator.ts rename to src/gql/gen/types/GetIndividualModelPlanCollaborator.ts index fb17be1186..cd4f8dae0b 100644 --- a/src/queries/Collaborators/types/GetModelCollaborator.ts +++ b/src/gql/gen/types/GetIndividualModelPlanCollaborator.ts @@ -6,10 +6,10 @@ import { TeamRole } from "./../../../types/graphql-global-types"; // ==================================================== -// GraphQL query operation: GetModelCollaborator +// GraphQL query operation: GetIndividualModelPlanCollaborator // ==================================================== -export interface GetModelCollaborator_planCollaboratorByID_userAccount { +export interface GetIndividualModelPlanCollaborator_planCollaboratorByID_userAccount { __typename: "UserAccount"; id: UUID; commonName: string; @@ -17,18 +17,18 @@ export interface GetModelCollaborator_planCollaboratorByID_userAccount { username: string; } -export interface GetModelCollaborator_planCollaboratorByID { +export interface GetIndividualModelPlanCollaborator_planCollaboratorByID { __typename: "PlanCollaborator"; id: UUID; - userAccount: GetModelCollaborator_planCollaboratorByID_userAccount; + userAccount: GetIndividualModelPlanCollaborator_planCollaboratorByID_userAccount; userID: UUID; teamRoles: TeamRole[]; } -export interface GetModelCollaborator { - planCollaboratorByID: GetModelCollaborator_planCollaboratorByID; +export interface GetIndividualModelPlanCollaborator { + planCollaboratorByID: GetIndividualModelPlanCollaborator_planCollaboratorByID; } -export interface GetModelCollaboratorVariables { +export interface GetIndividualModelPlanCollaboratorVariables { id: UUID; } diff --git a/src/queries/Collaborators/types/GetIsCollaborator.ts b/src/gql/gen/types/GetIsCollaborator.ts similarity index 100% rename from src/queries/Collaborators/types/GetIsCollaborator.ts rename to src/gql/gen/types/GetIsCollaborator.ts diff --git a/src/queries/Collaborators/types/GetModelCollaborators.ts b/src/gql/gen/types/GetModelCollaborators.ts similarity index 100% rename from src/queries/Collaborators/types/GetModelCollaborators.ts rename to src/gql/gen/types/GetModelCollaborators.ts diff --git a/src/queries/Collaborators/types/UpdateModelPlanCollaborator.ts b/src/gql/gen/types/UpdateModelPlanCollaborator.ts similarity index 100% rename from src/queries/Collaborators/types/UpdateModelPlanCollaborator.ts rename to src/gql/gen/types/UpdateModelPlanCollaborator.ts diff --git a/src/queries/NDA/types/UpdateNDA.ts b/src/gql/gen/types/UpdateNDA.ts similarity index 100% rename from src/queries/NDA/types/UpdateNDA.ts rename to src/gql/gen/types/UpdateNDA.ts diff --git a/src/utils/modelPlan.test.tsx b/src/utils/modelPlan.test.tsx index c320dae173..cfdd8d3303 100644 --- a/src/utils/modelPlan.test.tsx +++ b/src/utils/modelPlan.test.tsx @@ -1,6 +1,5 @@ import { TeamRole } from 'gql/gen/graphql'; - -import { GetModelCollaborators_modelPlan_collaborators as CollaboratorType } from 'queries/Collaborators/types/GetModelCollaborators'; +import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; import { collaboratorsOrderedByModelLeads, @@ -23,7 +22,7 @@ describe('model plan util', () => { }); it('returns array ordered by last name', () => { - const normalPerson: CollaboratorType = { + const normalPerson: GetCollaboratorsType = { __typename: 'PlanCollaborator', id: '123', userID: '123', @@ -38,7 +37,7 @@ describe('model plan util', () => { }, teamRoles: [TeamRole.IT_LEAD] }; - const steveRogers: CollaboratorType = { + const steveRogers: GetCollaboratorsType = { __typename: 'PlanCollaborator', id: '123', userID: '123', @@ -53,7 +52,7 @@ describe('model plan util', () => { }, teamRoles: [TeamRole.MODEL_LEAD] }; - const peterParker: CollaboratorType = { + const peterParker: GetCollaboratorsType = { __typename: 'PlanCollaborator', id: '123', userID: '123', diff --git a/src/utils/modelPlan.ts b/src/utils/modelPlan.ts index d7bc8fb1d8..9a80b88b98 100644 --- a/src/utils/modelPlan.ts +++ b/src/utils/modelPlan.ts @@ -1,8 +1,8 @@ import { TeamRole } from 'gql/gen/graphql'; +import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; import i18next from 'i18next'; import { orderBy } from 'lodash'; -import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'queries/Collaborators/types/GetModelCollaborators'; import { GetModelPlan_modelPlan_discussions as DiscussionType } from 'queries/types/GetModelPlan'; import { DocumentType, diff --git a/src/views/ModelAccessWrapper/index.tsx b/src/views/ModelAccessWrapper/index.tsx index 8bf97bb53c..10dae13d17 100644 --- a/src/views/ModelAccessWrapper/index.tsx +++ b/src/views/ModelAccessWrapper/index.tsx @@ -8,14 +8,9 @@ import React, { useEffect } from 'react'; import { RootStateOrAny, useSelector } from 'react-redux'; import { useHistory, useLocation } from 'react-router-dom'; -import { useQuery } from '@apollo/client'; +import { useGetIsCollaboratorQuery } from 'gql/gen/graphql'; import { useFlags } from 'launchdarkly-react-client-sdk'; -import GetIsCollaborator from 'queries/Collaborators/GetIsCollaborator'; -import { - GetIsCollaborator as GetIsCollaboratorType, - GetIsCollaboratorVariables -} from 'queries/Collaborators/types/GetIsCollaborator'; import { isUUID } from 'utils/modelPlan'; import { isAssessment, isMAC } from 'utils/user'; @@ -44,10 +39,7 @@ const ModelAccessWrapper = ({ children }: ModelAccessWrapperProps) => { const helpArticle: boolean = pathname.split('/')[1] === 'help-and-knowledge'; - const { data, loading } = useQuery< - GetIsCollaboratorType, - GetIsCollaboratorVariables - >(GetIsCollaborator, { + const { data, loading } = useGetIsCollaboratorQuery({ variables: { id: modelID }, diff --git a/src/views/ModelPlan/Collaborators/AddCollaborator/index.tsx b/src/views/ModelPlan/Collaborators/AddCollaborator/index.tsx index ae66127f48..6652eabb20 100644 --- a/src/views/ModelPlan/Collaborators/AddCollaborator/index.tsx +++ b/src/views/ModelPlan/Collaborators/AddCollaborator/index.tsx @@ -1,10 +1,16 @@ import React, { useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { useHistory, useLocation, useParams } from 'react-router-dom'; -import { useMutation, useQuery } from '@apollo/client'; import { Button, Fieldset, Label, TextInput } from '@trussworks/react-uswds'; import { Field, Form, Formik, FormikProps } from 'formik'; -import { TeamRole } from 'gql/gen/graphql'; +import { + TeamRole, + useCreateModelPlanCollaboratorMutation, + useGetModelCollaboratorsQuery, + useUpdateModelPlanCollaboratorMutation +} from 'gql/gen/graphql'; +import { GetIndividualModelPlanCollaborator_planCollaboratorByID as CollaboratorFormType } from 'gql/gen/types/GetIndividualModelPlanCollaborator'; +import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; import UswdsReactLink from 'components/LinkWrapper'; import MainContent from 'components/MainContent'; @@ -18,22 +24,6 @@ import MultiSelect from 'components/shared/MultiSelect'; import Spinner from 'components/Spinner'; import useMessage from 'hooks/useMessage'; import usePlanTranslation from 'hooks/usePlanTranslation'; -import CreateModelPlanCollaborator from 'queries/Collaborators/CreateModelPlanCollaborator'; -import GetModelPlanCollaborators from 'queries/Collaborators/GetModelCollaborators'; -import { - CreateModelPlanCollaborator as CreateCollaboratorsType, - CreateModelPlanCollaboratorVariables -} from 'queries/Collaborators/types/CreateModelPlanCollaborator'; -import { GetModelCollaborator_planCollaboratorByID as CollaboratorFormType } from 'queries/Collaborators/types/GetModelCollaborator'; -import { - GetModelCollaborators, - GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType -} from 'queries/Collaborators/types/GetModelCollaborators'; -import { - UpdateModelPlanCollaborator as UpdateModelPlanCollaboratorType, - UpdateModelPlanCollaboratorVariables -} from 'queries/Collaborators/types/UpdateModelPlanCollaborator'; -import UpdateModelPlanCollaborator from 'queries/Collaborators/UpdateModelPlanCollaborator'; import { getKeys } from 'types/translation'; import flattenErrors from 'utils/flattenErrors'; import { composeMultiSelectOptions } from 'utils/modelPlan'; @@ -64,20 +54,17 @@ const Collaborators = () => { const formikRef = useRef>(null); - const [create, { loading }] = useMutation< - CreateCollaboratorsType, - CreateModelPlanCollaboratorVariables - >(CreateModelPlanCollaborator); + const [create, { loading }] = useCreateModelPlanCollaboratorMutation(); - const [update, { loading: updateLoading }] = useMutation< - UpdateModelPlanCollaboratorType, - UpdateModelPlanCollaboratorVariables - >(UpdateModelPlanCollaborator); + const [ + update, + { loading: updateLoading } + ] = useUpdateModelPlanCollaboratorMutation(); const { data: allCollaboratorsData, loading: queryLoading - } = useQuery(GetModelPlanCollaborators, { + } = useGetModelCollaboratorsQuery({ variables: { id: modelID } diff --git a/src/views/ModelPlan/Collaborators/index.test.tsx b/src/views/ModelPlan/Collaborators/index.test.tsx index 6881b17b12..89dc010716 100644 --- a/src/views/ModelPlan/Collaborators/index.test.tsx +++ b/src/views/ModelPlan/Collaborators/index.test.tsx @@ -8,12 +8,12 @@ import { waitFor, waitForElementToBeRemoved } from '@testing-library/react'; +import { GetModelCollaboratorsDocument } from 'gql/gen/graphql'; +import { GetModelCollaborators_modelPlan as GetModelPlanType } from 'gql/gen/types/GetModelCollaborators'; import configureMockStore from 'redux-mock-store'; import { ASSESSMENT } from 'constants/jobCodes'; import { MessageProvider } from 'hooks/useMessage'; -import GetModelPlanCollaborators from 'queries/Collaborators/GetModelCollaborators'; -import { GetModelCollaborators_modelPlan as GetModelPlanCollaboratorsType } from 'queries/Collaborators/types/GetModelCollaborators'; import { TeamRole } from 'types/graphql-global-types'; import { CollaboratorsContent } from './index'; @@ -27,7 +27,7 @@ const mockAuthReducer = { const mockStore = configureMockStore(); const store = mockStore({ auth: mockAuthReducer }); -const mockCollaborator: GetModelPlanCollaboratorsType = { +const mockCollaborator: GetModelPlanType = { __typename: 'ModelPlan', id: '123', modelName: 'My Model', @@ -53,7 +53,7 @@ const mockCollaborator: GetModelPlanCollaboratorsType = { const mocks = [ { request: { - query: GetModelPlanCollaborators, + query: GetModelCollaboratorsDocument, variables: { id: 'f11eb129-2c80-4080-9440-439cbe1a286f' } }, result: { diff --git a/src/views/ModelPlan/Collaborators/index.tsx b/src/views/ModelPlan/Collaborators/index.tsx index 3c09c84ea7..824b6e4236 100644 --- a/src/views/ModelPlan/Collaborators/index.tsx +++ b/src/views/ModelPlan/Collaborators/index.tsx @@ -8,9 +8,14 @@ import { useLocation, useParams } from 'react-router-dom'; -import { useMutation, useQuery } from '@apollo/client'; import { Button, Grid, GridContainer } from '@trussworks/react-uswds'; -import { TeamRole } from 'gql/gen/graphql'; +import { + TeamRole, + useDeleteModelPlanCollaboratorMutation, + useGetModelCollaboratorsQuery +} from 'gql/gen/graphql'; +import { DeleteModelPlanCollaborator_deletePlanCollaborator as ModelPlanCollaboratorType } from 'gql/gen/types/DeleteModelPlanCollaborator'; +import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; import Breadcrumbs from 'components/Breadcrumbs'; import UswdsReactLink from 'components/LinkWrapper'; @@ -21,16 +26,6 @@ import PageLoading from 'components/PageLoading'; import Alert from 'components/shared/Alert'; import Expire from 'components/shared/Expire'; import useMessage from 'hooks/useMessage'; -import DeleteModelPlanCollaborator from 'queries/Collaborators/DeleteModelPlanCollaborator'; -import GetModelPlanCollaborators from 'queries/Collaborators/GetModelCollaborators'; -import { - DeleteModelPlanCollaborator as DeleteModelPlanCollaboratorType, - DeleteModelPlanCollaborator_deletePlanCollaborator as ModelPlanCollaboratorType -} from 'queries/Collaborators/types/DeleteModelPlanCollaborator'; -import { - GetModelCollaborators, - GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType -} from 'queries/Collaborators/types/GetModelCollaborators'; import { collaboratorsOrderedByModelLeads } from 'utils/modelPlan'; import { ModelInfoContext } from 'views/ModelInfoWrapper'; import NotFound from 'views/NotFound'; @@ -95,18 +90,13 @@ export const CollaboratorsContent = () => { // Current user's EUA id - to warn about removing yourself from model plan const { euaId } = useSelector((state: RootStateOrAny) => state.auth); - const [mutate] = useMutation( - DeleteModelPlanCollaborator - ); + const [mutate] = useDeleteModelPlanCollaboratorMutation(); - const { error, data, refetch, loading } = useQuery( - GetModelPlanCollaborators, - { - variables: { - id: modelID - } + const { error, data, refetch, loading } = useGetModelCollaboratorsQuery({ + variables: { + id: modelID } - ); + }); const collaborators = useMemo(() => { return (data?.modelPlan?.collaborators ?? []) as GetCollaboratorsType[]; diff --git a/src/views/ModelPlan/Collaborators/table.tsx b/src/views/ModelPlan/Collaborators/table.tsx index 0250b531d7..78adde221f 100644 --- a/src/views/ModelPlan/Collaborators/table.tsx +++ b/src/views/ModelPlan/Collaborators/table.tsx @@ -4,10 +4,10 @@ import { useLocation, useParams } from 'react-router-dom'; import { useSortBy, useTable } from 'react-table'; import { Table as UswdsTable } from '@trussworks/react-uswds'; import { TeamRole } from 'gql/gen/graphql'; +import { GetModelCollaborators_modelPlan_collaborators as CollaboratorType } from 'gql/gen/types/GetModelCollaborators'; import UswdsReactLink from 'components/LinkWrapper'; import IconInitial from 'components/shared/IconInitial'; -import { GetModelCollaborators_modelPlan_collaborators as CollaboratorType } from 'queries/Collaborators/types/GetModelCollaborators'; import { formatDateLocal } from 'utils/date'; import { currentTableSortDescription, diff --git a/src/views/ModelPlan/ReadOnly/Team/index.tsx b/src/views/ModelPlan/ReadOnly/Team/index.tsx index 1f55ece868..d4fe5b6a1b 100644 --- a/src/views/ModelPlan/ReadOnly/Team/index.tsx +++ b/src/views/ModelPlan/ReadOnly/Team/index.tsx @@ -1,13 +1,9 @@ import React from 'react'; import { Trans, useTranslation } from 'react-i18next'; -import { useQuery } from '@apollo/client'; import { Card, CardHeader, Grid, Icon, Link } from '@trussworks/react-uswds'; +import { useGetModelCollaboratorsQuery } from 'gql/gen/graphql'; +import { GetModelCollaborators_modelPlan_collaborators as CollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; -import GetModelPlanCollaborators from 'queries/Collaborators/GetModelCollaborators'; -import { - GetModelCollaborators, - GetModelCollaborators_modelPlan_collaborators as CollaboratorsType -} from 'queries/Collaborators/types/GetModelCollaborators'; import { TeamRole } from 'types/graphql-global-types'; import { collaboratorsOrderedByModelLeads } from 'utils/modelPlan'; import { NotFoundPartial } from 'views/NotFound'; @@ -106,14 +102,11 @@ const ReadOnlyTeamInfo = ({ filteredView?: string; }) => { const { t } = useTranslation('generalReadOnly'); - const { data, loading, error } = useQuery( - GetModelPlanCollaborators, - { - variables: { - id: modelID - } + const { data, loading, error } = useGetModelCollaboratorsQuery({ + variables: { + id: modelID } - ); + }); if ((!loading && error) || (!loading && !data?.modelPlan)) { return ; diff --git a/src/views/ModelPlan/ReadOnly/_components/ContactInfo/index.tsx b/src/views/ModelPlan/ReadOnly/_components/ContactInfo/index.tsx index 2980e5b95d..20be956524 100644 --- a/src/views/ModelPlan/ReadOnly/_components/ContactInfo/index.tsx +++ b/src/views/ModelPlan/ReadOnly/_components/ContactInfo/index.tsx @@ -1,14 +1,10 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; -import { useQuery } from '@apollo/client'; import { Icon, Link } from '@trussworks/react-uswds'; +import { useGetModelCollaboratorsQuery } from 'gql/gen/graphql'; +import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; import UswdsReactLink from 'components/LinkWrapper'; -import GetModelPlanCollaborators from 'queries/Collaborators/GetModelCollaborators'; -import { - GetModelCollaborators, - GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType -} from 'queries/Collaborators/types/GetModelCollaborators'; import { TeamRole } from 'types/graphql-global-types'; const ContactInfo = ({ @@ -20,7 +16,7 @@ const ContactInfo = ({ }) => { const { t: h } = useTranslation('generalReadOnly'); - const { data } = useQuery(GetModelPlanCollaborators, { + const { data } = useGetModelCollaboratorsQuery({ variables: { id: modelID } diff --git a/src/views/ModelPlan/TaskList/_components/TaskListSideNav/index.tsx b/src/views/ModelPlan/TaskList/_components/TaskListSideNav/index.tsx index b4d5a135c4..d0c6e64e44 100644 --- a/src/views/ModelPlan/TaskList/_components/TaskListSideNav/index.tsx +++ b/src/views/ModelPlan/TaskList/_components/TaskListSideNav/index.tsx @@ -3,6 +3,7 @@ import { Trans, useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; import { useMutation } from '@apollo/client'; import { Button } from '@trussworks/react-uswds'; +import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'gql/gen/types/GetModelCollaborators'; import UswdsReactLink from 'components/LinkWrapper'; import Modal from 'components/Modal'; @@ -12,7 +13,6 @@ import IconInitial from 'components/shared/IconInitial'; import ShareExportModal from 'components/ShareExport'; import useMessage from 'hooks/useMessage'; import ArchiveModelPlan from 'queries/ArchiveModelPlan'; -import { GetModelCollaborators_modelPlan_collaborators as GetCollaboratorsType } from 'queries/Collaborators/types/GetModelCollaborators'; import { ArchiveModelPlanVariables } from 'queries/types/ArchiveModelPlan'; import { GetModelPlan_modelPlan as GetModelPlanType } from 'queries/types/GetModelPlan'; import { collaboratorsOrderedByModelLeads } from 'utils/modelPlan'; diff --git a/src/views/NDA/index.tsx b/src/views/NDA/index.tsx index b0a26c00f8..dd6dd0eb5c 100644 --- a/src/views/NDA/index.tsx +++ b/src/views/NDA/index.tsx @@ -2,14 +2,13 @@ import React, { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { RootStateOrAny, useDispatch, useSelector } from 'react-redux'; import { useHistory, useLocation } from 'react-router-dom'; -import { useMutation } from '@apollo/client'; import { Button, Checkbox, Grid, GridContainer } from '@trussworks/react-uswds'; import { Field, Form, Formik, FormikProps } from 'formik'; +import { useUpdateNdaMutation } from 'gql/gen/graphql'; import UswdsReactLink from 'components/LinkWrapper'; import MainContent from 'components/MainContent'; import Alert from 'components/shared/Alert'; -import UpdateNDA from 'queries/NDA/UpdateNDA'; import { setUser } from 'reducers/authReducer'; import { formatDateLocal } from 'utils/date'; @@ -31,7 +30,7 @@ const NDA = () => { (state: RootStateOrAny) => state.auth ); - const [signNDA] = useMutation(UpdateNDA); + const [signNDA] = useUpdateNdaMutation(); useEffect(() => { if (locationState?.nextState) setOriginalRoute(locationState?.nextState);