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

fix: fix add responsibles field to boardData #799

Merged
merged 2 commits into from
Jan 5, 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
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