From b03f37be0eef76e15448af278a7b135db9ae9abd Mon Sep 17 00:00:00 2001 From: Hussain Omer Date: Fri, 13 Dec 2024 21:48:55 -0500 Subject: [PATCH] calendar styling, & more labels --- .../src/components/Modal Management/View.js | 17 ++++-- .../Streak Management/StreakTracker.js | 2 +- client/src/utils/CalendarView.js | 56 ++++++++++++++++++- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/client/src/components/Modal Management/View.js b/client/src/components/Modal Management/View.js index e58db33..1ffb719 100644 --- a/client/src/components/Modal Management/View.js +++ b/client/src/components/Modal Management/View.js @@ -110,7 +110,7 @@ const Task = ({ task, removeTask, completeTask, isCompleted, updateTask }) => { ) : ( {task.name} -
+
{task.subtasks && ( + OVERDUE ({calculateOverduePenalty(task.deadline)} XP) )} + {isCompleted && task.earlyBonus > 0 && ( + + BONUS (+{task.earlyBonus} XP) + + )}
)} diff --git a/client/src/components/Streak Management/StreakTracker.js b/client/src/components/Streak Management/StreakTracker.js index 83de401..c52a611 100644 --- a/client/src/components/Streak Management/StreakTracker.js +++ b/client/src/components/Streak Management/StreakTracker.js @@ -124,7 +124,7 @@ const StreakTracker = ({ completedTasks, today = new Date(), onStreakChange = ()

Longest Streak

-

{longestStreak}

+

{longestStreak}

diff --git a/client/src/utils/CalendarView.js b/client/src/utils/CalendarView.js index a52a1b6..269fd7c 100644 --- a/client/src/utils/CalendarView.js +++ b/client/src/utils/CalendarView.js @@ -1,8 +1,10 @@ import React, { useState } from 'react'; -import { ChevronLeft, ChevronRight } from 'lucide-react'; +import { ChevronLeft, ChevronRight, X } from 'lucide-react'; const CalendarView = ({ tasks }) => { const [currentDate, setCurrentDate] = useState(new Date()); + const [selectedDay, setSelectedDay] = useState(null); + const [selectedDayTasks, setSelectedDayTasks] = useState([]); const tasksWithDeadlines = tasks.filter(task => task.deadline); const monthStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1); @@ -32,6 +34,14 @@ const CalendarView = ({ tasks }) => { return tasksWithDeadlines.filter(task => task.deadline === dateStr); }; + const handleDayClick = (day) => { + if (!day) return; + const dateStr = new Date(currentDate.getFullYear(), currentDate.getMonth(), day).toISOString().split('T')[0]; + const tasksForDay = tasksWithDeadlines.filter(task => task.deadline === dateStr); + setSelectedDay(day); + setSelectedDayTasks(tasksForDay); + }; + return (
@@ -68,10 +78,13 @@ const CalendarView = ({ tasks }) => { return (
day && handleDayClick(day)} className={` min-h-[60px] sm:min-h-[80px] p-1 sm:p-2 border dark:border-gray-700 rounded-lg - ${!day ? 'invisible' : ''} + ${!day ? 'invisible' : 'cursor-pointer'} ${isToday ? 'bg-blue-50 dark:bg-blue-900/20' : ''} + ${day ? 'hover:border-blue-400 dark:hover:border-blue-500 hover:shadow-sm transition-all duration-200' : ''} + ${dayTasks.length > 0 ? 'hover:scale-[1.02]' : ''} `} > {day && ( @@ -97,6 +110,45 @@ const CalendarView = ({ tasks }) => { }) ))}
+ + {/* Day Detail Modal */} + {selectedDay && ( +
+
+
+

+ {new Date(currentDate.getFullYear(), currentDate.getMonth(), selectedDay) + .toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })} +

+ +
+
+ {selectedDayTasks.length > 0 ? ( +
+ {selectedDayTasks.map(task => ( +
+

{task.name}

+ {task.desc && ( +

{task.desc}

+ )} +
+ ))} +
+ ) : ( +

No tasks due on this day

+ )} +
+
+
+ )}
); };