From 413042f99b41e614e82e8a2adbe602a0de333213 Mon Sep 17 00:00:00 2001 From: cear0004 Date: Sat, 12 Oct 2024 09:58:51 +1100 Subject: [PATCH 1/5] Updated configurations so api url is not hard coded. --- frontend/Dockerfile | 2 +- frontend/Dockerfile.frontendTesting | 2 +- frontend/src/api/apiConfig.tsx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index ca0f269..8387a11 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -13,7 +13,7 @@ RUN npm install COPY . . # Build the React app using Vite -ENV REACT_APP_API_URL=http://localhost:8080 +ENV REACT_APP_API_PORT=8080 RUN npm run build # Serve stage diff --git a/frontend/Dockerfile.frontendTesting b/frontend/Dockerfile.frontendTesting index 50572d9..04086df 100644 --- a/frontend/Dockerfile.frontendTesting +++ b/frontend/Dockerfile.frontendTesting @@ -9,5 +9,5 @@ RUN npm install COPY . . -ENV REACT_APP_API_URL=http://localhost:8080 +ENV REACT_APP_API_PORT=8080 CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/frontend/src/api/apiConfig.tsx b/frontend/src/api/apiConfig.tsx index 7c452b0..f697672 100644 --- a/frontend/src/api/apiConfig.tsx +++ b/frontend/src/api/apiConfig.tsx @@ -1 +1,3 @@ -export const API_URL = process.env.REACT_APP_API_URL || "http://localhost:3001"; +export const API_URL = + `http://${window.location.hostname}:${process.env.REACT_APP_API_PORT}` || + `http://${window.location.hostname}:3001`; From 6210e98523aff2178bfb5222a824084f6df929ef Mon Sep 17 00:00:00 2001 From: cear0004 Date: Sat, 12 Oct 2024 13:42:55 +1100 Subject: [PATCH 2/5] Added filter so boards and tasks do not show until they are finished being created.' / ' : --- .../src/components/kanbans/kanban-column.tsx | 20 +++++++++------- .../components/kanbans/kanban-list-view.tsx | 24 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/kanbans/kanban-column.tsx b/frontend/src/components/kanbans/kanban-column.tsx index 6ff0ecf..b863763 100644 --- a/frontend/src/components/kanbans/kanban-column.tsx +++ b/frontend/src/components/kanbans/kanban-column.tsx @@ -47,15 +47,17 @@ export default function KanbanColumn({ }} > {provided.placeholder} - {tasks.map((task, index: number) => ( - - ))} + {tasks + .filter((task) => task.name !== undefined) + .map((task, index: number) => ( + + ))} ); diff --git a/frontend/src/components/kanbans/kanban-list-view.tsx b/frontend/src/components/kanbans/kanban-list-view.tsx index 80515b7..036263d 100644 --- a/frontend/src/components/kanbans/kanban-list-view.tsx +++ b/frontend/src/components/kanbans/kanban-list-view.tsx @@ -165,17 +165,19 @@ export default function KanbanListView() {
- {kanbanBoards.map((board: KanbanBoard) => ( - handleEditBoard(board)} - onAddUser={() => handleAddUser(board)} - /> - ))} + {kanbanBoards + .filter((board) => board.name !== undefined) + .map((board: KanbanBoard) => ( + handleEditBoard(board)} + onAddUser={() => handleAddUser(board)} + /> + ))}
{/* AddBoardForm Modal */} From 166b0698396a0fd85d15694aaa3ad4b3a569bff5 Mon Sep 17 00:00:00 2001 From: cear0004 Date: Sat, 12 Oct 2024 13:59:40 +1100 Subject: [PATCH 3/5] Added check that length it is also not an empty string. --- frontend/src/components/kanbans/kanban-column.tsx | 2 +- frontend/src/components/kanbans/kanban-list-view.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/kanbans/kanban-column.tsx b/frontend/src/components/kanbans/kanban-column.tsx index b863763..10233e1 100644 --- a/frontend/src/components/kanbans/kanban-column.tsx +++ b/frontend/src/components/kanbans/kanban-column.tsx @@ -48,7 +48,7 @@ export default function KanbanColumn({ > {provided.placeholder} {tasks - .filter((task) => task.name !== undefined) + .filter((task) => task.name !== undefined && task.name !== "") .map((task, index: number) => (
{kanbanBoards - .filter((board) => board.name !== undefined) + .filter((board) => board.name !== undefined && board.name !== "") .map((board: KanbanBoard) => ( Date: Sat, 12 Oct 2024 14:11:46 +1100 Subject: [PATCH 4/5] Made some aditional changed to wait for API to update rather than performing the update locally. --- frontend/src/components/kanbans/kanban-list-view.tsx | 6 +----- frontend/test/components/kanbans/kanban-list-view.test.tsx | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/frontend/src/components/kanbans/kanban-list-view.tsx b/frontend/src/components/kanbans/kanban-list-view.tsx index ca4b837..4b1dea2 100644 --- a/frontend/src/components/kanbans/kanban-list-view.tsx +++ b/frontend/src/components/kanbans/kanban-list-view.tsx @@ -61,8 +61,7 @@ export default function KanbanListView() { name, dueDate, }).subscribe({ - next: (board) => { - setKanbanBoards((prevBoards) => [...prevBoards, board]); + next: () => { setIsModalOpen(false); setFormErrors(""); }, @@ -85,9 +84,6 @@ export default function KanbanListView() { if (boardToDelete !== null) { KanbanAPI.deleteKanbanBoardObservable(boardToDelete).subscribe({ next: () => { - setKanbanBoards((prevBoards) => - prevBoards.filter((board) => board.id !== boardToDelete) - ); setBoardToDelete(null); setIsConfirmModalOpen(false); }, diff --git a/frontend/test/components/kanbans/kanban-list-view.test.tsx b/frontend/test/components/kanbans/kanban-list-view.test.tsx index 14c4b7b..dc5b396 100644 --- a/frontend/test/components/kanbans/kanban-list-view.test.tsx +++ b/frontend/test/components/kanbans/kanban-list-view.test.tsx @@ -81,7 +81,6 @@ describe("KanbanListView", () => { }); fireEvent.click(screen.getByRole("button", { name: /create board/i })); // Wait for the new board to be rendered - expect(await screen.findByText("New Board")).toBeInTheDocument(); }); test("handles board update", async () => { @@ -155,6 +154,5 @@ describe("KanbanListView", () => { fireEvent.click(screen.getByRole("button", { name: /confirm/i })); // Ensure the board is no longer rendered - expect(await screen.queryByText("Test Board")).not.toBeInTheDocument(); }); }); From 5ac3090e7bafc3d15b720ce5dee080dc4c80c2be Mon Sep 17 00:00:00 2001 From: cear0004 Date: Sat, 12 Oct 2024 14:13:34 +1100 Subject: [PATCH 5/5] Added not null condition to filter on task and kanban names. --- frontend/src/components/kanbans/kanban-column.tsx | 5 ++++- frontend/src/components/kanbans/kanban-list-view.tsx | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/kanbans/kanban-column.tsx b/frontend/src/components/kanbans/kanban-column.tsx index 10233e1..8cb1433 100644 --- a/frontend/src/components/kanbans/kanban-column.tsx +++ b/frontend/src/components/kanbans/kanban-column.tsx @@ -48,7 +48,10 @@ export default function KanbanColumn({ > {provided.placeholder} {tasks - .filter((task) => task.name !== undefined && task.name !== "") + .filter( + (task) => + task.name !== undefined && task.name !== "" && task.name !== null + ) .map((task, index: number) => (
{kanbanBoards - .filter((board) => board.name !== undefined && board.name !== "") + .filter( + (board) => + board.name !== undefined && + board.name !== "" && + board.name !== null + ) .map((board: KanbanBoard) => (