Skip to content

Commit 8d2272e

Browse files
authored
fix: regular board change tab (#1122)
1 parent 46176f5 commit 8d2272e

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

frontend/src/components/CreateBoard/RegularBoard/ParticipantsTab/RadioGroupParticipants/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ import { useSetRecoilState } from 'recoil';
1111
import { FormStyled } from './styles';
1212

1313
type RadioGroupParticipantsProps = {
14+
optionSelected: string;
1415
handleSelection: (value: string) => void;
1516
};
1617

17-
const RadioGroupParticipants = ({ handleSelection }: RadioGroupParticipantsProps) => {
18+
const RadioGroupParticipants = ({
19+
optionSelected,
20+
handleSelection,
21+
}: RadioGroupParticipantsProps) => {
1822
const setSelectedTeam = useSetRecoilState(createBoardTeam);
1923

2024
const handleSelect = (value: string) => {
@@ -30,6 +34,7 @@ const RadioGroupParticipants = ({ handleSelection }: RadioGroupParticipantsProps
3034
defaultValue="team"
3135
aria-label="View density"
3236
onValueChange={handleSelect}
37+
value={optionSelected}
3338
>
3439
<Flex>
3540
<RadioGroupItem value="team" id="selectTeam">

frontend/src/components/CreateBoard/RegularBoard/ParticipantsTab/SelectParticipants/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ const SelectParticipants = () => {
3333
useEffect(() => {
3434
const updateCheckedUser = usersList.map((user) => ({
3535
...user,
36-
isChecked: user._id === session?.user.id,
36+
isChecked: user._id === session?.user.id || user.isChecked,
3737
}));
3838

3939
const users = updateCheckedUser.flatMap((user) =>
40-
user._id === session?.user.id
41-
? [{ role: BoardUserRoles.RESPONSIBLE, user: user._id, votesCount: 0 }]
40+
user.isChecked
41+
? [
42+
{
43+
role:
44+
user._id === session?.user.id ? BoardUserRoles.RESPONSIBLE : BoardUserRoles.MEMBER,
45+
user: user._id,
46+
votesCount: 0,
47+
},
48+
]
4249
: [],
4350
);
4451
setUsersList(updateCheckedUser);
@@ -48,8 +55,6 @@ const SelectParticipants = () => {
4855
users,
4956
board: { ...prev.board, team: null },
5057
}));
51-
52-
// eslint-disable-next-line react-hooks/exhaustive-deps
5358
}, []);
5459

5560
return (

frontend/src/components/CreateBoard/RegularBoard/ParticipantsTab/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import Flex from '@/components/Primitives/Flex';
2-
import { useState } from 'react';
2+
import { Dispatch, SetStateAction } from 'react';
33
import SelectTeam from '@/components/CreateBoard/RegularBoard/SelectTeam';
44
import SelectParticipants from './SelectParticipants';
55
import RadioGroupParticipants from './RadioGroupParticipants';
66

7-
const ParticipantsTab = () => {
8-
const [optionSelected, setOptionSelected] = useState('team');
7+
type Props = { optionSelected: string; setOptionSelected: Dispatch<SetStateAction<string>> };
98

9+
const ParticipantsTab = ({ optionSelected, setOptionSelected }: Props) => {
1010
const handleChangeOption = (value: string) => {
1111
setOptionSelected(value);
1212
};
1313

1414
return (
1515
<Flex direction="column" css={{ width: '100%', mb: '$20', height: '$300' }} gap="24">
16-
<RadioGroupParticipants handleSelection={handleChangeOption} />
16+
<RadioGroupParticipants
17+
optionSelected={optionSelected}
18+
handleSelection={handleChangeOption}
19+
/>
1720
{optionSelected === 'team' ? <SelectTeam /> : <SelectParticipants />}
1821
</Flex>
1922
);

frontend/src/components/CreateBoard/RegularBoard/SettingsTabs/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import ParticipantsTab from '../ParticipantsTab';
1111
import BoardConfigurations from '../../Configurations/BoardConfigurations';
1212

1313
const SettingsTabs = () => {
14+
const [optionSelected, setOptionSelected] = useState('team');
15+
1416
const tabList: TabList[] = [
1517
{
1618
value: 'participants',
1719
label: 'Participants',
18-
content: <ParticipantsTab />,
20+
content: (
21+
<ParticipantsTab optionSelected={optionSelected} setOptionSelected={setOptionSelected} />
22+
),
1923
},
2024
{
2125
value: 'config',

0 commit comments

Comments
 (0)