This commit is contained in:
marshennikovaolga
2024-11-22 12:28:26 +01:00
parent 05018f4df1
commit 3629515bd4
3 changed files with 18 additions and 8 deletions

View File

@@ -12,6 +12,14 @@ export const TaskList: React.FC<TaskListProps> = ({
onUpdateTask,
onDeleteTask,
}) => {
if (tasks.length === 0) {
return (
<div className="flex flex-col items-center justify-center py-8">
<p className="text-sm text-muted-foreground">You have no tasks yet</p>
</div>
)
}
return (
<ul className="flex flex-col gap-y-2">
{tasks?.map(

View File

@@ -86,7 +86,7 @@ function TaskComponent() {
const tasks = me?.root.tasks
const { deleteTask } = useTaskActions()
const filteredTasks = tasks?.filter((task) => {
const filteredTasks = tasks?.filter((task: Task) => {
if (!task) return false
if (filter === "today") {
return task.status !== "done" && task.dueDate && isToday(task.dueDate)
@@ -98,7 +98,9 @@ function TaskComponent() {
const updateTask = (taskId: string, updates: Partial<Task>) => {
if (me?.root?.tasks) {
const taskIndex = me.root.tasks.findIndex((task) => task?.id === taskId)
const taskIndex = me.root.tasks.findIndex(
(task: Task) => task?.id === taskId,
)
if (taskIndex !== -1) {
Object.assign(me.root.tasks[taskIndex]!, updates)
}
@@ -135,9 +137,7 @@ function TaskComponent() {
</div> */}
<TaskForm />
<TaskList
tasks={
filteredTasks?.filter((task): task is Task => task !== null) || []
}
tasks={filteredTasks?.filter((task: Task) => task !== null) || []}
onUpdateTask={updateTask}
onDeleteTask={onDeleteTask}
/>