diff --git a/src/components/Home/HomePage.jsx b/src/components/Home/HomePage.jsx
index 92977ff..cce8f21 100644
--- a/src/components/Home/HomePage.jsx
+++ b/src/components/Home/HomePage.jsx
@@ -48,6 +48,7 @@ const Home = () => {
if (projectModalType == "add") dispatch(ADD_PROJECT(project));
else dispatch(UPDATE_PROJECT(project));
setProjectModalType(null);
+ setProjectModalInitialData(null);
};
const handleEditProjectClick = (projectId) => {
diff --git a/src/components/ProjectViewer/ProjectViewer.jsx b/src/components/ProjectViewer/ProjectViewer.jsx
index cccdfb3..e89aa9d 100644
--- a/src/components/ProjectViewer/ProjectViewer.jsx
+++ b/src/components/ProjectViewer/ProjectViewer.jsx
@@ -12,8 +12,9 @@ import { Add as AddIcon } from "@mui/icons-material";
import {
CLOSE_TASK,
ADD_TASK,
- REOPEN_TASK,
+ UPDATE_TASK,
DELETE_TASK,
+ REOPEN_TASK,
} from "@/state/slices/tasksSlice";
const ProjectViewer = () => {
@@ -36,6 +37,10 @@ const ProjectViewer = () => {
);
const lastClosedTaskId = useSelector((state) => state.tasks.lastClosedTaskId);
+ const findTaskById = (taskId) => {
+ return tasks.find((task) => task.id == taskId);
+ };
+
useEffect(() => {
if (lastClosedTaskId != null) {
setIsSnackBarOpen(true);
@@ -50,9 +55,14 @@ const ProjectViewer = () => {
dispatch(CLOSE_TASK(taskId));
};
- const handleTaskClick = (taskId) => {};
+ const handleTaskClick = (taskId) => {
+ //
+ };
- const handleTaskEditClick = (taskId) => {};
+ const handleTaskEditClick = (taskId) => {
+ setTaskEditorType("edit");
+ setTaskEditorInitialData(findTaskById(taskId));
+ };
const handleTaskOptionsClick = (event, taskId) => {
setTaskOptionsMenuAnchorEl(event.currentTarget);
@@ -71,7 +81,7 @@ const ProjectViewer = () => {
setTaskOptionsMenuAnchorEl(null);
};
- const handleTaskMenuEditClick = (taskId) => {
+ const handleTaskMenuClipboardClick = (taskId) => {
//
};
@@ -92,8 +102,9 @@ const ProjectViewer = () => {
task.project_id = selectedProjectId;
dispatch(ADD_TASK(task));
}
- //else dispatch(UPDATE_TASK(task));
+ else dispatch(UPDATE_TASK(task));
setTaskEditorType(null);
+ setTaskEditorInitialData(findTaskById(null));
};
if (!selectedProject) return null;
@@ -108,19 +119,31 @@ const ProjectViewer = () => {
{tasks
.sort((a, b) => a.order > b.order)
- .map((task) => (
-
- ))}
+ .map((task) => {
+ return taskEditorType === "edit" &&
+ task.id === taskEditorInitialData?.id ? (
+
+ ) : (
+
+ );
+ })}
- {taskEditorType ? (
+ {taskEditorType === "add" ? (
{
anchorEl={taskOptionsMenuAnchorEl}
taskId={taskOptionsMenuTaskId}
onClose={handleTaskMenuClose}
- onEditClick={handleTaskMenuEditClick}
onDeleteClick={handleTaskMenuDeleteClick}
+ onCopyToClipboardClick={handleTaskMenuClipboardClick}
/>
{!selectedProject && (
diff --git a/src/components/TaskEditor/TaskEditor.jsx b/src/components/TaskEditor/TaskEditor.jsx
index 487a840..f31bb29 100644
--- a/src/components/TaskEditor/TaskEditor.jsx
+++ b/src/components/TaskEditor/TaskEditor.jsx
@@ -38,6 +38,7 @@ const TaskEditor = ({
border: "1px solid LightGray",
borderRadius: 3,
p: "10px",
+ mt: 1,
}}
>
{
- const currentIndex = checked.indexOf(taskId);
+ const handleCheckToggle = () => {
+ const currentIndex = checked.indexOf(task.id);
const newChecked = [...checked];
if (currentIndex === -1) {
- newChecked.push(taskId);
+ newChecked.push(task.id);
} else {
newChecked.splice(currentIndex, 1);
}
setChecked(newChecked);
- onCheckToggle(taskId);
+ onCheckToggle(task.id);
};
- const handleClick = (taskId) => {
- onClick(taskId);
+ const handleClick = () => {
+ onClick(task.id);
};
- const handleEditClick = (taskId) => {
- onEditClick(taskId);
+ const handleEditClick = () => {
+ onEditClick(task.id);
};
- const handleOptionsClick = (event, taskId) => {
+ const handleOptionsClick = (event) => {
event.stopPropagation();
- onOptionsClick(event, taskId);
+ onOptionsClick(event, task.id);
};
return (
@@ -66,22 +66,23 @@ const TaskListItem = ({
}),
}}
>
-
-
-
- handleOptionsClick(event, task.id)}
- >
-
-
+
+
+
+
+
+
+
+
+
+
}
>
handleCheckToggle(task.id)}
+ onClick={handleCheckToggle}
disableRipple
/>
-
+
diff --git a/src/components/TaskOptionsMenu/TaskOptionsMenu.jsx b/src/components/TaskOptionsMenu/TaskOptionsMenu.jsx
index 07b0773..6b63ea3 100644
--- a/src/components/TaskOptionsMenu/TaskOptionsMenu.jsx
+++ b/src/components/TaskOptionsMenu/TaskOptionsMenu.jsx
@@ -10,12 +10,12 @@ const TaskOptionsMenu = ({
anchorEl,
taskId,
onClose,
- onEditClick,
onDeleteClick,
+ onCopyToClipboardClick,
}) => {
- const handleEditClick = (taskId) => {
+ const handleCopyToClipboardClick = (taskId) => {
onClose();
- onEditClick(taskId);
+ onCopyToClipboardClick(taskId);
};
const handleDeleteClick = (taskId) => {
@@ -30,7 +30,7 @@ const TaskOptionsMenu = ({
onClose={onClose}
sx={{ color: "gray" }}
>
-