diff --git a/inputs/passing/todoApp/main.tsx b/inputs/passing/todoApp/main.tsx new file mode 100644 index 0000000..4b48257 --- /dev/null +++ b/inputs/passing/todoApp/main.tsx @@ -0,0 +1,110 @@ +export default class TodosApp { + todos: Todo[] = []; + + ["GET /"]() { + return ( + + + Todos + {this.renderScript()} + + +

Todos

+ + {this.renderTodos()} + + + + +
+ + + +
+ + + ); + } + + ["POST /add"](todo: string) { + this.todos.push({ text: todo, done: false }); + + return this.todos.length - 1; + } + + ["POST /setDone"]({ index, done }: { index: number; done: boolean }) { + this.todos[index].done = done; + } + + ["POST /delete"](index: number) { + this.todos.splice(index, 1); + } + + renderTodos() { + return this.todos.map((todo, i) => ( + + + + + + {todo.text} + + + ❌ + + + )); + } + + renderScript() { + return ( + + ); + } +} + +type Todo = { + text: string; + done: boolean; +}; + +// deno-lint-ignore no-explicit-any +type ExplicitAny = any;