()
| 173 | }); |
| 174 | |
| 175 | const Todos: FC = () => { |
| 176 | const { create } = useMutation(); |
| 177 | const { rows } = useQuery( |
| 178 | (db) => |
| 179 | db |
| 180 | .selectFrom("todo") |
| 181 | .select(["id", "title", "isCompleted", "categoryId"]) |
| 182 | .where("isDeleted", "is not", Evolu.cast(true)) |
| 183 | .orderBy("createdAt"), |
| 184 | // (row) => row |
| 185 | ({ title, isCompleted, ...rest }) => |
| 186 | title && isCompleted != null && { title, isCompleted, ...rest }, |
| 187 | ); |
| 188 | const todoCategoriesList = useTodoCategoriesList(); |
| 189 | |
| 190 | return ( |
| 191 | <> |
| 192 | <h2 className="mt-6 text-xl font-semibold">Todos</h2> |
| 193 | <ul className="py-2"> |
| 194 | {rows.map((row) => ( |
| 195 | <TodoItem |
| 196 | key={row.id} |
| 197 | row={row} |
| 198 | todoCategoriesList={todoCategoriesList} |
| 199 | /> |
| 200 | ))} |
| 201 | </ul> |
| 202 | <Button |
| 203 | title="Add Todo" |
| 204 | onClick={(): void => { |
| 205 | // TODO: Use something for Electron. |
| 206 | create("todo", { |
| 207 | title: "yep" as Evolu.NonEmptyString1000, |
| 208 | isCompleted: false, |
| 209 | }); |
| 210 | // prompt( |
| 211 | // Evolu.NonEmptyString1000, |
| 212 | // "What needs to be done?", |
| 213 | // (title) => { |
| 214 | // create("todo", { title, isCompleted: false }); |
| 215 | // } |
| 216 | // ); |
| 217 | }} |
| 218 | /> |
| 219 | </> |
| 220 | ); |
| 221 | }; |
| 222 | |
| 223 | const TodoCategories: FC = () => { |
| 224 | const { create, update } = useMutation(); |
nothing calls this directly
no test coverage detected