diff --git a/src/components/ProjectTasksSection.js b/src/components/ProjectTasksSection.js index 07ead22..2bb6874 100644 --- a/src/components/ProjectTasksSection.js +++ b/src/components/ProjectTasksSection.js @@ -1,6 +1,6 @@ "use client"; -import { useState, useEffect } from "react"; +import React, { useState, useEffect } from "react"; import ProjectTaskForm from "./ProjectTaskForm"; import { Card, CardHeader, CardContent } from "./ui/Card"; import Button from "./ui/Button"; @@ -13,6 +13,8 @@ export default function ProjectTasksSection({ projectId }) { const [newNote, setNewNote] = useState({}); const [loadingNotes, setLoadingNotes] = useState({}); const [showAddTaskModal, setShowAddTaskModal] = useState(false); + const [expandedDescriptions, setExpandedDescriptions] = useState({}); + const [expandedNotes, setExpandedNotes] = useState({}); useEffect(() => { const fetchProjectTasks = async () => { try { @@ -241,7 +243,6 @@ export default function ProjectTasksSection({ projectId }) { return "default"; } }; - const getStatusVariant = (status) => { switch (status) { case "completed": @@ -256,6 +257,20 @@ export default function ProjectTasksSection({ projectId }) { return "default"; } }; + + const toggleDescription = (taskId) => { + setExpandedDescriptions((prev) => ({ + ...prev, + [taskId]: !prev[taskId], + })); + }; + + const toggleNotes = (taskId) => { + setExpandedNotes((prev) => ({ + ...prev, + [taskId]: !prev[taskId], + })); + }; return (
- {task.description} -
-| + Task + | ++ Priority + | ++ Max Wait + | {" "} ++ Date Started + | ++ Status + | ++ Actions + | +
|---|---|---|---|---|---|
|
+
+
- ))}
-
- )}
-
- {/* Add New Note */}
- + {task.task_name} ++ {task.description && ( +
-
- setNewNote((prev) => ({
- ...prev,
- [task.id]: e.target.value,
- }))
- }
- className="flex-1 px-3 py-1.5 text-sm border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
- onKeyPress={(e) => {
- if (e.key === "Enter") {
- handleAddNote(task.id);
- }
- }}
- />
-
+
+
+ )}
+
+ |
+
+ |
+ + {task.max_wait_days} days + | {" "} ++ {task.date_started + ? new Date(task.date_started).toLocaleDateString() + : "Not started"} + | +
+
+
+
+ |
+
+
+
+
+
+ |
+
|
+
+
+ Description:
+
+
+ {task.description} + |
+ |||||
|
+
+
+ + Notes ({taskNotes[task.id]?.length || 0}) ++ + {/* Existing Notes */} + {taskNotes[task.id] && + taskNotes[task.id].length > 0 && ( +
+ {taskNotes[task.id].map((note) => (
+
+ )}
+
+ {/* Add New Note */}
+
+
+ ))}
+
+
+
+ + {note.note} + ++ {new Date( + note.note_date + ).toLocaleDateString()}{" "} + at{" "} + {new Date( + note.note_date + ).toLocaleTimeString()} + +
+
+ setNewNote((prev) => ({
+ ...prev,
+ [task.id]: e.target.value,
+ }))
+ }
+ className="flex-1 px-3 py-1.5 text-sm border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
+ onKeyPress={(e) => {
+ if (e.key === "Enter") {
+ handleAddNote(task.id);
+ }
+ }}
+ />
+
+
+ |
+ |||||