diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx index a3d0bcdbc..19cd17378 100644 --- a/front/src/generated/graphql.tsx +++ b/front/src/generated/graphql.tsx @@ -128,10 +128,6 @@ export type AuthTokens = { tokens: AuthTokenPair; }; -export type BoolFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type BoolFilter = { equals?: InputMaybe; not?: InputMaybe; @@ -362,17 +358,17 @@ export type CommentThreadUpdateInput = { assignee?: InputMaybe; attachments?: InputMaybe; author?: InputMaybe; - body?: InputMaybe; + body?: InputMaybe; commentThreadTargets?: InputMaybe; comments?: InputMaybe; - completedAt?: InputMaybe; - createdAt?: InputMaybe; - dueAt?: InputMaybe; - id?: InputMaybe; - reminderAt?: InputMaybe; - title?: InputMaybe; - type?: InputMaybe; - updatedAt?: InputMaybe; + completedAt?: InputMaybe; + createdAt?: InputMaybe; + dueAt?: InputMaybe; + id?: InputMaybe; + reminderAt?: InputMaybe; + title?: InputMaybe; + type?: InputMaybe; + updatedAt?: InputMaybe; }; export type CommentThreadUpdateManyWithoutAssigneeNestedInput = { @@ -536,14 +532,14 @@ export enum CompanyScalarFieldEnum { export type CompanyUpdateInput = { accountOwner?: InputMaybe; - address?: InputMaybe; - createdAt?: InputMaybe; - domainName?: InputMaybe; - employees?: InputMaybe; - id?: InputMaybe; - name?: InputMaybe; + address?: InputMaybe; + createdAt?: InputMaybe; + domainName?: InputMaybe; + employees?: InputMaybe; + id?: InputMaybe; + name?: InputMaybe; people?: InputMaybe; - updatedAt?: InputMaybe; + updatedAt?: InputMaybe; }; export type CompanyUpdateManyWithoutAccountOwnerNestedInput = { @@ -583,10 +579,6 @@ export type CompanyWhereUniqueInput = { id?: InputMaybe; }; -export type DateTimeFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type DateTimeFilter = { equals?: InputMaybe; gt?: InputMaybe; @@ -609,10 +601,6 @@ export type DateTimeNullableFilter = { notIn?: InputMaybe>; }; -export type EnumActivityTypeFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type EnumActivityTypeFilter = { equals?: InputMaybe; in?: InputMaybe>; @@ -627,10 +615,6 @@ export type EnumAttachmentTypeFilter = { notIn?: InputMaybe>; }; -export type EnumColorSchemeFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type EnumColorSchemeFilter = { equals?: InputMaybe; in?: InputMaybe>; @@ -645,10 +629,6 @@ export type EnumCommentableTypeFilter = { notIn?: InputMaybe>; }; -export type EnumPipelineProgressableTypeFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type EnumPipelineProgressableTypeFilter = { equals?: InputMaybe; in?: InputMaybe>; @@ -974,51 +954,35 @@ export type NestedStringNullableFilter = { startsWith?: InputMaybe; }; -export type NullableDateTimeFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - -export type NullableIntFieldUpdateOperationsInput = { - decrement?: InputMaybe; - divide?: InputMaybe; - increment?: InputMaybe; - multiply?: InputMaybe; - set?: InputMaybe; -}; - -export type NullableStringFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type Person = { __typename?: 'Person'; - PipelineProgress?: Maybe>; _commentThreadCount: Scalars['Int']; - city: Scalars['String']; + city?: Maybe; commentThreads: Array; comments: Array; company?: Maybe; companyId?: Maybe; createdAt: Scalars['DateTime']; displayName: Scalars['String']; - email: Scalars['String']; - firstName: Scalars['String']; + email?: Maybe; + firstName?: Maybe; id: Scalars['ID']; - lastName: Scalars['String']; - phone: Scalars['String']; + lastName?: Maybe; + phone?: Maybe; + pipelineProgresses?: Maybe>; updatedAt: Scalars['DateTime']; }; export type PersonCreateInput = { - PipelineProgress?: InputMaybe; - city: Scalars['String']; + city?: InputMaybe; company?: InputMaybe; createdAt?: InputMaybe; - email: Scalars['String']; - firstName: Scalars['String']; + email?: InputMaybe; + firstName?: InputMaybe; id?: InputMaybe; - lastName: Scalars['String']; - phone: Scalars['String']; + lastName?: InputMaybe; + phone?: InputMaybe; + pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1026,7 +990,7 @@ export type PersonCreateNestedManyWithoutCompanyInput = { connect?: InputMaybe>; }; -export type PersonCreateNestedOneWithoutPipelineProgressInput = { +export type PersonCreateNestedOneWithoutPipelineProgressesInput = { connect?: InputMaybe; }; @@ -1041,7 +1005,6 @@ export type PersonOrderByRelationAggregateInput = { }; export type PersonOrderByWithRelationInput = { - PipelineProgress?: InputMaybe; city?: InputMaybe; company?: InputMaybe; companyId?: InputMaybe; @@ -1051,6 +1014,7 @@ export type PersonOrderByWithRelationInput = { id?: InputMaybe; lastName?: InputMaybe; phone?: InputMaybe; + pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1074,16 +1038,16 @@ export enum PersonScalarFieldEnum { } export type PersonUpdateInput = { - PipelineProgress?: InputMaybe; - city?: InputMaybe; + city?: InputMaybe; company?: InputMaybe; - createdAt?: InputMaybe; - email?: InputMaybe; - firstName?: InputMaybe; - id?: InputMaybe; - lastName?: InputMaybe; - phone?: InputMaybe; - updatedAt?: InputMaybe; + createdAt?: InputMaybe; + email?: InputMaybe; + firstName?: InputMaybe; + id?: InputMaybe; + lastName?: InputMaybe; + phone?: InputMaybe; + pipelineProgresses?: InputMaybe; + updatedAt?: InputMaybe; }; export type PersonUpdateManyWithoutCompanyNestedInput = { @@ -1098,7 +1062,7 @@ export type PersonUpdateManyWithoutWorkspaceNestedInput = { set?: InputMaybe>; }; -export type PersonUpdateOneWithoutPipelineProgressNestedInput = { +export type PersonUpdateOneWithoutPipelineProgressesNestedInput = { connect?: InputMaybe; disconnect?: InputMaybe; }; @@ -1107,16 +1071,16 @@ export type PersonWhereInput = { AND?: InputMaybe>; NOT?: InputMaybe>; OR?: InputMaybe>; - PipelineProgress?: InputMaybe; - city?: InputMaybe; + city?: InputMaybe; company?: InputMaybe; companyId?: InputMaybe; createdAt?: InputMaybe; - email?: InputMaybe; - firstName?: InputMaybe; + email?: InputMaybe; + firstName?: InputMaybe; id?: InputMaybe; - lastName?: InputMaybe; - phone?: InputMaybe; + lastName?: InputMaybe; + phone?: InputMaybe; + pipelineProgresses?: InputMaybe; updatedAt?: InputMaybe; }; @@ -1176,7 +1140,7 @@ export type PipelineProgressCreateInput = { id?: InputMaybe; pipeline: PipelineCreateNestedOneWithoutPipelineProgressesInput; pipelineStage: PipelineStageCreateNestedOneWithoutPipelineProgressesInput; - pointOfContact?: InputMaybe; + pointOfContact?: InputMaybe; probability?: InputMaybe; progressableId: Scalars['String']; progressableType: PipelineProgressableType; @@ -1231,17 +1195,17 @@ export enum PipelineProgressScalarFieldEnum { } export type PipelineProgressUpdateInput = { - amount?: InputMaybe; - closeDate?: InputMaybe; - createdAt?: InputMaybe; - id?: InputMaybe; + amount?: InputMaybe; + closeDate?: InputMaybe; + createdAt?: InputMaybe; + id?: InputMaybe; pipeline?: InputMaybe; pipelineStage?: InputMaybe; - pointOfContact?: InputMaybe; - probability?: InputMaybe; - progressableId?: InputMaybe; - progressableType?: InputMaybe; - updatedAt?: InputMaybe; + pointOfContact?: InputMaybe; + probability?: InputMaybe; + progressableId?: InputMaybe; + progressableType?: InputMaybe; + updatedAt?: InputMaybe; }; export type PipelineProgressUpdateManyWithoutPipelineStageNestedInput = { @@ -1367,15 +1331,15 @@ export enum PipelineStageScalarFieldEnum { } export type PipelineStageUpdateInput = { - color?: InputMaybe; - createdAt?: InputMaybe; - id?: InputMaybe; - index?: InputMaybe; - name?: InputMaybe; + color?: InputMaybe; + createdAt?: InputMaybe; + id?: InputMaybe; + index?: InputMaybe; + name?: InputMaybe; pipeline?: InputMaybe; pipelineProgresses?: InputMaybe; - type?: InputMaybe; - updatedAt?: InputMaybe; + type?: InputMaybe; + updatedAt?: InputMaybe; }; export type PipelineStageUpdateManyWithoutWorkspaceNestedInput = { @@ -1569,10 +1533,6 @@ export enum SortOrder { Desc = 'desc' } -export type StringFieldUpdateOperationsInput = { - set?: InputMaybe; -}; - export type StringFilter = { contains?: InputMaybe; endsWith?: InputMaybe; @@ -1732,11 +1692,11 @@ export type UserSettingsUpdateOneRequiredWithoutUserNestedInput = { }; export type UserSettingsUpdateWithoutUserInput = { - colorScheme?: InputMaybe; - createdAt?: InputMaybe; - id?: InputMaybe; - locale?: InputMaybe; - updatedAt?: InputMaybe; + colorScheme?: InputMaybe; + createdAt?: InputMaybe; + id?: InputMaybe; + locale?: InputMaybe; + updatedAt?: InputMaybe; }; export type UserSettingsWhereInput = { @@ -1755,22 +1715,22 @@ export type UserUpdateInput = { assignedCommentThreads?: InputMaybe; authoredAttachments?: InputMaybe; authoredCommentThreads?: InputMaybe; - avatarUrl?: InputMaybe; + avatarUrl?: InputMaybe; comments?: InputMaybe; companies?: InputMaybe; - createdAt?: InputMaybe; - disabled?: InputMaybe; - email?: InputMaybe; - emailVerified?: InputMaybe; - firstName?: InputMaybe; - id?: InputMaybe; - lastName?: InputMaybe; - lastSeen?: InputMaybe; - locale?: InputMaybe; + createdAt?: InputMaybe; + disabled?: InputMaybe; + email?: InputMaybe; + emailVerified?: InputMaybe; + firstName?: InputMaybe; + id?: InputMaybe; + lastName?: InputMaybe; + lastSeen?: InputMaybe; + locale?: InputMaybe; metadata?: InputMaybe; - phoneNumber?: InputMaybe; + phoneNumber?: InputMaybe; settings?: InputMaybe; - updatedAt?: InputMaybe; + updatedAt?: InputMaybe; }; export type UserUpdateOneRequiredWithoutAuthoredCommentThreadsNestedInput = { @@ -1902,17 +1862,17 @@ export type WorkspaceUpdateInput = { commentThreads?: InputMaybe; comments?: InputMaybe; companies?: InputMaybe; - createdAt?: InputMaybe; - displayName?: InputMaybe; - domainName?: InputMaybe; - id?: InputMaybe; - inviteHash?: InputMaybe; - logo?: InputMaybe; + createdAt?: InputMaybe; + displayName?: InputMaybe; + domainName?: InputMaybe; + id?: InputMaybe; + inviteHash?: InputMaybe; + logo?: InputMaybe; people?: InputMaybe; pipelineProgresses?: InputMaybe; pipelineStages?: InputMaybe; pipelines?: InputMaybe; - updatedAt?: InputMaybe; + updatedAt?: InputMaybe; workspaceMember?: InputMaybe; }; @@ -1946,14 +1906,14 @@ export type GetCommentThreadsByTargetsQueryVariables = Exact<{ }>; -export type GetCommentThreadsByTargetsQuery = { __typename?: 'Query', findManyCommentThreads: Array<{ __typename?: 'CommentThread', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, commentableId: string, commentableType: CommentableType }> | null }> }; +export type GetCommentThreadsByTargetsQuery = { __typename?: 'Query', findManyCommentThreads: Array<{ __typename?: 'CommentThread', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, commentableId: string, commentableType: CommentableType }> | null }> }; export type GetCommentThreadQueryVariables = Exact<{ commentThreadId: Scalars['String']; }>; -export type GetCommentThreadQuery = { __typename?: 'Query', findManyCommentThreads: Array<{ __typename?: 'CommentThread', id: string, createdAt: string, body?: string | null, title?: string | null, type: ActivityType, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, commentableId: string, commentableType: CommentableType }> | null }> }; +export type GetCommentThreadQuery = { __typename?: 'Query', findManyCommentThreads: Array<{ __typename?: 'CommentThread', id: string, createdAt: string, body?: string | null, title?: string | null, type: ActivityType, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName?: string | null, lastName?: string | null, avatarUrl?: string | null } }> | null, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, commentableId: string, commentableType: CommentableType }> | null }> }; export type AddCommentThreadTargetOnCommentThreadMutationVariables = Exact<{ commentThreadId: Scalars['String']; @@ -2065,37 +2025,27 @@ export type GetCompanyQueryVariables = Exact<{ export type GetCompanyQuery = { __typename?: 'Query', findUniqueCompany: { __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, employees?: number | null, _commentThreadCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, avatarUrl?: string | null } | null } }; -export type UpdateCompanyMutationVariables = Exact<{ - id?: InputMaybe; - name?: InputMaybe; - domainName?: InputMaybe; - accountOwnerId?: InputMaybe; - createdAt?: InputMaybe; - address?: InputMaybe; - employees?: InputMaybe; +export type UpdateOneCompanyMutationVariables = Exact<{ + where: CompanyWhereUniqueInput; + data: CompanyUpdateInput; }>; -export type UpdateCompanyMutation = { __typename?: 'Mutation', updateOneCompany?: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, firstName?: string | null, lastName?: string | null } | null } | null }; +export type UpdateOneCompanyMutation = { __typename?: 'Mutation', updateOneCompany?: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, firstName?: string | null, lastName?: string | null } | null } | null }; -export type InsertCompanyMutationVariables = Exact<{ - id: Scalars['String']; - name: Scalars['String']; - domainName: Scalars['String']; - createdAt?: InputMaybe; - address: Scalars['String']; - employees?: InputMaybe; +export type InsertOneCompanyMutationVariables = Exact<{ + data: CompanyCreateInput; }>; -export type InsertCompanyMutation = { __typename?: 'Mutation', createOneCompany: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, id: string, name: string } }; +export type InsertOneCompanyMutation = { __typename?: 'Mutation', createOneCompany: { __typename?: 'Company', address: string, createdAt: string, domainName: string, employees?: number | null, id: string, name: string } }; -export type DeleteCompaniesMutationVariables = Exact<{ +export type DeleteManyCompaniesMutationVariables = Exact<{ ids?: InputMaybe | Scalars['String']>; }>; -export type DeleteCompaniesMutation = { __typename?: 'Mutation', deleteManyCompany: { __typename?: 'AffectedRows', count: number } }; +export type DeleteManyCompaniesMutation = { __typename?: 'Mutation', deleteManyCompany: { __typename?: 'AffectedRows', count: number } }; export type GetPeopleQueryVariables = Exact<{ orderBy?: InputMaybe | PersonOrderByWithRelationInput>; @@ -2104,28 +2054,28 @@ export type GetPeopleQueryVariables = Exact<{ }>; -export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstName: string, lastName: string, createdAt: string, _commentThreadCount: number, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> }; +export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone?: string | null, email?: string | null, city?: string | null, firstName?: string | null, lastName?: string | null, displayName: string, createdAt: string, _commentThreadCount: number, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> }; export type GetPersonPhoneByIdQueryVariables = Exact<{ id: Scalars['String']; }>; -export type GetPersonPhoneByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, phone: string } }; +export type GetPersonPhoneByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, phone?: string | null } }; export type GetPersonEmailByIdQueryVariables = Exact<{ id: Scalars['String']; }>; -export type GetPersonEmailByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, email: string } }; +export type GetPersonEmailByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, email?: string | null } }; export type GetPersonNamesAndCommentCountByIdQueryVariables = Exact<{ id: Scalars['String']; }>; -export type GetPersonNamesAndCommentCountByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, firstName: string, lastName: string, _commentThreadCount: number } }; +export type GetPersonNamesAndCommentCountByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, firstName?: string | null, lastName?: string | null, displayName: string, _commentThreadCount: number } }; export type GetPersonCompanyByIdQueryVariables = Exact<{ id: Scalars['String']; @@ -2153,48 +2103,36 @@ export type GetPersonCityByIdQueryVariables = Exact<{ }>; -export type GetPersonCityByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, city: string } }; +export type GetPersonCityByIdQuery = { __typename?: 'Query', person: { __typename?: 'Person', id: string, city?: string | null } }; export type GetPersonQueryVariables = Exact<{ id: Scalars['String']; }>; -export type GetPersonQuery = { __typename?: 'Query', findUniquePerson: { __typename?: 'Person', id: string, firstName: string, lastName: string, displayName: string, email: string, createdAt: string, city: string, phone: string, _commentThreadCount: number, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null } }; +export type GetPersonQuery = { __typename?: 'Query', findUniquePerson: { __typename?: 'Person', id: string, firstName?: string | null, lastName?: string | null, displayName: string, email?: string | null, createdAt: string, city?: string | null, phone?: string | null, _commentThreadCount: number, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null } }; -export type UpdatePeopleMutationVariables = Exact<{ - id?: InputMaybe; - firstName?: InputMaybe; - lastName?: InputMaybe; - phone?: InputMaybe; - city?: InputMaybe; - companyId?: InputMaybe; - email?: InputMaybe; - createdAt?: InputMaybe; +export type UpdateOnePersonMutationVariables = Exact<{ + where: PersonWhereUniqueInput; + data: PersonUpdateInput; }>; -export type UpdatePeopleMutation = { __typename?: 'Mutation', updateOnePerson?: { __typename?: 'Person', id: string, city: string, email: string, firstName: string, lastName: string, phone: string, createdAt: string, company?: { __typename?: 'Company', domainName: string, name: string, id: string } | null } | null }; +export type UpdateOnePersonMutation = { __typename?: 'Mutation', updateOnePerson?: { __typename?: 'Person', id: string, city?: string | null, email?: string | null, firstName?: string | null, lastName?: string | null, displayName: string, phone?: string | null, createdAt: string, company?: { __typename?: 'Company', domainName: string, name: string, id: string } | null } | null }; -export type InsertPersonMutationVariables = Exact<{ - id: Scalars['String']; - firstName: Scalars['String']; - lastName: Scalars['String']; - phone: Scalars['String']; - city: Scalars['String']; - email: Scalars['String']; - createdAt?: InputMaybe; +export type InsertOnePersonMutationVariables = Exact<{ + data: PersonCreateInput; }>; -export type InsertPersonMutation = { __typename?: 'Mutation', createOnePerson: { __typename?: 'Person', id: string, city: string, email: string, firstName: string, lastName: string, phone: string, createdAt: string, company?: { __typename?: 'Company', domainName: string, name: string, id: string } | null } }; +export type InsertOnePersonMutation = { __typename?: 'Mutation', createOnePerson: { __typename?: 'Person', id: string, city?: string | null, email?: string | null, firstName?: string | null, lastName?: string | null, displayName: string, phone?: string | null, createdAt: string, company?: { __typename?: 'Company', domainName: string, name: string, id: string } | null } }; -export type DeletePeopleMutationVariables = Exact<{ +export type DeleteManyPersonMutationVariables = Exact<{ ids?: InputMaybe | Scalars['String']>; }>; -export type DeletePeopleMutation = { __typename?: 'Mutation', deleteManyPerson: { __typename?: 'AffectedRows', count: number } }; +export type DeleteManyPersonMutation = { __typename?: 'Mutation', deleteManyPerson: { __typename?: 'AffectedRows', count: number } }; export type GetPipelinesQueryVariables = Exact<{ where?: InputMaybe; @@ -2209,7 +2147,7 @@ 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, lastName: string } | null }> }; +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 } | null }> }; export type UpdateOnePipelineProgressMutationVariables = Exact<{ id?: InputMaybe; @@ -2263,7 +2201,7 @@ export type SearchPeopleQueryVariables = Exact<{ }>; -export type SearchPeopleQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstName: string, lastName: string, createdAt: string }> }; +export type SearchPeopleQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Person', id: string, phone?: string | null, email?: string | null, city?: string | null, firstName?: string | null, lastName?: string | null, createdAt: string }> }; export type SearchUserQueryVariables = Exact<{ where?: InputMaybe; @@ -2323,7 +2261,7 @@ export type RemoveProfilePictureMutation = { __typename?: 'Mutation', updateUser export type GetWorkspaceMembersQueryVariables = Exact<{ [key: string]: never; }>; -export type GetWorkspaceMembersQuery = { __typename?: 'Query', workspaceMembers: Array<{ __typename?: 'WorkspaceMember', id: string, user: { __typename?: 'User', id: string, email: string, avatarUrl?: string | null, firstName?: string | null, lastName?: string | null } }> }; +export type GetWorkspaceMembersQuery = { __typename?: 'Query', workspaceMembers: Array<{ __typename?: 'WorkspaceMember', id: string, user: { __typename?: 'User', id: string, email: string, avatarUrl?: string | null, firstName?: string | null, lastName?: string | null, displayName: string } }> }; export type UpdateWorkspaceMutationVariables = Exact<{ data: WorkspaceUpdateInput; @@ -2478,6 +2416,7 @@ export const GetCommentThreadsByTargetsDocument = gql` id firstName lastName + displayName } comments { id @@ -2541,6 +2480,7 @@ export const GetCommentThreadDocument = gql` id firstName lastName + displayName } comments { id @@ -2723,7 +2663,7 @@ export const UpdateCommentThreadDocument = gql` mutation UpdateCommentThread($id: String!, $body: String, $title: String, $type: ActivityType) { updateOneCommentThread( where: {id: $id} - data: {body: {set: $body}, title: {set: $title}, type: {set: $type}} + data: {body: $body, title: $title, type: $type} ) { id body @@ -3181,12 +3121,9 @@ export function useGetCompanyLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type GetCompanyQueryHookResult = ReturnType; export type GetCompanyLazyQueryHookResult = ReturnType; export type GetCompanyQueryResult = Apollo.QueryResult; -export const UpdateCompanyDocument = gql` - mutation UpdateCompany($id: String, $name: String, $domainName: String, $accountOwnerId: String, $createdAt: DateTime, $address: String, $employees: Int) { - updateOneCompany( - where: {id: $id} - data: {accountOwner: {connect: {id: $accountOwnerId}}, address: {set: $address}, domainName: {set: $domainName}, employees: {set: $employees}, name: {set: $name}, createdAt: {set: $createdAt}} - ) { +export const UpdateOneCompanyDocument = gql` + mutation UpdateOneCompany($where: CompanyWhereUniqueInput!, $data: CompanyUpdateInput!) { + updateOneCompany(data: $data, where: $where) { accountOwner { id email @@ -3203,43 +3140,36 @@ export const UpdateCompanyDocument = gql` } } `; -export type UpdateCompanyMutationFn = Apollo.MutationFunction; +export type UpdateOneCompanyMutationFn = Apollo.MutationFunction; /** - * __useUpdateCompanyMutation__ + * __useUpdateOneCompanyMutation__ * - * To run a mutation, you first call `useUpdateCompanyMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useUpdateCompanyMutation` returns a tuple that includes: + * To run a mutation, you first call `useUpdateOneCompanyMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateOneCompanyMutation` 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 [updateCompanyMutation, { data, loading, error }] = useUpdateCompanyMutation({ + * const [updateOneCompanyMutation, { data, loading, error }] = useUpdateOneCompanyMutation({ * variables: { - * id: // value for 'id' - * name: // value for 'name' - * domainName: // value for 'domainName' - * accountOwnerId: // value for 'accountOwnerId' - * createdAt: // value for 'createdAt' - * address: // value for 'address' - * employees: // value for 'employees' + * where: // value for 'where' + * data: // value for 'data' * }, * }); */ -export function useUpdateCompanyMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useUpdateOneCompanyMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(UpdateCompanyDocument, options); + return Apollo.useMutation(UpdateOneCompanyDocument, options); } -export type UpdateCompanyMutationHookResult = ReturnType; -export type UpdateCompanyMutationResult = Apollo.MutationResult; -export type UpdateCompanyMutationOptions = Apollo.BaseMutationOptions; -export const InsertCompanyDocument = gql` - mutation InsertCompany($id: String!, $name: String!, $domainName: String!, $createdAt: DateTime, $address: String!, $employees: Int) { - createOneCompany( - data: {id: $id, name: $name, domainName: $domainName, createdAt: $createdAt, address: $address, employees: $employees} - ) { +export type UpdateOneCompanyMutationHookResult = ReturnType; +export type UpdateOneCompanyMutationResult = Apollo.MutationResult; +export type UpdateOneCompanyMutationOptions = Apollo.BaseMutationOptions; +export const InsertOneCompanyDocument = gql` + mutation InsertOneCompany($data: CompanyCreateInput!) { + createOneCompany(data: $data) { address createdAt domainName @@ -3249,70 +3179,65 @@ export const InsertCompanyDocument = gql` } } `; -export type InsertCompanyMutationFn = Apollo.MutationFunction; +export type InsertOneCompanyMutationFn = Apollo.MutationFunction; /** - * __useInsertCompanyMutation__ + * __useInsertOneCompanyMutation__ * - * To run a mutation, you first call `useInsertCompanyMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useInsertCompanyMutation` returns a tuple that includes: + * To run a mutation, you first call `useInsertOneCompanyMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useInsertOneCompanyMutation` 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 [insertCompanyMutation, { data, loading, error }] = useInsertCompanyMutation({ + * const [insertOneCompanyMutation, { data, loading, error }] = useInsertOneCompanyMutation({ * variables: { - * id: // value for 'id' - * name: // value for 'name' - * domainName: // value for 'domainName' - * createdAt: // value for 'createdAt' - * address: // value for 'address' - * employees: // value for 'employees' + * data: // value for 'data' * }, * }); */ -export function useInsertCompanyMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useInsertOneCompanyMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(InsertCompanyDocument, options); + return Apollo.useMutation(InsertOneCompanyDocument, options); } -export type InsertCompanyMutationHookResult = ReturnType; -export type InsertCompanyMutationResult = Apollo.MutationResult; -export type InsertCompanyMutationOptions = Apollo.BaseMutationOptions; -export const DeleteCompaniesDocument = gql` - mutation DeleteCompanies($ids: [String!]) { +export type InsertOneCompanyMutationHookResult = ReturnType; +export type InsertOneCompanyMutationResult = Apollo.MutationResult; +export type InsertOneCompanyMutationOptions = Apollo.BaseMutationOptions; +export const DeleteManyCompaniesDocument = gql` + mutation DeleteManyCompanies($ids: [String!]) { deleteManyCompany(where: {id: {in: $ids}}) { count } } `; -export type DeleteCompaniesMutationFn = Apollo.MutationFunction; +export type DeleteManyCompaniesMutationFn = Apollo.MutationFunction; /** - * __useDeleteCompaniesMutation__ + * __useDeleteManyCompaniesMutation__ * - * To run a mutation, you first call `useDeleteCompaniesMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useDeleteCompaniesMutation` returns a tuple that includes: + * To run a mutation, you first call `useDeleteManyCompaniesMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useDeleteManyCompaniesMutation` 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 [deleteCompaniesMutation, { data, loading, error }] = useDeleteCompaniesMutation({ + * const [deleteManyCompaniesMutation, { data, loading, error }] = useDeleteManyCompaniesMutation({ * variables: { * ids: // value for 'ids' * }, * }); */ -export function useDeleteCompaniesMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useDeleteManyCompaniesMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(DeleteCompaniesDocument, options); + return Apollo.useMutation(DeleteManyCompaniesDocument, options); } -export type DeleteCompaniesMutationHookResult = ReturnType; -export type DeleteCompaniesMutationResult = Apollo.MutationResult; -export type DeleteCompaniesMutationOptions = Apollo.BaseMutationOptions; +export type DeleteManyCompaniesMutationHookResult = ReturnType; +export type DeleteManyCompaniesMutationResult = Apollo.MutationResult; +export type DeleteManyCompaniesMutationOptions = Apollo.BaseMutationOptions; export const GetPeopleDocument = gql` query GetPeople($orderBy: [PersonOrderByWithRelationInput!], $where: PersonWhereInput, $limit: Int) { people: findManyPerson(orderBy: $orderBy, where: $where, take: $limit) { @@ -3322,6 +3247,7 @@ export const GetPeopleDocument = gql` city firstName lastName + displayName createdAt _commentThreadCount company { @@ -3440,6 +3366,7 @@ export const GetPersonNamesAndCommentCountByIdDocument = gql` id firstName lastName + displayName _commentThreadCount } } @@ -3668,12 +3595,9 @@ export function useGetPersonLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions< export type GetPersonQueryHookResult = ReturnType; export type GetPersonLazyQueryHookResult = ReturnType; export type GetPersonQueryResult = Apollo.QueryResult; -export const UpdatePeopleDocument = gql` - mutation UpdatePeople($id: String, $firstName: String, $lastName: String, $phone: String, $city: String, $companyId: String, $email: String, $createdAt: DateTime) { - updateOnePerson( - where: {id: $id} - data: {city: {set: $city}, company: {connect: {id: $companyId}}, email: {set: $email}, firstName: {set: $firstName}, id: {set: $id}, lastName: {set: $lastName}, phone: {set: $phone}, createdAt: {set: $createdAt}} - ) { +export const UpdateOnePersonDocument = gql` + mutation UpdateOnePerson($where: PersonWhereUniqueInput!, $data: PersonUpdateInput!) { + updateOnePerson(data: $data, where: $where) { id city company { @@ -3684,49 +3608,42 @@ export const UpdatePeopleDocument = gql` email firstName lastName + displayName phone createdAt } } `; -export type UpdatePeopleMutationFn = Apollo.MutationFunction; +export type UpdateOnePersonMutationFn = Apollo.MutationFunction; /** - * __useUpdatePeopleMutation__ + * __useUpdateOnePersonMutation__ * - * To run a mutation, you first call `useUpdatePeopleMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useUpdatePeopleMutation` returns a tuple that includes: + * To run a mutation, you first call `useUpdateOnePersonMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useUpdateOnePersonMutation` 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 [updatePeopleMutation, { data, loading, error }] = useUpdatePeopleMutation({ + * const [updateOnePersonMutation, { data, loading, error }] = useUpdateOnePersonMutation({ * variables: { - * id: // value for 'id' - * firstName: // value for 'firstName' - * lastName: // value for 'lastName' - * phone: // value for 'phone' - * city: // value for 'city' - * companyId: // value for 'companyId' - * email: // value for 'email' - * createdAt: // value for 'createdAt' + * where: // value for 'where' + * data: // value for 'data' * }, * }); */ -export function useUpdatePeopleMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useUpdateOnePersonMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(UpdatePeopleDocument, options); + return Apollo.useMutation(UpdateOnePersonDocument, options); } -export type UpdatePeopleMutationHookResult = ReturnType; -export type UpdatePeopleMutationResult = Apollo.MutationResult; -export type UpdatePeopleMutationOptions = Apollo.BaseMutationOptions; -export const InsertPersonDocument = gql` - mutation InsertPerson($id: String!, $firstName: String!, $lastName: String!, $phone: String!, $city: String!, $email: String!, $createdAt: DateTime) { - createOnePerson( - data: {id: $id, firstName: $firstName, lastName: $lastName, phone: $phone, city: $city, email: $email, createdAt: $createdAt} - ) { +export type UpdateOnePersonMutationHookResult = ReturnType; +export type UpdateOnePersonMutationResult = Apollo.MutationResult; +export type UpdateOnePersonMutationOptions = Apollo.BaseMutationOptions; +export const InsertOnePersonDocument = gql` + mutation InsertOnePerson($data: PersonCreateInput!) { + createOnePerson(data: $data) { id city company { @@ -3737,76 +3654,71 @@ export const InsertPersonDocument = gql` email firstName lastName + displayName phone createdAt } } `; -export type InsertPersonMutationFn = Apollo.MutationFunction; +export type InsertOnePersonMutationFn = Apollo.MutationFunction; /** - * __useInsertPersonMutation__ + * __useInsertOnePersonMutation__ * - * To run a mutation, you first call `useInsertPersonMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useInsertPersonMutation` returns a tuple that includes: + * To run a mutation, you first call `useInsertOnePersonMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useInsertOnePersonMutation` 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 [insertPersonMutation, { data, loading, error }] = useInsertPersonMutation({ + * const [insertOnePersonMutation, { data, loading, error }] = useInsertOnePersonMutation({ * variables: { - * id: // value for 'id' - * firstName: // value for 'firstName' - * lastName: // value for 'lastName' - * phone: // value for 'phone' - * city: // value for 'city' - * email: // value for 'email' - * createdAt: // value for 'createdAt' + * data: // value for 'data' * }, * }); */ -export function useInsertPersonMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useInsertOnePersonMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(InsertPersonDocument, options); + return Apollo.useMutation(InsertOnePersonDocument, options); } -export type InsertPersonMutationHookResult = ReturnType; -export type InsertPersonMutationResult = Apollo.MutationResult; -export type InsertPersonMutationOptions = Apollo.BaseMutationOptions; -export const DeletePeopleDocument = gql` - mutation DeletePeople($ids: [String!]) { +export type InsertOnePersonMutationHookResult = ReturnType; +export type InsertOnePersonMutationResult = Apollo.MutationResult; +export type InsertOnePersonMutationOptions = Apollo.BaseMutationOptions; +export const DeleteManyPersonDocument = gql` + mutation DeleteManyPerson($ids: [String!]) { deleteManyPerson(where: {id: {in: $ids}}) { count } } `; -export type DeletePeopleMutationFn = Apollo.MutationFunction; +export type DeleteManyPersonMutationFn = Apollo.MutationFunction; /** - * __useDeletePeopleMutation__ + * __useDeleteManyPersonMutation__ * - * To run a mutation, you first call `useDeletePeopleMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useDeletePeopleMutation` returns a tuple that includes: + * To run a mutation, you first call `useDeleteManyPersonMutation` within a React component and pass it any options that fit your needs. + * When your component renders, `useDeleteManyPersonMutation` 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 [deletePeopleMutation, { data, loading, error }] = useDeletePeopleMutation({ + * const [deleteManyPersonMutation, { data, loading, error }] = useDeleteManyPersonMutation({ * variables: { * ids: // value for 'ids' * }, * }); */ -export function useDeletePeopleMutation(baseOptions?: Apollo.MutationHookOptions) { +export function useDeleteManyPersonMutation(baseOptions?: Apollo.MutationHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(DeletePeopleDocument, options); + return Apollo.useMutation(DeleteManyPersonDocument, options); } -export type DeletePeopleMutationHookResult = ReturnType; -export type DeletePeopleMutationResult = Apollo.MutationResult; -export type DeletePeopleMutationOptions = Apollo.BaseMutationOptions; +export type DeleteManyPersonMutationHookResult = ReturnType; +export type DeleteManyPersonMutationResult = Apollo.MutationResult; +export type DeleteManyPersonMutationOptions = Apollo.BaseMutationOptions; export const GetPipelinesDocument = gql` query GetPipelines($where: PipelineWhereInput) { findManyPipeline(where: $where) { @@ -3864,6 +3776,7 @@ export const GetPipelineProgressDocument = gql` id firstName lastName + displayName } probability } @@ -3902,7 +3815,7 @@ export const UpdateOnePipelineProgressDocument = gql` mutation UpdateOnePipelineProgress($id: String, $amount: Int, $closeDate: DateTime, $probability: Int, $pointOfContactId: String) { updateOnePipelineProgress( where: {id: $id} - data: {amount: {set: $amount}, closeDate: {set: $closeDate}, probability: {set: $probability}, pointOfContact: {connect: {id: $pointOfContactId}}} + data: {amount: $amount, closeDate: $closeDate, probability: $probability, pointOfContact: {connect: {id: $pointOfContactId}}} ) { id amount @@ -4051,7 +3964,7 @@ export type DeleteManyPipelineProgressMutationResult = Apollo.MutationResult; export const UpdatePipelineStageDocument = gql` mutation UpdatePipelineStage($id: String, $name: String) { - updateOnePipelineStage(where: {id: $id}, data: {name: {set: $name}}) { + updateOnePipelineStage(where: {id: $id}, data: {name: $name}) { id name } @@ -4421,7 +4334,7 @@ export type UploadProfilePictureMutationResult = Apollo.MutationResult; export const RemoveProfilePictureDocument = gql` mutation RemoveProfilePicture($where: UserWhereUniqueInput!) { - updateUser(data: {avatarUrl: {set: null}}, where: $where) { + updateUser(data: {avatarUrl: null}, where: $where) { id avatarUrl } @@ -4463,6 +4376,7 @@ export const GetWorkspaceMembersDocument = gql` avatarUrl firstName lastName + displayName } } } @@ -4563,7 +4477,7 @@ export type UploadWorkspaceLogoMutationResult = Apollo.MutationResult; export const RemoveWorkspaceLogoDocument = gql` mutation RemoveWorkspaceLogo { - updateWorkspace(data: {logo: {set: null}}) { + updateWorkspace(data: {logo: null}) { id } } diff --git a/front/src/modules/activities/queries/select.ts b/front/src/modules/activities/queries/select.ts index 1ac553dc4..8a3db3014 100644 --- a/front/src/modules/activities/queries/select.ts +++ b/front/src/modules/activities/queries/select.ts @@ -22,6 +22,7 @@ export const GET_COMMENT_THREADS_BY_TARGETS = gql` id firstName lastName + displayName } comments { id @@ -57,6 +58,7 @@ export const GET_COMMENT_THREAD = gql` id firstName lastName + displayName } comments { id diff --git a/front/src/modules/activities/queries/update.ts b/front/src/modules/activities/queries/update.ts index bf5c27a36..673b47182 100644 --- a/front/src/modules/activities/queries/update.ts +++ b/front/src/modules/activities/queries/update.ts @@ -78,11 +78,7 @@ export const UPDATE_COMMENT_THREAD = gql` ) { updateOneCommentThread( where: { id: $id } - data: { - body: { set: $body } - title: { set: $title } - type: { set: $type } - } + data: { body: $body, title: $title, type: $type } ) { id body diff --git a/front/src/modules/activities/timeline/components/Timeline.tsx b/front/src/modules/activities/timeline/components/Timeline.tsx index 3ab4df0a9..9eee2f519 100644 --- a/front/src/modules/activities/timeline/components/Timeline.tsx +++ b/front/src/modules/activities/timeline/components/Timeline.tsx @@ -252,10 +252,7 @@ export function Timeline({ entity }: { entity: CommentableEntity }) { - - {commentThread.author.firstName}{' '} - {commentThread.author.lastName} - + {commentThread.author.displayName} created a note diff --git a/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx b/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx index b19490ccb..66ee92cbd 100644 --- a/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx +++ b/front/src/modules/companies/components/CompanyAccountOwnerPicker.tsx @@ -8,7 +8,7 @@ import { Company, User, useSearchUserQuery, - useUpdateCompanyMutation, + useUpdateOneCompanyMutation, } from '~/generated/graphql'; export type OwnProps = { @@ -31,7 +31,7 @@ export function CompanyAccountOwnerPicker({ const [searchFilter] = useRecoilScopedState( relationPickerSearchFilterScopedState, ); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); const companies = useFilteredSearchEntityQuery({ queryHook: useSearchUserQuery, @@ -51,8 +51,10 @@ export function CompanyAccountOwnerPicker({ async function handleEntitySelected(selectedUser: UserForSelect) { await updateCompany({ variables: { - ...company, - accountOwnerId: selectedUser.id, + where: { id: company.id }, + data: { + accountOwner: { connect: { id: selectedUser.id } }, + }, }, }); diff --git a/front/src/modules/companies/components/CompanyEditableNameCell.tsx b/front/src/modules/companies/components/CompanyEditableNameCell.tsx index 402ac6f78..a509e2d79 100644 --- a/front/src/modules/companies/components/CompanyEditableNameCell.tsx +++ b/front/src/modules/companies/components/CompanyEditableNameCell.tsx @@ -4,7 +4,7 @@ import { getOperationName } from '@apollo/client/utilities'; import { EditableCellChip } from '@/ui/table/editable-cell/types/EditableChip'; import { GetCompaniesQuery, - useUpdateCompanyMutation, + useUpdateOneCompanyMutation, } from '~/generated/graphql'; import { getLogoUrlFromDomainName } from '~/utils'; @@ -20,7 +20,7 @@ type OwnProps = { }; export function CompanyEditableNameChipCell({ company }: OwnProps) { - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); const [internalValue, setInternalValue] = useState(company.name ?? ''); @@ -44,8 +44,10 @@ export function CompanyEditableNameChipCell({ company }: OwnProps) { onSubmit={() => updateCompany({ variables: { - id: company.id, - name: internalValue, + where: { id: company.id }, + data: { + name: internalValue, + }, }, refetchQueries: [getOperationName(GET_COMPANY) ?? ''], }) diff --git a/front/src/modules/companies/editable-field/components/CompanyAddressEditableField.tsx b/front/src/modules/companies/editable-field/components/CompanyAddressEditableField.tsx index 6869cead6..21e1d8dfd 100644 --- a/front/src/modules/companies/editable-field/components/CompanyAddressEditableField.tsx +++ b/front/src/modules/companies/editable-field/components/CompanyAddressEditableField.tsx @@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext'; import { IconMap } from '@/ui/icon'; import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText'; import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; -import { Company, useUpdateCompanyMutation } from '~/generated/graphql'; +import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql'; type OwnProps = { company: Pick; @@ -14,7 +14,7 @@ type OwnProps = { export function CompanyAddressEditableField({ company }: OwnProps) { const [internalValue, setInternalValue] = useState(company.address); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); useEffect(() => { setInternalValue(company.address); @@ -27,8 +27,12 @@ export function CompanyAddressEditableField({ company }: OwnProps) { async function handleSubmit() { await updateCompany({ variables: { - id: company.id, - address: internalValue ?? '', + where: { + id: company.id, + }, + data: { + address: internalValue ?? '', + }, }, }); } diff --git a/front/src/modules/companies/editable-field/components/CompanyCreatedAtEditableField.tsx b/front/src/modules/companies/editable-field/components/CompanyCreatedAtEditableField.tsx index 4de2a36ca..89be7946e 100644 --- a/front/src/modules/companies/editable-field/components/CompanyCreatedAtEditableField.tsx +++ b/front/src/modules/companies/editable-field/components/CompanyCreatedAtEditableField.tsx @@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext'; import { EditableFieldEditModeDate } from '@/ui/editable-field/variants/components/EditableFieldEditModeDate'; import { IconCalendar } from '@/ui/icon'; import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; -import { Company, useUpdateCompanyMutation } from '~/generated/graphql'; +import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql'; import { formatToHumanReadableDate } from '~/utils'; import { parseDate } from '~/utils/date-utils'; @@ -16,7 +16,7 @@ type OwnProps = { export function CompanyCreatedAtEditableField({ company }: OwnProps) { const [internalValue, setInternalValue] = useState(company.createdAt); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); useEffect(() => { setInternalValue(company.createdAt); @@ -29,8 +29,12 @@ export function CompanyCreatedAtEditableField({ company }: OwnProps) { async function handleSubmit() { await updateCompany({ variables: { - id: company.id, - createdAt: internalValue ?? '', + where: { + id: company.id, + }, + data: { + createdAt: internalValue ?? '', + }, }, }); } diff --git a/front/src/modules/companies/editable-field/components/CompanyDomainNameEditableField.tsx b/front/src/modules/companies/editable-field/components/CompanyDomainNameEditableField.tsx index 5bb6ae0b0..e4ad8530e 100644 --- a/front/src/modules/companies/editable-field/components/CompanyDomainNameEditableField.tsx +++ b/front/src/modules/companies/editable-field/components/CompanyDomainNameEditableField.tsx @@ -6,7 +6,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext'; import { IconLink } from '@/ui/icon'; import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText'; import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; -import { Company, useUpdateCompanyMutation } from '~/generated/graphql'; +import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql'; type OwnProps = { company: Pick; @@ -15,7 +15,7 @@ type OwnProps = { export function CompanyDomainNameEditableField({ company }: OwnProps) { const [internalValue, setInternalValue] = useState(company.domainName); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); useEffect(() => { setInternalValue(company.domainName); @@ -28,8 +28,12 @@ export function CompanyDomainNameEditableField({ company }: OwnProps) { async function handleSubmit() { await updateCompany({ variables: { - id: company.id, - domainName: internalValue ?? '', + where: { + id: company.id, + }, + data: { + domainName: internalValue ?? '', + }, }, }); } diff --git a/front/src/modules/companies/editable-field/components/CompanyEmployeesEditableField.tsx b/front/src/modules/companies/editable-field/components/CompanyEmployeesEditableField.tsx index c62924194..8983adc8c 100644 --- a/front/src/modules/companies/editable-field/components/CompanyEmployeesEditableField.tsx +++ b/front/src/modules/companies/editable-field/components/CompanyEmployeesEditableField.tsx @@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext'; import { IconUsers } from '@/ui/icon'; import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText'; import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; -import { Company, useUpdateCompanyMutation } from '~/generated/graphql'; +import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql'; type OwnProps = { company: Pick; @@ -16,7 +16,7 @@ export function CompanyEmployeesEditableField({ company }: OwnProps) { company.employees?.toString(), ); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); useEffect(() => { setInternalValue(company.employees?.toString()); @@ -38,8 +38,12 @@ export function CompanyEmployeesEditableField({ company }: OwnProps) { await updateCompany({ variables: { - id: company.id, - employees: numberValue, + where: { + id: company.id, + }, + data: { + employees: numberValue, + }, }, }); diff --git a/front/src/modules/companies/queries/update.ts b/front/src/modules/companies/queries/update.ts index 57bc3fa63..2d43e5ad3 100644 --- a/front/src/modules/companies/queries/update.ts +++ b/front/src/modules/companies/queries/update.ts @@ -1,26 +1,11 @@ import { gql } from '@apollo/client'; -export const UPDATE_COMPANY = gql` - mutation UpdateCompany( - $id: String - $name: String - $domainName: String - $accountOwnerId: String - $createdAt: DateTime - $address: String - $employees: Int +export const UPDATE_ONE_COMPANY = gql` + mutation UpdateOneCompany( + $where: CompanyWhereUniqueInput! + $data: CompanyUpdateInput! ) { - updateOneCompany( - where: { id: $id } - data: { - accountOwner: { connect: { id: $accountOwnerId } } - address: { set: $address } - domainName: { set: $domainName } - employees: { set: $employees } - name: { set: $name } - createdAt: { set: $createdAt } - } - ) { + updateOneCompany(data: $data, where: $where) { accountOwner { id email @@ -38,25 +23,9 @@ export const UPDATE_COMPANY = gql` } `; -export const INSERT_COMPANY = gql` - mutation InsertCompany( - $id: String! - $name: String! - $domainName: String! - $createdAt: DateTime - $address: String! - $employees: Int - ) { - createOneCompany( - data: { - id: $id - name: $name - domainName: $domainName - createdAt: $createdAt - address: $address - employees: $employees - } - ) { +export const INSERT_ONE_COMPANY = gql` + mutation InsertOneCompany($data: CompanyCreateInput!) { + createOneCompany(data: $data) { address createdAt domainName @@ -67,8 +36,8 @@ export const INSERT_COMPANY = gql` } `; -export const DELETE_COMPANIES = gql` - mutation DeleteCompanies($ids: [String!]) { +export const DELETE_MANY_COMPANIES = gql` + mutation DeleteManyCompanies($ids: [String!]) { deleteManyCompany(where: { id: { in: $ids } }) { count } diff --git a/front/src/modules/companies/table/components/EditableCompanyAddressCell.tsx b/front/src/modules/companies/table/components/EditableCompanyAddressCell.tsx index 6fa1bca63..68c9b8089 100644 --- a/front/src/modules/companies/table/components/EditableCompanyAddressCell.tsx +++ b/front/src/modules/companies/table/components/EditableCompanyAddressCell.tsx @@ -4,12 +4,12 @@ import { useRecoilValue } from 'recoil'; import { companyAddressFamilyState } from '@/companies/states/companyAddressFamilyState'; import { EditableCellText } from '@/ui/table/editable-cell/types/EditableCellText'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdateCompanyMutation } from '~/generated/graphql'; +import { useUpdateOneCompanyMutation } from '~/generated/graphql'; export function EditableCompanyAddressCell() { const currentRowEntityId = useCurrentRowEntityId(); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); const address = useRecoilValue( companyAddressFamilyState(currentRowEntityId ?? ''), @@ -27,8 +27,12 @@ export function EditableCompanyAddressCell() { onSubmit={() => updateCompany({ variables: { - id: currentRowEntityId, - address: internalValue, + where: { + id: currentRowEntityId, + }, + data: { + address: internalValue, + }, }, }) } diff --git a/front/src/modules/companies/table/components/EditableCompanyCreatedAtCell.tsx b/front/src/modules/companies/table/components/EditableCompanyCreatedAtCell.tsx index ac12e2df6..08b0a0052 100644 --- a/front/src/modules/companies/table/components/EditableCompanyCreatedAtCell.tsx +++ b/front/src/modules/companies/table/components/EditableCompanyCreatedAtCell.tsx @@ -4,7 +4,7 @@ import { useRecoilValue } from 'recoil'; import { companyCreatedAtFamilyState } from '@/companies/states/companyCreatedAtFamilyState'; import { EditableCellDate } from '@/ui/table/editable-cell/types/EditableCellDate'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdateCompanyMutation } from '~/generated/graphql'; +import { useUpdateOneCompanyMutation } from '~/generated/graphql'; export function EditableCompanyCreatedAtCell() { const currentRowEntityId = useCurrentRowEntityId(); @@ -13,7 +13,7 @@ export function EditableCompanyCreatedAtCell() { companyCreatedAtFamilyState(currentRowEntityId ?? ''), ); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); return ( updateCompany({ variables: { - id: currentRowEntityId, - domainName: internalValue, + where: { + id: currentRowEntityId, + }, + data: { + domainName: internalValue, + }, }, }) } diff --git a/front/src/modules/companies/table/components/EditableCompanyEmployeesCell.tsx b/front/src/modules/companies/table/components/EditableCompanyEmployeesCell.tsx index 6ea18b3d3..5489a592c 100644 --- a/front/src/modules/companies/table/components/EditableCompanyEmployeesCell.tsx +++ b/front/src/modules/companies/table/components/EditableCompanyEmployeesCell.tsx @@ -4,12 +4,12 @@ import { useRecoilValue } from 'recoil'; import { companyEmployeesFamilyState } from '@/companies/states/companyEmployeesFamilyState'; import { EditableCellText } from '@/ui/table/editable-cell/types/EditableCellText'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdateCompanyMutation } from '~/generated/graphql'; +import { useUpdateOneCompanyMutation } from '~/generated/graphql'; export function EditableCompanyEmployeesCell() { const currentRowEntityId = useCurrentRowEntityId(); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); const employees = useRecoilValue( companyEmployeesFamilyState(currentRowEntityId ?? ''), @@ -29,8 +29,12 @@ export function EditableCompanyEmployeesCell() { onSubmit={() => updateCompany({ variables: { - id: currentRowEntityId, - employees: parseInt(internalValue), + where: { + id: currentRowEntityId, + }, + data: { + employees: parseInt(internalValue), + }, }, }) } diff --git a/front/src/modules/companies/table/components/TableActionBarButtonDeleteCompanies.tsx b/front/src/modules/companies/table/components/TableActionBarButtonDeleteCompanies.tsx index 2db94aa1c..1f65b6369 100644 --- a/front/src/modules/companies/table/components/TableActionBarButtonDeleteCompanies.tsx +++ b/front/src/modules/companies/table/components/TableActionBarButtonDeleteCompanies.tsx @@ -6,14 +6,14 @@ import { IconTrash } from '@/ui/icon/index'; import { EntityTableActionBarButton } from '@/ui/table/action-bar/components/EntityTableActionBarButton'; import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection'; import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector'; -import { useDeleteCompaniesMutation } from '~/generated/graphql'; +import { useDeleteManyCompaniesMutation } from '~/generated/graphql'; export function TableActionBarButtonDeleteCompanies() { const selectedRowIds = useRecoilValue(selectedRowIdsSelector); const resetRowSelection = useResetTableRowSelection(); - const [deleteCompanies] = useDeleteCompaniesMutation({ + const [deleteCompanies] = useDeleteManyCompaniesMutation({ refetchQueries: [getOperationName(GET_COMPANIES) ?? ''], }); diff --git a/front/src/modules/companies/types/CompanyProgress.ts b/front/src/modules/companies/types/CompanyProgress.ts index e6c9e0cfe..4ae44321a 100644 --- a/front/src/modules/companies/types/CompanyProgress.ts +++ b/front/src/modules/companies/types/CompanyProgress.ts @@ -10,7 +10,7 @@ export type PipelineProgressForBoard = Pick< | 'probability' | 'pointOfContactId' > & { - pointOfContact?: Pick | null; + pointOfContact?: Pick | null; }; export type CompanyProgress = { diff --git a/front/src/modules/people/components/EditablePeopleFullName.tsx b/front/src/modules/people/components/EditablePeopleFullName.tsx index 355070146..5326867b1 100644 --- a/front/src/modules/people/components/EditablePeopleFullName.tsx +++ b/front/src/modules/people/components/EditablePeopleFullName.tsx @@ -8,7 +8,14 @@ import { PersonChip } from './PersonChip'; type OwnProps = { person: | Partial< - Pick + Pick< + Person, + | 'id' + | 'firstName' + | 'lastName' + | 'displayName' + | '_commentThreadCount' + > > | null | undefined; @@ -49,7 +56,7 @@ export function EditablePeopleFullName({ nonEditModeContent={ diff --git a/front/src/modules/people/components/PeopleCompanyCreateCell.tsx b/front/src/modules/people/components/PeopleCompanyCreateCell.tsx index 2def7f237..62cd31419 100644 --- a/front/src/modules/people/components/PeopleCompanyCreateCell.tsx +++ b/front/src/modules/people/components/PeopleCompanyCreateCell.tsx @@ -9,8 +9,8 @@ import { isCreateModeScopedState } from '@/ui/table/editable-cell/states/isCreat import { EditableCellDoubleTextEditMode } from '@/ui/table/editable-cell/types/EditableCellDoubleTextEditMode'; import { Person, - useInsertCompanyMutation, - useUpdatePeopleMutation, + useInsertOneCompanyMutation, + useUpdateOnePersonMutation, } from '~/generated/graphql'; import { logError } from '~/utils/logError'; @@ -30,8 +30,8 @@ export function PeopleCompanyCreateCell({ people }: OwnProps) { const [companyName, setCompanyName] = useState(currentSearchFilter); const [companyDomainName, setCompanyDomainName] = useState(''); - const [insertCompany] = useInsertCompanyMutation(); - const [updatePeople] = useUpdatePeopleMutation(); + const [insertCompany] = useInsertOneCompanyMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); function handleDoubleTextChange(leftValue: string, rightValue: string): void { setCompanyDomainName(leftValue); @@ -47,11 +47,12 @@ export function PeopleCompanyCreateCell({ people }: OwnProps) { try { await insertCompany({ variables: { - id: newCompanyId, - name: companyName, - domainName: companyDomainName, - address: '', - createdAt: new Date().toISOString(), + data: { + id: newCompanyId, + name: companyName, + domainName: companyDomainName, + address: '', + }, }, refetchQueries: [ getOperationName(GET_COMPANIES) ?? '', @@ -59,10 +60,14 @@ export function PeopleCompanyCreateCell({ people }: OwnProps) { ], }); - await updatePeople({ + await updatePerson({ variables: { - ...people, - companyId: newCompanyId, + where: { + id: people.id, + }, + data: { + company: { connect: { id: newCompanyId } }, + }, }, }); } catch (error) { diff --git a/front/src/modules/people/components/PeopleCompanyPicker.tsx b/front/src/modules/people/components/PeopleCompanyPicker.tsx index 3c6a12f52..f52451c96 100644 --- a/front/src/modules/people/components/PeopleCompanyPicker.tsx +++ b/front/src/modules/people/components/PeopleCompanyPicker.tsx @@ -10,7 +10,11 @@ import { RelationPickerHotkeyScope } from '@/ui/relation-picker/types/RelationPi import { useEditableCell } from '@/ui/table/editable-cell/hooks/useEditableCell'; import { isCreateModeScopedState } from '@/ui/table/editable-cell/states/isCreateModeScopedState'; import { TableHotkeyScope } from '@/ui/table/types/TableHotkeyScope'; -import { Company, Person, useUpdatePeopleMutation } from '~/generated/graphql'; +import { + Company, + Person, + useUpdateOnePersonMutation, +} from '~/generated/graphql'; export type OwnProps = { people: Pick & { company?: Pick | null }; @@ -22,7 +26,7 @@ export function PeopleCompanyPicker({ people }: OwnProps) { const [searchFilter] = useRecoilScopedState( relationPickerSearchFilterScopedState, ); - const [updatePeople] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); const { closeEditableCell } = useEditableCell(); @@ -34,10 +38,14 @@ export function PeopleCompanyPicker({ people }: OwnProps) { }); async function handleEntitySelected(entity: any) { - await updatePeople({ + await updatePerson({ variables: { - ...people, - companyId: entity.id, + where: { + id: people.id, + }, + data: { + company: { connect: { id: entity.id } }, + }, }, }); diff --git a/front/src/modules/people/components/PersonPropertyBox.tsx b/front/src/modules/people/components/PersonPropertyBox.tsx index c2c6cc113..841758b38 100644 --- a/front/src/modules/people/components/PersonPropertyBox.tsx +++ b/front/src/modules/people/components/PersonPropertyBox.tsx @@ -9,7 +9,11 @@ import { PropertyBox } from '@/ui/editable-field/property-box/components/Propert import { DateEditableField } from '@/ui/editable-field/variants/components/DateEditableField'; import { PhoneEditableField } from '@/ui/editable-field/variants/components/PhoneEditableField'; import { TextEditableField } from '@/ui/editable-field/variants/components/TextEditableField'; -import { Company, Person, useUpdatePeopleMutation } from '~/generated/graphql'; +import { + Company, + Person, + useUpdateOnePersonMutation, +} from '~/generated/graphql'; import { PeopleCompanyEditableField } from '../editable-field/components/PeopleCompanyEditableField'; @@ -23,7 +27,7 @@ type OwnProps = { }; export function PersonPropertyBox({ person }: OwnProps) { - const [updatePerson] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); return ( @@ -34,8 +38,12 @@ export function PersonPropertyBox({ person }: OwnProps) { onSubmit={(newEmail) => { updatePerson({ variables: { - id: person.id, - email: newEmail, + where: { + id: person.id, + }, + data: { + email: newEmail, + }, }, }); }} @@ -47,8 +55,12 @@ export function PersonPropertyBox({ person }: OwnProps) { onSubmit={(newPhone) => { updatePerson({ variables: { - id: person.id, - phone: newPhone, + where: { + id: person.id, + }, + data: { + phone: newPhone, + }, }, }); }} @@ -59,8 +71,12 @@ export function PersonPropertyBox({ person }: OwnProps) { onSubmit={(newDate) => { updatePerson({ variables: { - id: person.id, - createdAt: newDate, + where: { + id: person.id, + }, + data: { + createdAt: newDate, + }, }, }); }} @@ -73,8 +89,12 @@ export function PersonPropertyBox({ person }: OwnProps) { onSubmit={(newCity) => { updatePerson({ variables: { - id: person.id, - city: newCity, + where: { + id: person.id, + }, + data: { + city: newCity, + }, }, }); }} diff --git a/front/src/modules/people/editable-field/components/PeopleCompanyEditableFieldEditMode.tsx b/front/src/modules/people/editable-field/components/PeopleCompanyEditableFieldEditMode.tsx index 605d520f4..97fb219c6 100644 --- a/front/src/modules/people/editable-field/components/PeopleCompanyEditableFieldEditMode.tsx +++ b/front/src/modules/people/editable-field/components/PeopleCompanyEditableFieldEditMode.tsx @@ -4,7 +4,11 @@ import { useRecoilScopedState } from '@/ui/recoil-scope/hooks/useRecoilScopedSta import { SingleEntitySelect } from '@/ui/relation-picker/components/SingleEntitySelect'; import { relationPickerSearchFilterScopedState } from '@/ui/relation-picker/states/relationPickerSearchFilterScopedState'; import { EntityForSelect } from '@/ui/relation-picker/types/EntityForSelect'; -import { Company, Person, useUpdatePeopleMutation } from '~/generated/graphql'; +import { + Company, + Person, + useUpdateOnePersonMutation, +} from '~/generated/graphql'; export type OwnProps = { people: Pick & { company?: Pick | null }; @@ -16,7 +20,7 @@ export function PeopleCompanyEditableFieldEditMode({ people }: OwnProps) { const [searchFilter] = useRecoilScopedState( relationPickerSearchFilterScopedState, ); - const [updatePeople] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); const companies = useFilteredSearchCompanyQuery({ searchFilter, @@ -24,10 +28,14 @@ export function PeopleCompanyEditableFieldEditMode({ people }: OwnProps) { }); async function handleEntitySelected(entity: EntityForSelect) { - await updatePeople({ + await updatePerson({ variables: { - ...people, - companyId: entity.id, + where: { + id: people.id, + }, + data: { + company: { connect: { id: entity.id } }, + }, }, }); closeEditableField(); diff --git a/front/src/modules/people/hooks/useSetPeopleEntityTable.ts b/front/src/modules/people/hooks/useSetPeopleEntityTable.ts index d2de8bed9..e13652349 100644 --- a/front/src/modules/people/hooks/useSetPeopleEntityTable.ts +++ b/front/src/modules/people/hooks/useSetPeopleEntityTable.ts @@ -19,7 +19,7 @@ export function useSetPeopleEntityTable() { .valueOrThrow(); if (currentEmail !== person.email) { - set(peopleEmailFamilyState(person.id), person.email); + set(peopleEmailFamilyState(person.id), person.email ?? null); } const currentCity = snapshot @@ -27,7 +27,7 @@ export function useSetPeopleEntityTable() { .valueOrThrow(); if (currentCity !== person.city) { - set(peopleCityFamilyState(person.id), person.city); + set(peopleCityFamilyState(person.id), person.city ?? null); } const currentCompany = snapshot @@ -45,7 +45,7 @@ export function useSetPeopleEntityTable() { .valueOrThrow(); if (currentPhone !== person.phone) { - set(peoplePhoneFamilyState(person.id), person.phone); + set(peoplePhoneFamilyState(person.id), person.phone ?? null); } const currentCreatedAt = snapshot @@ -66,9 +66,10 @@ export function useSetPeopleEntityTable() { currentNameCell.commentCount !== person._commentThreadCount ) { set(peopleNameCellFamilyState(person.id), { - firstName: person.firstName, - lastName: person.lastName, + firstName: person.firstName ?? null, + lastName: person.lastName ?? null, commentCount: person._commentThreadCount, + displayName: person.displayName ?? null, }); } } diff --git a/front/src/modules/people/queries/__tests__/select.test.ts b/front/src/modules/people/queries/__tests__/select.test.ts index 177fd819a..ab4885bac 100644 --- a/front/src/modules/people/queries/__tests__/select.test.ts +++ b/front/src/modules/people/queries/__tests__/select.test.ts @@ -9,13 +9,11 @@ describe('reduceSortsToOrderBy', () => { key: 'firstName', label: 'firstName', order: 'asc', - _type: 'default_sort', }, { key: 'lastName', label: 'lastName', order: 'desc', - _type: 'default_sort', }, ] satisfies PeopleSelectedSortType[]; const result = reduceSortsToOrderBy(sorts); diff --git a/front/src/modules/people/queries/select.ts b/front/src/modules/people/queries/select.ts index 8c1ffe59d..50f2a5651 100644 --- a/front/src/modules/people/queries/select.ts +++ b/front/src/modules/people/queries/select.ts @@ -27,6 +27,7 @@ export const GET_PEOPLE = gql` city firstName lastName + displayName createdAt _commentThreadCount company { @@ -103,6 +104,7 @@ export const GET_PERSON_NAMES_AND_COMMENT_COUNT = gql` id firstName lastName + displayName _commentThreadCount } } diff --git a/front/src/modules/people/queries/update.ts b/front/src/modules/people/queries/update.ts index 1e4b15c88..d108cd9ce 100644 --- a/front/src/modules/people/queries/update.ts +++ b/front/src/modules/people/queries/update.ts @@ -1,29 +1,11 @@ import { gql } from '@apollo/client'; -export const UPDATE_PERSON = gql` - mutation UpdatePeople( - $id: String - $firstName: String - $lastName: String - $phone: String - $city: String - $companyId: String - $email: String - $createdAt: DateTime +export const UPDATE_ONE_PERSON = gql` + mutation UpdateOnePerson( + $where: PersonWhereUniqueInput! + $data: PersonUpdateInput! ) { - updateOnePerson( - where: { id: $id } - data: { - city: { set: $city } - company: { connect: { id: $companyId } } - email: { set: $email } - firstName: { set: $firstName } - id: { set: $id } - lastName: { set: $lastName } - phone: { set: $phone } - createdAt: { set: $createdAt } - } - ) { + updateOnePerson(data: $data, where: $where) { id city company { @@ -34,33 +16,16 @@ export const UPDATE_PERSON = gql` email firstName lastName + displayName phone createdAt } } `; -export const INSERT_PERSON = gql` - mutation InsertPerson( - $id: String! - $firstName: String! - $lastName: String! - $phone: String! - $city: String! - $email: String! - $createdAt: DateTime - ) { - createOnePerson( - data: { - id: $id - firstName: $firstName - lastName: $lastName - phone: $phone - city: $city - email: $email - createdAt: $createdAt - } - ) { +export const INSERT_ONE_PERSON = gql` + mutation InsertOnePerson($data: PersonCreateInput!) { + createOnePerson(data: $data) { id city company { @@ -71,14 +36,15 @@ export const INSERT_PERSON = gql` email firstName lastName + displayName phone createdAt } } `; -export const DELETE_PEOPLE = gql` - mutation DeletePeople($ids: [String!]) { +export const DELETE_MANY_PERSON = gql` + mutation DeleteManyPerson($ids: [String!]) { deleteManyPerson(where: { id: { in: $ids } }) { count } diff --git a/front/src/modules/people/states/peopleNamesFamilyState.ts b/front/src/modules/people/states/peopleNamesFamilyState.ts index 03254fd5f..bd213efd8 100644 --- a/front/src/modules/people/states/peopleNamesFamilyState.ts +++ b/front/src/modules/people/states/peopleNamesFamilyState.ts @@ -5,6 +5,7 @@ export const peopleNameCellFamilyState = atomFamily< firstName: string | null; lastName: string | null; commentCount: number | null; + displayName: string | null; }, string >({ @@ -13,5 +14,6 @@ export const peopleNameCellFamilyState = atomFamily< firstName: null, lastName: null, commentCount: null, + displayName: null, }, }); diff --git a/front/src/modules/people/table/components/EditablePeopleCityCell.tsx b/front/src/modules/people/table/components/EditablePeopleCityCell.tsx index c9477d64d..ea81ff170 100644 --- a/front/src/modules/people/table/components/EditablePeopleCityCell.tsx +++ b/front/src/modules/people/table/components/EditablePeopleCityCell.tsx @@ -4,12 +4,12 @@ import { useRecoilValue } from 'recoil'; import { peopleCityFamilyState } from '@/people/states/peopleCityFamilyState'; import { EditableCellText } from '@/ui/table/editable-cell/types/EditableCellText'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdatePeopleMutation } from '~/generated/graphql'; +import { useUpdateOnePersonMutation } from '~/generated/graphql'; export function EditablePeopleCityCell() { const currentRowEntityId = useCurrentRowEntityId(); - const [updatePerson] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); const city = useRecoilValue(peopleCityFamilyState(currentRowEntityId ?? '')); @@ -26,8 +26,12 @@ export function EditablePeopleCityCell() { onSubmit={() => updatePerson({ variables: { - id: currentRowEntityId, - city: internalValue, + where: { + id: currentRowEntityId, + }, + data: { + city: internalValue, + }, }, }) } diff --git a/front/src/modules/people/table/components/EditablePeopleCreatedAtCell.tsx b/front/src/modules/people/table/components/EditablePeopleCreatedAtCell.tsx index ba74af137..f7b5fe6f8 100644 --- a/front/src/modules/people/table/components/EditablePeopleCreatedAtCell.tsx +++ b/front/src/modules/people/table/components/EditablePeopleCreatedAtCell.tsx @@ -4,7 +4,7 @@ import { useRecoilValue } from 'recoil'; import { peopleCreatedAtFamilyState } from '@/people/states/peopleCreatedAtFamilyState'; import { EditableCellDate } from '@/ui/table/editable-cell/types/EditableCellDate'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdatePeopleMutation } from '~/generated/graphql'; +import { useUpdateOnePersonMutation } from '~/generated/graphql'; export function EditablePeopleCreatedAtCell() { const currentRowEntityId = useCurrentRowEntityId(); @@ -13,7 +13,7 @@ export function EditablePeopleCreatedAtCell() { peopleCreatedAtFamilyState(currentRowEntityId ?? ''), ); - const [updatePerson] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); return ( updatePerson({ variables: { - id: currentRowEntityId, - email: internalValue, + where: { + id: currentRowEntityId, + }, + data: { + email: internalValue, + }, }, }) } diff --git a/front/src/modules/people/table/components/EditablePeopleFullNameCell.tsx b/front/src/modules/people/table/components/EditablePeopleFullNameCell.tsx index 939c4d1af..2ef4280d4 100644 --- a/front/src/modules/people/table/components/EditablePeopleFullNameCell.tsx +++ b/front/src/modules/people/table/components/EditablePeopleFullNameCell.tsx @@ -5,16 +5,16 @@ import { useRecoilValue } from 'recoil'; import { EditablePeopleFullName } from '@/people/components/EditablePeopleFullName'; import { peopleNameCellFamilyState } from '@/people/states/peopleNamesFamilyState'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdatePeopleMutation } from '~/generated/graphql'; +import { useUpdateOnePersonMutation } from '~/generated/graphql'; import { GET_PERSON } from '../../queries'; export function EditablePeopleFullNameCell() { const currentRowEntityId = useCurrentRowEntityId(); - const [updatePerson] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); - const { commentCount, firstName, lastName } = useRecoilValue( + const { commentCount, firstName, lastName, displayName } = useRecoilValue( peopleNameCellFamilyState(currentRowEntityId ?? ''), ); @@ -33,6 +33,7 @@ export function EditablePeopleFullNameCell() { _commentThreadCount: commentCount ?? undefined, firstName: internalFirstName, lastName: internalLastName, + displayName: displayName ?? undefined, }} onChange={(firstName, lastName) => { setInternalFirstName(firstName); @@ -41,9 +42,13 @@ export function EditablePeopleFullNameCell() { onSubmit={() => updatePerson({ variables: { - id: currentRowEntityId, - firstName: internalFirstName, - lastName: internalLastName, + where: { + id: currentRowEntityId, + }, + data: { + firstName: internalFirstName, + lastName: internalLastName, + }, }, refetchQueries: [getOperationName(GET_PERSON) ?? ''], }) diff --git a/front/src/modules/people/table/components/EditablePeoplePhoneCell.tsx b/front/src/modules/people/table/components/EditablePeoplePhoneCell.tsx index 38dc2c551..a5dea6dbe 100644 --- a/front/src/modules/people/table/components/EditablePeoplePhoneCell.tsx +++ b/front/src/modules/people/table/components/EditablePeoplePhoneCell.tsx @@ -4,12 +4,12 @@ import { useRecoilValue } from 'recoil'; import { peoplePhoneFamilyState } from '@/people/states/peoplePhoneFamilyState'; import { EditableCellPhone } from '@/ui/table/editable-cell/types/EditableCellPhone'; import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId'; -import { useUpdatePeopleMutation } from '~/generated/graphql'; +import { useUpdateOnePersonMutation } from '~/generated/graphql'; export function EditablePeoplePhoneCell() { const currentRowEntityId = useCurrentRowEntityId(); - const [updatePerson] = useUpdatePeopleMutation(); + const [updatePerson] = useUpdateOnePersonMutation(); const phone = useRecoilValue( peoplePhoneFamilyState(currentRowEntityId ?? ''), @@ -28,8 +28,12 @@ export function EditablePeoplePhoneCell() { onSubmit={() => updatePerson({ variables: { - id: currentRowEntityId, - phone: internalValue, + where: { + id: currentRowEntityId, + }, + data: { + phone: internalValue, + }, }, }) } diff --git a/front/src/modules/people/table/components/TableActionBarButtonDeletePeople.tsx b/front/src/modules/people/table/components/TableActionBarButtonDeletePeople.tsx index 1475e39a2..f431e96ad 100644 --- a/front/src/modules/people/table/components/TableActionBarButtonDeletePeople.tsx +++ b/front/src/modules/people/table/components/TableActionBarButtonDeletePeople.tsx @@ -6,14 +6,14 @@ import { IconTrash } from '@/ui/icon/index'; import { EntityTableActionBarButton } from '@/ui/table/action-bar/components/EntityTableActionBarButton'; import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection'; import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector'; -import { useDeletePeopleMutation } from '~/generated/graphql'; +import { useDeleteManyPersonMutation } from '~/generated/graphql'; export function TableActionBarButtonDeletePeople() { const selectedRowIds = useRecoilValue(selectedRowIdsSelector); const resetRowSelection = useResetTableRowSelection(); - const [deletePeople] = useDeletePeopleMutation({ + const [deleteManyPerson] = useDeleteManyPersonMutation({ refetchQueries: [getOperationName(GET_PEOPLE) ?? ''], }); @@ -22,7 +22,7 @@ export function TableActionBarButtonDeletePeople() { resetRowSelection(); - await deletePeople({ + await deleteManyPerson({ variables: { ids: rowIdsToDelete, }, diff --git a/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactEditableField.tsx b/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactEditableField.tsx index 1867aaf74..2d43fff5d 100644 --- a/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactEditableField.tsx +++ b/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactEditableField.tsx @@ -10,7 +10,7 @@ import { PipelineProgressPointOfContactPickerFieldEditMode } from './PipelinePro type OwnProps = { pipelineProgress: Pick & { - pointOfContact?: Pick | null; + pointOfContact?: Pick | null; }; }; @@ -34,10 +34,7 @@ export function PipelineProgressPointOfContactEditableField({ pipelineProgress.pointOfContact ? ( ) : ( <> diff --git a/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactPickerFieldEditMode.tsx b/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactPickerFieldEditMode.tsx index f04078942..03a3ff16b 100644 --- a/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactPickerFieldEditMode.tsx +++ b/front/src/modules/pipeline/editable-field/components/PipelineProgressPointOfContactPickerFieldEditMode.tsx @@ -12,7 +12,10 @@ const PipelineProgressPointOfContactPickerContainer = styled.div` export type OwnProps = { pipelineProgress: Pick & { - pointOfContact?: Pick | null; + pointOfContact?: Pick< + Person, + 'id' | 'firstName' | 'lastName' | 'displayName' + > | null; }; onSubmit?: () => void; onCancel?: () => void; diff --git a/front/src/modules/pipeline/queries/select.ts b/front/src/modules/pipeline/queries/select.ts index 3d7fc8744..b91512224 100644 --- a/front/src/modules/pipeline/queries/select.ts +++ b/front/src/modules/pipeline/queries/select.ts @@ -42,6 +42,7 @@ export const GET_PIPELINE_PROGRESS = gql` id firstName lastName + displayName } probability } @@ -59,9 +60,9 @@ export const UPDATE_PIPELINE_PROGRESS = gql` updateOnePipelineProgress( where: { id: $id } data: { - amount: { set: $amount } - closeDate: { set: $closeDate } - probability: { set: $probability } + amount: $amount + closeDate: $closeDate + probability: $probability pointOfContact: { connect: { id: $pointOfContactId } } } ) { diff --git a/front/src/modules/pipeline/queries/update.ts b/front/src/modules/pipeline/queries/update.ts index 2b135df12..1ca23d2e3 100644 --- a/front/src/modules/pipeline/queries/update.ts +++ b/front/src/modules/pipeline/queries/update.ts @@ -10,7 +10,7 @@ export const DELETE_PIPELINE_PROGRESS = gql` export const UPDATE_PIPELINE_STAGE = gql` mutation UpdatePipelineStage($id: String, $name: String) { - updateOnePipelineStage(where: { id: $id }, data: { name: { set: $name } }) { + updateOnePipelineStage(where: { id: $id }, data: { name: $name }) { id name } diff --git a/front/src/modules/settings/profile/components/NameFields.tsx b/front/src/modules/settings/profile/components/NameFields.tsx index d72fd1fe9..0269b2ff3 100644 --- a/front/src/modules/settings/profile/components/NameFields.tsx +++ b/front/src/modules/settings/profile/components/NameFields.tsx @@ -51,12 +51,8 @@ export function NameFields({ id: currentUser?.id, }, data: { - firstName: { - set: firstName, - }, - lastName: { - set: lastName, - }, + firstName, + lastName, }, }, refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''], diff --git a/front/src/modules/settings/workspace/components/NameField.tsx b/front/src/modules/settings/workspace/components/NameField.tsx index f56a0b1b8..6120bf5bf 100644 --- a/front/src/modules/settings/workspace/components/NameField.tsx +++ b/front/src/modules/settings/workspace/components/NameField.tsx @@ -44,9 +44,7 @@ export function NameField({ autoSave = true, onNameUpdate }: OwnProps) { const { data, errors } = await updateWorkspace({ variables: { data: { - displayName: { - set: name, - }, + displayName: name, }, }, refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''], diff --git a/front/src/modules/ui/editable-field/components/EditableFieldEntityText.tsx b/front/src/modules/ui/editable-field/components/EditableFieldEntityText.tsx index 079ff3a52..e8b3b1c26 100644 --- a/front/src/modules/ui/editable-field/components/EditableFieldEntityText.tsx +++ b/front/src/modules/ui/editable-field/components/EditableFieldEntityText.tsx @@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext'; import { IconMap } from '@/ui/icon'; import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText'; import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; -import { Company, useUpdateCompanyMutation } from '~/generated/graphql'; +import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql'; type OwnProps = { company: Pick; @@ -14,7 +14,7 @@ type OwnProps = { export function CompanyEditableFieldAddress({ company }: OwnProps) { const [internalValue, setInternalValue] = useState(company.address); - const [updateCompany] = useUpdateCompanyMutation(); + const [updateCompany] = useUpdateOneCompanyMutation(); useEffect(() => { setInternalValue(company.address); @@ -27,8 +27,12 @@ export function CompanyEditableFieldAddress({ company }: OwnProps) { async function handleSubmit() { await updateCompany({ variables: { - id: company.id, - address: internalValue ?? '', + where: { + id: company.id, + }, + data: { + address: internalValue ?? '', + }, }, }); } diff --git a/front/src/modules/ui/themes/hooks/useColorScheme.ts b/front/src/modules/ui/themes/hooks/useColorScheme.ts index cf79374c2..e23d359ed 100644 --- a/front/src/modules/ui/themes/hooks/useColorScheme.ts +++ b/front/src/modules/ui/themes/hooks/useColorScheme.ts @@ -29,9 +29,7 @@ export function useColorScheme() { data: { settings: { update: { - colorScheme: { - set: value, - }, + colorScheme: value, }, }, }, diff --git a/front/src/modules/users/queries/update.ts b/front/src/modules/users/queries/update.ts index 0d11b1338..9d3a56ed3 100644 --- a/front/src/modules/users/queries/update.ts +++ b/front/src/modules/users/queries/update.ts @@ -36,7 +36,7 @@ export const UPDATE_PROFILE_PICTURE = gql` export const REMOVE_PROFILE_PICTURE = gql` mutation RemoveProfilePicture($where: UserWhereUniqueInput!) { - updateUser(data: { avatarUrl: { set: null } }, where: $where) { + updateUser(data: { avatarUrl: null }, where: $where) { id avatarUrl } diff --git a/front/src/modules/workspace/components/WorkspaceMemberCard.tsx b/front/src/modules/workspace/components/WorkspaceMemberCard.tsx index b5ca0a4ec..51a29363c 100644 --- a/front/src/modules/workspace/components/WorkspaceMemberCard.tsx +++ b/front/src/modules/workspace/components/WorkspaceMemberCard.tsx @@ -1,7 +1,6 @@ import styled from '@emotion/styled'; import { Avatar } from '@/users/components/Avatar'; -import { getImageAbsoluteURIOrBase64 } from '@/users/utils/getProfilePictureAbsoluteURI'; import { User } from '~/generated/graphql'; const StyledContainer = styled.div` @@ -33,7 +32,10 @@ const EmailText = styled.span` type OwnProps = { workspaceMember: { - user: Pick; + user: Pick< + User, + 'id' | 'firstName' | 'lastName' | 'displayName' | 'avatarUrl' | 'email' + >; }; accessory?: React.ReactNode; }; @@ -42,16 +44,14 @@ export function WorkspaceMemberCard({ workspaceMember, accessory }: OwnProps) { return ( - - {workspaceMember.user.firstName} {workspaceMember.user.lastName}{' '} - + {workspaceMember.user.displayName} {workspaceMember.user.email} diff --git a/front/src/modules/workspace/queries/select.ts b/front/src/modules/workspace/queries/select.ts index d0ed31436..5a670d7c5 100644 --- a/front/src/modules/workspace/queries/select.ts +++ b/front/src/modules/workspace/queries/select.ts @@ -10,6 +10,7 @@ export const GET_WORKSPACE_MEMBERS = gql` avatarUrl firstName lastName + displayName } } } diff --git a/front/src/modules/workspace/queries/update.ts b/front/src/modules/workspace/queries/update.ts index ca11c29d5..91b824ff7 100644 --- a/front/src/modules/workspace/queries/update.ts +++ b/front/src/modules/workspace/queries/update.ts @@ -19,7 +19,7 @@ export const UPDATE_WORKSPACE_LOGO = gql` export const REMOVE_WORKSPACE_LOGO = gql` mutation RemoveWorkspaceLogo { - updateWorkspace(data: { logo: { set: null } }) { + updateWorkspace(data: { logo: null }) { id } } diff --git a/front/src/pages/auth/CreateProfile.tsx b/front/src/pages/auth/CreateProfile.tsx index ba52fdb9c..410e45c36 100644 --- a/front/src/pages/auth/CreateProfile.tsx +++ b/front/src/pages/auth/CreateProfile.tsx @@ -98,12 +98,8 @@ export function CreateProfile() { id: currentUser?.id, }, data: { - firstName: { - set: data.firstName, - }, - lastName: { - set: data.lastName, - }, + firstName: data.firstName, + lastName: data.lastName, }, }, refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''], diff --git a/front/src/pages/auth/CreateWorkspace.tsx b/front/src/pages/auth/CreateWorkspace.tsx index 068991f4a..dd9003949 100644 --- a/front/src/pages/auth/CreateWorkspace.tsx +++ b/front/src/pages/auth/CreateWorkspace.tsx @@ -73,9 +73,7 @@ export function CreateWorkspace() { const result = await updateWorkspace({ variables: { data: { - displayName: { - set: data.name, - }, + displayName: data.name, }, }, refetchQueries: [getOperationName(GET_CURRENT_USER) ?? ''], diff --git a/front/src/pages/companies/Companies.tsx b/front/src/pages/companies/Companies.tsx index 8599ae7d6..cde2c8541 100644 --- a/front/src/pages/companies/Companies.tsx +++ b/front/src/pages/companies/Companies.tsx @@ -1,7 +1,6 @@ import { getOperationName } from '@apollo/client/utilities'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { v4 as uuidv4 } from 'uuid'; import { GET_COMPANIES } from '@/companies/queries'; import { CompanyTable } from '@/companies/table/components/CompanyTable'; @@ -12,10 +11,7 @@ import { WithTopBarContainer } from '@/ui/layout/components/WithTopBarContainer' import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; import { EntityTableActionBar } from '@/ui/table/action-bar/components/EntityTableActionBar'; import { TableContext } from '@/ui/table/states/TableContext'; -import { - InsertCompanyMutationVariables, - useInsertCompanyMutation, -} from '~/generated/graphql'; +import { useInsertOneCompanyMutation } from '~/generated/graphql'; import { SEARCH_COMPANY_QUERY } from '../../modules/search/queries/search'; @@ -25,20 +21,17 @@ const StyledTableContainer = styled.div` `; export function Companies() { - const [insertCompany] = useInsertCompanyMutation(); + const [insertCompany] = useInsertOneCompanyMutation(); async function handleAddButtonClick() { - const newCompany: InsertCompanyMutationVariables = { - id: uuidv4(), - name: '', - domainName: '', - employees: null, - address: '', - createdAt: new Date().toISOString(), - }; - await insertCompany({ - variables: newCompany, + variables: { + data: { + name: '', + domainName: '', + address: '', + }, + }, refetchQueries: [ getOperationName(GET_COMPANIES) ?? '', getOperationName(SEARCH_COMPANY_QUERY) ?? '', diff --git a/front/src/pages/people/People.tsx b/front/src/pages/people/People.tsx index 95ecc3bb0..9767ac9bf 100644 --- a/front/src/pages/people/People.tsx +++ b/front/src/pages/people/People.tsx @@ -1,7 +1,6 @@ import { getOperationName } from '@apollo/client/utilities'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { v4 as uuidv4 } from 'uuid'; import { GET_PEOPLE } from '@/people/queries'; import { PeopleTable } from '@/people/table/components/PeopleTable'; @@ -12,7 +11,7 @@ import { WithTopBarContainer } from '@/ui/layout/components/WithTopBarContainer' import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope'; import { EntityTableActionBar } from '@/ui/table/action-bar/components/EntityTableActionBar'; import { TableContext } from '@/ui/table/states/TableContext'; -import { useInsertPersonMutation } from '~/generated/graphql'; +import { useInsertOnePersonMutation } from '~/generated/graphql'; const StyledTableContainer = styled.div` display: flex; @@ -20,18 +19,12 @@ const StyledTableContainer = styled.div` `; export function People() { - const [insertPersonMutation] = useInsertPersonMutation(); + const [insertOnePerson] = useInsertOnePersonMutation(); async function handleAddButtonClick() { - await insertPersonMutation({ + await insertOnePerson({ variables: { - id: uuidv4(), - firstName: '', - lastName: '', - email: '', - phone: '', - createdAt: new Date().toISOString(), - city: '', + data: {}, }, refetchQueries: [getOperationName(GET_PEOPLE) ?? ''], }); diff --git a/front/src/pages/people/__stories__/People.inputs.stories.tsx b/front/src/pages/people/__stories__/People.inputs.stories.tsx index b0e5f6f24..1b0cbe7b9 100644 --- a/front/src/pages/people/__stories__/People.inputs.stories.tsx +++ b/front/src/pages/people/__stories__/People.inputs.stories.tsx @@ -4,7 +4,7 @@ import type { Meta } from '@storybook/react'; import { userEvent, within } from '@storybook/testing-library'; import { graphql } from 'msw'; -import { UPDATE_PERSON } from '@/people/queries'; +import { UPDATE_ONE_PERSON } from '@/people/queries'; import { SEARCH_COMPANY_QUERY } from '@/search/queries/search'; import { Company } from '~/generated/graphql'; import { graphqlMocks } from '~/testing/graphqlMocks'; @@ -113,7 +113,7 @@ const editRelationMocks = ( if ( typeof graphqlMock.info.operationName === 'string' && [ - getOperationName(UPDATE_PERSON), + getOperationName(UPDATE_ONE_PERSON), getOperationName(SEARCH_COMPANY_QUERY), ].includes(graphqlMock.info.operationName) ) { @@ -122,23 +122,26 @@ const editRelationMocks = ( return true; }), ...[ - graphql.mutation(getOperationName(UPDATE_PERSON) ?? '', (req, res, ctx) => { - return res( - ctx.data({ - updateOnePerson: { - ...fetchOneFromData(mockedPeopleData, req.variables.id), - ...{ - company: { - id: req.variables.companyId, - name: updateSelectedCompany.name, - domainName: updateSelectedCompany.domainName, - __typename: 'Company', + graphql.mutation( + getOperationName(UPDATE_ONE_PERSON) ?? '', + (req, res, ctx) => { + return res( + ctx.data({ + updateOnePerson: { + ...fetchOneFromData(mockedPeopleData, req.variables.where.id), + ...{ + company: { + id: req.variables.where.id, + name: updateSelectedCompany.name, + domainName: updateSelectedCompany.domainName, + __typename: 'Company', + }, }, }, - }, - }), - ); - }), + }), + ); + }, + ), graphql.query( getOperationName(SEARCH_COMPANY_QUERY) ?? '', (req, res, ctx) => { diff --git a/front/src/testing/graphqlMocks.ts b/front/src/testing/graphqlMocks.ts index 15cc3110d..af96ae45f 100644 --- a/front/src/testing/graphqlMocks.ts +++ b/front/src/testing/graphqlMocks.ts @@ -4,7 +4,7 @@ import { graphql } from 'msw'; import { CREATE_EVENT } from '@/analytics/queries'; import { GET_CLIENT_CONFIG } from '@/client-config/queries'; import { GET_COMPANIES } from '@/companies/queries'; -import { GET_PEOPLE, GET_PERSON, UPDATE_PERSON } from '@/people/queries'; +import { GET_PEOPLE, GET_PERSON, UPDATE_ONE_PERSON } from '@/people/queries'; import { GET_PIPELINE_PROGRESS, GET_PIPELINES } from '@/pipeline/queries'; import { SEARCH_COMPANY_QUERY, @@ -134,17 +134,20 @@ export const graphqlMocks = [ }), ); }), - graphql.mutation(getOperationName(UPDATE_PERSON) ?? '', (req, res, ctx) => { - return res( - ctx.data({ - updateOnePerson: updateOneFromData( - mockedPeopleData, - req.variables.id, - req.variables, - ), - }), - ); - }), + graphql.mutation( + getOperationName(UPDATE_ONE_PERSON) ?? '', + (req, res, ctx) => { + return res( + ctx.data({ + updateOnePerson: updateOneFromData( + mockedPeopleData, + req.variables.where.id, + req.variables, + ), + }), + ); + }, + ), graphql.query(getOperationName(GET_PIPELINES) ?? '', (req, res, ctx) => { return res( ctx.data({ diff --git a/front/src/testing/mock-data/comment-threads.ts b/front/src/testing/mock-data/comment-threads.ts index 9c44a2d5a..b523d7d44 100644 --- a/front/src/testing/mock-data/comment-threads.ts +++ b/front/src/testing/mock-data/comment-threads.ts @@ -22,6 +22,7 @@ type MockedCommentThread = Pick< id: string; firstName: string; lastName: string; + displayName: string; }; comments: Array>; commentThreadTargets: Array< @@ -50,6 +51,7 @@ export const mockedCommentThreads: Array = [ id: '374fe3a5-df1e-4119-afe0-2a62a2ba481e', firstName: 'Charles', lastName: 'Test', + displayName: 'Charles Test', }, authorId: '374fe3a5-df1e-4119-afe0-2a62a2ba481e', comments: [], @@ -96,6 +98,7 @@ export const mockedCommentThreads: Array = [ id: '374fe3a5-df1e-4119-afe0-2a62a2ba481e', firstName: 'Charles', lastName: 'Test', + displayName: 'Charles Test', }, authorId: '374fe3a5-df1e-4119-afe0-2a62a2ba481e', comments: [], diff --git a/front/src/testing/mock-data/index.ts b/front/src/testing/mock-data/index.ts index e21cf0770..001c49277 100644 --- a/front/src/testing/mock-data/index.ts +++ b/front/src/testing/mock-data/index.ts @@ -7,6 +7,8 @@ import { UserOrderByWithRelationInput, } from '~/generated/graphql'; +import { isDefined } from '../../utils/isDefined'; + function filterData( data: Array, where: Record, @@ -135,15 +137,28 @@ export function fetchOneFromData( data: Array, id: string, ): DataT | undefined { + if (!isDefined(id)) { + throw new Error( + `id is not defined in updateOneFromData, check that you provided where.id if needed.`, + ); + } + return data.filter((item) => item.id === id)[0]; } export function updateOneFromData( data: Array, - id: string, + id: string | undefined, payload: GraphQLVariables, ): DataT | undefined { + if (!isDefined(id)) { + throw new Error( + `id is not defined in updateOneFromData, check that you provided where.id if needed.`, + ); + } + const object = data.filter((item) => item.id === id)[0]; + const newObject = Object.assign(object, payload); return newObject; diff --git a/front/src/testing/mock-data/people.ts b/front/src/testing/mock-data/people.ts index 47bb33e8f..89135ed91 100644 --- a/front/src/testing/mock-data/people.ts +++ b/front/src/testing/mock-data/people.ts @@ -1,22 +1,28 @@ import { Company, Person } from '~/generated/graphql'; -type MockedPerson = Pick< - Person, - | 'id' - | 'firstName' - | 'lastName' - | 'displayName' - | 'email' - | '__typename' - | 'phone' - | 'city' - | '_commentThreadCount' - | 'createdAt' -> & { - company: Pick; +type RequiredAndNotNull = { + [P in keyof T]-?: Exclude; }; -export const mockedPeopleData: Array = [ +type MockedPerson = RequiredAndNotNull< + Pick< + Person, + | 'id' + | 'firstName' + | 'lastName' + | 'displayName' + | 'email' + | '__typename' + | 'phone' + | 'city' + | '_commentThreadCount' + | 'createdAt' + > & { + company: Pick; + } +>; + +export const mockedPeopleData: MockedPerson[] = [ { id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b', __typename: 'Person', diff --git a/server/src/core/company/company.resolver.ts b/server/src/core/company/company.resolver.ts index db46f6ef3..11c21f5cb 100644 --- a/server/src/core/company/company.resolver.ts +++ b/server/src/core/company/company.resolver.ts @@ -89,21 +89,6 @@ export class CompanyResolver { @PrismaSelector({ modelName: 'Company' }) prismaSelect: PrismaSelect<'Company'>, ): Promise | null> { - // TODO: Do a proper check with recursion testing on args in a more generic place - for (const key in args.data) { - if (args.data[key]) { - for (const subKey in args.data[key]) { - if (JSON.stringify(args.data[key][subKey]) === '{}') { - delete args.data[key][subKey]; - } - } - } - - if (JSON.stringify(args.data[key]) === '{}') { - delete args.data[key]; - } - } - return this.companyService.update({ where: args.where, data: args.data, diff --git a/server/src/database/migrations/20230720075726_alter_table_person_make_fields_optional/migration.sql b/server/src/database/migrations/20230720075726_alter_table_person_make_fields_optional/migration.sql new file mode 100644 index 000000000..3f2b71c27 --- /dev/null +++ b/server/src/database/migrations/20230720075726_alter_table_person_make_fields_optional/migration.sql @@ -0,0 +1,6 @@ +-- AlterTable +ALTER TABLE "people" ALTER COLUMN "email" DROP NOT NULL, +ALTER COLUMN "phone" DROP NOT NULL, +ALTER COLUMN "city" DROP NOT NULL, +ALTER COLUMN "firstName" DROP NOT NULL, +ALTER COLUMN "lastName" DROP NOT NULL; diff --git a/server/src/database/schema.prisma b/server/src/database/schema.prisma index 34bc0c970..10c5a34b4 100644 --- a/server/src/database/schema.prisma +++ b/server/src/database/schema.prisma @@ -9,8 +9,9 @@ datasource db { } generator nestgraphql { - provider = "node node_modules/prisma-nestjs-graphql" - output = "../../src/core/@generated" + provider = "node node_modules/prisma-nestjs-graphql" + output = "../../src/core/@generated" + noAtomicOperations = true // field validator fields_Validator_input = true @@ -47,11 +48,13 @@ generator nestgraphql { decorate_count_arguments = "[]" // create data validator - decorate_classValidator_type = "@(Create|Update|Upsert)*Args" - decorate_classValidator_field = "@(data|[A-Z]*)" - decorate_classValidator_name = ValidateNested - decorate_classValidator_from = "class-validator" - decorate_classValidator_arguments = "['{each: true}']" + decorate_classValidator_type = "@(Create|Update|Upsert)*Args" + decorate_classValidator_field = "@(data|[A-Z]*)" + decorate_classValidator_name = ValidateNested + decorate_classValidator_from = "class-validator" + decorate_classValidator_arguments = "['{each: true}']" + + // create data transformer decorate_classTransformer_type = "@(Create|Update|Upsert)*Args" decorate_classTransformer_field = "@(data|[A-Z]*)" decorate_classTransformer_from = "class-transformer" @@ -70,6 +73,7 @@ model User { /// @Validator.IsOptional() lastName String? /// @Validator.IsEmail() + /// @Validator.IsOptional() email String @unique /// @Validator.IsBoolean() /// @Validator.IsOptional() @@ -78,6 +82,7 @@ model User { /// @Validator.IsOptional() avatarUrl String? /// @Validator.IsString() + /// @Validator.IsOptional() locale String /// @Validator.IsString() /// @Validator.IsOptional() @@ -200,10 +205,13 @@ model Company { /// @Validator.IsOptional() id String @id @default(uuid()) /// @Validator.IsString() + /// @Validator.IsOptional() name String /// @Validator.IsString() + /// @Validator.IsOptional() domainName String /// @Validator.IsString() + /// @Validator.IsOptional() address String /// @Validator.IsNumber() /// @Validator.IsOptional() @@ -229,31 +237,36 @@ model Company { model Person { /// @Validator.IsString() /// @Validator.IsOptional() - id String @id @default(uuid()) + id String @id @default(uuid()) /// @Validator.IsString() - firstName String + /// @Validator.IsOptional() + firstName String? /// @Validator.IsString() - lastName String + /// @Validator.IsOptional() + lastName String? /// @Validator.IsString() - email String + /// @Validator.IsOptional() + email String? /// @Validator.IsString() - phone String + /// @Validator.IsOptional() + phone String? /// @Validator.IsString() - city String + /// @Validator.IsOptional() + city 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 + workspaceId String + pipelineProgresses PipelineProgress[] /// @TypeGraphQL.omit(input: true, output: true) deletedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - PipelineProgress PipelineProgress[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt @@map("people") } @@ -413,6 +426,7 @@ model PipelineStage { index Int? pipelineProgresses PipelineProgress[] + /// pipeline Pipeline @relation(fields: [pipelineId], references: [id]) pipelineId String /// @TypeGraphQL.omit(input: true, output: true) diff --git a/server/src/decorators/prisma-select.decorator.ts b/server/src/decorators/prisma-select.decorator.ts index 2efd8fbe7..7984dc2c1 100644 --- a/server/src/decorators/prisma-select.decorator.ts +++ b/server/src/decorators/prisma-select.decorator.ts @@ -17,6 +17,11 @@ const globalDefaultFields: DefaultFieldsMap = { firstName: true, lastName: true, }, + Person: { + // Needed for displayName resolve field + firstName: true, + lastName: true, + }, }; export const PrismaSelector = createParamDecorator(