From 7f86f6416484669db1ef6804af384f197e66a9a9 Mon Sep 17 00:00:00 2001 From: Tomas Balsys Date: Sat, 26 Oct 2024 22:12:35 +0300 Subject: [PATCH] Delete tasks --- src/components/task-form.tsx | 22 ++-------------------- src/components/task-row.tsx | 27 +++++++++++++++++---------- src/components/task-table.tsx | 4 ++-- src/routes/list.tsx | 32 +++++++++++++++++++++++++++----- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/components/task-form.tsx b/src/components/task-form.tsx index 1a86887..ff4b17c 100644 --- a/src/components/task-form.tsx +++ b/src/components/task-form.tsx @@ -2,26 +2,11 @@ import { } from 'react' import { taskTypes, taskStatuses } from './consts'; import { EnumSelect } from './enum-select'; -export function TaskForm({ tasks, setTasks, setExpanded }: { tasks: TodoTasks, setTasks: (t: TodoTasks) => void, setExpanded: (p: number) => void }): JSX.Element { +export function TaskForm({ createTask }: { createTask: (t: Record) => void }): JSX.Element { return (
{ event.preventDefault(); - - const data = Object.fromEntries(new FormData(event.currentTarget)); - const newTask = { - id: tasks.reduce((max, row) => row.id > max ? row.id : max, 1) + 1, - type: data.type as TaskType, - title: data.title as string, - status: data.status as TaskStatus, - }; - - if (data.insert) { - setTasks([newTask, ...tasks]); - } else { - setTasks([...tasks, newTask]); - } - - setExpanded(0); + createTask(Object.fromEntries(new FormData(event.currentTarget))); }}>
@@ -46,9 +31,6 @@ export function TaskForm({ tasks, setTasks, setExpanded }: { tasks: TodoTasks, s
- -