Add ApproveChore and RejectChore functions; update ActivityItem to handle Pending Approval and Rejected statuses
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import {
|
||||
CheckCircle,
|
||||
EventNote,
|
||||
HourglassEmpty,
|
||||
Notes,
|
||||
Person,
|
||||
Redo,
|
||||
Refresh,
|
||||
ThumbDown,
|
||||
Timelapse,
|
||||
Toll,
|
||||
WatchLater,
|
||||
@@ -57,38 +59,49 @@ const ActivityItem = ({ activity, members }) => {
|
||||
text: 'Started',
|
||||
icon: <Timelapse />,
|
||||
}
|
||||
}
|
||||
if (!activity.status === 1) {
|
||||
return {
|
||||
color: 'neutral',
|
||||
text: 'Completed',
|
||||
icon: <CheckCircle />,
|
||||
} else if (activity.status === 1) {
|
||||
const wasOnTime = moment(activity.performedAt).isSameOrBefore(
|
||||
moment(activity.dueDate),
|
||||
)
|
||||
|
||||
if (wasOnTime) {
|
||||
return {
|
||||
color: 'success',
|
||||
text: 'Done',
|
||||
icon: <CheckCircle />,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
color: 'primary',
|
||||
text: 'Late',
|
||||
icon: <WatchLater />,
|
||||
}
|
||||
}
|
||||
} else if (activity.status === 2) {
|
||||
// skipped
|
||||
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 />,
|
||||
}
|
||||
}
|
||||
|
||||
const wasOnTime = moment(activity.performedAt).isSameOrBefore(
|
||||
moment(activity.dueDate),
|
||||
)
|
||||
|
||||
if (wasOnTime) {
|
||||
return {
|
||||
color: 'success',
|
||||
text: 'Done',
|
||||
icon: <CheckCircle />,
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
color: 'primary',
|
||||
text: 'Late',
|
||||
icon: <WatchLater />,
|
||||
}
|
||||
// Fallback for completed status
|
||||
return {
|
||||
color: 'success',
|
||||
text: 'Completed',
|
||||
icon: <CheckCircle />,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user