add finish todos list
This commit is contained in:
@@ -6,7 +6,7 @@ import useTracker from "../../hooks/TraskerHook";
|
||||
import {Simulate} from "react-dom/test-utils";
|
||||
import load = Simulate.load;
|
||||
|
||||
const ToDoIndex: FC<ToDoIndexProps> = ({reload}) => {
|
||||
const ToDoIndex: FC<ToDoIndexProps> = ({reload, setReload}) => {
|
||||
|
||||
const {loading, setLoading, errorCatch, errorLabel, axiosGet, axiosPut} = useAxiosTools(true)
|
||||
const [toDos, setToDos] = useState<toDo[]>([])
|
||||
@@ -37,6 +37,7 @@ const ToDoIndex: FC<ToDoIndexProps> = ({reload}) => {
|
||||
console.log(toDo)
|
||||
try {
|
||||
await axiosPut('api/todos/' + toDo.id, {checked: ! toDo.checked})
|
||||
setReload(new Date())
|
||||
await fetchToDos()
|
||||
} catch (error) {
|
||||
errorCatch(error)
|
||||
@@ -51,7 +52,7 @@ const ToDoIndex: FC<ToDoIndexProps> = ({reload}) => {
|
||||
{toDos.map(toDo => <li key={toDo.id} className="flex gap-2">
|
||||
<span>Move</span>
|
||||
<input type={"checkbox"}
|
||||
checked={toDo.checked}
|
||||
checked={!!toDo.checked}
|
||||
onChange={() =>toggleCheck(toDo)}
|
||||
className=""/>
|
||||
<Link to={"/todos/" + toDo.id}
|
||||
@@ -71,4 +72,5 @@ export default ToDoIndex
|
||||
|
||||
interface ToDoIndexProps {
|
||||
reload: Date|null,
|
||||
setReload: (date: Date) => void,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user