From 629fba6aa317b039006110a64070a946f76f789e Mon Sep 17 00:00:00 2001 From: Hussain Omer Date: Tue, 31 Dec 2024 00:58:10 -0500 Subject: [PATCH] allow multiple subtasks within projects in view --- .../Modal Management/Layout/View.js | 2 +- .../Modal Management/Projects/ProjectView.js | 198 +++++++++++++++++- 2 files changed, 197 insertions(+), 3 deletions(-) diff --git a/client/src/components/Modal Management/Layout/View.js b/client/src/components/Modal Management/Layout/View.js index 57012b0..ebabe15 100644 --- a/client/src/components/Modal Management/Layout/View.js +++ b/client/src/components/Modal Management/Layout/View.js @@ -283,7 +283,7 @@ const View = ({ showDetails ? 'max-h-[500px] py-3' : 'max-h-0' } overflow-hidden`} > -
+
{!isCompleted && (
+ ); + } + + return ( +
+
+ {/* Task Name Input */} +
+ { + setNewSubtask({ ...newSubtask, name: e.target.value }); + setError(''); + }} + className="w-full px-3 py-1.5 bg-white dark:bg-gray-700 + border border-gray-300 dark:border-gray-600 + rounded-lg text-sm text-gray-900 dark:text-gray-200" + /> + {error && ( +

+ {error} +

+ )} +
+ + {/* Mobile: Single Combined Slider */} +
+
+ + { + const value = Number(e.target.value); + setNewSubtask({ + ...newSubtask, + difficulty: value, + importance: value + }); + }} + className="flex-1 h-1 appearance-none bg-gray-200 dark:bg-gray-700 rounded-full + [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 + [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:rounded-full + [&::-webkit-slider-thumb]:bg-blue-500 dark:[&::-webkit-slider-thumb]:bg-blue-400" + /> + + {calculateSubtaskXP(newSubtask)}xp + +
+
+ + {/* Desktop: Separate Sliders */} +
+
+ + setNewSubtask({ ...newSubtask, difficulty: Number(e.target.value) })} + className="w-16 h-1 appearance-none bg-gray-200 dark:bg-gray-700 rounded-full + [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 + [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:rounded-full + [&::-webkit-slider-thumb]:bg-blue-500 dark:[&::-webkit-slider-thumb]:bg-blue-400" + /> + + {Math.round(newSubtask.difficulty/10)} + +
+ +
+ + setNewSubtask({ ...newSubtask, importance: Number(e.target.value) })} + className="w-16 h-1 appearance-none bg-gray-200 dark:bg-gray-700 rounded-full + [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 + [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:rounded-full + [&::-webkit-slider-thumb]:bg-blue-500 dark:[&::-webkit-slider-thumb]:bg-blue-400" + /> + + {Math.round(newSubtask.importance/10)} + +
+ +
+ + {calculateSubtaskXP(newSubtask)} + +
+
+ + {/* Action Buttons */} +
+ + +
+
+
+ ); + }; + + useEffect(() => { + let cleanup; + if (task.isShared) { + // Start syncing the project + cleanup = collaborationManager.startProjectSync(task.id); + } + return () => { + if (cleanup) cleanup(); + }; + }, [task.id, task.isShared, collaborationManager]); + return (
{/* Progress Bar and Share Button */} @@ -108,7 +299,7 @@ const ProjectView = ({ task, isCompleted, updateTask, collaborationManager, user
)} - {/* Subtasks List */} + {/* Subtasks List with Add Button */}
{task.subtasks.map((subtask, index) => ( @@ -149,6 +340,9 @@ const ProjectView = ({ task, isCompleted, updateTask, collaborationManager, user
))} + + {/* Subtask Interface */} + {!isCompleted && renderAddSubtaskInterface()}