import { deleteCompletedTasks, getTasks, useQuery, } from "wasp/client/operations"; import { Button } from "../../shared/components/Button"; import { TaskListItem } from "./TaskListItem"; export function TaskList() { const { data: tasks, isLoading, isSuccess } = useQuery(getTasks); if (isLoading) { return
Loading...
; } if (!isSuccess) { returnError loading tasks.
; } const completedTasks = tasks.filter((task) => task.isDone); async function handleDeleteCompletedTasks() { try { await deleteCompletedTasks(); } catch (err: unknown) { window.alert(`Error while deleting tasks: ${String(err)}`); } } if (tasks.length === 0) { returnNo tasks found.
; } return (