From 90d2fce570766bea0d1b52e7c56c15a266d8df30 Mon Sep 17 00:00:00 2001 From: hruthwikkk Date: Thu, 19 Oct 2023 11:54:44 -0400 Subject: [PATCH 1/3] Added a column component and drag and drop feature --- frontend/src/components/Column.js | 63 +++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 frontend/src/components/Column.js diff --git a/frontend/src/components/Column.js b/frontend/src/components/Column.js new file mode 100644 index 00000000..e8bb79a4 --- /dev/null +++ b/frontend/src/components/Column.js @@ -0,0 +1,63 @@ +import { shuffle } from "lodash"; +import React, { useEffect, useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import boardsSlice from "../redux/boardsSlice"; +import Task from "./Task"; + +function Column({ colIndex }) { + const colors = [ + "bg-red-500", + "bg-orange-500", + "bg-blue-500", + "bg-purple-500", + "bg-green-500", + "bg-indigo-500", + "bg-yellow-500", + "bg-pink-500", + "bg-sky-500", + ]; + + const dispatch = useDispatch(); + const [color, setColor] = useState(null); + const boards = useSelector((state) => state.boards); + const board = boards.find((board) => board.isActive === true); + const col = board.columns.find((col, i) => i === colIndex); + useEffect(() => { + setColor(shuffle(colors).pop()); + }, [dispatch]); + + const handleOnDrop = (e) => { + const { prevColIndex, taskIndex } = JSON.parse( + e.dataTransfer.getData("text") + ); + + if (colIndex !== prevColIndex) { + dispatch( + boardsSlice.actions.dragTask({ colIndex, prevColIndex, taskIndex }) + ); + } + }; + + const handleOnDragOver = (e) => { + e.preventDefault(); + }; + + return ( +
+

+

+ {col.name} ({col.tasks.length}) +

+ + {col.tasks.map((task, index) => ( + + ))} +
+ ); +} + +export default Column; From ff569df49646f56b531544ce667f1122a34dcbf7 Mon Sep 17 00:00:00 2001 From: hruthwikkk Date: Thu, 19 Oct 2023 11:56:44 -0400 Subject: [PATCH 2/3] Added ellipsis menu for delete and edit function --- frontend/src/components/ElipsisMenu.js | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 frontend/src/components/ElipsisMenu.js diff --git a/frontend/src/components/ElipsisMenu.js b/frontend/src/components/ElipsisMenu.js new file mode 100644 index 00000000..44871053 --- /dev/null +++ b/frontend/src/components/ElipsisMenu.js @@ -0,0 +1,35 @@ +import React from "react"; + +function ElipsisMenu({ type, setOpenEditModal, setOpenDeleteModal }) { + return ( +
+
+
+

{ + setOpenEditModal(); + }} + className=" cursor-pointer dark:text-gray-400 text-gray-700" + > + Edit {type === "Boards" ? type : "Updates"} +

+ +

setOpenDeleteModal()} + className=" cursor-pointer text-red-500" + > + Delete {type === "Boards" ? type : "Updates"} +

+
+
+
+ ); +} + +export default ElipsisMenu; From 9091351ed51d4a04d38170bf58ba5c5cb4eb9230 Mon Sep 17 00:00:00 2001 From: hruthwikkk Date: Thu, 19 Oct 2023 11:57:41 -0400 Subject: [PATCH 3/3] Added component for empty board --- frontend/src/components/EmptyBoard.js | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 frontend/src/components/EmptyBoard.js diff --git a/frontend/src/components/EmptyBoard.js b/frontend/src/components/EmptyBoard.js new file mode 100644 index 00000000..64645fa8 --- /dev/null +++ b/frontend/src/components/EmptyBoard.js @@ -0,0 +1,31 @@ +import React, { useState } from "react"; +import AddEditBoardModal from "../modals/AddEditBoardModal"; + +function EmptyBoard({ type }) { + const [isBoardModalOpen, setIsBoardModalOpen] = useState(false); + return ( +
+

+ {type === "edit" + ? "This board is empty. Create a new column to get started." + : "There are no boards available. Create a new board to get started"} +

+ + {isBoardModalOpen && ( + + )} +
+ ); +} + +export default EmptyBoard;