From c52e83fe105b17e5174465587ae2cc47fdfb48ff Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sat, 16 Aug 2025 01:20:18 -0400 Subject: [PATCH] Enhance ChoreEdit component with approval and visibility options --- src/views/ChoreEdit/ChoreEdit.jsx | 115 ++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 28 deletions(-) diff --git a/src/views/ChoreEdit/ChoreEdit.jsx b/src/views/ChoreEdit/ChoreEdit.jsx index 0000932..4241210 100644 --- a/src/views/ChoreEdit/ChoreEdit.jsx +++ b/src/views/ChoreEdit/ChoreEdit.jsx @@ -84,6 +84,8 @@ const ChoreEdit = () => { const [labelsV2, setLabelsV2] = useState([]) const [priority, setPriority] = useState(0) const [points, setPoints] = useState(-1) + const [requireApproval, setRequireApproval] = useState(false) + const [isPrivate, setIsPrivate] = useState(false) const [subTasks, setSubTasks] = useState(null) const [completionWindow, setCompletionWindow] = useState(-1) const [allUserThings, setAllUserThings] = useState([]) @@ -141,13 +143,24 @@ const ChoreEdit = () => { frequencyType === 'days_of_the_week' && frequencyMetadata['days']?.length === 0 ) { - errors.frequency = 'At least 1 day is required' + errors.frequency = 'Please select at least one day of the week' + } + + // Validate advanced scheduling patterns + if ( + frequencyType === 'days_of_the_week' && + frequencyMetadata?.weekPattern === 'nth_day_of_month' && + (!frequencyMetadata?.occurrences || + frequencyMetadata.occurrences.length === 0) + ) { + errors.frequency = + 'Please select at least one day occurrence for the month' } if ( frequencyType === 'day_of_the_month' && frequencyMetadata['months']?.length === 0 ) { - errors.frequency = 'At least 1 month is required' + errors.frequency = 'Please select at least one month' } if ( dueDate === null && @@ -220,6 +233,8 @@ const ChoreEdit = () => { notificationMetadata: notificationMetadata, thingTrigger: thingTrigger, points: points < 0 ? null : points, + requireApproval: requireApproval, + isPrivate: isPrivate, completionWindow: // if completionWindow is -1 then set it to null or dueDate is null completionWindow < 0 || dueDate === null ? null : completionWindow, @@ -274,6 +289,8 @@ const ChoreEdit = () => { setNotificationMetadata(data.res.notificationMetadata) setPoints(data.res.points && data.res.points > -1 ? data.res.points : -1) + setRequireApproval(data.res.requireApproval || false) + setIsPrivate(data.res.isPrivate || false) setCompletionWindow( data.res.completionWindow && data.res.completionWindow > -1 ? data.res.completionWindow @@ -418,8 +435,7 @@ const ChoreEdit = () => { entityId={choreId} entityType={'chore_description'} /> - - {errors.name} + {errors.description} @@ -468,16 +484,16 @@ const ChoreEdit = () => { // if we have only one then no need to display this section <> - Assigned : - - Who is assigned the next due chore? + Assigned : + + Who is assigned the next due? - Picking Mode : - - How to pick the next assignee for the following chore? + Picking Mode : + + How to pick the next assignee for the following task? @@ -561,7 +577,7 @@ const ChoreEdit = () => { /> - + {REPEAT_ON_TYPE.includes(frequencyType) ? 'Start date' : 'Due date'} : {frequencyType === 'trigger' && !dueDate && ( @@ -592,10 +608,10 @@ const ChoreEdit = () => { )} {dueDate && ( - + {REPEAT_ON_TYPE.includes(frequencyType) - ? 'When does this chore start?' - : 'When is the next first time this chore is due?'} + ? 'When does this task start?' + : 'When is the next first time this task is due?'} { />
{/* Completion window (hours) */} - Completion window (hours) + + Completion window (hours) + {"Set a time window that task can't be completed before"} @@ -668,8 +686,8 @@ const ChoreEdit = () => { {!['once', 'no_repeat'].includes(frequencyType) && ( - Scheduling Preferences: - + Scheduling Preferences: + How to reschedule the next due date? @@ -702,8 +720,8 @@ const ChoreEdit = () => { )} - Notifications : - + Notifications : + Get Reminders when this task is due or completed {!isPlusAccount(userProfile) && ( @@ -768,7 +786,7 @@ const ChoreEdit = () => { value={notificationMetadata} /> - Choose Who to Notify: + Who to Notify: { )} - Labels : - - Things to remember about this chore or to tag it + Labels : + + Things to remember about this task or to tag it - Priority : - How important is this task? + Priority : + How important is this task?