Implement chore completion logic and user assignment validation

This commit is contained in:
Mo Tarbin 2025-02-15 00:07:34 -05:00
parent 99453d0869
commit 41be361463
4 changed files with 159 additions and 10 deletions

View file

@ -1000,6 +1000,15 @@ func (h *Handler) completeChore(c *gin.Context) {
})
return
}
// user need to be assigned to the chore to complete it
if !chore.CanComplete(currentUser.ID) {
c.JSON(400, gin.H{
"error": "User is not assigned to chore",
})
return
}
// confirm that the chore in completion window:
if chore.CompletionWindow != nil {
if completedDate.Before(chore.NextDueDate.Add(time.Hour * time.Duration(*chore.CompletionWindow))) {