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: round maxUsers to 2 decimal places #1463

Merged
merged 5 commits into from
May 3, 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
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