import { useReducer } from 'react'
import AddTask from './AddTask.js'
import TaskList from './TaskList.js'
let nextId = 3
const initialTasks = [
{ id: 0, text: 'Philosopher’s Path', done: true },
{ id: 1, text: 'Visit the temple', done: false },
{ id: 2, text: 'Drink matcha', done: false },
]
export default function TaskBoard() {
const [tasks, dispatch] = useReducer(tasksReducer, initialTasks)
function handleAddTask(text) {
dispatch({
type: 'added',
id: nextId++,
text: text,
})
}
function handleChangeTask(task) {
dispatch({
type: 'changed',
task: task,
})
}
function handleDeleteTask(taskId) {
dispatch({
type: 'deleted',
id: taskId,
})
}