diff --git a/frontend/src/helper/board/transformBoard.tsx b/frontend/src/helper/board/transformBoard.tsx index 081422997..392cb1bc3 100644 --- a/frontend/src/helper/board/transformBoard.tsx +++ b/frontend/src/helper/board/transformBoard.tsx @@ -113,6 +113,7 @@ export const handleDeleteCard = (board: BoardType, data: DeleteCardDto): BoardTy } const boardUserIdx = boardData.users.findIndex((bUser) => bUser.user._id === userId); + if (boardUserIdx > -1) { boardData.users[boardUserIdx].votesCount -= votesOfUser; } diff --git a/frontend/src/pages/boards/[boardId].tsx b/frontend/src/pages/boards/[boardId].tsx index 676c5261c..de116d4e2 100644 --- a/frontend/src/pages/boards/[boardId].tsx +++ b/frontend/src/pages/boards/[boardId].tsx @@ -3,7 +3,7 @@ import { dehydrate, QueryClient } from '@tanstack/react-query'; import { GetServerSideProps, NextPage } from 'next'; import { useRouter } from 'next/router'; import { getSession, useSession } from 'next-auth/react'; -import { useRecoilState } from 'recoil'; +import { useRecoilState, useSetRecoilState } from 'recoil'; import { Container } from '@/styles/pages/boards/board.styles'; @@ -15,7 +15,12 @@ import AlertBox from '@/components/Primitives/AlertBox'; import Flex from '@/components/Primitives/Flex'; import useBoard from '@/hooks/useBoard'; import { useSocketIO } from '@/hooks/useSocketIO'; -import { boardInfoState, newBoardState } from '@/store/board/atoms/board.atom'; +import { + boardInfoState, + deletedColumnsState, + editColumnsState, + newBoardState, +} from '@/store/board/atoms/board.atom'; import { BoardUserRoles } from '@/utils/enums/board.user.roles'; import { TeamUserRoles } from '@/utils/enums/team.user.roles'; import isEmpty from '@/utils/isEmpty'; @@ -94,6 +99,8 @@ const Board: NextPage = ({ boardId, mainBoardId }) => { // Recoil States const [newBoard, setNewBoard] = useRecoilState(newBoardState); const [recoilBoard, setRecoilBoard] = useRecoilState(boardInfoState); + const setEditColumns = useSetRecoilState(editColumnsState); + const setDeletedColumns = useSetRecoilState(deletedColumnsState); // Session Details const { data: session } = useSession(); @@ -124,8 +131,10 @@ const Board: NextPage = ({ boardId, mainBoardId }) => { useEffect(() => { if (data) { setRecoilBoard(data); + setEditColumns(data.board.columns); + setDeletedColumns([]); } - }, [data, setRecoilBoard]); + }, [data, setDeletedColumns, setEditColumns, setRecoilBoard]); // Board Settings permissions const isStakeholderOrAdmin = useMemo( diff --git a/frontend/src/pages/boards/newRegularBoard.tsx b/frontend/src/pages/boards/newRegularBoard.tsx index 10ea79a19..4d52d6934 100644 --- a/frontend/src/pages/boards/newRegularBoard.tsx +++ b/frontend/src/pages/boards/newRegularBoard.tsx @@ -122,7 +122,7 @@ const NewRegularBoard: NextPage = () => { reValidateMode: 'onBlur', defaultValues: { text: '', - maxVotes: 2, + maxVotes: boardState.board.maxVotes, slackEnable: false, }, resolver: joiResolver(SchemaCreateRegularBoard), @@ -181,7 +181,7 @@ const NewRegularBoard: NextPage = () => { mutate({ ...boardState.board, users: isEmpty(boardState.users) ? users : boardState.users, - title: title || boardState.board.title, + title: title || defaultBoard.board.title, dividedBoards: [], maxVotes, slackEnable, @@ -200,7 +200,7 @@ const NewRegularBoard: NextPage = () => { mutate({ ...boardState.board, users: isEmpty(boardState.users) ? users : boardState.users, - title: boardState.board.title, + title: defaultBoard.board.title, dividedBoards: [], maxUsers: boardState.count.maxUsersCount, recurrent: false,