fix: improve date comparison for chore completion status
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Has been cancelled
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -224,9 +224,13 @@ const triggerTask = async (task: ChildTask) => {
|
||||
|
||||
function isChoreCompletedToday(item: ChildTask): boolean {
|
||||
if (item.pending_status !== 'approved' || !item.approved_at) return false
|
||||
const approvedDate = item.approved_at.substring(0, 10)
|
||||
const today = new Date().toISOString().slice(0, 10)
|
||||
return approvedDate === today
|
||||
const approvedDate = new Date(item.approved_at)
|
||||
const today = new Date()
|
||||
return (
|
||||
approvedDate.getFullYear() === today.getFullYear() &&
|
||||
approvedDate.getMonth() === today.getMonth() &&
|
||||
approvedDate.getDate() === today.getDate()
|
||||
)
|
||||
}
|
||||
|
||||
async function doConfirmChore() {
|
||||
|
||||
@@ -300,8 +300,13 @@ function handleChoreConfirmation(event: Event) {
|
||||
|
||||
function isChoreCompletedToday(item: ChildTask): boolean {
|
||||
if (item.pending_status !== 'approved' || !item.approved_at) return false
|
||||
const today = new Date().toISOString().slice(0, 10)
|
||||
if (item.approved_at.slice(0, 10) !== today) return false
|
||||
const approvedDate = new Date(item.approved_at)
|
||||
const today = new Date()
|
||||
const sameDay =
|
||||
approvedDate.getFullYear() === today.getFullYear() &&
|
||||
approvedDate.getMonth() === today.getMonth() &&
|
||||
approvedDate.getDate() === today.getDate()
|
||||
if (!sameDay) return false
|
||||
// If the task has a schedule and today is not a scheduled day, don't show as completed
|
||||
if (item.schedule && !isScheduledToday(item.schedule, new Date())) return false
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user