diff --git a/backend/src/modules/boards/utils/clean-board.ts b/backend/src/modules/boards/utils/clean-board.ts index 7ea0956ea..256e69e54 100644 --- a/backend/src/modules/boards/utils/clean-board.ts +++ b/backend/src/modules/boards/utils/clean-board.ts @@ -55,9 +55,9 @@ export const replaceCard = ( const { anonymous, createdByTeam } = input; const createdByAsUserDocument = createdBy as UserDocument; - if (hideCards && String(createdByAsUserDocument._id) !== String(userId)) { + if (hideCards && String(createdByAsUserDocument?._id) !== String(userId)) { text = hideText(input.text); - createdBy = replaceUser(createdByAsUserDocument, userId); + createdBy = createdByAsUserDocument ? replaceUser(createdByAsUserDocument, userId) : null; } if (comments?.length > 0) { @@ -101,9 +101,9 @@ export const filterVotes = (input: Card | CardItem, userId: string) => { export const replaceUser = (input: UserDocument, userId: string): LeanDocument => { return { ...input, - _id: String(userId) === String(input._id) ? input._id : undefined, - firstName: hideText(input.firstName), - lastName: hideText(input.lastName) + _id: String(userId) === String(input?._id) ? input?._id : undefined, + firstName: hideText(input?.firstName), + lastName: hideText(input?.lastName) }; }; @@ -133,7 +133,10 @@ export const replaceComments = ( if (hideCards && String(createdByAsUserDocument._id) !== String(userId)) { return { ...comment, - createdBy: replaceUser(comment.createdBy as UserDocument, userId), + createdBy: + comment.createdBy && userId + ? replaceUser(comment.createdBy as UserDocument, userId) + : null, text: hideText(text) }; } diff --git a/backend/src/modules/cards/dto/card.item.dto.ts b/backend/src/modules/cards/dto/card.item.dto.ts index c1d6b523e..8b7338582 100644 --- a/backend/src/modules/cards/dto/card.item.dto.ts +++ b/backend/src/modules/cards/dto/card.item.dto.ts @@ -24,7 +24,6 @@ export default class CardItemDto { text!: string; @ApiPropertyOptional({ description: 'User Id' }) - @IsNotEmpty() createdBy?: string; @ApiProperty({ type: CommentDto, isArray: true }) diff --git a/backend/src/modules/comments/services/update.comment.service.ts b/backend/src/modules/comments/services/update.comment.service.ts index 42da9b863..ec66db1a0 100644 --- a/backend/src/modules/comments/services/update.comment.service.ts +++ b/backend/src/modules/comments/services/update.comment.service.ts @@ -22,8 +22,7 @@ export default class UpdateCommentServiceImpl implements UpdateCommentService { .findOneAndUpdate( { _id: boardId, - 'columns.cards.items.comments._id': commentId, - 'columns.cards.items.comments.createdBy': userId + 'columns.cards.items.comments._id': commentId }, { $set: { @@ -32,11 +31,7 @@ export default class UpdateCommentServiceImpl implements UpdateCommentService { } }, { - arrayFilters: [ - { 'c._id': cardId }, - { 'i._id': cardItemId }, - { 'com._id': commentId, 'com.createdBy': userId } - ], + arrayFilters: [{ 'c._id': cardId }, { 'i._id': cardItemId }, { 'com._id': commentId }], new: true } ) @@ -66,7 +61,7 @@ export default class UpdateCommentServiceImpl implements UpdateCommentService { } }, { - arrayFilters: [{ 'c._id': cardId }, { 'com._id': commentId, 'com.createdBy': userId }], + arrayFilters: [{ 'c._id': cardId }, { 'com._id': commentId }], new: true } ) diff --git a/backend/src/modules/communication/applications/slack-merge-board.application.ts b/backend/src/modules/communication/applications/slack-merge-board.application.ts index 8e33dfee8..0aeeaf408 100644 --- a/backend/src/modules/communication/applications/slack-merge-board.application.ts +++ b/backend/src/modules/communication/applications/slack-merge-board.application.ts @@ -13,6 +13,8 @@ export class SlackMergeBoardApplication implements MergeBoardApplicationInterfac const message = `, The board of team ${teamNumber} is ready`; this.chatHandler.postMessage(responsiblesChannelId, message); + await new Promise((r) => setTimeout(r, 1000)); + if (isLastSubBoard) { const responsiblesMessage = `All sub-boards merged! Here's the complete board: ${this.frontendUrl}/boards/${data.mainBoardId}`; this.chatHandler.postMessage(responsiblesChannelId, responsiblesMessage); diff --git a/frontend/src/components/Board/Card/CardItem/CardItem.tsx b/frontend/src/components/Board/Card/CardItem/CardItem.tsx index e1998e067..4ecb1cdd0 100644 --- a/frontend/src/components/Board/Card/CardItem/CardItem.tsx +++ b/frontend/src/components/Board/Card/CardItem/CardItem.tsx @@ -3,7 +3,6 @@ import React, { useState } from 'react'; import { styled } from '@/styles/stitches/stitches.config'; import AddCardOrComment from '@/components/Board/AddCardOrComment'; -import Icon from '@/components/icons/Icon'; import Flex from '@/components/Primitives/Flex'; import Text from '@/components/Primitives/Text'; import { CardItemType } from '@/types/card/cardItem'; @@ -81,22 +80,6 @@ const CardItem: React.FC = React.memo( > {item.text} - {isSubmited && ( - - - - )} {!isSubmited && ((userId === item?.createdBy?._id && !isMainboard) || hasAdminRole) && ( ( py: '$2', }} > - {cards.length} cards + {countColumnCards(cards)} cards diff --git a/frontend/src/components/Board/Comment/Comment.tsx b/frontend/src/components/Board/Comment/Comment.tsx index abee42cbf..b05a5cd2c 100644 --- a/frontend/src/components/Board/Comment/Comment.tsx +++ b/frontend/src/components/Board/Comment/Comment.tsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; -import Icon from '@/components/icons/Icon'; import Flex from '@/components/Primitives/Flex'; import Text from '@/components/Primitives/Text'; import useComments from '@/hooks/useComments'; @@ -82,15 +81,6 @@ const Comment: React.FC = React.memo( > {comment.text} - {isSubmited && userId === comment.createdBy._id && ( - - )} {!isSubmited && ((userId === comment.createdBy._id && !isMainboard) || hasAdminRole) && ( @@ -7,3 +8,9 @@ export const countBoardCards = (columns: ColumnType[]) => }); return acc; }, 0); + +export const countColumnCards = (cards: CardType[]) => + cards.reduce((acc, card) => { + acc += card.items.length; + return acc; + }, 0); diff --git a/frontend/src/hooks/useCards.tsx b/frontend/src/hooks/useCards.tsx index e64632ab6..aec7c965c 100644 --- a/frontend/src/hooks/useCards.tsx +++ b/frontend/src/hooks/useCards.tsx @@ -189,7 +189,7 @@ const useCards = () => { setToastState({ open: true, type: ToastStateEnum.SUCCESS, - content: 'Card deleted with success!', + content: 'Card deleted!', }); }, onError: (_, variables) => {