(e: FormEvent)
| 99 | } |
| 100 | |
| 101 | const handleSubmit = (e: FormEvent) => { |
| 102 | e.preventDefault() |
| 103 | const todo = newTodo.trim() |
| 104 | setNewTodo(``) |
| 105 | |
| 106 | if (todo) { |
| 107 | todoCollection.insert({ |
| 108 | text: todo, |
| 109 | completed: false, |
| 110 | id: Math.round(Math.random() * 1000000), |
| 111 | created_at: new Date(), |
| 112 | updated_at: new Date(), |
| 113 | }) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | const activeTodos = todos.filter((todo) => !todo.completed) |
| 118 | const completedTodos = todos.filter((todo) => todo.completed) |