add finish todos list

This commit is contained in:
Romulus21
2024-02-15 21:38:05 +01:00
parent 04b8f7566c
commit 583d128bf8
9 changed files with 90 additions and 10 deletions

View File

@@ -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,
}