diff --git a/front/src/generated/graphql.tsx b/front/src/generated/graphql.tsx index 6f86413780..4f38c08f19 100644 --- a/front/src/generated/graphql.tsx +++ b/front/src/generated/graphql.tsx @@ -2328,7 +2328,7 @@ export type CreateActivityMutationVariables = Exact<{ }>; -export type CreateActivityMutation = { __typename?: 'Mutation', createOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, authorId: string, type: ActivityType, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, activityId: string, commentableType?: CommentableType | null, commentableId?: string | null }> | null, comments?: Array<{ __typename?: 'Comment', id: string, createdAt: string, updatedAt: string, body: string, author: { __typename?: 'User', id: string } }> | null } }; +export type CreateActivityMutation = { __typename?: 'Mutation', createOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, authorId: string, type: ActivityType, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, activityId: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null, comments?: Array<{ __typename?: 'Comment', id: string, createdAt: string, updatedAt: string, body: string, author: { __typename?: 'User', id: string } }> | null } }; export type GetActivitiesByTargetsQueryVariables = Exact<{ activityTargetIds: Array | Scalars['String']; @@ -2336,7 +2336,7 @@ export type GetActivitiesByTargetsQueryVariables = Exact<{ }>; -export type GetActivitiesByTargetsQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, 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, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null }> | null }> }; +export type GetActivitiesByTargetsQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, 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, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null }> }; export type GetActivitiesQueryVariables = Exact<{ where: ActivityWhereInput; @@ -2344,14 +2344,14 @@ export type GetActivitiesQueryVariables = Exact<{ }>; -export type GetActivitiesQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null }> | null }> }; +export type GetActivitiesQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, title?: string | null, body?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, author: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string }, comments?: Array<{ __typename?: 'Comment', id: string }> | null, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null }> }; export type GetActivityQueryVariables = Exact<{ activityId: Scalars['String']; }>; -export type GetActivityQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, body?: string | null, title?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, 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, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null }> | null }> }; +export type GetActivityQuery = { __typename?: 'Query', findManyActivities: Array<{ __typename?: 'Activity', id: string, createdAt: string, body?: string | null, title?: string | null, type: ActivityType, completedAt?: string | null, dueAt?: string | null, assignee?: { __typename?: 'User', id: string, firstName?: string | null, lastName?: string | null, displayName: string, avatarUrl?: string | null } | null, 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, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null }> }; export type AddActivityTargetsOnActivityMutationVariables = Exact<{ activityId: Scalars['String']; @@ -2359,7 +2359,7 @@ export type AddActivityTargetsOnActivityMutationVariables = Exact<{ }>; -export type AddActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, commentableType?: CommentableType | null, commentableId?: string | null }> | null } }; +export type AddActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null } }; export type RemoveActivityTargetsOnActivityMutationVariables = Exact<{ activityId: Scalars['String']; @@ -2367,7 +2367,7 @@ export type RemoveActivityTargetsOnActivityMutationVariables = Exact<{ }>; -export type RemoveActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, commentableType?: CommentableType | null, commentableId?: string | null }> | null } }; +export type RemoveActivityTargetsOnActivityMutation = { __typename?: 'Mutation', updateOneActivity: { __typename?: 'Activity', id: string, createdAt: string, updatedAt: string, activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, createdAt: string, updatedAt: string, commentableType?: CommentableType | null, commentableId?: string | null, companyId?: string | null, personId?: string | null }> | null } }; export type DeleteActivityMutationVariables = Exact<{ activityId: Scalars['String']; @@ -2849,6 +2849,8 @@ export const CreateActivityDocument = gql` activityId commentableType commentableId + companyId + personId } comments { id @@ -2931,6 +2933,8 @@ export const GetActivitiesByTargetsDocument = gql` id commentableType commentableId + companyId + personId } } } @@ -2994,6 +2998,8 @@ export const GetActivitiesDocument = gql` id commentableType commentableId + companyId + personId } } } @@ -3067,6 +3073,8 @@ export const GetActivityDocument = gql` id commentableType commentableId + companyId + personId } } } @@ -3114,6 +3122,8 @@ export const AddActivityTargetsOnActivityDocument = gql` updatedAt commentableType commentableId + companyId + personId } } } @@ -3160,6 +3170,8 @@ export const RemoveActivityTargetsOnActivityDocument = gql` updatedAt commentableType commentableId + companyId + personId } } } diff --git a/front/src/modules/activities/components/ActivityRelationPicker.tsx b/front/src/modules/activities/components/ActivityRelationPicker.tsx index 2a9a6d4071..d3234e278c 100644 --- a/front/src/modules/activities/components/ActivityRelationPicker.tsx +++ b/front/src/modules/activities/components/ActivityRelationPicker.tsx @@ -27,7 +27,10 @@ import { flatMapAndSortEntityForSelectArrayOfArrayByName } from '../utils/flatMa type OwnProps = { activity?: Pick & { activityTargets: Array< - Pick + Pick< + ActivityTarget, + 'id' | 'commentableId' | 'commentableType' | 'companyId' | 'personId' + > >; }; }; @@ -87,7 +90,7 @@ export function ActivityRelationPicker({ activity }: OwnProps) { () => activity?.activityTargets ?.filter((relation) => relation.commentableType === 'Person') - .map((relation) => relation.commentableId) + .map((relation) => relation.personId || relation.commentableId) .filter(assertNotNull) ?? [], [activity?.activityTargets], ); @@ -96,7 +99,7 @@ export function ActivityRelationPicker({ activity }: OwnProps) { () => activity?.activityTargets ?.filter((relation) => relation.commentableType === 'Company') - .map((relation) => relation.commentableId) + .map((relation) => relation.companyId || relation.commentableId) .filter(assertNotNull) ?? [], [activity?.activityTargets], ); diff --git a/front/src/modules/activities/components/TaskRow.tsx b/front/src/modules/activities/components/TaskRow.tsx index d3f0c450e7..41b1cd665f 100644 --- a/front/src/modules/activities/components/TaskRow.tsx +++ b/front/src/modules/activities/components/TaskRow.tsx @@ -68,7 +68,9 @@ export function TaskRow({ task }: { task: TaskForList }) { in: task?.activityTargets ? task?.activityTargets .filter((target) => target.commentableType === 'Person') - .map((target) => target.commentableId ?? '') + .map( + (target) => (target.personId || target.commentableId) ?? '', + ) : [], }, }, @@ -82,7 +84,9 @@ export function TaskRow({ task }: { task: TaskForList }) { in: task?.activityTargets ? task?.activityTargets .filter((target) => target.commentableType === 'Company') - .map((target) => target.commentableId ?? '') + .map( + (target) => (target.companyId || target.commentableId) ?? '', + ) : [], }, }, diff --git a/front/src/modules/activities/editable-fields/components/ActivityRelationEditableField.tsx b/front/src/modules/activities/editable-fields/components/ActivityRelationEditableField.tsx index 7c6c805de3..f99d71263a 100644 --- a/front/src/modules/activities/editable-fields/components/ActivityRelationEditableField.tsx +++ b/front/src/modules/activities/editable-fields/components/ActivityRelationEditableField.tsx @@ -16,7 +16,10 @@ import { ActivityRelationEditableFieldEditMode } from './ActivityRelationEditabl type OwnProps = { activity?: Pick & { activityTargets?: Array< - Pick + Pick< + ActivityTarget, + 'id' | 'commentableId' | 'commentableType' | 'personId' | 'companyId' + > > | null; }; }; @@ -29,7 +32,9 @@ export function ActivityRelationEditableField({ activity }: OwnProps) { in: activity?.activityTargets ? activity?.activityTargets .filter((target) => target.commentableType === 'Person') - .map((target) => target.commentableId ?? '') + .map( + (target) => (target.personId || target.commentableId) ?? '', + ) : [], }, }, @@ -43,7 +48,9 @@ export function ActivityRelationEditableField({ activity }: OwnProps) { in: activity?.activityTargets ? activity?.activityTargets .filter((target) => target.commentableType === 'Company') - .map((target) => target.commentableId ?? '') + .map( + (target) => (target.companyId || target.commentableId) ?? '', + ) : [], }, }, diff --git a/front/src/modules/activities/editable-fields/components/ActivityRelationEditableFieldEditMode.tsx b/front/src/modules/activities/editable-fields/components/ActivityRelationEditableFieldEditMode.tsx index 5539f812a6..2a3c975012 100644 --- a/front/src/modules/activities/editable-fields/components/ActivityRelationEditableFieldEditMode.tsx +++ b/front/src/modules/activities/editable-fields/components/ActivityRelationEditableFieldEditMode.tsx @@ -13,7 +13,10 @@ import { assertNotNull } from '~/utils/assert'; type OwnProps = { activity?: Pick & { activityTargets?: Array< - Pick + Pick< + ActivityTarget, + 'id' | 'commentableId' | 'commentableType' | 'personId' | 'companyId' + > > | null; }; }; @@ -31,7 +34,7 @@ export function ActivityRelationEditableFieldEditMode({ activity }: OwnProps) { () => activity?.activityTargets ?.filter((relation) => relation.commentableType === 'Person') - .map((relation) => relation.commentableId) + .map((relation) => relation.personId || relation.commentableId) .filter(assertNotNull) ?? [], [activity?.activityTargets], ); @@ -40,7 +43,7 @@ export function ActivityRelationEditableFieldEditMode({ activity }: OwnProps) { () => activity?.activityTargets ?.filter((relation) => relation.commentableType === 'Company') - .map((relation) => relation.commentableId) + .map((relation) => relation.companyId || relation.commentableId) .filter(assertNotNull) ?? [], [activity?.activityTargets], ); diff --git a/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts b/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts index 5814ee2a49..8c10b39be1 100644 --- a/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts +++ b/front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts @@ -6,6 +6,7 @@ import { GET_PEOPLE } from '@/people/queries'; import { Activity, ActivityTarget, + CommentableType, useAddActivityTargetsOnActivityMutation, useRemoveActivityTargetsOnActivityMutation, } from '~/generated/graphql'; @@ -65,6 +66,10 @@ export function useHandleCheckableActivityTargetChange({ createdAt: new Date().toISOString(), commentableType: entity.entityType, commentableId: entity.id, + companyId: + entity.entityType === CommentableType.Company ? entity.id : null, + personId: + entity.entityType === CommentableType.Person ? entity.id : null, })), }, }); diff --git a/front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts b/front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts index 94f1029e16..90896062ca 100644 --- a/front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts +++ b/front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts @@ -9,7 +9,11 @@ import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer'; import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope'; import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages'; import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope'; -import { ActivityType, useCreateActivityMutation } from '~/generated/graphql'; +import { + ActivityType, + CommentableType, + useCreateActivityMutation, +} from '~/generated/graphql'; import { GET_ACTIVITIES, @@ -53,6 +57,14 @@ export function useOpenCreateActivityDrawer() { { commentableId: entity.id, commentableType: entity.type, + companyId: + entity.type === CommentableType.Company + ? entity.id + : null, + personId: + entity.type === CommentableType.Person + ? entity.id + : null, id: v4(), createdAt: now, }, diff --git a/front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts b/front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts index af3e762e66..b363d9af2a 100644 --- a/front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts +++ b/front/src/modules/activities/hooks/useOpenCreateActivityDrawerForSelectedRowIds.ts @@ -61,6 +61,10 @@ export function useOpenCreateActivityDrawerForSelectedRowIds() { commentableType: entity.type, id: v4(), createdAt: new Date().toISOString(), + companyId: + entity.type === CommentableType.Company ? entity.id : null, + personId: + entity.type === CommentableType.Person ? entity.id : null, })), skipDuplicates: true, }, diff --git a/front/src/modules/activities/queries/create.ts b/front/src/modules/activities/queries/create.ts index e7954ca299..f79548631a 100644 --- a/front/src/modules/activities/queries/create.ts +++ b/front/src/modules/activities/queries/create.ts @@ -47,6 +47,8 @@ export const CREATE_ACTIVITY_WITH_COMMENT = gql` activityId commentableType commentableId + companyId + personId } comments { id diff --git a/front/src/modules/activities/queries/select.ts b/front/src/modules/activities/queries/select.ts index 821ee602e3..c7acc033d6 100644 --- a/front/src/modules/activities/queries/select.ts +++ b/front/src/modules/activities/queries/select.ts @@ -48,6 +48,8 @@ export const GET_ACTIVITIES_BY_TARGETS = gql` id commentableType commentableId + companyId + personId } } } @@ -86,6 +88,8 @@ export const GET_ACTIVITIES = gql` id commentableType commentableId + companyId + personId } } } @@ -131,6 +135,8 @@ export const GET_ACTIVITY = gql` id commentableType commentableId + companyId + personId } } } diff --git a/front/src/modules/activities/queries/update.ts b/front/src/modules/activities/queries/update.ts index 50900d3bd8..f136dd41bb 100644 --- a/front/src/modules/activities/queries/update.ts +++ b/front/src/modules/activities/queries/update.ts @@ -18,6 +18,8 @@ export const ADD_ACTIVITY_TARGETS = gql` updatedAt commentableType commentableId + companyId + personId } } } @@ -43,6 +45,8 @@ export const REMOVE_ACTIVITY_TARGETS = gql` updatedAt commentableType commentableId + companyId + personId } } }