Skip to content

Commit

Permalink
fix: settings in a split board (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunocaseiro authored Jan 30, 2023
1 parent e8b333d commit 54c078e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 20 deletions.
17 changes: 17 additions & 0 deletions backend/src/libs/utils/ordinal-date.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable padding-line-between-statements */
export const get_nth_suffix = (date: number): string => {
switch (date) {
case 1:
case 21:
case 31:
return 'st';
case 2:
case 22:
return 'nd';
case 3:
case 23:
return 'rd';
default:
return 'th';
}
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Logger } from '@nestjs/common';
import { get_nth_suffix } from 'src/libs/utils/ordinal-date';
import { TeamDto } from 'src/modules/communication/dto/team.dto';
import { BoardRoles, BoardType, ConfigurationType } from 'src/modules/communication/dto/types';
import { UserDto } from 'src/modules/communication/dto/user.dto';
Expand Down Expand Up @@ -47,7 +48,9 @@ export class SlackCommunicationApplication implements CommunicationApplicationIn
}, '');

const today = new Date();
const until = new Date(today.setMonth(today.getMonth() + 1)).toLocaleDateString('en-US', {
const until = new Date();
until.setDate(today.getDate() + 7);
const month = until.toLocaleDateString('en-US', {
month: 'long'
});

Expand All @@ -57,7 +60,7 @@ export class SlackCommunicationApplication implements CommunicationApplicationIn
)}* \nIn order to proceed with the retro of this month, here are the random teams: \n\n
${textGeneralTeams} \n
Each team has a *random* selected responsible, in order to organize the retro and everything else that is described in the doc(https://confluence.kigroup.de/display/OX/Retro) :eyes: :thumbsup:\n\n
This must be done until \`${until} 1st\`\n\n
This must be done until \`${month} ${until.getDate()}${get_nth_suffix(until.getDate())}\`\n\n
All the needed boards and channels have been automatically created for your team and another one for responsibles of the teams.\n\n
Talent wins games, but teamwork and intelligence wins championships. :fire: :muscle:`;

Expand Down
47 changes: 30 additions & 17 deletions frontend/src/components/Board/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const BoardSettings = ({
addCards,
},
} = useRecoilValue(boardInfoState);

const [editColumns, setEditColumns] = useRecoilState(editColumnsState);

// State used to change values
Expand All @@ -82,7 +83,7 @@ const BoardSettings = ({
maxVotes: boardMaxVotes,
users,
isPublic,
columns: editColumns,
columns: isRegularBoard ? editColumns : columns,
addCards,
};

Expand Down Expand Up @@ -132,7 +133,7 @@ const BoardSettings = ({
defaultValues: {
title: data.title,
maxVotes: data.maxVotes,
column1title: editColumns[0].title,
column1title: editColumns[0]?.title,
column2title: editColumns[1]?.title,
column3title: editColumns[2]?.title,
column4title: editColumns[3]?.title,
Expand All @@ -150,18 +151,20 @@ const BoardSettings = ({
...prev,
title: boardTitle,
maxVotes: boardMaxVotes,
columns: editColumns,
columns: isRegularBoard ? editColumns : columns,
hideCards,
hideVotes,
isPublic,
addCards,
}));
methods.setValue('title', boardTitle);
methods.setValue('maxVotes', boardMaxVotes ?? null);
methods.setValue('column1title', editColumns[0].title);
methods.setValue('column2title', editColumns[1]?.title);
methods.setValue('column3title', editColumns[2]?.title);
methods.setValue('column4title', editColumns[3]?.title);
if (isRegularBoard) {
methods.setValue('column1title', editColumns[0]?.title);
methods.setValue('column2title', editColumns[1]?.title);
methods.setValue('column3title', editColumns[2]?.title);
methods.setValue('column4title', editColumns[3]?.title);
}

setSwitchesState((prev) => ({
...prev,
Expand All @@ -181,6 +184,7 @@ const BoardSettings = ({
methods,
editColumns,
addCards,
isRegularBoard,
]);

const handleHideCardsChange = () => {
Expand Down Expand Up @@ -260,7 +264,7 @@ const BoardSettings = ({
...data,
title,
maxVotes,
columns: updatedColumns,
columns: isRegularBoard ? updatedColumns : data.columns,
socketId,
},
{
Expand Down Expand Up @@ -351,15 +355,24 @@ const BoardSettings = ({
<StyledForm
onSubmit={methods.handleSubmit(
({ title, maxVotes, column1title, column2title, column3title, column4title }) => {
const updatedColumnTitles = [column1title, column2title, column3title, column4title];
const updatedColumns = [...editColumns];
updatedColumns.forEach((column, index) => {
updatedColumns[index] = {
...column,
title: updatedColumnTitles[index] as string,
};
});
updateBoard(title, maxVotes, updatedColumns);
if (isRegularBoard) {
const updatedColumnTitles = [
column1title,
column2title,
column3title,
column4title,
];
const updatedColumns = [...editColumns];
updatedColumns.forEach((column, index) => {
updatedColumns[index] = {
...column,
title: updatedColumnTitles[index] as string,
};
});
updateBoard(title, maxVotes, updatedColumns);
} else {
updateBoard(title, maxVotes);
}
},
)}
>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/schema/schemaUpdateBoardForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const SchemaUpdateBoard = Joi.object({
'number.base': 'Max votes needs to be a number',
'number.min': 'Please insert a number greater than zero.',
}),
column1title: Joi.string().required().trim().max(15).messages({
column1title: Joi.string().trim().max(15).messages({
'any.required': 'Please enter the Column 1 name',
'string.empty': 'Please enter the Column 1 name',
'string.max': 'Maximum of 15 characters',
Expand Down

0 comments on commit 54c078e

Please sign in to comment.