diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx index 15db6ea2e..a8f219d93 100644 --- a/front/src/generated/graphql.tsx +++ b/front/src/generated/graphql.tsx @@ -639,6 +639,7 @@ export enum CommentableType { export type Company = { __typename?: 'Company'; ActivityTarget?: Maybe>; + PipelineProgress?: Maybe>; _activityCount: Scalars['Int']; accountOwner?: Maybe; accountOwnerId?: Maybe; @@ -657,6 +658,7 @@ export type Company = { export type CompanyCreateInput = { ActivityTarget?: InputMaybe; + PipelineProgress?: InputMaybe; accountOwner?: InputMaybe; address: Scalars['String']; createdAt?: InputMaybe; @@ -677,6 +679,10 @@ export type CompanyCreateNestedOneWithoutPeopleInput = { connect?: InputMaybe; }; +export type CompanyCreateNestedOneWithoutPipelineProgressInput = { + connect?: InputMaybe; +}; + export type CompanyListRelationFilter = { every?: InputMaybe; none?: InputMaybe; @@ -689,6 +695,7 @@ export type CompanyOrderByRelationAggregateInput = { export type CompanyOrderByWithRelationInput = { ActivityTarget?: InputMaybe; + PipelineProgress?: InputMaybe; accountOwner?: InputMaybe; accountOwnerId?: InputMaybe; address?: InputMaybe; @@ -723,6 +730,7 @@ export enum CompanyScalarFieldEnum { export type CompanyUpdateInput = { ActivityTarget?: InputMaybe; + PipelineProgress?: InputMaybe; accountOwner?: InputMaybe; address?: InputMaybe; createdAt?: InputMaybe; @@ -752,11 +760,17 @@ export type CompanyUpdateOneWithoutPeopleNestedInput = { disconnect?: InputMaybe; }; +export type CompanyUpdateOneWithoutPipelineProgressNestedInput = { + connect?: InputMaybe; + disconnect?: InputMaybe; +}; + export type CompanyWhereInput = { AND?: InputMaybe>; ActivityTarget?: InputMaybe; NOT?: InputMaybe>; OR?: InputMaybe>; + PipelineProgress?: InputMaybe; accountOwner?: InputMaybe; accountOwnerId?: InputMaybe; address?: InputMaybe; @@ -1202,6 +1216,7 @@ export type NestedStringNullableFilter = { export type Person = { __typename?: 'Person'; ActivityTarget?: Maybe>; + PipelineProgress?: Maybe>; _activityCount: Scalars['Int']; activities: Array; avatarUrl?: Maybe; @@ -1209,6 +1224,7 @@ export type Person = { comments: Array; company?: Maybe; companyId?: Maybe; + contactPipelineProgresses?: Maybe>; createdAt: Scalars['DateTime']; displayName: Scalars['String']; email?: Maybe; @@ -1218,15 +1234,16 @@ export type Person = { lastName?: Maybe; linkedinUrl?: Maybe; phone?: Maybe; - pipelineProgresses?: Maybe>; updatedAt: Scalars['DateTime']; }; export type PersonCreateInput = { ActivityTarget?: InputMaybe; + PipelineProgress?: InputMaybe; avatarUrl?: InputMaybe; city?: InputMaybe; company?: InputMaybe; + contactPipelineProgresses?: InputMaybe; createdAt?: InputMaybe; email?: InputMaybe; firstName?: InputMaybe; @@ -1235,7 +1252,6 @@ export type PersonCreateInput = { lastName?: InputMaybe; linkedinUrl?: InputMaybe; phone?: InputMaybe; - pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1247,7 +1263,11 @@ export type PersonCreateNestedOneWithoutActivityTargetInput = { connect?: InputMaybe; }; -export type PersonCreateNestedOneWithoutPipelineProgressesInput = { +export type PersonCreateNestedOneWithoutContactPipelineProgressesInput = { + connect?: InputMaybe; +}; + +export type PersonCreateNestedOneWithoutPipelineProgressInput = { connect?: InputMaybe; }; @@ -1263,10 +1283,12 @@ export type PersonOrderByRelationAggregateInput = { export type PersonOrderByWithRelationInput = { ActivityTarget?: InputMaybe; + PipelineProgress?: InputMaybe; avatarUrl?: InputMaybe; city?: InputMaybe; company?: InputMaybe; companyId?: InputMaybe; + contactPipelineProgresses?: InputMaybe; createdAt?: InputMaybe; email?: InputMaybe; firstName?: InputMaybe; @@ -1275,7 +1297,6 @@ export type PersonOrderByWithRelationInput = { lastName?: InputMaybe; linkedinUrl?: InputMaybe; phone?: InputMaybe; - pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1303,9 +1324,11 @@ export enum PersonScalarFieldEnum { export type PersonUpdateInput = { ActivityTarget?: InputMaybe; + PipelineProgress?: InputMaybe; avatarUrl?: InputMaybe; city?: InputMaybe; company?: InputMaybe; + contactPipelineProgresses?: InputMaybe; createdAt?: InputMaybe; email?: InputMaybe; firstName?: InputMaybe; @@ -1314,7 +1337,6 @@ export type PersonUpdateInput = { lastName?: InputMaybe; linkedinUrl?: InputMaybe; phone?: InputMaybe; - pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1330,7 +1352,12 @@ export type PersonUpdateManyWithoutWorkspaceNestedInput = { set?: InputMaybe>; }; -export type PersonUpdateOneWithoutPipelineProgressesNestedInput = { +export type PersonUpdateOneWithoutContactPipelineProgressesNestedInput = { + connect?: InputMaybe; + disconnect?: InputMaybe; +}; + +export type PersonUpdateOneWithoutPipelineProgressNestedInput = { connect?: InputMaybe; disconnect?: InputMaybe; }; @@ -1340,10 +1367,12 @@ export type PersonWhereInput = { ActivityTarget?: InputMaybe; NOT?: InputMaybe>; OR?: InputMaybe>; + PipelineProgress?: InputMaybe; avatarUrl?: InputMaybe; city?: InputMaybe; company?: InputMaybe; companyId?: InputMaybe; + contactPipelineProgresses?: InputMaybe; createdAt?: InputMaybe; email?: InputMaybe; firstName?: InputMaybe; @@ -1352,7 +1381,6 @@ export type PersonWhereInput = { lastName?: InputMaybe; linkedinUrl?: InputMaybe; phone?: InputMaybe; - pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1391,8 +1419,12 @@ export type PipelineProgress = { __typename?: 'PipelineProgress'; amount?: Maybe; closeDate?: Maybe; + company?: Maybe; + companyId?: Maybe; createdAt: Scalars['DateTime']; id: Scalars['ID']; + person?: Maybe; + personId?: Maybe; pipeline: Pipeline; pipelineId: Scalars['String']; pipelineStage: PipelineStage; @@ -1400,25 +1432,31 @@ export type PipelineProgress = { pointOfContact?: Maybe; pointOfContactId?: Maybe; probability?: Maybe; - progressableId: Scalars['String']; - progressableType: PipelineProgressableType; updatedAt: Scalars['DateTime']; }; export type PipelineProgressCreateInput = { amount?: InputMaybe; closeDate?: InputMaybe; + company?: InputMaybe; createdAt?: InputMaybe; id?: InputMaybe; + person?: InputMaybe; pipeline: PipelineCreateNestedOneWithoutPipelineProgressesInput; pipelineStage: PipelineStageCreateNestedOneWithoutPipelineProgressesInput; - pointOfContact?: InputMaybe; + pointOfContact?: InputMaybe; probability?: InputMaybe; - progressableId: Scalars['String']; - progressableType: PipelineProgressableType; updatedAt?: InputMaybe; }; +export type PipelineProgressCreateNestedManyWithoutCompanyInput = { + connect?: InputMaybe>; +}; + +export type PipelineProgressCreateNestedManyWithoutPersonInput = { + connect?: InputMaybe>; +}; + export type PipelineProgressCreateNestedManyWithoutPointOfContactInput = { connect?: InputMaybe>; }; @@ -1436,8 +1474,12 @@ export type PipelineProgressOrderByRelationAggregateInput = { export type PipelineProgressOrderByWithRelationInput = { amount?: InputMaybe; closeDate?: InputMaybe; + company?: InputMaybe; + companyId?: InputMaybe; createdAt?: InputMaybe; id?: InputMaybe; + person?: InputMaybe; + personId?: InputMaybe; pipeline?: InputMaybe; pipelineId?: InputMaybe; pipelineStage?: InputMaybe; @@ -1445,23 +1487,21 @@ export type PipelineProgressOrderByWithRelationInput = { pointOfContact?: InputMaybe; pointOfContactId?: InputMaybe; probability?: InputMaybe; - progressableId?: InputMaybe; - progressableType?: InputMaybe; updatedAt?: InputMaybe; }; export enum PipelineProgressScalarFieldEnum { Amount = 'amount', CloseDate = 'closeDate', + CompanyId = 'companyId', CreatedAt = 'createdAt', DeletedAt = 'deletedAt', Id = 'id', + PersonId = 'personId', PipelineId = 'pipelineId', PipelineStageId = 'pipelineStageId', PointOfContactId = 'pointOfContactId', Probability = 'probability', - ProgressableId = 'progressableId', - ProgressableType = 'progressableType', UpdatedAt = 'updatedAt', WorkspaceId = 'workspaceId' } @@ -1469,17 +1509,29 @@ export enum PipelineProgressScalarFieldEnum { export type PipelineProgressUpdateInput = { amount?: InputMaybe; closeDate?: InputMaybe; + company?: InputMaybe; createdAt?: InputMaybe; id?: InputMaybe; + person?: InputMaybe; pipeline?: InputMaybe; pipelineStage?: InputMaybe; - pointOfContact?: InputMaybe; + pointOfContact?: InputMaybe; probability?: InputMaybe; - progressableId?: InputMaybe; - progressableType?: InputMaybe; updatedAt?: InputMaybe; }; +export type PipelineProgressUpdateManyWithoutCompanyNestedInput = { + connect?: InputMaybe>; + disconnect?: InputMaybe>; + set?: InputMaybe>; +}; + +export type PipelineProgressUpdateManyWithoutPersonNestedInput = { + connect?: InputMaybe>; + disconnect?: InputMaybe>; + set?: InputMaybe>; +}; + export type PipelineProgressUpdateManyWithoutPipelineStageNestedInput = { connect?: InputMaybe>; disconnect?: InputMaybe>; @@ -1504,8 +1556,12 @@ export type PipelineProgressWhereInput = { OR?: InputMaybe>; amount?: InputMaybe; closeDate?: InputMaybe; + company?: InputMaybe; + companyId?: InputMaybe; createdAt?: InputMaybe; id?: InputMaybe; + person?: InputMaybe; + personId?: InputMaybe; pipeline?: InputMaybe; pipelineId?: InputMaybe; pipelineStage?: InputMaybe; @@ -1513,8 +1569,6 @@ export type PipelineProgressWhereInput = { pointOfContact?: InputMaybe; pointOfContactId?: InputMaybe; probability?: InputMaybe; - progressableId?: InputMaybe; - progressableType?: InputMaybe; updatedAt?: InputMaybe; }; @@ -2524,7 +2578,22 @@ export type GetPipelineProgressQueryVariables = Exact<{ }>; -export type GetPipelineProgressQuery = { __typename?: 'Query', findManyPipelineProgress: Array<{ __typename?: 'PipelineProgress', id: string, pipelineStageId: string, progressableType: PipelineProgressableType, progressableId: string, amount?: number | null, closeDate?: string | null, pointOfContactId?: string | null, probability?: number | null, pointOfContact?: { __typename?: 'Person', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null }> }; +export type GetPipelineProgressQuery = { __typename?: 'Query', findManyPipelineProgress: Array<{ __typename?: 'PipelineProgress', id: string, pipelineStageId: string, companyId?: string | null, personId?: string | null, amount?: number | null, closeDate?: string | null, pointOfContactId?: string | null, probability?: number | null, pointOfContact?: { __typename?: 'Person', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null }> }; + +export type DeleteManyPipelineProgressMutationVariables = Exact<{ + ids?: InputMaybe | Scalars['String']>; +}>; + + +export type DeleteManyPipelineProgressMutation = { __typename?: 'Mutation', deleteManyPipelineProgress: { __typename?: 'AffectedRows', count: number } }; + +export type UpdatePipelineStageMutationVariables = Exact<{ + id?: InputMaybe; + data: PipelineStageUpdateInput; +}>; + + +export type UpdatePipelineStageMutation = { __typename?: 'Mutation', updateOnePipelineStage?: { __typename?: 'PipelineStage', id: string, name: string, color: string } | null }; export type UpdateOnePipelineProgressMutationVariables = Exact<{ id?: InputMaybe; @@ -2545,31 +2614,15 @@ export type UpdateOnePipelineProgressStageMutationVariables = Exact<{ export type UpdateOnePipelineProgressStageMutation = { __typename?: 'Mutation', updateOnePipelineProgress?: { __typename?: 'PipelineProgress', id: string } | null }; -export type CreateOnePipelineProgressMutationVariables = Exact<{ +export type CreateOneCompanyPipelineProgressMutationVariables = Exact<{ uuid: Scalars['String']; - entityType: PipelineProgressableType; - entityId: Scalars['String']; + companyId: Scalars['String']; pipelineId: Scalars['String']; pipelineStageId: Scalars['String']; }>; -export type CreateOnePipelineProgressMutation = { __typename?: 'Mutation', createOnePipelineProgress: { __typename?: 'PipelineProgress', id: string } }; - -export type DeleteManyPipelineProgressMutationVariables = Exact<{ - ids?: InputMaybe | Scalars['String']>; -}>; - - -export type DeleteManyPipelineProgressMutation = { __typename?: 'Mutation', deleteManyPipelineProgress: { __typename?: 'AffectedRows', count: number } }; - -export type UpdatePipelineStageMutationVariables = Exact<{ - id?: InputMaybe; - data: PipelineStageUpdateInput; -}>; - - -export type UpdatePipelineStageMutation = { __typename?: 'Mutation', updateOnePipelineStage?: { __typename?: 'PipelineStage', id: string, name: string, color: string } | null }; +export type CreateOneCompanyPipelineProgressMutation = { __typename?: 'Mutation', createOnePipelineProgress: { __typename?: 'PipelineProgress', id: string } }; export type SearchPeopleQueryVariables = Exact<{ where?: InputMaybe; @@ -4360,8 +4413,8 @@ export const GetPipelineProgressDocument = gql` findManyPipelineProgress(where: $where, orderBy: $orderBy) { id pipelineStageId - progressableType - progressableId + companyId + personId amount closeDate pointOfContactId @@ -4405,6 +4458,75 @@ export function useGetPipelineProgressLazyQuery(baseOptions?: Apollo.LazyQueryHo export type GetPipelineProgressQueryHookResult = ReturnType; export type GetPipelineProgressLazyQueryHookResult = ReturnType; export type GetPipelineProgressQueryResult = Apollo.QueryResult; +export const DeleteManyPipelineProgressDocument = gql` + mutation DeleteManyPipelineProgress($ids: [String!]) { + deleteManyPipelineProgress(where: {id: {in: $ids}}) { + count + } +} + `; +export type DeleteManyPipelineProgressMutationFn = Apollo.MutationFunction; + +/** + * __useDeleteManyPipelineProgressMutation__ + * + * To run a mutation, you first call `useDeleteManyPipelineProgressMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useDeleteManyPipelineProgressMutation` 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 [deleteManyPipelineProgressMutation, { data, loading, error }] = useDeleteManyPipelineProgressMutation({ + * variables: { + * ids: // value for 'ids' + * }, + * }); + */ +export function useDeleteManyPipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(DeleteManyPipelineProgressDocument, options); + } +export type DeleteManyPipelineProgressMutationHookResult = ReturnType; +export type DeleteManyPipelineProgressMutationResult = Apollo.MutationResult; +export type DeleteManyPipelineProgressMutationOptions = Apollo.BaseMutationOptions; +export const UpdatePipelineStageDocument = gql` + mutation UpdatePipelineStage($id: String, $data: PipelineStageUpdateInput!) { + updateOnePipelineStage(where: {id: $id}, data: $data) { + id + name + color + } +} + `; +export type UpdatePipelineStageMutationFn = Apollo.MutationFunction; + +/** + * __useUpdatePipelineStageMutation__ + * + * To run a mutation, you first call `useUpdatePipelineStageMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdatePipelineStageMutation` 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 [updatePipelineStageMutation, { data, loading, error }] = useUpdatePipelineStageMutation({ + * variables: { + * id: // value for 'id' + * data: // value for 'data' + * }, + * }); + */ +export function useUpdatePipelineStageMutation(baseOptions?: Apollo.MutationHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useMutation(UpdatePipelineStageDocument, options); + } +export type UpdatePipelineStageMutationHookResult = ReturnType; +export type UpdatePipelineStageMutationResult = Apollo.MutationResult; +export type UpdatePipelineStageMutationOptions = Apollo.BaseMutationOptions; export const UpdateOnePipelineProgressDocument = gql` mutation UpdateOnePipelineProgress($id: String, $amount: Int, $closeDate: DateTime, $probability: Int, $pointOfContactId: String) { updateOnePipelineProgress( @@ -4484,114 +4606,44 @@ export function useUpdateOnePipelineProgressStageMutation(baseOptions?: Apollo.M export type UpdateOnePipelineProgressStageMutationHookResult = ReturnType; export type UpdateOnePipelineProgressStageMutationResult = Apollo.MutationResult; export type UpdateOnePipelineProgressStageMutationOptions = Apollo.BaseMutationOptions; -export const CreateOnePipelineProgressDocument = gql` - mutation CreateOnePipelineProgress($uuid: String!, $entityType: PipelineProgressableType!, $entityId: String!, $pipelineId: String!, $pipelineStageId: String!) { +export const CreateOneCompanyPipelineProgressDocument = gql` + mutation CreateOneCompanyPipelineProgress($uuid: String!, $companyId: String!, $pipelineId: String!, $pipelineStageId: String!) { createOnePipelineProgress( - data: {id: $uuid, progressableType: $entityType, progressableId: $entityId, pipeline: {connect: {id: $pipelineId}}, pipelineStage: {connect: {id: $pipelineStageId}}} + data: {id: $uuid, company: {connect: {id: $companyId}}, pipeline: {connect: {id: $pipelineId}}, pipelineStage: {connect: {id: $pipelineStageId}}} ) { id } } `; -export type CreateOnePipelineProgressMutationFn = Apollo.MutationFunction; +export type CreateOneCompanyPipelineProgressMutationFn = Apollo.MutationFunction; /** - * __useCreateOnePipelineProgressMutation__ + * __useCreateOneCompanyPipelineProgressMutation__ * - * To run a mutation, you first call `useCreateOnePipelineProgressMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useCreateOnePipelineProgressMutation` returns a tuple that includes: + * To run a mutation, you first call `useCreateOneCompanyPipelineProgressMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useCreateOneCompanyPipelineProgressMutation` 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 [createOnePipelineProgressMutation, { data, loading, error }] = useCreateOnePipelineProgressMutation({ + * const [createOneCompanyPipelineProgressMutation, { data, loading, error }] = useCreateOneCompanyPipelineProgressMutation({ * variables: { * uuid: // value for 'uuid' - * entityType: // value for 'entityType' - * entityId: // value for 'entityId' + * companyId: // value for 'companyId' * pipelineId: // value for 'pipelineId' * pipelineStageId: // value for 'pipelineStageId' * }, * }); */ -export function useCreateOnePipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useCreateOneCompanyPipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(CreateOnePipelineProgressDocument, options); + return Apollo.useMutation(CreateOneCompanyPipelineProgressDocument, options); } -export type CreateOnePipelineProgressMutationHookResult = ReturnType; -export type CreateOnePipelineProgressMutationResult = Apollo.MutationResult; -export type CreateOnePipelineProgressMutationOptions = Apollo.BaseMutationOptions; -export const DeleteManyPipelineProgressDocument = gql` - mutation DeleteManyPipelineProgress($ids: [String!]) { - deleteManyPipelineProgress(where: {id: {in: $ids}}) { - count - } -} - `; -export type DeleteManyPipelineProgressMutationFn = Apollo.MutationFunction; - -/** - * __useDeleteManyPipelineProgressMutation__ - * - * To run a mutation, you first call `useDeleteManyPipelineProgressMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useDeleteManyPipelineProgressMutation` 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 [deleteManyPipelineProgressMutation, { data, loading, error }] = useDeleteManyPipelineProgressMutation({ - * variables: { - * ids: // value for 'ids' - * }, - * }); - */ -export function useDeleteManyPipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(DeleteManyPipelineProgressDocument, options); - } -export type DeleteManyPipelineProgressMutationHookResult = ReturnType; -export type DeleteManyPipelineProgressMutationResult = Apollo.MutationResult; -export type DeleteManyPipelineProgressMutationOptions = Apollo.BaseMutationOptions; -export const UpdatePipelineStageDocument = gql` - mutation UpdatePipelineStage($id: String, $data: PipelineStageUpdateInput!) { - updateOnePipelineStage(where: {id: $id}, data: $data) { - id - name - color - } -} - `; -export type UpdatePipelineStageMutationFn = Apollo.MutationFunction; - -/** - * __useUpdatePipelineStageMutation__ - * - * To run a mutation, you first call `useUpdatePipelineStageMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useUpdatePipelineStageMutation` 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 [updatePipelineStageMutation, { data, loading, error }] = useUpdatePipelineStageMutation({ - * variables: { - * id: // value for 'id' - * data: // value for 'data' - * }, - * }); - */ -export function useUpdatePipelineStageMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(UpdatePipelineStageDocument, options); - } -export type UpdatePipelineStageMutationHookResult = ReturnType; -export type UpdatePipelineStageMutationResult = Apollo.MutationResult; -export type UpdatePipelineStageMutationOptions = Apollo.BaseMutationOptions; +export type CreateOneCompanyPipelineProgressMutationHookResult = ReturnType; +export type CreateOneCompanyPipelineProgressMutationResult = Apollo.MutationResult; +export type CreateOneCompanyPipelineProgressMutationOptions = Apollo.BaseMutationOptions; export const SearchPeopleDocument = gql` query SearchPeople($where: PersonWhereInput, $limit: Int, $orderBy: [PersonOrderByWithRelationInput!]) { searchResults: findManyPerson(where: $where, take: $limit, orderBy: $orderBy) { diff --git a/front/src/modules/companies/components/HooksCompanyBoard.tsx b/front/src/modules/companies/components/HooksCompanyBoard.tsx index f31e824fd..8acb76005 100644 --- a/front/src/modules/companies/components/HooksCompanyBoard.tsx +++ b/front/src/modules/companies/components/HooksCompanyBoard.tsx @@ -119,7 +119,7 @@ export function HooksCompanyBoard({ variables: { where: { id: { - in: pipelineProgresses.map((item) => item.progressableId), + in: pipelineProgresses.map((item) => item.companyId || ''), }, }, }, @@ -145,7 +145,9 @@ export function HooksCompanyBoard({ }, pipelineProgress: PipelineProgressForBoard, ) => { - const company = companiesDict[pipelineProgress.progressableId]; + const company = + pipelineProgress.companyId && companiesDict[pipelineProgress.companyId]; + if (!company) return acc; return { ...acc, [pipelineProgress.id]: { diff --git a/front/src/modules/companies/components/NewCompanyProgressButton.tsx b/front/src/modules/companies/components/NewCompanyProgressButton.tsx index ef5f24ce2..59724b013 100644 --- a/front/src/modules/companies/components/NewCompanyProgressButton.tsx +++ b/front/src/modules/companies/components/NewCompanyProgressButton.tsx @@ -15,10 +15,7 @@ import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picke import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState'; -import { - PipelineProgressableType, - useCreateOnePipelineProgressMutation, -} from '~/generated/graphql'; +import { useCreateOneCompanyPipelineProgressMutation } from '~/generated/graphql'; import { useFilteredSearchCompanyQuery } from '../queries'; @@ -36,12 +33,13 @@ export function NewCompanyProgressButton() { setHotkeyScopeAndMemorizePreviousScope, } = usePreviousHotkeyScope(); - const [createOnePipelineProgress] = useCreateOnePipelineProgressMutation({ - refetchQueries: [ - getOperationName(GET_PIPELINE_PROGRESS) ?? '', - getOperationName(GET_PIPELINES) ?? '', - ], - }); + const [createOneCompanyPipelineProgress] = + useCreateOneCompanyPipelineProgressMutation({ + refetchQueries: [ + getOperationName(GET_PIPELINE_PROGRESS) ?? '', + getOperationName(GET_PIPELINES) ?? '', + ], + }); const handleEntitySelect = useCallback( async (company: any) => { @@ -58,13 +56,12 @@ export function NewCompanyProgressButton() { ); newBoard[destinationColumnIndex].pipelineProgressIds.push(newUuid); setBoard(newBoard); - await createOnePipelineProgress({ + await createOneCompanyPipelineProgress({ variables: { uuid: newUuid, pipelineStageId: pipelineStageId || '', pipelineId: pipeline?.id || '', - entityId: company.id || '', - entityType: PipelineProgressableType.Company, + companyId: company.id || '', }, }); }, @@ -72,7 +69,7 @@ export function NewCompanyProgressButton() { goBackToPreviousHotkeyScope, board, setBoard, - createOnePipelineProgress, + createOneCompanyPipelineProgress, pipelineStageId, pipeline?.id, ], diff --git a/front/src/modules/companies/types/CompanyProgress.ts b/front/src/modules/companies/types/CompanyProgress.ts index 4ae44321a..250c7711a 100644 --- a/front/src/modules/companies/types/CompanyProgress.ts +++ b/front/src/modules/companies/types/CompanyProgress.ts @@ -6,7 +6,7 @@ export type PipelineProgressForBoard = Pick< | 'id' | 'amount' | 'closeDate' - | 'progressableId' + | 'companyId' | 'probability' | 'pointOfContactId' > & { diff --git a/front/src/modules/pipeline/queries/select.ts b/front/src/modules/pipeline/queries/select.ts index e9b847eea..ce830135e 100644 --- a/front/src/modules/pipeline/queries/select.ts +++ b/front/src/modules/pipeline/queries/select.ts @@ -33,8 +33,8 @@ export const GET_PIPELINE_PROGRESS = gql` findManyPipelineProgress(where: $where, orderBy: $orderBy) { id pipelineStageId - progressableType - progressableId + companyId + personId amount closeDate pointOfContactId @@ -50,66 +50,6 @@ export const GET_PIPELINE_PROGRESS = gql` } `; -export const UPDATE_PIPELINE_PROGRESS = gql` - mutation UpdateOnePipelineProgress( - $id: String - $amount: Int - $closeDate: DateTime - $probability: Int - $pointOfContactId: String - ) { - updateOnePipelineProgress( - where: { id: $id } - data: { - amount: $amount - closeDate: $closeDate - probability: $probability - pointOfContact: { connect: { id: $pointOfContactId } } - } - ) { - id - amount - closeDate - } - } -`; - -export const UPDATE_PIPELINE_PROGRESS_STAGE = gql` - mutation UpdateOnePipelineProgressStage( - $id: String - $pipelineStageId: String - ) { - updateOnePipelineProgress( - where: { id: $id } - data: { pipelineStage: { connect: { id: $pipelineStageId } } } - ) { - id - } - } -`; - -export const ADD_ENTITY_TO_PIPELINE = gql` - mutation CreateOnePipelineProgress( - $uuid: String! - $entityType: PipelineProgressableType! - $entityId: String! - $pipelineId: String! - $pipelineStageId: String! - ) { - createOnePipelineProgress( - data: { - id: $uuid - progressableType: $entityType - progressableId: $entityId - pipeline: { connect: { id: $pipelineId } } - pipelineStage: { connect: { id: $pipelineStageId } } - } - ) { - id - } - } -`; - export const defaultPipelineProgressOrderBy: PipelineProgresses_Order_By[] = [ { createdAt: Order_By.Asc, diff --git a/front/src/modules/pipeline/queries/update.ts b/front/src/modules/pipeline/queries/update.ts index 157b0c02f..295a78deb 100644 --- a/front/src/modules/pipeline/queries/update.ts +++ b/front/src/modules/pipeline/queries/update.ts @@ -17,3 +17,61 @@ export const UPDATE_PIPELINE_STAGE = gql` } } `; + +export const UPDATE_PIPELINE_PROGRESS = gql` + mutation UpdateOnePipelineProgress( + $id: String + $amount: Int + $closeDate: DateTime + $probability: Int + $pointOfContactId: String + ) { + updateOnePipelineProgress( + where: { id: $id } + data: { + amount: $amount + closeDate: $closeDate + probability: $probability + pointOfContact: { connect: { id: $pointOfContactId } } + } + ) { + id + amount + closeDate + } + } +`; + +export const UPDATE_PIPELINE_PROGRESS_STAGE = gql` + mutation UpdateOnePipelineProgressStage( + $id: String + $pipelineStageId: String + ) { + updateOnePipelineProgress( + where: { id: $id } + data: { pipelineStage: { connect: { id: $pipelineStageId } } } + ) { + id + } + } +`; + +export const CREATE_COMPANY_PIPELINE_PROGRESS = gql` + mutation CreateOneCompanyPipelineProgress( + $uuid: String! + $companyId: String! + $pipelineId: String! + $pipelineStageId: String! + ) { + createOnePipelineProgress( + data: { + id: $uuid + company: { connect: { id: $companyId } } + pipeline: { connect: { id: $pipelineId } } + pipelineStage: { connect: { id: $pipelineStageId } } + } + ) { + id + } + } +`; diff --git a/front/src/pages/opportunities/opportunities-filters.tsx b/front/src/pages/opportunities/opportunities-filters.tsx index b75cd4a27..66d295523 100644 --- a/front/src/pages/opportunities/opportunities-filters.tsx +++ b/front/src/pages/opportunities/opportunities-filters.tsx @@ -27,7 +27,7 @@ export const opportunitiesFilters: FilterDefinitionByEntity[] type: 'date', }, { - field: 'progressableId', + field: 'companyId', label: 'Company', icon: ( diff --git a/front/src/testing/mock-data/pipeline-progress.ts b/front/src/testing/mock-data/pipeline-progress.ts index ea16ce7ce..c3d717727 100644 --- a/front/src/testing/mock-data/pipeline-progress.ts +++ b/front/src/testing/mock-data/pipeline-progress.ts @@ -1,17 +1,8 @@ -import { - PipelineProgress, - PipelineProgressableType, - User, -} from '../../generated/graphql'; +import { PipelineProgress, User } from '../../generated/graphql'; type MockedPipelineProgress = Pick< PipelineProgress, - | 'id' - | 'amount' - | 'closeDate' - | 'progressableId' - | 'pipelineStageId' - | 'progressableType' + 'id' | 'amount' | 'closeDate' | 'companyId' | 'pipelineStageId' > & { accountOwner: Pick< User, @@ -38,27 +29,24 @@ export const mockedPipelineProgressData: Array = [ id: '0ac8761c-1ad6-11ee-be56-0242ac120002', amount: 78, closeDate: '2021-10-01T00:00:00.000Z', - progressableId: '0', + companyId: '0', accountOwner: accountOwner, pipelineStageId: 'another-pipeline-stage-1', - progressableType: PipelineProgressableType.Company, }, { id: 'fe256b39-3ec3-4fe7-8998-b76aa0bfb600', - progressableId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', + companyId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', pipelineStageId: 'fe256b39-3ec3-4fe3-8998-b76aa0bfb600', amount: 7, closeDate: '2021-10-01T00:00:00.000Z', accountOwner, - progressableType: PipelineProgressableType.Company, }, { id: '4a886c90-f4f2-4984-8222-882ebbb905d6', - progressableId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae', + companyId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae', amount: 100, closeDate: '2021-10-01T00:00:00.000Z', accountOwner, pipelineStageId: 'fe256b39-3ec3-4fe3-8998-b76aa0bfb600', - progressableType: PipelineProgressableType.Company, }, ]; diff --git a/front/src/testing/mock-data/pipelines.ts b/front/src/testing/mock-data/pipelines.ts index 93b0c269d..e5fc0e6f5 100644 --- a/front/src/testing/mock-data/pipelines.ts +++ b/front/src/testing/mock-data/pipelines.ts @@ -14,12 +14,7 @@ type MockedPipeline = Pick< pipelineProgresses: Array< Pick< PipelineProgress, - | 'id' - | 'progressableType' - | 'progressableId' - | 'amount' - | 'closeDate' - | '__typename' + 'id' | 'companyId' | 'amount' | 'closeDate' | '__typename' > >; } @@ -40,16 +35,14 @@ export const mockedPipelinesData: Array = [ pipelineProgresses: [ { id: 'fe256b39-3ec3-4fe7-8998-b76aa0bfb600', - progressableType: PipelineProgressableType.Company, - progressableId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', + companyId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', amount: null, closeDate: null, __typename: 'PipelineProgress', }, { id: '4a886c90-f4f2-4984-8222-882ebbb905d6', - progressableType: PipelineProgressableType.Company, - progressableId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae', + companyId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae', amount: null, closeDate: null, __typename: 'PipelineProgress', diff --git a/server/src/database/migrations/20230803115502_add_entities_on_pipeline_progress/migration.sql b/server/src/database/migrations/20230803115502_add_entities_on_pipeline_progress/migration.sql new file mode 100644 index 000000000..003a2e7ee --- /dev/null +++ b/server/src/database/migrations/20230803115502_add_entities_on_pipeline_progress/migration.sql @@ -0,0 +1,9 @@ +-- AlterTable +ALTER TABLE "pipeline_progresses" ADD COLUMN "companyId" TEXT, +ADD COLUMN "personId" TEXT; + +-- AddForeignKey +ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/server/src/database/migrations/20230803121208_data_migration_move_progressable_ids_to_typed_fields/migration.sql b/server/src/database/migrations/20230803121208_data_migration_move_progressable_ids_to_typed_fields/migration.sql new file mode 100644 index 000000000..2cbb82a32 --- /dev/null +++ b/server/src/database/migrations/20230803121208_data_migration_move_progressable_ids_to_typed_fields/migration.sql @@ -0,0 +1,8 @@ +-- This is a manually written data migration that copies the progressable ids to the right colums in pipeline progress. +UPDATE "pipeline_progresses" SET + "companyId"="progressableId" +WHERE "progressableType"='Company'; + +UPDATE "pipeline_progresses" SET + "personId"="progressableId" +WHERE "progressableType"='Person'; \ No newline at end of file diff --git a/server/src/database/migrations/20230803141808_remove_progressable_id_from_pipeline_progress/migration.sql b/server/src/database/migrations/20230803141808_remove_progressable_id_from_pipeline_progress/migration.sql new file mode 100644 index 000000000..a8596427d --- /dev/null +++ b/server/src/database/migrations/20230803141808_remove_progressable_id_from_pipeline_progress/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - You are about to drop the column `progressableId` on the `pipeline_progresses` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "pipeline_progresses" DROP COLUMN "progressableId"; diff --git a/server/src/database/migrations/20230803143326_remove_progressable_type_on_pipeline_progress/migration.sql b/server/src/database/migrations/20230803143326_remove_progressable_type_on_pipeline_progress/migration.sql new file mode 100644 index 000000000..df8c52e6c --- /dev/null +++ b/server/src/database/migrations/20230803143326_remove_progressable_type_on_pipeline_progress/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - You are about to drop the column `progressableType` on the `pipeline_progresses` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "pipeline_progresses" DROP COLUMN "progressableType"; diff --git a/server/src/database/schema.prisma b/server/src/database/schema.prisma index ba650f8e3..d11279bb3 100644 --- a/server/src/database/schema.prisma +++ b/server/src/database/schema.prisma @@ -240,9 +240,10 @@ model Company { /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - ActivityTarget ActivityTarget[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + ActivityTarget ActivityTarget[] + PipelineProgress PipelineProgress[] @@map("companies") } @@ -276,20 +277,21 @@ model Person { /// @Validator.IsOptional() avatarUrl String? - company Company? @relation(fields: [companyId], references: [id]) - companyId String? + company Company? @relation(fields: [companyId], references: [id]) + companyId String? /// @TypeGraphQL.omit(input: true, output: true) - workspace Workspace @relation(fields: [workspaceId], references: [id]) + workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) - workspaceId String - pipelineProgresses PipelineProgress[] + workspaceId String + contactPipelineProgresses PipelineProgress[] @relation("PointOfContactPipelineProgress") /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - ActivityTarget ActivityTarget[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + ActivityTarget ActivityTarget[] + PipelineProgress PipelineProgress[] @@map("people") } @@ -488,18 +490,17 @@ model PipelineProgress { closeDate DateTime? probability Int? - pipeline Pipeline @relation(fields: [pipelineId], references: [id]) + pipeline Pipeline @relation(fields: [pipelineId], references: [id]) pipelineId String - pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id]) + pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id]) pipelineStageId String - pointOfContact Person? @relation(fields: [pointOfContactId], references: [id]) + pointOfContact Person? @relation("PointOfContactPipelineProgress", fields: [pointOfContactId], references: [id]) pointOfContactId String? - progressableType PipelineProgressableType - progressableId String + /// @TypeGraphQL.omit(input: true, output: true) - workspace Workspace @relation(fields: [workspaceId], references: [id]) + workspace Workspace @relation(fields: [workspaceId], references: [id]) /// @TypeGraphQL.omit(input: true, output: true) - workspaceId String + workspaceId String /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? @@ -507,6 +508,12 @@ model PipelineProgress { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + companyId String? + company Company? @relation(fields: [companyId], references: [id]) + + personId String? + person Person? @relation(fields: [personId], references: [id]) + @@map("pipeline_progresses") } diff --git a/server/src/database/seeds/pipelines.ts b/server/src/database/seeds/pipelines.ts index b4cd94904..3f2426649 100644 --- a/server/src/database/seeds/pipelines.ts +++ b/server/src/database/seeds/pipelines.ts @@ -89,8 +89,7 @@ export const seedPipelines = async (prisma: PrismaClient) => { id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600', - progressableType: 'Company', - progressableId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', + companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', }, }); @@ -102,8 +101,7 @@ export const seedPipelines = async (prisma: PrismaClient) => { id: 'twenty-4a886c90-f4f2-4984-8222-882ebbb905d6', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineStageId: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600', - progressableType: 'Company', - progressableId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102', + companyId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', }, }); @@ -115,8 +113,7 @@ export const seedPipelines = async (prisma: PrismaClient) => { id: 'twenty-af92f3eb-d51d-4528-9b97-b8f132865b00', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600', - progressableType: 'Company', - progressableId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e', + companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', }, }); @@ -128,8 +125,7 @@ export const seedPipelines = async (prisma: PrismaClient) => { id: 'twenty-08369b1a-acdb-43d6-95f9-67ac7436941a', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600', - progressableType: 'Company', - progressableId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', + companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', }, }); @@ -167,8 +163,7 @@ export const seedPipelines = async (prisma: PrismaClient) => { id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400', pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600', - progressableType: 'Person', - progressableId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1', + personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', }, }); @@ -181,7 +176,6 @@ export const seedPipelines = async (prisma: PrismaClient) => { name: 'Sales pipeline', icon: '💰', workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420', - pipelineProgressableType: 'Person', }, });