Skip to content

Commit

Permalink
Merge pull request #67 from cearps/fixing-bug-to-not-show-empty-items
Browse files Browse the repository at this point in the history
Fixing bug to not show empty items
  • Loading branch information
cearps authored Oct 13, 2024
2 parents 945cd22 + 5ac3090 commit 8c356bf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile.frontendTesting
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 3 additions & 1 deletion frontend/src/api/apiConfig.tsx
Original file line number Diff line number Diff line change
@@ -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`;
23 changes: 14 additions & 9 deletions frontend/src/components/kanbans/kanban-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,20 @@ export default function KanbanColumn({
}}
>
{provided.placeholder}
{tasks.map((task, index: number) => (
<KanbanCard
key={task.id} // Add key prop with task id
task={task}
setActiveTaskMethod={setActiveTaskMethod}
currentUser={currentUser}
position={index} // Add position prop with the index
/>
))}
{tasks
.filter(
(task) =>
task.name !== undefined && task.name !== "" && task.name !== null
)
.map((task, index: number) => (
<KanbanCard
key={task.id} // Add key prop with task id
task={task}
setActiveTaskMethod={setActiveTaskMethod}
currentUser={currentUser}
position={index} // Add position prop with the index
/>
))}
</div>
</div>
);
Expand Down
35 changes: 19 additions & 16 deletions frontend/src/components/kanbans/kanban-list-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export default function KanbanListView() {
name,
dueDate,
}).subscribe({
next: (board) => {
setKanbanBoards((prevBoards) => [...prevBoards, board]);
next: () => {
setIsModalOpen(false);
setFormErrors("");
},
Expand All @@ -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);
},
Expand Down Expand Up @@ -165,17 +161,24 @@ export default function KanbanListView() {
</svg>
</div>
<div className="flex flex-wrap flex-col lg:flex-row">
{kanbanBoards.map((board: KanbanBoard) => (
<BoardCard
key={board.id}
id={board.id}
title={board.name}
dueDate={board.dueDate}
onDelete={handleDeleteBoard}
onEdit={() => handleEditBoard(board)}
onAddUser={() => handleAddUser(board)}
/>
))}
{kanbanBoards
.filter(
(board) =>
board.name !== undefined &&
board.name !== "" &&
board.name !== null
)
.map((board: KanbanBoard) => (
<BoardCard
key={board.id}
id={board.id}
title={board.name}
dueDate={board.dueDate}
onDelete={handleDeleteBoard}
onEdit={() => handleEditBoard(board)}
onAddUser={() => handleAddUser(board)}
/>
))}
</div>

{/* AddBoardForm Modal */}
Expand Down
2 changes: 0 additions & 2 deletions frontend/test/components/kanbans/kanban-list-view.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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();
});
});

0 comments on commit 8c356bf

Please sign in to comment.