From 7559036abed8f1073a83e75a587fd8ab735e9da1 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Tue, 3 Jun 2025 00:18:51 -0400 Subject: [PATCH 1/3] refactor: Update chore grouping and color constants for improved clarity and organization --- src/utils/Chores.jsx | 51 ++++++++++++++++++--------- src/utils/Colors.jsx | 8 ++++- src/views/Chores/CompactChoreCard.jsx | 7 ++-- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/utils/Chores.jsx b/src/utils/Chores.jsx index b85ad4b..b8d3833 100644 --- a/src/utils/Chores.jsx +++ b/src/utils/Chores.jsx @@ -15,9 +15,10 @@ export const ChoresGrouper = (groupBy, chores, filter) => { case 'due_date': var groupRaw = { Today: [], - 'In a week': [], - 'This month': [], - Later: [], + Tomorrow: [], + 'Next 7 Days': [], + 'Later This Month': [], + Future: [], Overdue: [], Anytime: [], } @@ -32,17 +33,24 @@ export const ChoresGrouper = (groupBy, chores, filter) => { ) { groupRaw['Today'].push(chore) } else if ( - new Date(chore.nextDueDate) < - new Date(Date.now() + 7 * 24 * 60 * 60 * 1000) && - new Date(chore.nextDueDate) > new Date() + new Date(chore.nextDueDate).toDateString() === + new Date(Date.now() + 24 * 60 * 60 * 1000).toDateString() ) { - groupRaw['In a week'].push(chore) + groupRaw['Tomorrow'].push(chore) } else if ( - new Date(chore.nextDueDate).getMonth() === new Date().getMonth() + new Date(chore.nextDueDate) < + new Date(Date.now() + 8 * 24 * 60 * 60 * 1000) && + new Date(chore.nextDueDate) > + new Date(Date.now() + 24 * 60 * 60 * 1000) ) { - groupRaw['This month'].push(chore) + groupRaw['Next 7 Days'].push(chore) + } else if ( + new Date(chore.nextDueDate).getMonth() === new Date().getMonth() && + new Date(chore.nextDueDate).getFullYear() === new Date().getFullYear() + ) { + groupRaw['Later This Month'].push(chore) } else { - groupRaw['Later'].push(chore) + groupRaw['Future'].push(chore) } }) groups = [ @@ -53,16 +61,25 @@ export const ChoresGrouper = (groupBy, chores, filter) => { }, { name: 'Today', content: groupRaw['Today'], color: TASK_COLOR.TODAY }, { - name: 'In a week', - content: groupRaw['In a week'], - color: TASK_COLOR.IN_A_WEEK, + name: 'Tomorrow', + content: groupRaw['Tomorrow'], + color: TASK_COLOR.TOMORROW, }, { - name: 'This month', - content: groupRaw['This month'], - color: TASK_COLOR.THIS_MONTH, + name: 'Next 7 Days', + content: groupRaw['Next 7 Days'], + color: TASK_COLOR.NEXT_7_DAYS, + }, + { + name: 'Later This Month', + content: groupRaw['Later This Month'], + color: TASK_COLOR.LATER_THIS_MONTH, + }, + { + name: 'Future', + content: groupRaw['Future'], + color: TASK_COLOR.FUTURE, }, - { name: 'Later', content: groupRaw['Later'], color: TASK_COLOR.LATER }, { name: 'Anytime', content: groupRaw['Anytime'], diff --git a/src/utils/Colors.jsx b/src/utils/Colors.jsx index b7f31e4..61b01de 100644 --- a/src/utils/Colors.jsx +++ b/src/utils/Colors.jsx @@ -64,10 +64,16 @@ export const TASK_COLOR = { // For the calendar OVERDUE: '#F03A47', TODAY: '#ffc107', + TOMORROW: '#4ec1a2', + NEXT_7_DAYS: '#00bcd4', + LATER_THIS_MONTH: '#b39ddb', + FUTURE: '#d7ccc8', + ANYTIME: '#90a4ae', + + // Legacy colors for backward compatibility IN_A_WEEK: '#4ec1a2', THIS_MONTH: '#00bcd4', LATER: '#d7ccc8', - ANYTIME: '#90a4ae', // FOR ASSIGNEE: ASSIGNED_TO_ME: '#4ec1a2', diff --git a/src/views/Chores/CompactChoreCard.jsx b/src/views/Chores/CompactChoreCard.jsx index a3fa4dd..e336eb4 100644 --- a/src/views/Chores/CompactChoreCard.jsx +++ b/src/views/Chores/CompactChoreCard.jsx @@ -205,13 +205,12 @@ const CompactChoreCard = ({ // Utility functions const getDueDateText = nextDueDate => { if (chore.nextDueDate === null) return 'No Due Date' + // if due in next 48 hours, we should it in this format : Tomorrow 11:00 AM const diff = moment(nextDueDate).diff(moment(), 'hours') - if (diff < 24 && diff > 0) { + if (diff < 48 && diff > 0) { return moment(nextDueDate).calendar().replace(' at', '') } - if (diff < 0) { - return 'Overdue' - } + return moment(nextDueDate).fromNow() } From 321250f30efe59c6b3df66a165572a736b0c6ad0 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Tue, 3 Jun 2025 00:22:48 -0400 Subject: [PATCH 2/3] refactor: Update due date display logic and fix performer ID reference in ChoreCard component --- src/views/Chores/ChoreCard.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Chores/ChoreCard.jsx b/src/views/Chores/ChoreCard.jsx index 03e2085..7a472ad 100644 --- a/src/views/Chores/ChoreCard.jsx +++ b/src/views/Chores/ChoreCard.jsx @@ -420,7 +420,7 @@ const ChoreCard = ({ { - performers.find(p => p.id === chore.assignedTo) + performers.find(p => p.userId === chore.assignedTo) ?.displayName } From 6c1be53f86817075a1c167f9a30b2d8a09841a39 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Tue, 3 Jun 2025 23:33:55 -0400 Subject: [PATCH 3/3] refactor: Rename parameter in CompleteSubTask back to completedAt to match backend https://github.com/donetick/donetick/issues/224 --- src/utils/Fetcher.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/Fetcher.jsx b/src/utils/Fetcher.jsx index 41d425a..d9594c4 100644 --- a/src/utils/Fetcher.jsx +++ b/src/utils/Fetcher.jsx @@ -123,12 +123,12 @@ const MarkChoreComplete = (id, body, completedDate, performer) => { }) } -const CompleteSubTask = (id, choreId, performedAt) => { +const CompleteSubTask = (id, choreId, completedAt) => { var markChoreURL = `/chores/${choreId}/subtask` return Fetch(markChoreURL, { method: 'PUT', headers: HEADERS(), - body: JSON.stringify({ performedAt, id, choreId }), + body: JSON.stringify({ completedAt, id, choreId }), }) }