Improve MarkChoreComplete, allow complete in past ,etc

This commit is contained in:
Mo Tarbin 2024-07-07 00:25:11 -04:00
parent df83cc8948
commit e039b732a8
3 changed files with 228 additions and 92 deletions

View file

@ -57,11 +57,20 @@ const GetChoreDetailById = id => {
headers: HEADERS(),
})
}
const MarkChoreComplete = id => {
return Fetch(`${API_URL}/chores/${id}/do`, {
const MarkChoreComplete = (id, note, completedDate) => {
const body = {
note,
}
let completedDateFormated = ''
if (completedDate) {
completedDateFormated = `?completedDate=${new Date(
completedDate,
).toISOString()}`
}
return Fetch(`${API_URL}/chores/${id}/do${completedDateFormated}`, {
method: 'POST',
headers: HEADERS(),
body: JSON.stringify(body),
})
}
const CreateChore = chore => {