| 81 | } |
| 82 | |
| 83 | render() { |
| 84 | const query = this.todos() |
| 85 | const mutation = this.addTodo() |
| 86 | const items = query.data?.items ?? [] |
| 87 | |
| 88 | return html` |
| 89 | <main> |
| 90 | <h1>Mutation Example</h1> |
| 91 | <p data-testid="mutation-query-status"> |
| 92 | Query: <strong>${query.status}</strong> |
| 93 | </p> |
| 94 | <p data-testid="mutation-mutation-status"> |
| 95 | Mutation: <strong>${mutation.status}</strong> |
| 96 | </p> |
| 97 | |
| 98 | <label for="title">Todo title</label> |
| 99 | <input |
| 100 | id="title" |
| 101 | data-testid="mutation-input" |
| 102 | .value=${this.nextTitle} |
| 103 | @input=${this.onInput} |
| 104 | /> |
| 105 | <button data-testid="mutation-add" @click=${this.submit}> |
| 106 | Add Todo |
| 107 | </button> |
| 108 | |
| 109 | <ul data-testid="mutation-todo-list"> |
| 110 | ${items.map( |
| 111 | (todo) => |
| 112 | html`<li data-testid="mutation-todo-item">${todo.title}</li>`, |
| 113 | )} |
| 114 | </ul> |
| 115 | </main> |
| 116 | ` |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | customElements.define('mutation-example', MutationExample) |