Skip to content

The open alternative to Salesforce, designed for AI.

Refactor: Morph strategy on `PipelineProgress` (#1065)

Emilien Chauvet21e3d8fcac84
diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx
index 15db6ea2ee3..a8f219d93ce 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<Array<ActivityTarget>>;
+ PipelineProgress?: Maybe<Array<PipelineProgress>>;
_activityCount: Scalars['Int'];
accountOwner?: Maybe<User>;
accountOwnerId?: Maybe<Scalars['String']>;
@@ -657,6 +658,7 @@ export type Company = {
export type CompanyCreateInput = {
ActivityTarget?: InputMaybe<ActivityTargetCreateNestedManyWithoutCompanyInput>;
+ PipelineProgress?: InputMaybe<PipelineProgressCreateNestedManyWithoutCompanyInput>;
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
address: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>;
@@ -677,6 +679,10 @@ export type CompanyCreateNestedOneWithoutPeopleInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
};
+export type CompanyCreateNestedOneWithoutPipelineProgressInput = {
+ connect?: InputMaybe<CompanyWhereUniqueInput>;
+};
+
export type CompanyListRelationFilter = {
every?: InputMaybe<CompanyWhereInput>;
none?: InputMaybe<CompanyWhereInput>;
@@ -689,6 +695,7 @@ export type CompanyOrderByRelationAggregateInput = {
export type CompanyOrderByWithRelationInput = {
ActivityTarget?: InputMaybe<ActivityTargetOrderByRelationAggregateInput>;
+ PipelineProgress?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
accountOwner?: InputMaybe<UserOrderByWithRelationInput>;
accountOwnerId?: InputMaybe<SortOrder>;
address?: InputMaybe<SortOrder>;
@@ -723,6 +730,7 @@ export enum CompanyScalarFieldEnum {
export type CompanyUpdateInput = {
ActivityTarget?: InputMaybe<ActivityTargetUpdateManyWithoutCompanyNestedInput>;
+ PipelineProgress?: InputMaybe<PipelineProgressUpdateManyWithoutCompanyNestedInput>;
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
@@ -752,11 +760,17 @@ export type CompanyUpdateOneWithoutPeopleNestedInput = {
disconnect?: InputMaybe<Scalars['Boolean']>;
};
+export type CompanyUpdateOneWithoutPipelineProgressNestedInput = {
+ connect?: InputMaybe<CompanyWhereUniqueInput>;
+ disconnect?: InputMaybe<Scalars['Boolean']>;
+};
+
export type CompanyWhereInput = {
AND?: InputMaybe<Array<CompanyWhereInput>>;
ActivityTarget?: InputMaybe<ActivityTargetListRelationFilter>;
NOT?: InputMaybe<Array<CompanyWhereInput>>;
OR?: InputMaybe<Array<CompanyWhereInput>>;
+ PipelineProgress?: InputMaybe<PipelineProgressListRelationFilter>;
accountOwner?: InputMaybe<UserRelationFilter>;
accountOwnerId?: InputMaybe<StringNullableFilter>;
address?: InputMaybe<StringFilter>;
@@ -1202,6 +1216,7 @@ export type NestedStringNullableFilter = {
export type Person = {
__typename?: 'Person';
ActivityTarget?: Maybe<Array<ActivityTarget>>;
+ PipelineProgress?: Maybe<Array<PipelineProgress>>;
_activityCount: Scalars['Int'];
activities: Array<Activity>;
avatarUrl?: Maybe<Scalars['String']>;
@@ -1209,6 +1224,7 @@ export type Person = {
comments: Array<Comment>;
company?: Maybe<Company>;
companyId?: Maybe<Scalars['String']>;
+ contactPipelineProgresses?: Maybe<Array<PipelineProgress>>;
createdAt: Scalars['DateTime'];
displayName: Scalars['String'];
email?: Maybe<Scalars['String']>;
@@ -1218,15 +1234,16 @@ export type Person = {
lastName?: Maybe<Scalars['String']>;
linkedinUrl?: Maybe<Scalars['String']>;
phone?: Maybe<Scalars['String']>;
- pipelineProgresses?: Maybe<Array<PipelineProgress>>;
updatedAt: Scalars['DateTime'];
};
export type PersonCreateInput = {
ActivityTarget?: InputMaybe<ActivityTargetCreateNestedManyWithoutPersonInput>;
+ PipelineProgress?: InputMaybe<PipelineProgressCreateNestedManyWithoutPersonInput>;
avatarUrl?: InputMaybe<Scalars['String']>;
city?: InputMaybe<Scalars['String']>;
company?: InputMaybe<CompanyCreateNestedOneWithoutPeopleInput>;
+ contactPipelineProgresses?: InputMaybe<PipelineProgressCreateNestedManyWithoutPointOfContactInput>;
createdAt?: InputMaybe<Scalars['DateTime']>;
email?: InputMaybe<Scalars['String']>;
firstName?: InputMaybe<Scalars['String']>;
@@ -1235,7 +1252,6 @@ export type PersonCreateInput = {
lastName?: InputMaybe<Scalars['String']>;
linkedinUrl?: InputMaybe<Scalars['String']>;
phone?: InputMaybe<Scalars['String']>;
- pipelineProgresses?: InputMaybe<PipelineProgressCreateNestedManyWithoutPointOfContactInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
@@ -1247,7 +1263,11 @@ export type PersonCreateNestedOneWithoutActivityTargetInput = {
connect?: InputMaybe<PersonWhereUniqueInput>;
};
-export type PersonCreateNestedOneWithoutPipelineProgressesInput = {
+export type PersonCreateNestedOneWithoutContactPipelineProgressesInput = {
+ connect?: InputMaybe<PersonWhereUniqueInput>;
+};
+
+export type PersonCreateNestedOneWithoutPipelineProgressInput = {
connect?: InputMaybe<PersonWhereUniqueInput>;
};
@@ -1263,10 +1283,12 @@ export type PersonOrderByRelationAggregateInput = {
export type PersonOrderByWithRelationInput = {
ActivityTarget?: InputMaybe<ActivityTargetOrderByRelationAggregateInput>;
+ PipelineProgress?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
avatarUrl?: InputMaybe<SortOrder>;
city?: InputMaybe<SortOrder>;
company?: InputMaybe<CompanyOrderByWithRelationInput>;
companyId?: InputMaybe<SortOrder>;
+ contactPipelineProgresses?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
createdAt?: InputMaybe<SortOrder>;
email?: InputMaybe<SortOrder>;
firstName?: InputMaybe<SortOrder>;
@@ -1275,7 +1297,6 @@ export type PersonOrderByWithRelationInput = {
lastName?: InputMaybe<SortOrder>;
linkedinUrl?: InputMaybe<SortOrder>;
phone?: InputMaybe<SortOrder>;
- pipelineProgresses?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
updatedAt?: InputMaybe<SortOrder>;
};
@@ -1303,9 +1324,11 @@ export enum PersonScalarFieldEnum {
export type PersonUpdateInput = {
ActivityTarget?: InputMaybe<ActivityTargetUpdateManyWithoutPersonNestedInput>;
+ PipelineProgress?: InputMaybe<PipelineProgressUpdateManyWithoutPersonNestedInput>;
avatarUrl?: InputMaybe<Scalars['String']>;
city?: InputMaybe<Scalars['String']>;
company?: InputMaybe<CompanyUpdateOneWithoutPeopleNestedInput>;
+ contactPipelineProgresses?: InputMaybe<PipelineProgressUpdateManyWithoutPointOfContactNestedInput>;
createdAt?: InputMaybe<Scalars['DateTime']>;
email?: InputMaybe<Scalars['String']>;
firstName?: InputMaybe<Scalars['String']>;
@@ -1314,7 +1337,6 @@ export type PersonUpdateInput = {
lastName?: InputMaybe<Scalars['String']>;
linkedinUrl?: InputMaybe<Scalars['String']>;
phone?: InputMaybe<Scalars['String']>;
- pipelineProgresses?: InputMaybe<PipelineProgressUpdateManyWithoutPointOfContactNestedInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
@@ -1330,7 +1352,12 @@ export type PersonUpdateManyWithoutWorkspaceNestedInput = {
set?: InputMaybe<Array<PersonWhereUniqueInput>>;
};
-export type PersonUpdateOneWithoutPipelineProgressesNestedInput = {
+export type PersonUpdateOneWithoutContactPipelineProgressesNestedInput = {
+ connect?: InputMaybe<PersonWhereUniqueInput>;
+ disconnect?: InputMaybe<Scalars['Boolean']>;
+};
+
+export type PersonUpdateOneWithoutPipelineProgressNestedInput = {
connect?: InputMaybe<PersonWhereUniqueInput>;
disconnect?: InputMaybe<Scalars['Boolean']>;
};
@@ -1340,10 +1367,12 @@ export type PersonWhereInput = {
ActivityTarget?: InputMaybe<ActivityTargetListRelationFilter>;
NOT?: InputMaybe<Array<PersonWhereInput>>;
OR?: InputMaybe<Array<PersonWhereInput>>;
+ PipelineProgress?: InputMaybe<PipelineProgressListRelationFilter>;
avatarUrl?: InputMaybe<StringNullableFilter>;
city?: InputMaybe<StringNullableFilter>;
company?: InputMaybe<CompanyRelationFilter>;
companyId?: InputMaybe<StringNullableFilter>;
+ contactPipelineProgresses?: InputMaybe<PipelineProgressListRelationFilter>;
createdAt?: InputMaybe<DateTimeFilter>;
email?: InputMaybe<StringNullableFilter>;
firstName?: InputMaybe<StringNullableFilter>;
@@ -1352,7 +1381,6 @@ export type PersonWhereInput = {
lastName?: InputMaybe<StringNullableFilter>;
linkedinUrl?: InputMaybe<StringNullableFilter>;
phone?: InputMaybe<StringNullableFilter>;
- pipelineProgresses?: InputMaybe<PipelineProgressListRelationFilter>;
updatedAt?: InputMaybe<DateTimeFilter>;
};
@@ -1391,8 +1419,12 @@ export type PipelineProgress = {
__typename?: 'PipelineProgress';
amount?: Maybe<Scalars['Int']>;
closeDate?: Maybe<Scalars['DateTime']>;
+ company?: Maybe<Company>;
+ companyId?: Maybe<Scalars['String']>;
createdAt: Scalars['DateTime'];
id: Scalars['ID'];
+ person?: Maybe<Person>;
+ personId?: Maybe<Scalars['String']>;
pipeline: Pipeline;
pipelineId: Scalars['String'];
pipelineStage: PipelineStage;
@@ -1400,25 +1432,31 @@ export type PipelineProgress = {
pointOfContact?: Maybe<Person>;
pointOfContactId?: Maybe<Scalars['String']>;
probability?: Maybe<Scalars['Int']>;
- progressableId: Scalars['String'];
- progressableType: PipelineProgressableType;
updatedAt: Scalars['DateTime'];
};
export type PipelineProgressCreateInput = {
amount?: InputMaybe<Scalars['Int']>;
closeDate?: InputMaybe<Scalars['DateTime']>;
+ company?: InputMaybe<CompanyCreateNestedOneWithoutPipelineProgressInput>;
createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>;
+ person?: InputMaybe<PersonCreateNestedOneWithoutPipelineProgressInput>;
pipeline: PipelineCreateNestedOneWithoutPipelineProgressesInput;
pipelineStage: PipelineStageCreateNestedOneWithoutPipelineProgressesInput;
- pointOfContact?: InputMaybe<PersonCreateNestedOneWithoutPipelineProgressesInput>;
+ pointOfContact?: InputMaybe<PersonCreateNestedOneWithoutContactPipelineProgressesInput>;
probability?: InputMaybe<Scalars['Int']>;
- progressableId: Scalars['String'];
- progressableType: PipelineProgressableType;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
+export type PipelineProgressCreateNestedManyWithoutCompanyInput = {
+ connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+};
+
+export type PipelineProgressCreateNestedManyWithoutPersonInput = {
+ connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+};
+
export type PipelineProgressCreateNestedManyWithoutPointOfContactInput = {
connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
};
@@ -1436,8 +1474,12 @@ export type PipelineProgressOrderByRelationAggregateInput = {
export type PipelineProgressOrderByWithRelationInput = {
amount?: InputMaybe<SortOrder>;
closeDate?: InputMaybe<SortOrder>;
+ company?: InputMaybe<CompanyOrderByWithRelationInput>;
+ companyId?: InputMaybe<SortOrder>;
createdAt?: InputMaybe<SortOrder>;
id?: InputMaybe<SortOrder>;
+ person?: InputMaybe<PersonOrderByWithRelationInput>;
+ personId?: InputMaybe<SortOrder>;
pipeline?: InputMaybe<PipelineOrderByWithRelationInput>;
pipelineId?: InputMaybe<SortOrder>;
pipelineStage?: InputMaybe<PipelineStageOrderByWithRelationInput>;
@@ -1445,23 +1487,21 @@ export type PipelineProgressOrderByWithRelationInput = {
pointOfContact?: InputMaybe<PersonOrderByWithRelationInput>;
pointOfContactId?: InputMaybe<SortOrder>;
probability?: InputMaybe<SortOrder>;
- progressableId?: InputMaybe<SortOrder>;
- progressableType?: InputMaybe<SortOrder>;
updatedAt?: InputMaybe<SortOrder>;
};
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<Scalars['Int']>;
closeDate?: InputMaybe<Scalars['DateTime']>;
+ company?: InputMaybe<CompanyUpdateOneWithoutPipelineProgressNestedInput>;
createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>;
+ person?: InputMaybe<PersonUpdateOneWithoutPipelineProgressNestedInput>;
pipeline?: InputMaybe<PipelineUpdateOneRequiredWithoutPipelineProgressesNestedInput>;
pipelineStage?: InputMaybe<PipelineStageUpdateOneRequiredWithoutPipelineProgressesNestedInput>;
- pointOfContact?: InputMaybe<PersonUpdateOneWithoutPipelineProgressesNestedInput>;
+ pointOfContact?: InputMaybe<PersonUpdateOneWithoutContactPipelineProgressesNestedInput>;
probability?: InputMaybe<Scalars['Int']>;
- progressableId?: InputMaybe<Scalars['String']>;
- progressableType?: InputMaybe<PipelineProgressableType>;
updatedAt?: InputMaybe<Scalars['DateTime']>;
};
+export type PipelineProgressUpdateManyWithoutCompanyNestedInput = {
+ connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+ disconnect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+ set?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+};
+
+export type PipelineProgressUpdateManyWithoutPersonNestedInput = {
+ connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+ disconnect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+ set?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
+};
+
export type PipelineProgressUpdateManyWithoutPipelineStageNestedInput = {
connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
disconnect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
@@ -1504,8 +1556,12 @@ export type PipelineProgressWhereInput = {
OR?: InputMaybe<Array<PipelineProgressWhereInput>>;
amount?: InputMaybe<IntNullableFilter>;
closeDate?: InputMaybe<DateTimeNullableFilter>;
+ company?: InputMaybe<CompanyRelationFilter>;
+ companyId?: InputMaybe<StringNullableFilter>;
createdAt?: InputMaybe<DateTimeFilter>;
id?: InputMaybe<StringFilter>;
+ person?: InputMaybe<PersonRelationFilter>;
+ personId?: InputMaybe<StringNullableFilter>;
pipeline?: InputMaybe<PipelineRelationFilter>;
pipelineId?: InputMaybe<StringFilter>;
pipelineStage?: InputMaybe<PipelineStageRelationFilter>;
@@ -1513,8 +1569,6 @@ export type PipelineProgressWhereInput = {
pointOfContact?: InputMaybe<PersonRelationFilter>;
pointOfContactId?: InputMaybe<StringNullableFilter>;
probability?: InputMaybe<IntNullableFilter>;
- progressableId?: InputMaybe<StringFilter>;
- progressableType?: InputMaybe<EnumPipelineProgressableTypeFilter>;
updatedAt?: InputMaybe<DateTimeFilter>;
};
@@ -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<Array<Scalars['String']> | Scalars['String']>;
+}>;
+
+
+export type DeleteManyPipelineProgressMutation = { __typename?: 'Mutation', deleteManyPipelineProgress: { __typename?: 'AffectedRows', count: number } };
+
+export type UpdatePipelineStageMutationVariables = Exact<{
+ id?: InputMaybe<Scalars['String']>;
+ data: PipelineStageUpdateInput;
+}>;
+
+
+export type UpdatePipelineStageMutation = { __typename?: 'Mutation', updateOnePipelineStage?: { __typename?: 'PipelineStage', id: string, name: string, color: string } | null };
export type UpdateOnePipelineProgressMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
@@ -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<Array<Scalars['String']> | Scalars['String']>;
-}>;
-
-
-export type DeleteManyPipelineProgressMutation = { __typename?: 'Mutation', deleteManyPipelineProgress: { __typename?: 'AffectedRows', count: number } };
-
-export type UpdatePipelineStageMutationVariables = Exact<{
- id?: InputMaybe<Scalars['String']>;
- 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<PersonWhereInput>;
@@ -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<typeof useGetPipelineProgressQuery>;
export type GetPipelineProgressLazyQueryHookResult = ReturnType<typeof useGetPipelineProgressLazyQuery>;
export type GetPipelineProgressQueryResult = Apollo.QueryResult<GetPipelineProgressQuery, GetPipelineProgressQueryVariables>;
+export const DeleteManyPipelineProgressDocument = gql`
+ mutation DeleteManyPipelineProgress($ids: [String!]) {
+ deleteManyPipelineProgress(where: {id: {in: $ids}}) {
+ count
+ }
+}
+ `;
+export type DeleteManyPipelineProgressMutationFn = Apollo.MutationFunction<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>;
+
+/**
+ * __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<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useMutation<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>(DeleteManyPipelineProgressDocument, options);
+ }
+export type DeleteManyPipelineProgressMutationHookResult = ReturnType<typeof useDeleteManyPipelineProgressMutation>;
+export type DeleteManyPipelineProgressMutationResult = Apollo.MutationResult<DeleteManyPipelineProgressMutation>;
+export type DeleteManyPipelineProgressMutationOptions = Apollo.BaseMutationOptions<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>;
+export const UpdatePipelineStageDocument = gql`
+ mutation UpdatePipelineStage($id: String, $data: PipelineStageUpdateInput!) {
+ updateOnePipelineStage(where: {id: $id}, data: $data) {
+ id
+ name
+ color
+ }
+}
+ `;
+export type UpdatePipelineStageMutationFn = Apollo.MutationFunction<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>;
+
+/**
+ * __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<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>) {
+ const options = {...defaultOptions, ...baseOptions}
+ return Apollo.useMutation<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>(UpdatePipelineStageDocument, options);
+ }
+export type UpdatePipelineStageMutationHookResult = ReturnType<typeof useUpdatePipelineStageMutation>;
+export type UpdatePipelineStageMutationResult = Apollo.MutationResult<UpdatePipelineStageMutation>;
+export type UpdatePipelineStageMutationOptions = Apollo.BaseMutationOptions<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>;
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<typeof useUpdateOnePipelineProgressStageMutation>;
export type UpdateOnePipelineProgressStageMutationResult = Apollo.MutationResult<UpdateOnePipelineProgressStageMutation>;
export type UpdateOnePipelineProgressStageMutationOptions = Apollo.BaseMutationOptions<UpdateOnePipelineProgressStageMutation, UpdateOnePipelineProgressStageMutationVariables>;
-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<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>;
+export type CreateOneCompanyPipelineProgressMutationFn = Apollo.MutationFunction<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>;
/**
- * __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<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>) {
- const options = {...defaultOptions, ...baseOptions}
- return Apollo.useMutation<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>(CreateOnePipelineProgressDocument, options);
- }
-export type CreateOnePipelineProgressMutationHookResult = ReturnType<typeof useCreateOnePipelineProgressMutation>;
-export type CreateOnePipelineProgressMutationResult = Apollo.MutationResult<CreateOnePipelineProgressMutation>;
-export type CreateOnePipelineProgressMutationOptions = Apollo.BaseMutationOptions<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>;
-export const DeleteManyPipelineProgressDocument = gql`
- mutation DeleteManyPipelineProgress($ids: [String!]) {
- deleteManyPipelineProgress(where: {id: {in: $ids}}) {
- count
- }
-}
- `;
-export type DeleteManyPipelineProgressMutationFn = Apollo.MutationFunction<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>;
-
-/**
- * __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<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>) {
+export function useCreateOneCompanyPipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
- return Apollo.useMutation<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>(DeleteManyPipelineProgressDocument, options);
+ return Apollo.useMutation<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>(CreateOneCompanyPipelineProgressDocument, options);
}
-export type DeleteManyPipelineProgressMutationHookResult = ReturnType<typeof useDeleteManyPipelineProgressMutation>;
-export type DeleteManyPipelineProgressMutationResult = Apollo.MutationResult<DeleteManyPipelineProgressMutation>;
-export type DeleteManyPipelineProgressMutationOptions = Apollo.BaseMutationOptions<DeleteManyPipelineProgressMutation, DeleteManyPipelineProgressMutationVariables>;
-export const UpdatePipelineStageDocument = gql`
- mutation UpdatePipelineStage($id: String, $data: PipelineStageUpdateInput!) {
- updateOnePipelineStage(where: {id: $id}, data: $data) {
- id
- name
- color
- }
-}
- `;
-export type UpdatePipelineStageMutationFn = Apollo.MutationFunction<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>;
-
-/**
- * __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<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>) {
- const options = {...defaultOptions, ...baseOptions}
- return Apollo.useMutation<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>(UpdatePipelineStageDocument, options);
- }
-export type UpdatePipelineStageMutationHookResult = ReturnType<typeof useUpdatePipelineStageMutation>;
-export type UpdatePipelineStageMutationResult = Apollo.MutationResult<UpdatePipelineStageMutation>;
-export type UpdatePipelineStageMutationOptions = Apollo.BaseMutationOptions<UpdatePipelineStageMutation, UpdatePipelineStageMutationVariables>;
+export type CreateOneCompanyPipelineProgressMutationHookResult = ReturnType<typeof useCreateOneCompanyPipelineProgressMutation>;
+export type CreateOneCompanyPipelineProgressMutationResult = Apollo.MutationResult<CreateOneCompanyPipelineProgressMutation>;
+export type CreateOneCompanyPipelineProgressMutationOptions = Apollo.BaseMutationOptions<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>;
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 f31e824fd8f..8acb76005d1 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 ef5f24ce285..59724b0136c 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 4ae44321a6f..250c7711a27 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 e9b847eea8a..ce830135ece 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 157b0c02faa..295a78deb15 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 b75cd4a27ad..66d295523f4 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<PipelineProgress>[]
type: 'date',
},
{
- field: 'progressableId',
+ field: 'companyId',
label: 'Company',
icon: (
<IconBuildingSkyscraper size={icon.size.md} stroke={icon.stroke.sm} />
diff --git a/front/src/testing/mock-data/pipeline-progress.ts b/front/src/testing/mock-data/pipeline-progress.ts
index ea16ce7ce9d..c3d71772753 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<MockedPipelineProgress> = [
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 93b0c269d27..e5fc0e6f542 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<MockedPipeline> = [
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 00000000000..003a2e7ee1a
--- /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 00000000000..2cbb82a328d
--- /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 00000000000..a8596427d7e
--- /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 00000000000..df8c52e6c56
--- /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 ba650f8e36a..d11279bb34c 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 b4cd949047b..3f24266490a 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',
},
});