Skip to content

Commit

Permalink
fix: round maxUsers to 2 decimal places (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
CatiaAntunes96 authored May 3, 2023
1 parent 50511b4 commit 54229f0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions backend/src/modules/boards/services/create.board.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default class CreateBoardService implements CreateBoardServiceInterface {
const teamLength = teamUsersWotStakeholders.length;

const rawMaxTeams = teamLength / Number(configs.maxUsersPerTeam);
const maxTeams = Math.ceil(rawMaxTeams);
const maxTeams = Math.round(rawMaxTeams);

if (maxTeams < 2 || configs.maxUsersPerTeam < 2) {
return null;
Expand All @@ -295,7 +295,7 @@ export default class CreateBoardService implements CreateBoardServiceInterface {
hideCards: true,
postAnonymously: configs.postAnonymously,
hideVotes: configs.hideVotes ?? false,
maxUsers: Math.ceil(configs.maxUsersPerTeam),
maxUsers: configs.maxUsersPerTeam,
slackEnable: configs.slackEnable,
responsibles
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const QuickEditSubTeams = ({ team }: QuickEditSubTeamsProps) => {
const error = hasError(value, minTeams, maxTeams);
setIsSubmitDisabled(error);

if (!error) setValue('maxUsers', Math.ceil(teamLength / +value));
if (!error) setValue('maxUsers', Math.round(teamLength / +value));

setErrors((prev) => ({
...prev,
Expand Down Expand Up @@ -87,7 +87,7 @@ const QuickEditSubTeams = ({ team }: QuickEditSubTeamsProps) => {
count: {
...prev.count,
teamsCount: Math.floor(getValues('maxTeams')),
maxUsersCount: Math.floor(getValues('maxUsers')),
maxUsersCount: Number((teamLength / Math.floor(getValues('maxTeams'))).toFixed(2)),
},
board: {
...prev.board,
Expand All @@ -98,7 +98,8 @@ const QuickEditSubTeams = ({ team }: QuickEditSubTeamsProps) => {

useEffect(() => {
setValue('maxTeams', teamsCount);
setValue('maxUsers', maxUsersCount);
setValue('maxUsers', Math.round(maxUsersCount));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [teamsCount, maxUsersCount]);

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/hooks/useCreateBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const useCreateBoard = (team?: Team) => {

const handleAddTeam = () => {
if (!canAdd) return;
const countUsers = (teamMembersLength / (dividedBoardsCount + 1)).toFixed(0);
const countUsers = (teamMembersLength / (dividedBoardsCount + 1)).toFixed(2);

setCreateBoardData((prev) => ({
...prev,
Expand All @@ -229,7 +229,7 @@ const useCreateBoard = (team?: Team) => {

const handleRemoveTeam = () => {
if (!canReduce) return;
const countUsers = (teamMembersLength / (dividedBoardsCount - 1)).toFixed(0);
const countUsers = (teamMembersLength / (dividedBoardsCount - 1)).toFixed(2);

setCreateBoardData((prev) => ({
...prev,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/boards/newSplitBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const NewSplitBoard: NextPage = () => {
title,
dividedBoards: newDividedBoards,
maxVotes,
maxUsers,
maxUsers: boardState.count.maxUsersCount,
team,
responsibles,
slackEnable,
Expand Down

0 comments on commit 54229f0

Please sign in to comment.