Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

Commit 43a9d79

Browse files
committed
code cleaning
1 parent 872232a commit 43a9d79

10 files changed

Lines changed: 10 additions & 50 deletions

File tree

server/controllers/boardsController.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { BoardListItemState, BoardType } from "../../src/types.ts";
66
const boardsController = {
77
getMyBoards: async (req: Request, res: Response, next: NextFunction) => {
88
try {
9-
// find all boards beloning to the user, push board names into an array and save on locals
9+
// find all boards from the user, push board names into an array and save on locals
1010
const user = await User.findOne({ _id: req.params.userId }).populate(
1111
"boards"
1212
);
@@ -144,7 +144,6 @@ const boardsController = {
144144
await Board.findOneAndDelete({
145145
_id: req.params.boardId,
146146
});
147-
console.log("board deleted");
148147
return next();
149148
} catch (err) {
150149
// pass error through to global error handler
@@ -164,7 +163,6 @@ const boardsController = {
164163
},
165164
{ new: true }
166165
);
167-
console.log("editedBoard: ", editedBoard);
168166
res.locals.board = editedBoard;
169167
return next();
170168
} catch (err) {

server/controllers/userController.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ const userController = {
4141

4242
// middleware for verifying a user on login
4343
verifyUser: async (req: Request, res: Response, next: NextFunction) => {
44-
// obtain user name password from request body
4544
// obtain user name password from request body
4645
const { username, password } = req.body;
4746
// check for a missing input
48-
// check for a missing input
4947
if (!username || !password) {
5048
return next({
5149
log: "Missing username or password in verifyUser",
@@ -54,23 +52,19 @@ const userController = {
5452
});
5553
}
5654
try {
57-
// search DB for the user based on the username
5855
// search DB for the user based on the username
5956
const user = await User.findOne({ username });
6057
// if now user is found error out
61-
// if now user is found error out
6258
if (!user) {
6359
return next({
6460
log: `userController.verifyUser ERROR: no user with input username found in DB`,
6561
status: 400,
6662
message: { err: "Invalid username or password" },
6763
});
6864
} else {
69-
// else a user is found, check passwords
7065
// else a user is found, check passwords
7166
const resultPassword = await bcrypt.compare(password, user.password);
7267
// if passwords do not match error out
73-
// if passwords do not match error out
7468
if (!resultPassword) {
7569
return next({
7670
log: `userController.verifyUser ERROR: input password does not match stored password`,
@@ -89,12 +83,6 @@ const userController = {
8983
status: 500,
9084
message: { err: "Error occured creating user" },
9185
});
92-
// send any errors to global error handler
93-
return next({
94-
log: `usersController.createUser ERROR: ${err}`,
95-
status: 500,
96-
message: { err: "Error occured creating user" },
97-
});
9886
}
9987
},
10088
};

server/routes/boardsRouter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ router.get(
1818
}
1919
);
2020

21+
// route for getting all tasks associated with a board
2122
router.get(
2223
"/board",
2324
boardsController.getCurrentBoard,
@@ -27,6 +28,7 @@ router.get(
2728
}
2829
);
2930

31+
// route for creating a new baord
3032
router.post(
3133
"/create",
3234
boardsController.createBoard,

src/components/Column.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,19 @@ const Column = ({
1111
boardState,
1212
setBoardState,
1313
}: ColumnProps) => {
14-
// state for rendering new task modal
1514
const [addingTask, setAddingTask] = useState<boolean>(false);
16-
17-
// state for number of tasks in a column
1815
const [numTasks, setNumTasks] = useState<number>(0);
19-
20-
// state for storing task card components
2116
const [taskCards, setTaskCards] = useState<ReactNode[]>([]);
22-
23-
// state for editing a task card
2417
const [editingTask, setEditingTask] = useState<TaskState | null>(null);
2518

26-
// render new task modal on button click
2719
const handleNewTask = () => {
2820
setAddingTask(true);
2921
};
3022

3123
//effect for rendering cards
3224
useEffect(() => {
3325
const column = boardState[name];
34-
console.log("Column column: ", column);
3526
setNumTasks(column.length);
36-
// map column to an array of task card components and then set as the state
3727
const cardsArray = column.map((task: TaskState) => {
3828
return (
3929
<Card info={task} setEditingTask={setEditingTask} key={task._id} />

src/components/CreateBoardModal.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ const CreateBoardModal = ({
3434
},
3535
body: JSON.stringify(body),
3636
});
37-
// receive username and id from backend
38-
// if request success, save username to state and route to dashboard
37+
// receive board name and id from backend
3938
if (response.status === 200) {
4039
const responseData = await response.json();
41-
console.log("Board created: ", responseData);
4240
const newBoardListItem = (
4341
<button
4442
className={`board-selector ${
@@ -61,7 +59,7 @@ const CreateBoardModal = ({
6159
}
6260
};
6361

64-
const isButtonDisabled: boolean = boardName === ""; //checking if boardName is empty? using trim in handle input
62+
const isButtonDisabled: boolean = boardName === "";
6563

6664
return createPortal(
6765
<div className="modal-overlay">

src/components/EditBoardModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const EditBoardModal = ({
2929
},
3030
body: JSON.stringify(body),
3131
});
32-
// if request success, update currentBoard
32+
// receive board name and id from backend
3333
if (response.status === 200) {
3434
const responseData = await response.json();
3535
setCurrentBoard({ name: responseData.name, id: responseData._id });
@@ -58,7 +58,7 @@ const EditBoardModal = ({
5858
fetchDeleteBoard().catch(console.error);
5959
};
6060

61-
const isButtonDisabled: boolean = boardName === ""; //checking if boardName is empty? using trim in handle input
61+
const isButtonDisabled: boolean = boardName === "";
6262

6363
return createPortal(
6464
<div className="modal-overlay">

src/components/EditTaskModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const EditTaskModal = ({
2424
const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
2525
e.preventDefault;
2626
console.log("Edit Task Form Submitted: ", formData);
27-
// send POST request with the new task card, edited task and current board
27+
// send POST request with the edited task, originla column and current board
2828
const fetchEditTask = async () => {
2929
const body = {
3030
...formData,

src/containers/LeftContainer.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ const LeftContainer = ({
88
setCurrentBoard,
99
currentBoard,
1010
}: LeftContainerProps) => {
11-
// creating state to open board creating modal
1211
const [creatingBoard, setCreatingBoard] = useState<boolean>(false);
13-
// creating state to store the list of board names
1412
const [boardList, setBoardList] = useState<ReactNode[]>([]);
15-
//state for selected board
1613
const [selectedBoard, setSelectedBoard] = useState<string | null>(null);
17-
// make a request for all board naames, return an array containing strings of the board names
14+
15+
// make a request for all board names, return an array containing strings of the board names
1816
useEffect(() => {
1917
const fetchBoardList = async () => {
2018
const reponse: Response = await fetch(`/boards/myboards/${user.id}`);
@@ -35,10 +33,8 @@ const LeftContainer = ({
3533
setBoardList(boardSelectors);
3634
};
3735
fetchBoardList().catch(console.error);
38-
// iterate through board names push buttons or components into array boardlist in state
3936
}, [currentBoard]);
4037

41-
// function for changing board when click selection button
4238
const handleBoardSelect = (e: React.MouseEvent<HTMLButtonElement>) => {
4339
e.preventDefault();
4440
setCurrentBoard({
@@ -48,9 +44,7 @@ const LeftContainer = ({
4844
setSelectedBoard(e.currentTarget.id);
4945
};
5046

51-
// function for creating a new board
5247
const handleCreateBoard = () => {
53-
// create a pop up to create the new board
5448
setCreatingBoard(true);
5549
};
5650

src/containers/MainContainer.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const MainContainer = ({
1717
inReview: [],
1818
completed: [],
1919
});
20-
2120
const [editingBoard, setEditingBoard] = useState<boolean>(false);
2221

2322
// effect for fetching the current board info whenever currentBoard changes
@@ -29,8 +28,6 @@ const MainContainer = ({
2928
`/boards/board?board=${currentBoard.id}&user=${user.id}`
3029
);
3130
const board = await reponse.json();
32-
// update state with the fetched data
33-
console.log("MainContainer board: ", board);
3431
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3532
const { boardOwner, name, _id, __v, ...columns } = board;
3633
await setBoardState({ ...columns });
@@ -39,11 +36,6 @@ const MainContainer = ({
3936
fetchBoard().catch(console.error);
4037
}, [currentBoard]);
4138

42-
//
43-
useEffect(() => {
44-
console.log("MainContainer boardState:", boardState); // Log the updated state after it's set
45-
}, [boardState]); // Log when the boardState changes
46-
4739
if (!currentBoard?.name) {
4840
return (
4941
<div className="main-container">

src/routes/Dashboard.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import { useState } from "react";
55
import "../scss/dashBoard.scss";
66

77
const Dashboard = ({ user }: DashboardProps) => {
8-
// state of current board selected
98
const [currentBoard, setCurrentBoard] = useState<CurrentBoardState>({
109
name: "",
1110
id: "",
1211
});
13-
//state confirmDelete false
1412
return (
1513
<div className="main-page">
1614
<LeftContainer

0 commit comments

Comments
 (0)