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

* fix

* #2133 added comments icon and count on notes tab

* reverted changes in people-filters.tsx
This commit is contained in:
Pallavi Varshney
2023-10-23 02:23:37 -07:00
committed by GitHub
parent c80eb5c0b0
commit aaa8ec574d
3 changed files with 36 additions and 8 deletions

View File

@ -3719,7 +3719,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<{ export type GetActivitiesByTargetsQueryVariables = Exact<{
activityTargetIds: Array<Scalars['String']> | Scalars['String']; activityTargetIds: Array<Scalars['String']> | Scalars['String'];

View File

@ -1,4 +1,5 @@
import { useMemo } from 'react'; import { useMemo } from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { ActivityRelationEditableField } from '@/activities/editable-fields/components/ActivityRelationEditableField'; import { ActivityRelationEditableField } from '@/activities/editable-fields/components/ActivityRelationEditableField';
@ -7,6 +8,7 @@ import {
FieldContext, FieldContext,
GenericFieldContextType, GenericFieldContextType,
} from '@/ui/data/field/contexts/FieldContext'; } from '@/ui/data/field/contexts/FieldContext';
import { IconComment } from '@/ui/display/icon';
import { Activity, ActivityTarget } from '~/generated/graphql'; import { Activity, ActivityTarget } from '~/generated/graphql';
const StyledCard = styled.div` const StyledCard = styled.div`
@ -54,23 +56,32 @@ const StyledFooter = styled.div`
border-top: 1px solid ${({ theme }) => theme.border.color.light}; border-top: 1px solid ${({ theme }) => theme.border.color.light};
color: ${({ theme }) => theme.font.color.primary}; color: ${({ theme }) => theme.font.color.primary};
display: flex; display: flex;
flex-direction: column; flex-direction: row;
gap: ${({ theme }) => theme.spacing(1)}; gap: ${({ theme }) => theme.spacing(1)};
justify-content: center; justify-content: center;
padding: ${({ theme }) => theme.spacing(2)}; padding: ${({ theme }) => theme.spacing(2)};
width: calc(100% - ${({ theme }) => theme.spacing(4)}); 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 = ({ export const NoteCard = ({
note, note,
}: { }: {
note: Pick< note: Pick<
Activity, Activity,
'id' | 'title' | 'body' | 'type' | 'completedAt' | 'dueAt' 'id' | 'title' | 'body' | 'type' | 'completedAt' | 'dueAt' | 'comments'
> & { > & {
activityTargets?: Array<Pick<ActivityTarget, 'id'>> | null; activityTargets?: Array<Pick<ActivityTarget, 'id'>> | null;
}; };
}) => { }) => {
const theme = useTheme();
const openActivityRightDrawer = useOpenActivityRightDrawer(); const openActivityRightDrawer = useOpenActivityRightDrawer();
const body = JSON.parse(note.body ?? '{}')[0] const body = JSON.parse(note.body ?? '{}')[0]
?.content.map((x: any) => x.text) ?.content.map((x: any) => x.text)
@ -92,6 +103,12 @@ export const NoteCard = ({
</StyledCardDetailsContainer> </StyledCardDetailsContainer>
<StyledFooter> <StyledFooter>
<ActivityRelationEditableField activity={note} /> <ActivityRelationEditableField activity={note} />
{note.comments && note.comments.length > 0 && (
<StyledCommentIcon>
<IconComment size={theme.icon.size.md} />
{note.comments.length}
</StyledCommentIcon>
)}
</StyledFooter> </StyledFooter>
</StyledCard> </StyledCard>
</FieldContext.Provider> </FieldContext.Provider>

View File

@ -29,11 +29,7 @@ type MockedActivity = Pick<
User, User,
'id' | 'firstName' | 'lastName' | 'displayName' | 'avatarUrl' 'id' | 'firstName' | 'lastName' | 'displayName' | 'avatarUrl'
>; >;
comments: Array< comments: Array<Comment>;
Pick<Comment, 'body' | 'id' | 'createdAt' | 'updatedAt'> & {
author: Pick<User, 'id' | 'displayName' | 'avatarUrl'>;
}
>;
activityTargets: Array< activityTargets: Array<
Pick< Pick<
ActivityTarget, ActivityTarget,