Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2133 added comments icon and count on notes tab #2186

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion front/src/generated/graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3690,7 +3690,22 @@ 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, 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, companyId?: string | null, personId?: string | null, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null, person?: { __typename?: 'Person', id: string, displayName: string, avatarUrl?: string | null } | 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<Comment>,
activityTargets?: Array<{ __typename?: 'ActivityTarget', id: string, companyId?: string | null, personId?: string | null, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null, person?: { __typename?: 'Person', id: string, displayName: string, avatarUrl?: string | null } | null }> | null
}> };

export type GetActivitiesByTargetsQueryVariables = Exact<{
activityTargetIds: Array<Scalars['String']> | Scalars['String'];
Expand Down
21 changes: 19 additions & 2 deletions front/src/modules/activities/notes/components/NoteCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useMemo } from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';

import { ActivityRelationEditableField } from '@/activities/editable-fields/components/ActivityRelationEditableField';
Expand All @@ -7,6 +8,7 @@ import {
FieldContext,
GenericFieldContextType,
} from '@/ui/data/field/contexts/FieldContext';
import { IconComment } from '@/ui/display/icon';
import { Activity, ActivityTarget } from '~/generated/graphql';

const StyledCard = styled.div`
Expand Down Expand Up @@ -54,23 +56,32 @@ const StyledFooter = styled.div`
border-top: 1px solid ${({ theme }) => theme.border.color.light};
color: ${({ theme }) => theme.font.color.primary};
display: flex;
flex-direction: column;
flex-direction: row;
gap: ${({ theme }) => theme.spacing(1)};
justify-content: center;
padding: ${({ theme }) => theme.spacing(2)};
width: calc(100% - ${({ theme }) => theme.spacing(4)});
`;

const StyledCommentIcon = styled.div`
align-items: center;
color: ${({ theme }) => theme.font.color.light};
display: flex;
gap: ${({ theme }) => theme.spacing(1)};
margin-left: ${({ theme }) => theme.spacing(2)};
`;

export const NoteCard = ({
note,
}: {
note: Pick<
Activity,
'id' | 'title' | 'body' | 'type' | 'completedAt' | 'dueAt'
'id' | 'title' | 'body' | 'type' | 'completedAt' | 'dueAt' | 'comments'
> & {
activityTargets?: Array<Pick<ActivityTarget, 'id'>> | null;
};
}) => {
const theme = useTheme();
const openActivityRightDrawer = useOpenActivityRightDrawer();
const body = JSON.parse(note.body ?? '{}')[0]
?.content.map((x: any) => x.text)
Expand All @@ -92,6 +103,12 @@ export const NoteCard = ({
</StyledCardDetailsContainer>
<StyledFooter>
<ActivityRelationEditableField activity={note} />
{note.comments && note.comments.length > 0 && (
<StyledCommentIcon>
<IconComment size={theme.icon.size.md} />
{note.comments.length}
</StyledCommentIcon>
)}
</StyledFooter>
</StyledCard>
</FieldContext.Provider>
Expand Down
6 changes: 1 addition & 5 deletions front/src/testing/mock-data/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ type MockedActivity = Pick<
User,
'id' | 'firstName' | 'lastName' | 'displayName' | 'avatarUrl'
>;
comments: Array<
Pick<Comment, 'body' | 'id' | 'createdAt' | 'updatedAt'> & {
author: Pick<User, 'id' | 'displayName' | 'avatarUrl'>;
}
>;
comments: Array<Comment>;
activityTargets: Array<
Pick<
ActivityTarget,
Expand Down