feature: edit task

This commit is contained in:
kkzzhizhou 2021-11-29 23:20:09 +08:00
parent 6433c4c72a
commit 300f44503b
12 changed files with 253 additions and 151 deletions

View file

@ -85,7 +85,7 @@ export async function deleteTask(username: string, credentials: string, id: stri
return(response)
}
export async function updateTask(username: string, credentials: string, id: string, type: string, title: string, notes: string) {
export async function updateTask(username: string, credentials: string, id: string, type: string, title: string, notes: string, coin: string) {
const url = "https://habitica.com/api/v4/tasks/".concat(id)
const response = fetch(url, {
method: 'PUT',
@ -95,7 +95,7 @@ export async function updateTask(username: string, credentials: string, id: stri
"x-api-user": username,
"x-api-key": credentials,
},
body: JSON.stringify({id: id,type: type, text: title,notes: notes})
body: type === 'reward' ? JSON.stringify({id: id,type: type, text: title,notes: notes, coin: coin}):JSON.stringify({id: id,type: type, text: title,notes: notes})
})
return(response)
}