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