aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-07 00:25:11 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-07 00:25:11 -0400
commite039b732a8f74ae2d2c9ebaf9330c74c09502099 (patch)
tree1609806a6f26ebad1e76ad23f2e68a1ce74aab8d /src/utils
parentdf83cc894889ff2c8a121d4cb621776930e220a6 (diff)
downloaddonetick-frontend-e039b732a8f74ae2d2c9ebaf9330c74c09502099.tar.gz
donetick-frontend-e039b732a8f74ae2d2c9ebaf9330c74c09502099.tar.bz2
donetick-frontend-e039b732a8f74ae2d2c9ebaf9330c74c09502099.zip
Improve MarkChoreComplete, allow complete in past ,etc
Diffstat (limited to '')
-rw-r--r--src/utils/Fetcher.jsx15
1 files changed, 12 insertions, 3 deletions
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 => {