Refactor: Morph strategy on PipelineProgress (#1065)

* Deprecate pipelineprogress backref on person to improve naming

* Remove deprecated point of contact fields

* Add company and person entities on pipelineprogress

* Migrate data from old progressable to new entity fields

* Codegen frontend

* Use company Id, deprecate progressableId

* Get rid of deprecated progressableId field

* Remove deprecated progressableType field from pipeline progress

* Remove useless migrations
This commit is contained in:
Emilien Chauvet
2023-08-03 18:08:35 +02:00
committed by GitHub
parent 4252a0a2c3
commit 21e3d8fcac
15 changed files with 327 additions and 263 deletions

View File

@ -639,6 +639,7 @@ export enum CommentableType {
export type Company = { export type Company = {
__typename?: 'Company'; __typename?: 'Company';
ActivityTarget?: Maybe<Array<ActivityTarget>>; ActivityTarget?: Maybe<Array<ActivityTarget>>;
PipelineProgress?: Maybe<Array<PipelineProgress>>;
_activityCount: Scalars['Int']; _activityCount: Scalars['Int'];
accountOwner?: Maybe<User>; accountOwner?: Maybe<User>;
accountOwnerId?: Maybe<Scalars['String']>; accountOwnerId?: Maybe<Scalars['String']>;
@ -657,6 +658,7 @@ export type Company = {
export type CompanyCreateInput = { export type CompanyCreateInput = {
ActivityTarget?: InputMaybe<ActivityTargetCreateNestedManyWithoutCompanyInput>; ActivityTarget?: InputMaybe<ActivityTargetCreateNestedManyWithoutCompanyInput>;
PipelineProgress?: InputMaybe<PipelineProgressCreateNestedManyWithoutCompanyInput>;
accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>; accountOwner?: InputMaybe<UserCreateNestedOneWithoutCompaniesInput>;
address: Scalars['String']; address: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
@ -677,6 +679,10 @@ export type CompanyCreateNestedOneWithoutPeopleInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>; connect?: InputMaybe<CompanyWhereUniqueInput>;
}; };
export type CompanyCreateNestedOneWithoutPipelineProgressInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
};
export type CompanyListRelationFilter = { export type CompanyListRelationFilter = {
every?: InputMaybe<CompanyWhereInput>; every?: InputMaybe<CompanyWhereInput>;
none?: InputMaybe<CompanyWhereInput>; none?: InputMaybe<CompanyWhereInput>;
@ -689,6 +695,7 @@ export type CompanyOrderByRelationAggregateInput = {
export type CompanyOrderByWithRelationInput = { export type CompanyOrderByWithRelationInput = {
ActivityTarget?: InputMaybe<ActivityTargetOrderByRelationAggregateInput>; ActivityTarget?: InputMaybe<ActivityTargetOrderByRelationAggregateInput>;
PipelineProgress?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
accountOwner?: InputMaybe<UserOrderByWithRelationInput>; accountOwner?: InputMaybe<UserOrderByWithRelationInput>;
accountOwnerId?: InputMaybe<SortOrder>; accountOwnerId?: InputMaybe<SortOrder>;
address?: InputMaybe<SortOrder>; address?: InputMaybe<SortOrder>;
@ -723,6 +730,7 @@ export enum CompanyScalarFieldEnum {
export type CompanyUpdateInput = { export type CompanyUpdateInput = {
ActivityTarget?: InputMaybe<ActivityTargetUpdateManyWithoutCompanyNestedInput>; ActivityTarget?: InputMaybe<ActivityTargetUpdateManyWithoutCompanyNestedInput>;
PipelineProgress?: InputMaybe<PipelineProgressUpdateManyWithoutCompanyNestedInput>;
accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>; accountOwner?: InputMaybe<UserUpdateOneWithoutCompaniesNestedInput>;
address?: InputMaybe<Scalars['String']>; address?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
@ -752,11 +760,17 @@ export type CompanyUpdateOneWithoutPeopleNestedInput = {
disconnect?: InputMaybe<Scalars['Boolean']>; disconnect?: InputMaybe<Scalars['Boolean']>;
}; };
export type CompanyUpdateOneWithoutPipelineProgressNestedInput = {
connect?: InputMaybe<CompanyWhereUniqueInput>;
disconnect?: InputMaybe<Scalars['Boolean']>;
};
export type CompanyWhereInput = { export type CompanyWhereInput = {
AND?: InputMaybe<Array<CompanyWhereInput>>; AND?: InputMaybe<Array<CompanyWhereInput>>;
ActivityTarget?: InputMaybe<ActivityTargetListRelationFilter>; ActivityTarget?: InputMaybe<ActivityTargetListRelationFilter>;
NOT?: InputMaybe<Array<CompanyWhereInput>>; NOT?: InputMaybe<Array<CompanyWhereInput>>;
OR?: InputMaybe<Array<CompanyWhereInput>>; OR?: InputMaybe<Array<CompanyWhereInput>>;
PipelineProgress?: InputMaybe<PipelineProgressListRelationFilter>;
accountOwner?: InputMaybe<UserRelationFilter>; accountOwner?: InputMaybe<UserRelationFilter>;
accountOwnerId?: InputMaybe<StringNullableFilter>; accountOwnerId?: InputMaybe<StringNullableFilter>;
address?: InputMaybe<StringFilter>; address?: InputMaybe<StringFilter>;
@ -1202,6 +1216,7 @@ export type NestedStringNullableFilter = {
export type Person = { export type Person = {
__typename?: 'Person'; __typename?: 'Person';
ActivityTarget?: Maybe<Array<ActivityTarget>>; ActivityTarget?: Maybe<Array<ActivityTarget>>;
PipelineProgress?: Maybe<Array<PipelineProgress>>;
_activityCount: Scalars['Int']; _activityCount: Scalars['Int'];
activities: Array<Activity>; activities: Array<Activity>;
avatarUrl?: Maybe<Scalars['String']>; avatarUrl?: Maybe<Scalars['String']>;
@ -1209,6 +1224,7 @@ export type Person = {
comments: Array<Comment>; comments: Array<Comment>;
company?: Maybe<Company>; company?: Maybe<Company>;
companyId?: Maybe<Scalars['String']>; companyId?: Maybe<Scalars['String']>;
contactPipelineProgresses?: Maybe<Array<PipelineProgress>>;
createdAt: Scalars['DateTime']; createdAt: Scalars['DateTime'];
displayName: Scalars['String']; displayName: Scalars['String'];
email?: Maybe<Scalars['String']>; email?: Maybe<Scalars['String']>;
@ -1218,15 +1234,16 @@ export type Person = {
lastName?: Maybe<Scalars['String']>; lastName?: Maybe<Scalars['String']>;
linkedinUrl?: Maybe<Scalars['String']>; linkedinUrl?: Maybe<Scalars['String']>;
phone?: Maybe<Scalars['String']>; phone?: Maybe<Scalars['String']>;
pipelineProgresses?: Maybe<Array<PipelineProgress>>;
updatedAt: Scalars['DateTime']; updatedAt: Scalars['DateTime'];
}; };
export type PersonCreateInput = { export type PersonCreateInput = {
ActivityTarget?: InputMaybe<ActivityTargetCreateNestedManyWithoutPersonInput>; ActivityTarget?: InputMaybe<ActivityTargetCreateNestedManyWithoutPersonInput>;
PipelineProgress?: InputMaybe<PipelineProgressCreateNestedManyWithoutPersonInput>;
avatarUrl?: InputMaybe<Scalars['String']>; avatarUrl?: InputMaybe<Scalars['String']>;
city?: InputMaybe<Scalars['String']>; city?: InputMaybe<Scalars['String']>;
company?: InputMaybe<CompanyCreateNestedOneWithoutPeopleInput>; company?: InputMaybe<CompanyCreateNestedOneWithoutPeopleInput>;
contactPipelineProgresses?: InputMaybe<PipelineProgressCreateNestedManyWithoutPointOfContactInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
email?: InputMaybe<Scalars['String']>; email?: InputMaybe<Scalars['String']>;
firstName?: InputMaybe<Scalars['String']>; firstName?: InputMaybe<Scalars['String']>;
@ -1235,7 +1252,6 @@ export type PersonCreateInput = {
lastName?: InputMaybe<Scalars['String']>; lastName?: InputMaybe<Scalars['String']>;
linkedinUrl?: InputMaybe<Scalars['String']>; linkedinUrl?: InputMaybe<Scalars['String']>;
phone?: InputMaybe<Scalars['String']>; phone?: InputMaybe<Scalars['String']>;
pipelineProgresses?: InputMaybe<PipelineProgressCreateNestedManyWithoutPointOfContactInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>; updatedAt?: InputMaybe<Scalars['DateTime']>;
}; };
@ -1247,7 +1263,11 @@ export type PersonCreateNestedOneWithoutActivityTargetInput = {
connect?: InputMaybe<PersonWhereUniqueInput>; connect?: InputMaybe<PersonWhereUniqueInput>;
}; };
export type PersonCreateNestedOneWithoutPipelineProgressesInput = { export type PersonCreateNestedOneWithoutContactPipelineProgressesInput = {
connect?: InputMaybe<PersonWhereUniqueInput>;
};
export type PersonCreateNestedOneWithoutPipelineProgressInput = {
connect?: InputMaybe<PersonWhereUniqueInput>; connect?: InputMaybe<PersonWhereUniqueInput>;
}; };
@ -1263,10 +1283,12 @@ export type PersonOrderByRelationAggregateInput = {
export type PersonOrderByWithRelationInput = { export type PersonOrderByWithRelationInput = {
ActivityTarget?: InputMaybe<ActivityTargetOrderByRelationAggregateInput>; ActivityTarget?: InputMaybe<ActivityTargetOrderByRelationAggregateInput>;
PipelineProgress?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
avatarUrl?: InputMaybe<SortOrder>; avatarUrl?: InputMaybe<SortOrder>;
city?: InputMaybe<SortOrder>; city?: InputMaybe<SortOrder>;
company?: InputMaybe<CompanyOrderByWithRelationInput>; company?: InputMaybe<CompanyOrderByWithRelationInput>;
companyId?: InputMaybe<SortOrder>; companyId?: InputMaybe<SortOrder>;
contactPipelineProgresses?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
createdAt?: InputMaybe<SortOrder>; createdAt?: InputMaybe<SortOrder>;
email?: InputMaybe<SortOrder>; email?: InputMaybe<SortOrder>;
firstName?: InputMaybe<SortOrder>; firstName?: InputMaybe<SortOrder>;
@ -1275,7 +1297,6 @@ export type PersonOrderByWithRelationInput = {
lastName?: InputMaybe<SortOrder>; lastName?: InputMaybe<SortOrder>;
linkedinUrl?: InputMaybe<SortOrder>; linkedinUrl?: InputMaybe<SortOrder>;
phone?: InputMaybe<SortOrder>; phone?: InputMaybe<SortOrder>;
pipelineProgresses?: InputMaybe<PipelineProgressOrderByRelationAggregateInput>;
updatedAt?: InputMaybe<SortOrder>; updatedAt?: InputMaybe<SortOrder>;
}; };
@ -1303,9 +1324,11 @@ export enum PersonScalarFieldEnum {
export type PersonUpdateInput = { export type PersonUpdateInput = {
ActivityTarget?: InputMaybe<ActivityTargetUpdateManyWithoutPersonNestedInput>; ActivityTarget?: InputMaybe<ActivityTargetUpdateManyWithoutPersonNestedInput>;
PipelineProgress?: InputMaybe<PipelineProgressUpdateManyWithoutPersonNestedInput>;
avatarUrl?: InputMaybe<Scalars['String']>; avatarUrl?: InputMaybe<Scalars['String']>;
city?: InputMaybe<Scalars['String']>; city?: InputMaybe<Scalars['String']>;
company?: InputMaybe<CompanyUpdateOneWithoutPeopleNestedInput>; company?: InputMaybe<CompanyUpdateOneWithoutPeopleNestedInput>;
contactPipelineProgresses?: InputMaybe<PipelineProgressUpdateManyWithoutPointOfContactNestedInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
email?: InputMaybe<Scalars['String']>; email?: InputMaybe<Scalars['String']>;
firstName?: InputMaybe<Scalars['String']>; firstName?: InputMaybe<Scalars['String']>;
@ -1314,7 +1337,6 @@ export type PersonUpdateInput = {
lastName?: InputMaybe<Scalars['String']>; lastName?: InputMaybe<Scalars['String']>;
linkedinUrl?: InputMaybe<Scalars['String']>; linkedinUrl?: InputMaybe<Scalars['String']>;
phone?: InputMaybe<Scalars['String']>; phone?: InputMaybe<Scalars['String']>;
pipelineProgresses?: InputMaybe<PipelineProgressUpdateManyWithoutPointOfContactNestedInput>;
updatedAt?: InputMaybe<Scalars['DateTime']>; updatedAt?: InputMaybe<Scalars['DateTime']>;
}; };
@ -1330,7 +1352,12 @@ export type PersonUpdateManyWithoutWorkspaceNestedInput = {
set?: InputMaybe<Array<PersonWhereUniqueInput>>; set?: InputMaybe<Array<PersonWhereUniqueInput>>;
}; };
export type PersonUpdateOneWithoutPipelineProgressesNestedInput = { export type PersonUpdateOneWithoutContactPipelineProgressesNestedInput = {
connect?: InputMaybe<PersonWhereUniqueInput>;
disconnect?: InputMaybe<Scalars['Boolean']>;
};
export type PersonUpdateOneWithoutPipelineProgressNestedInput = {
connect?: InputMaybe<PersonWhereUniqueInput>; connect?: InputMaybe<PersonWhereUniqueInput>;
disconnect?: InputMaybe<Scalars['Boolean']>; disconnect?: InputMaybe<Scalars['Boolean']>;
}; };
@ -1340,10 +1367,12 @@ export type PersonWhereInput = {
ActivityTarget?: InputMaybe<ActivityTargetListRelationFilter>; ActivityTarget?: InputMaybe<ActivityTargetListRelationFilter>;
NOT?: InputMaybe<Array<PersonWhereInput>>; NOT?: InputMaybe<Array<PersonWhereInput>>;
OR?: InputMaybe<Array<PersonWhereInput>>; OR?: InputMaybe<Array<PersonWhereInput>>;
PipelineProgress?: InputMaybe<PipelineProgressListRelationFilter>;
avatarUrl?: InputMaybe<StringNullableFilter>; avatarUrl?: InputMaybe<StringNullableFilter>;
city?: InputMaybe<StringNullableFilter>; city?: InputMaybe<StringNullableFilter>;
company?: InputMaybe<CompanyRelationFilter>; company?: InputMaybe<CompanyRelationFilter>;
companyId?: InputMaybe<StringNullableFilter>; companyId?: InputMaybe<StringNullableFilter>;
contactPipelineProgresses?: InputMaybe<PipelineProgressListRelationFilter>;
createdAt?: InputMaybe<DateTimeFilter>; createdAt?: InputMaybe<DateTimeFilter>;
email?: InputMaybe<StringNullableFilter>; email?: InputMaybe<StringNullableFilter>;
firstName?: InputMaybe<StringNullableFilter>; firstName?: InputMaybe<StringNullableFilter>;
@ -1352,7 +1381,6 @@ export type PersonWhereInput = {
lastName?: InputMaybe<StringNullableFilter>; lastName?: InputMaybe<StringNullableFilter>;
linkedinUrl?: InputMaybe<StringNullableFilter>; linkedinUrl?: InputMaybe<StringNullableFilter>;
phone?: InputMaybe<StringNullableFilter>; phone?: InputMaybe<StringNullableFilter>;
pipelineProgresses?: InputMaybe<PipelineProgressListRelationFilter>;
updatedAt?: InputMaybe<DateTimeFilter>; updatedAt?: InputMaybe<DateTimeFilter>;
}; };
@ -1391,8 +1419,12 @@ export type PipelineProgress = {
__typename?: 'PipelineProgress'; __typename?: 'PipelineProgress';
amount?: Maybe<Scalars['Int']>; amount?: Maybe<Scalars['Int']>;
closeDate?: Maybe<Scalars['DateTime']>; closeDate?: Maybe<Scalars['DateTime']>;
company?: Maybe<Company>;
companyId?: Maybe<Scalars['String']>;
createdAt: Scalars['DateTime']; createdAt: Scalars['DateTime'];
id: Scalars['ID']; id: Scalars['ID'];
person?: Maybe<Person>;
personId?: Maybe<Scalars['String']>;
pipeline: Pipeline; pipeline: Pipeline;
pipelineId: Scalars['String']; pipelineId: Scalars['String'];
pipelineStage: PipelineStage; pipelineStage: PipelineStage;
@ -1400,25 +1432,31 @@ export type PipelineProgress = {
pointOfContact?: Maybe<Person>; pointOfContact?: Maybe<Person>;
pointOfContactId?: Maybe<Scalars['String']>; pointOfContactId?: Maybe<Scalars['String']>;
probability?: Maybe<Scalars['Int']>; probability?: Maybe<Scalars['Int']>;
progressableId: Scalars['String'];
progressableType: PipelineProgressableType;
updatedAt: Scalars['DateTime']; updatedAt: Scalars['DateTime'];
}; };
export type PipelineProgressCreateInput = { export type PipelineProgressCreateInput = {
amount?: InputMaybe<Scalars['Int']>; amount?: InputMaybe<Scalars['Int']>;
closeDate?: InputMaybe<Scalars['DateTime']>; closeDate?: InputMaybe<Scalars['DateTime']>;
company?: InputMaybe<CompanyCreateNestedOneWithoutPipelineProgressInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
person?: InputMaybe<PersonCreateNestedOneWithoutPipelineProgressInput>;
pipeline: PipelineCreateNestedOneWithoutPipelineProgressesInput; pipeline: PipelineCreateNestedOneWithoutPipelineProgressesInput;
pipelineStage: PipelineStageCreateNestedOneWithoutPipelineProgressesInput; pipelineStage: PipelineStageCreateNestedOneWithoutPipelineProgressesInput;
pointOfContact?: InputMaybe<PersonCreateNestedOneWithoutPipelineProgressesInput>; pointOfContact?: InputMaybe<PersonCreateNestedOneWithoutContactPipelineProgressesInput>;
probability?: InputMaybe<Scalars['Int']>; probability?: InputMaybe<Scalars['Int']>;
progressableId: Scalars['String'];
progressableType: PipelineProgressableType;
updatedAt?: InputMaybe<Scalars['DateTime']>; updatedAt?: InputMaybe<Scalars['DateTime']>;
}; };
export type PipelineProgressCreateNestedManyWithoutCompanyInput = {
connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
};
export type PipelineProgressCreateNestedManyWithoutPersonInput = {
connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
};
export type PipelineProgressCreateNestedManyWithoutPointOfContactInput = { export type PipelineProgressCreateNestedManyWithoutPointOfContactInput = {
connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>; connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
}; };
@ -1436,8 +1474,12 @@ export type PipelineProgressOrderByRelationAggregateInput = {
export type PipelineProgressOrderByWithRelationInput = { export type PipelineProgressOrderByWithRelationInput = {
amount?: InputMaybe<SortOrder>; amount?: InputMaybe<SortOrder>;
closeDate?: InputMaybe<SortOrder>; closeDate?: InputMaybe<SortOrder>;
company?: InputMaybe<CompanyOrderByWithRelationInput>;
companyId?: InputMaybe<SortOrder>;
createdAt?: InputMaybe<SortOrder>; createdAt?: InputMaybe<SortOrder>;
id?: InputMaybe<SortOrder>; id?: InputMaybe<SortOrder>;
person?: InputMaybe<PersonOrderByWithRelationInput>;
personId?: InputMaybe<SortOrder>;
pipeline?: InputMaybe<PipelineOrderByWithRelationInput>; pipeline?: InputMaybe<PipelineOrderByWithRelationInput>;
pipelineId?: InputMaybe<SortOrder>; pipelineId?: InputMaybe<SortOrder>;
pipelineStage?: InputMaybe<PipelineStageOrderByWithRelationInput>; pipelineStage?: InputMaybe<PipelineStageOrderByWithRelationInput>;
@ -1445,23 +1487,21 @@ export type PipelineProgressOrderByWithRelationInput = {
pointOfContact?: InputMaybe<PersonOrderByWithRelationInput>; pointOfContact?: InputMaybe<PersonOrderByWithRelationInput>;
pointOfContactId?: InputMaybe<SortOrder>; pointOfContactId?: InputMaybe<SortOrder>;
probability?: InputMaybe<SortOrder>; probability?: InputMaybe<SortOrder>;
progressableId?: InputMaybe<SortOrder>;
progressableType?: InputMaybe<SortOrder>;
updatedAt?: InputMaybe<SortOrder>; updatedAt?: InputMaybe<SortOrder>;
}; };
export enum PipelineProgressScalarFieldEnum { export enum PipelineProgressScalarFieldEnum {
Amount = 'amount', Amount = 'amount',
CloseDate = 'closeDate', CloseDate = 'closeDate',
CompanyId = 'companyId',
CreatedAt = 'createdAt', CreatedAt = 'createdAt',
DeletedAt = 'deletedAt', DeletedAt = 'deletedAt',
Id = 'id', Id = 'id',
PersonId = 'personId',
PipelineId = 'pipelineId', PipelineId = 'pipelineId',
PipelineStageId = 'pipelineStageId', PipelineStageId = 'pipelineStageId',
PointOfContactId = 'pointOfContactId', PointOfContactId = 'pointOfContactId',
Probability = 'probability', Probability = 'probability',
ProgressableId = 'progressableId',
ProgressableType = 'progressableType',
UpdatedAt = 'updatedAt', UpdatedAt = 'updatedAt',
WorkspaceId = 'workspaceId' WorkspaceId = 'workspaceId'
} }
@ -1469,17 +1509,29 @@ export enum PipelineProgressScalarFieldEnum {
export type PipelineProgressUpdateInput = { export type PipelineProgressUpdateInput = {
amount?: InputMaybe<Scalars['Int']>; amount?: InputMaybe<Scalars['Int']>;
closeDate?: InputMaybe<Scalars['DateTime']>; closeDate?: InputMaybe<Scalars['DateTime']>;
company?: InputMaybe<CompanyUpdateOneWithoutPipelineProgressNestedInput>;
createdAt?: InputMaybe<Scalars['DateTime']>; createdAt?: InputMaybe<Scalars['DateTime']>;
id?: InputMaybe<Scalars['String']>; id?: InputMaybe<Scalars['String']>;
person?: InputMaybe<PersonUpdateOneWithoutPipelineProgressNestedInput>;
pipeline?: InputMaybe<PipelineUpdateOneRequiredWithoutPipelineProgressesNestedInput>; pipeline?: InputMaybe<PipelineUpdateOneRequiredWithoutPipelineProgressesNestedInput>;
pipelineStage?: InputMaybe<PipelineStageUpdateOneRequiredWithoutPipelineProgressesNestedInput>; pipelineStage?: InputMaybe<PipelineStageUpdateOneRequiredWithoutPipelineProgressesNestedInput>;
pointOfContact?: InputMaybe<PersonUpdateOneWithoutPipelineProgressesNestedInput>; pointOfContact?: InputMaybe<PersonUpdateOneWithoutContactPipelineProgressesNestedInput>;
probability?: InputMaybe<Scalars['Int']>; probability?: InputMaybe<Scalars['Int']>;
progressableId?: InputMaybe<Scalars['String']>;
progressableType?: InputMaybe<PipelineProgressableType>;
updatedAt?: InputMaybe<Scalars['DateTime']>; 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 = { export type PipelineProgressUpdateManyWithoutPipelineStageNestedInput = {
connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>; connect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
disconnect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>; disconnect?: InputMaybe<Array<PipelineProgressWhereUniqueInput>>;
@ -1504,8 +1556,12 @@ export type PipelineProgressWhereInput = {
OR?: InputMaybe<Array<PipelineProgressWhereInput>>; OR?: InputMaybe<Array<PipelineProgressWhereInput>>;
amount?: InputMaybe<IntNullableFilter>; amount?: InputMaybe<IntNullableFilter>;
closeDate?: InputMaybe<DateTimeNullableFilter>; closeDate?: InputMaybe<DateTimeNullableFilter>;
company?: InputMaybe<CompanyRelationFilter>;
companyId?: InputMaybe<StringNullableFilter>;
createdAt?: InputMaybe<DateTimeFilter>; createdAt?: InputMaybe<DateTimeFilter>;
id?: InputMaybe<StringFilter>; id?: InputMaybe<StringFilter>;
person?: InputMaybe<PersonRelationFilter>;
personId?: InputMaybe<StringNullableFilter>;
pipeline?: InputMaybe<PipelineRelationFilter>; pipeline?: InputMaybe<PipelineRelationFilter>;
pipelineId?: InputMaybe<StringFilter>; pipelineId?: InputMaybe<StringFilter>;
pipelineStage?: InputMaybe<PipelineStageRelationFilter>; pipelineStage?: InputMaybe<PipelineStageRelationFilter>;
@ -1513,8 +1569,6 @@ export type PipelineProgressWhereInput = {
pointOfContact?: InputMaybe<PersonRelationFilter>; pointOfContact?: InputMaybe<PersonRelationFilter>;
pointOfContactId?: InputMaybe<StringNullableFilter>; pointOfContactId?: InputMaybe<StringNullableFilter>;
probability?: InputMaybe<IntNullableFilter>; probability?: InputMaybe<IntNullableFilter>;
progressableId?: InputMaybe<StringFilter>;
progressableType?: InputMaybe<EnumPipelineProgressableTypeFilter>;
updatedAt?: InputMaybe<DateTimeFilter>; 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<{ export type UpdateOnePipelineProgressMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>; 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 UpdateOnePipelineProgressStageMutation = { __typename?: 'Mutation', updateOnePipelineProgress?: { __typename?: 'PipelineProgress', id: string } | null };
export type CreateOnePipelineProgressMutationVariables = Exact<{ export type CreateOneCompanyPipelineProgressMutationVariables = Exact<{
uuid: Scalars['String']; uuid: Scalars['String'];
entityType: PipelineProgressableType; companyId: Scalars['String'];
entityId: Scalars['String'];
pipelineId: Scalars['String']; pipelineId: Scalars['String'];
pipelineStageId: Scalars['String']; pipelineStageId: Scalars['String'];
}>; }>;
export type CreateOnePipelineProgressMutation = { __typename?: 'Mutation', createOnePipelineProgress: { __typename?: 'PipelineProgress', id: string } }; export type CreateOneCompanyPipelineProgressMutation = { __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 SearchPeopleQueryVariables = Exact<{ export type SearchPeopleQueryVariables = Exact<{
where?: InputMaybe<PersonWhereInput>; where?: InputMaybe<PersonWhereInput>;
@ -4360,8 +4413,8 @@ export const GetPipelineProgressDocument = gql`
findManyPipelineProgress(where: $where, orderBy: $orderBy) { findManyPipelineProgress(where: $where, orderBy: $orderBy) {
id id
pipelineStageId pipelineStageId
progressableType companyId
progressableId personId
amount amount
closeDate closeDate
pointOfContactId pointOfContactId
@ -4405,6 +4458,75 @@ export function useGetPipelineProgressLazyQuery(baseOptions?: Apollo.LazyQueryHo
export type GetPipelineProgressQueryHookResult = ReturnType<typeof useGetPipelineProgressQuery>; export type GetPipelineProgressQueryHookResult = ReturnType<typeof useGetPipelineProgressQuery>;
export type GetPipelineProgressLazyQueryHookResult = ReturnType<typeof useGetPipelineProgressLazyQuery>; export type GetPipelineProgressLazyQueryHookResult = ReturnType<typeof useGetPipelineProgressLazyQuery>;
export type GetPipelineProgressQueryResult = Apollo.QueryResult<GetPipelineProgressQuery, GetPipelineProgressQueryVariables>; 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` export const UpdateOnePipelineProgressDocument = gql`
mutation UpdateOnePipelineProgress($id: String, $amount: Int, $closeDate: DateTime, $probability: Int, $pointOfContactId: String) { mutation UpdateOnePipelineProgress($id: String, $amount: Int, $closeDate: DateTime, $probability: Int, $pointOfContactId: String) {
updateOnePipelineProgress( updateOnePipelineProgress(
@ -4484,114 +4606,44 @@ export function useUpdateOnePipelineProgressStageMutation(baseOptions?: Apollo.M
export type UpdateOnePipelineProgressStageMutationHookResult = ReturnType<typeof useUpdateOnePipelineProgressStageMutation>; export type UpdateOnePipelineProgressStageMutationHookResult = ReturnType<typeof useUpdateOnePipelineProgressStageMutation>;
export type UpdateOnePipelineProgressStageMutationResult = Apollo.MutationResult<UpdateOnePipelineProgressStageMutation>; export type UpdateOnePipelineProgressStageMutationResult = Apollo.MutationResult<UpdateOnePipelineProgressStageMutation>;
export type UpdateOnePipelineProgressStageMutationOptions = Apollo.BaseMutationOptions<UpdateOnePipelineProgressStageMutation, UpdateOnePipelineProgressStageMutationVariables>; export type UpdateOnePipelineProgressStageMutationOptions = Apollo.BaseMutationOptions<UpdateOnePipelineProgressStageMutation, UpdateOnePipelineProgressStageMutationVariables>;
export const CreateOnePipelineProgressDocument = gql` export const CreateOneCompanyPipelineProgressDocument = gql`
mutation CreateOnePipelineProgress($uuid: String!, $entityType: PipelineProgressableType!, $entityId: String!, $pipelineId: String!, $pipelineStageId: String!) { mutation CreateOneCompanyPipelineProgress($uuid: String!, $companyId: String!, $pipelineId: String!, $pipelineStageId: String!) {
createOnePipelineProgress( 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 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. * 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, `useCreateOnePipelineProgressMutation` returns a tuple that includes: * When your component renders, `useCreateOneCompanyPipelineProgressMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation * - 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 * - 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; * @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 * @example
* const [createOnePipelineProgressMutation, { data, loading, error }] = useCreateOnePipelineProgressMutation({ * const [createOneCompanyPipelineProgressMutation, { data, loading, error }] = useCreateOneCompanyPipelineProgressMutation({
* variables: { * variables: {
* uuid: // value for 'uuid' * uuid: // value for 'uuid'
* entityType: // value for 'entityType' * companyId: // value for 'companyId'
* entityId: // value for 'entityId'
* pipelineId: // value for 'pipelineId' * pipelineId: // value for 'pipelineId'
* pipelineStageId: // value for 'pipelineStageId' * pipelineStageId: // value for 'pipelineStageId'
* }, * },
* }); * });
*/ */
export function useCreateOnePipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>) { export function useCreateOneCompanyPipelineProgressMutation(baseOptions?: Apollo.MutationHookOptions<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>) {
const options = {...defaultOptions, ...baseOptions} const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>(CreateOnePipelineProgressDocument, options); return Apollo.useMutation<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>(CreateOneCompanyPipelineProgressDocument, options);
} }
export type CreateOnePipelineProgressMutationHookResult = ReturnType<typeof useCreateOnePipelineProgressMutation>; export type CreateOneCompanyPipelineProgressMutationHookResult = ReturnType<typeof useCreateOneCompanyPipelineProgressMutation>;
export type CreateOnePipelineProgressMutationResult = Apollo.MutationResult<CreateOnePipelineProgressMutation>; export type CreateOneCompanyPipelineProgressMutationResult = Apollo.MutationResult<CreateOneCompanyPipelineProgressMutation>;
export type CreateOnePipelineProgressMutationOptions = Apollo.BaseMutationOptions<CreateOnePipelineProgressMutation, CreateOnePipelineProgressMutationVariables>; export type CreateOneCompanyPipelineProgressMutationOptions = Apollo.BaseMutationOptions<CreateOneCompanyPipelineProgressMutation, CreateOneCompanyPipelineProgressMutationVariables>;
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 SearchPeopleDocument = gql` export const SearchPeopleDocument = gql`
query SearchPeople($where: PersonWhereInput, $limit: Int, $orderBy: [PersonOrderByWithRelationInput!]) { query SearchPeople($where: PersonWhereInput, $limit: Int, $orderBy: [PersonOrderByWithRelationInput!]) {
searchResults: findManyPerson(where: $where, take: $limit, orderBy: $orderBy) { searchResults: findManyPerson(where: $where, take: $limit, orderBy: $orderBy) {

View File

@ -119,7 +119,7 @@ export function HooksCompanyBoard({
variables: { variables: {
where: { where: {
id: { id: {
in: pipelineProgresses.map((item) => item.progressableId), in: pipelineProgresses.map((item) => item.companyId || ''),
}, },
}, },
}, },
@ -145,7 +145,9 @@ export function HooksCompanyBoard({
}, },
pipelineProgress: PipelineProgressForBoard, pipelineProgress: PipelineProgressForBoard,
) => { ) => {
const company = companiesDict[pipelineProgress.progressableId]; const company =
pipelineProgress.companyId && companiesDict[pipelineProgress.companyId];
if (!company) return acc;
return { return {
...acc, ...acc,
[pipelineProgress.id]: { [pipelineProgress.id]: {

View File

@ -15,10 +15,7 @@ import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picke
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope'; import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState'; import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
import { import { useCreateOneCompanyPipelineProgressMutation } from '~/generated/graphql';
PipelineProgressableType,
useCreateOnePipelineProgressMutation,
} from '~/generated/graphql';
import { useFilteredSearchCompanyQuery } from '../queries'; import { useFilteredSearchCompanyQuery } from '../queries';
@ -36,12 +33,13 @@ export function NewCompanyProgressButton() {
setHotkeyScopeAndMemorizePreviousScope, setHotkeyScopeAndMemorizePreviousScope,
} = usePreviousHotkeyScope(); } = usePreviousHotkeyScope();
const [createOnePipelineProgress] = useCreateOnePipelineProgressMutation({ const [createOneCompanyPipelineProgress] =
refetchQueries: [ useCreateOneCompanyPipelineProgressMutation({
getOperationName(GET_PIPELINE_PROGRESS) ?? '', refetchQueries: [
getOperationName(GET_PIPELINES) ?? '', getOperationName(GET_PIPELINE_PROGRESS) ?? '',
], getOperationName(GET_PIPELINES) ?? '',
}); ],
});
const handleEntitySelect = useCallback( const handleEntitySelect = useCallback(
async (company: any) => { async (company: any) => {
@ -58,13 +56,12 @@ export function NewCompanyProgressButton() {
); );
newBoard[destinationColumnIndex].pipelineProgressIds.push(newUuid); newBoard[destinationColumnIndex].pipelineProgressIds.push(newUuid);
setBoard(newBoard); setBoard(newBoard);
await createOnePipelineProgress({ await createOneCompanyPipelineProgress({
variables: { variables: {
uuid: newUuid, uuid: newUuid,
pipelineStageId: pipelineStageId || '', pipelineStageId: pipelineStageId || '',
pipelineId: pipeline?.id || '', pipelineId: pipeline?.id || '',
entityId: company.id || '', companyId: company.id || '',
entityType: PipelineProgressableType.Company,
}, },
}); });
}, },
@ -72,7 +69,7 @@ export function NewCompanyProgressButton() {
goBackToPreviousHotkeyScope, goBackToPreviousHotkeyScope,
board, board,
setBoard, setBoard,
createOnePipelineProgress, createOneCompanyPipelineProgress,
pipelineStageId, pipelineStageId,
pipeline?.id, pipeline?.id,
], ],

View File

@ -6,7 +6,7 @@ export type PipelineProgressForBoard = Pick<
| 'id' | 'id'
| 'amount' | 'amount'
| 'closeDate' | 'closeDate'
| 'progressableId' | 'companyId'
| 'probability' | 'probability'
| 'pointOfContactId' | 'pointOfContactId'
> & { > & {

View File

@ -33,8 +33,8 @@ export const GET_PIPELINE_PROGRESS = gql`
findManyPipelineProgress(where: $where, orderBy: $orderBy) { findManyPipelineProgress(where: $where, orderBy: $orderBy) {
id id
pipelineStageId pipelineStageId
progressableType companyId
progressableId personId
amount amount
closeDate closeDate
pointOfContactId 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[] = [ export const defaultPipelineProgressOrderBy: PipelineProgresses_Order_By[] = [
{ {
createdAt: Order_By.Asc, createdAt: Order_By.Asc,

View File

@ -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
}
}
`;

View File

@ -27,7 +27,7 @@ export const opportunitiesFilters: FilterDefinitionByEntity<PipelineProgress>[]
type: 'date', type: 'date',
}, },
{ {
field: 'progressableId', field: 'companyId',
label: 'Company', label: 'Company',
icon: ( icon: (
<IconBuildingSkyscraper size={icon.size.md} stroke={icon.stroke.sm} /> <IconBuildingSkyscraper size={icon.size.md} stroke={icon.stroke.sm} />

View File

@ -1,17 +1,8 @@
import { import { PipelineProgress, User } from '../../generated/graphql';
PipelineProgress,
PipelineProgressableType,
User,
} from '../../generated/graphql';
type MockedPipelineProgress = Pick< type MockedPipelineProgress = Pick<
PipelineProgress, PipelineProgress,
| 'id' 'id' | 'amount' | 'closeDate' | 'companyId' | 'pipelineStageId'
| 'amount'
| 'closeDate'
| 'progressableId'
| 'pipelineStageId'
| 'progressableType'
> & { > & {
accountOwner: Pick< accountOwner: Pick<
User, User,
@ -38,27 +29,24 @@ export const mockedPipelineProgressData: Array<MockedPipelineProgress> = [
id: '0ac8761c-1ad6-11ee-be56-0242ac120002', id: '0ac8761c-1ad6-11ee-be56-0242ac120002',
amount: 78, amount: 78,
closeDate: '2021-10-01T00:00:00.000Z', closeDate: '2021-10-01T00:00:00.000Z',
progressableId: '0', companyId: '0',
accountOwner: accountOwner, accountOwner: accountOwner,
pipelineStageId: 'another-pipeline-stage-1', pipelineStageId: 'another-pipeline-stage-1',
progressableType: PipelineProgressableType.Company,
}, },
{ {
id: 'fe256b39-3ec3-4fe7-8998-b76aa0bfb600', id: 'fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
progressableId: '89bb825c-171e-4bcc-9cf7-43448d6fb278', companyId: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
pipelineStageId: 'fe256b39-3ec3-4fe3-8998-b76aa0bfb600', pipelineStageId: 'fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
amount: 7, amount: 7,
closeDate: '2021-10-01T00:00:00.000Z', closeDate: '2021-10-01T00:00:00.000Z',
accountOwner, accountOwner,
progressableType: PipelineProgressableType.Company,
}, },
{ {
id: '4a886c90-f4f2-4984-8222-882ebbb905d6', id: '4a886c90-f4f2-4984-8222-882ebbb905d6',
progressableId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae', companyId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
amount: 100, amount: 100,
closeDate: '2021-10-01T00:00:00.000Z', closeDate: '2021-10-01T00:00:00.000Z',
accountOwner, accountOwner,
pipelineStageId: 'fe256b39-3ec3-4fe3-8998-b76aa0bfb600', pipelineStageId: 'fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
progressableType: PipelineProgressableType.Company,
}, },
]; ];

View File

@ -14,12 +14,7 @@ type MockedPipeline = Pick<
pipelineProgresses: Array< pipelineProgresses: Array<
Pick< Pick<
PipelineProgress, PipelineProgress,
| 'id' 'id' | 'companyId' | 'amount' | 'closeDate' | '__typename'
| 'progressableType'
| 'progressableId'
| 'amount'
| 'closeDate'
| '__typename'
> >
>; >;
} }
@ -40,16 +35,14 @@ export const mockedPipelinesData: Array<MockedPipeline> = [
pipelineProgresses: [ pipelineProgresses: [
{ {
id: 'fe256b39-3ec3-4fe7-8998-b76aa0bfb600', id: 'fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
progressableType: PipelineProgressableType.Company, companyId: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
progressableId: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
amount: null, amount: null,
closeDate: null, closeDate: null,
__typename: 'PipelineProgress', __typename: 'PipelineProgress',
}, },
{ {
id: '4a886c90-f4f2-4984-8222-882ebbb905d6', id: '4a886c90-f4f2-4984-8222-882ebbb905d6',
progressableType: PipelineProgressableType.Company, companyId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
progressableId: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
amount: null, amount: null,
closeDate: null, closeDate: null,
__typename: 'PipelineProgress', __typename: 'PipelineProgress',

View File

@ -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;

View File

@ -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';

View File

@ -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";

View File

@ -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";

View File

@ -240,9 +240,10 @@ model Company {
/// @TypeGraphQL.omit(input: true, output: true) /// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime? deletedAt DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[] ActivityTarget ActivityTarget[]
PipelineProgress PipelineProgress[]
@@map("companies") @@map("companies")
} }
@ -276,20 +277,21 @@ model Person {
/// @Validator.IsOptional() /// @Validator.IsOptional()
avatarUrl String? avatarUrl String?
company Company? @relation(fields: [companyId], references: [id]) company Company? @relation(fields: [companyId], references: [id])
companyId String? companyId String?
/// @TypeGraphQL.omit(input: true, output: true) /// @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) /// @TypeGraphQL.omit(input: true, output: true)
workspaceId String workspaceId String
pipelineProgresses PipelineProgress[] contactPipelineProgresses PipelineProgress[] @relation("PointOfContactPipelineProgress")
/// @TypeGraphQL.omit(input: true, output: true) /// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime? deletedAt DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[] ActivityTarget ActivityTarget[]
PipelineProgress PipelineProgress[]
@@map("people") @@map("people")
} }
@ -488,18 +490,17 @@ model PipelineProgress {
closeDate DateTime? closeDate DateTime?
probability Int? probability Int?
pipeline Pipeline @relation(fields: [pipelineId], references: [id]) pipeline Pipeline @relation(fields: [pipelineId], references: [id])
pipelineId String pipelineId String
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id]) pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id])
pipelineStageId String pipelineStageId String
pointOfContact Person? @relation(fields: [pointOfContactId], references: [id]) pointOfContact Person? @relation("PointOfContactPipelineProgress", fields: [pointOfContactId], references: [id])
pointOfContactId String? pointOfContactId String?
progressableType PipelineProgressableType
progressableId String
/// @TypeGraphQL.omit(input: true, output: true) /// @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) /// @TypeGraphQL.omit(input: true, output: true)
workspaceId String workspaceId String
/// @TypeGraphQL.omit(input: true, output: true) /// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime? deletedAt DateTime?
@ -507,6 +508,12 @@ model PipelineProgress {
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
companyId String?
company Company? @relation(fields: [companyId], references: [id])
personId String?
person Person? @relation(fields: [personId], references: [id])
@@map("pipeline_progresses") @@map("pipeline_progresses")
} }

View File

@ -89,8 +89,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600', id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
progressableType: 'Company', companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
progressableId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -102,8 +101,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-4a886c90-f4f2-4984-8222-882ebbb905d6', id: 'twenty-4a886c90-f4f2-4984-8222-882ebbb905d6',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
progressableType: 'Company', companyId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102',
progressableId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -115,8 +113,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-af92f3eb-d51d-4528-9b97-b8f132865b00', id: 'twenty-af92f3eb-d51d-4528-9b97-b8f132865b00',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
progressableType: 'Company', companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
progressableId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -128,8 +125,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-08369b1a-acdb-43d6-95f9-67ac7436941a', id: 'twenty-08369b1a-acdb-43d6-95f9-67ac7436941a',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
progressableType: 'Company', companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
progressableId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -167,8 +163,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600', id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400', pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600', pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600',
progressableType: 'Person', personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
progressableId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419', workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
}, },
}); });
@ -181,7 +176,6 @@ export const seedPipelines = async (prisma: PrismaClient) => {
name: 'Sales pipeline', name: 'Sales pipeline',
icon: '💰', icon: '💰',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420', workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
pipelineProgressableType: 'Person',
}, },
}); });