Add ApproveChore and RejectChore functions; update ActivityItem to handle Pending Approval and Rejected statuses

This commit is contained in:
Mo Tarbin
2025-08-17 22:28:44 -04:00
parent bf97b1c115
commit 692ccd7838
2 changed files with 55 additions and 24 deletions

View File

@@ -156,6 +156,22 @@ const SkipChore = id => {
})
}
const ApproveChore = id => {
return Fetch(`/chores/${id}/approve`, {
method: 'POST',
headers: HEADERS(),
body: JSON.stringify({}),
})
}
const RejectChore = id => {
return Fetch(`/chores/${id}/reject`, {
method: 'POST',
headers: HEADERS(),
body: JSON.stringify({}),
})
}
const UpdateChoreAssignee = (id, assignee) => {
return Fetch(`/chores/${id}/assignee`, {
method: 'PUT',
@@ -596,7 +612,7 @@ const ClearChoreTimer = choreId => {
})
}
const CheckUserDeletion = (password) => {
const CheckUserDeletion = password => {
return Fetch(`/users/delete/check`, {
method: 'POST',
headers: HEADERS(),
@@ -643,6 +659,7 @@ const RestoreBackup = (encryptionKey, backupData) => {
export {
AcceptCircleMemberRequest,
ApproveChore,
ArchiveChore,
CancelSubscription,
ChangePassword,
@@ -694,6 +711,7 @@ export {
RedeemPoints,
RefreshToken,
RegenerateBackupCodes,
RejectChore,
ResetChoreTimer,
ResetPassword,
RestoreBackup,

View File

@@ -1,10 +1,12 @@
import {
CheckCircle,
EventNote,
HourglassEmpty,
Notes,
Person,
Redo,
Refresh,
ThumbDown,
Timelapse,
Toll,
WatchLater,
@@ -57,22 +59,7 @@ const ActivityItem = ({ activity, members }) => {
text: 'Started',
icon: <Timelapse />,
}
}
if (!activity.status === 1) {
return {
color: 'neutral',
text: 'Completed',
icon: <CheckCircle />,
}
} else if (activity.status === 2) {
// skipped
return {
color: 'warning',
text: 'Skipped',
icon: <Redo />,
}
}
} else if (activity.status === 1) {
const wasOnTime = moment(activity.performedAt).isSameOrBefore(
moment(activity.dueDate),
)
@@ -90,6 +77,32 @@ const ActivityItem = ({ activity, members }) => {
icon: <WatchLater />,
}
}
} else if (activity.status === 2) {
return {
color: 'warning',
text: 'Skipped',
icon: <Redo />,
}
} else if (activity.status === 3) {
return {
color: 'neutral',
text: 'Pending Approval',
icon: <HourglassEmpty />,
}
} else if (activity.status === 4) {
return {
color: 'danger',
text: 'Rejected',
icon: <ThumbDown />,
}
}
// Fallback for completed status
return {
color: 'success',
text: 'Completed',
icon: <CheckCircle />,
}
}
return (