-
Notifications
You must be signed in to change notification settings - Fork 1
/
TodoItem.tsx
34 lines (31 loc) · 881 Bytes
/
TodoItem.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react'
type Props = TodoProps & {
updateTodo: (todo: ITodo) => void
deleteTodo: (_id: string) => void
}
const Todo: React.FC<Props> = ({ todo, updateTodo, deleteTodo }) => {
const checkTodo: string = todo.status ? `line-through` : ''
return (
<div className='Card'>
<div className='Card--text'>
<h1 className={checkTodo}>{todo.name}</h1>
<span className={checkTodo}>{todo.description}</span>
</div>
<div className='Card--button'>
<button
onClick={() => updateTodo(todo)}
className={todo.status ? `hide-button` : 'Card--button__done'}
>
Complete
</button>
<button
onClick={() => deleteTodo(todo._id)}
className='Card--button__delete'
>
Delete
</button>
</div>
</div>
)
}
export default Todo