From e039b732a8f74ae2d2c9ebaf9330c74c09502099 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sun, 7 Jul 2024 00:25:11 -0400 Subject: Improve MarkChoreComplete, allow complete in past ,etc --- src/utils/Fetcher.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/utils') diff --git a/src/utils/Fetcher.jsx b/src/utils/Fetcher.jsx index 0acc91f..afa9235 100644 --- a/src/utils/Fetcher.jsx +++ b/src/utils/Fetcher.jsx @@ -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 => { -- cgit