Skip to content

Commit

Permalink
fix: fix add responsibles field to boardData (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatiaAntunes96 authored Jan 5, 2023
1 parent 739145c commit 029f082
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
24 changes: 22 additions & 2 deletions frontend/src/components/Teams/Team/ListCardMembers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { MouseEvent, useEffect, useRef, useState } from 'react';
import { useSession } from 'next-auth/react';
import { useRecoilValue } from 'recoil';

Expand All @@ -8,6 +8,8 @@ import { membersListState } from '@/store/team/atom/team.atom';
import { TeamUserRoles } from '@/utils/enums/team.user.roles';

import CardMember from '@/components/Teams/CreateTeam/CardMember';
import { ButtonAddMember } from '@/components/Primitives/Dialog/styles';
import Icon from '@/components/icons/Icon';
import { ListMembers } from '../../CreateTeam/ListMembers';
import { ScrollableContent } from './styles';

Expand All @@ -26,6 +28,11 @@ const TeamMembersList = ({ handleMembersList }: TeamMemberListProps) => {

const user = membersList.find((member) => member.user._id === session?.user.id);

const handleOpen = (event: MouseEvent) => {
event.preventDefault();
setIsOpen(true);
};

useEffect(() => {
if (didMountRef.current && !isOpen) {
handleMembersList();
Expand All @@ -44,7 +51,19 @@ const TeamMembersList = ({ handleMembersList }: TeamMemberListProps) => {
Team Members
</Text>
{(!isTeamMember || isSAdmin) && (
<ListMembers isOpen={isOpen} setIsOpen={setIsOpen} isTeamPage />
<ButtonAddMember onClick={handleOpen}>
<Icon css={{ width: '$16', height: '$16' }} name="plus" />{' '}
<Text
weight="medium"
css={{
ml: '$10',
fontSize: '$14',
lineHeight: '$18',
}}
>
Add/remove members
</Text>
</ButtonAddMember>
)}
</Flex>
<ScrollableContent direction="column" justify="start">
Expand All @@ -59,6 +78,7 @@ const TeamMembersList = ({ handleMembersList }: TeamMemberListProps) => {
/>
))}
</ScrollableContent>
<ListMembers isOpen={isOpen} setIsOpen={setIsOpen} isTeamPage />
</Flex>
);
};
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/pages/boards/newRegularBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ const NewRegularBoard: NextPage = () => {
*/
const saveBoard = (title?: string, maxVotes?: number, slackEnable?: boolean) => {
const users: BoardUserDto[] = [];
const responsibles: string[] = [];

const responsible = boardState.users.find((user) => user.role === BoardUserRoles.RESPONSIBLE);

if (!isEmpty(responsible)) {
responsibles.push(responsible.user);
}

if (isEmpty(boardState.users) && session) {
users.push({ role: BoardUserRoles.RESPONSIBLE, user: session?.user.id });
}
Expand All @@ -180,6 +188,7 @@ const NewRegularBoard: NextPage = () => {
slackEnable,
maxUsers: boardState.count.maxUsersCount,
recurrent: false,
responsibles,
});
};

Expand Down

0 comments on commit 029f082

Please sign in to comment.