diff --git a/www/components/item.jsx b/www/components/item.jsx
index 0e07068..0fb6f94 100644
--- a/www/components/item.jsx
+++ b/www/components/item.jsx
@@ -4,11 +4,11 @@ import React from 'react'
const Item = ({ id, text, done, refresh }) => {
- const _done = (e) => callAPI(null, {
+ const _done = () => callAPI(null, {
url: `/api/items/${id}`,
method: 'patch',
data: {
- done: e.target.checked,
+ done: !done,
},
}).then(refresh)
@@ -17,36 +17,30 @@ const Item = ({ id, text, done, refresh }) => {
method: 'delete',
}).then(refresh)
- return
+ return
|
{text} |
-
+
|
{/* language=CSS */}
}
diff --git a/www/pages/list.jsx b/www/pages/list.jsx
index ff7aef0..5e1f19b 100644
--- a/www/pages/list.jsx
+++ b/www/pages/list.jsx
@@ -17,11 +17,16 @@ const List = ({ fetched }) => {
input.current.focus()
}, [input])
- const _submit = () => callAPI(null, {
- url: `/api/items/`,
- method: 'post',
- data: { text },
- }).then(refresh)
+ const _submit = async (e) => {
+ e.preventDefault()
+ await callAPI(null, {
+ url: `/api/items/`,
+ method: 'post',
+ data: { text },
+ })
+ setText('')
+ refresh()
+ }
const _clear = () => callAPI(null, {
url: `/api/items/`,