@prisma/client#Todo TypeScript Examples
The following examples show how to use
@prisma/client#Todo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TodoList.tsx From telefunc with MIT License | 6 votes |
function TodoItem({ refetch, ...todo }: Todo & { refetch: () => void }) {
const textStyle = {
textDecoration: todo.completed ? 'line-through' : undefined
}
return (
<li key={todo.id}>
<h2>
<span style={textStyle}>{todo.title}</span>
<input
type="checkbox"
checked={todo.completed}
onChange={async () => {
await onToggleTodo(todo.id)
refetch()
}}
style={{ cursor: 'pointer', margin: 13 }}
/>
<button
className="remove"
onClick={async () => {
await onDeleteTodo(todo.id)
refetch()
}}
>
remove
</button>
</h2>
<p>
<span style={textStyle}>{todo.content}</span>
{todo.completed && ' ✅ done'}
</p>
</li>
)
}
Example #2
Source File: TodoList.tsx From telefunc with MIT License | 6 votes |
function TodoList() {
const [todoItems, setTodoItems] = useState<Todo[]>([])
const fetch = async () => {
setTodoItems(await onGetTodos())
}
useEffect(() => {
fetch()
}, [])
return (
<>
<NewTodo refetch={fetch} />
<hr />
<ul>
{todoItems.map((todoItem) => (
<TodoItem key={todoItem.id} refetch={fetch} {...todoItem} />
))}
</ul>
</>
)
}