import { useState, useReducer } from 'react'

function counterReducer(state, action) {
    switch (action.type) {
        case 'increment':
            return state + 1
        case 'decrement':
            return state - 1
        case 'reset':
            return 0
        case 'set_value':
            return action.value
        default:
            return state
    }
}

function Counter() {
    const [count, dispatch] = useReducer(counterReducer,0);
    
    return (
        <div>
            <span>Счетчик: {count}</span>
            <button onClick={()=> dispatch({type: 'increment'})}>+</button>
            <button onClick={()=> dispatch({type: 'decrement'})}>-</button>
            <button onClick={()=> dispatch({type: 'reset'})}>reset</button>
            <button onClick={()=> dispatch({type: 'set_value', value: 5})}>set 5</button>
        </div>
    )
}

function App() {
    const [tasks, setTasks] = useState([])
    const [filter, setFilter] = useState('all')
    const [sortBy,setSortBy] = useState('date')
    
    const addTask = newTask => {
        setTasks([...tasks,newTask])
    }
    
    
    
	return (
		<>
			{/* Добавьте тестовый контент для проверки */}
			<h1>Hello, React!</h1>
            <Counter />
		</>
	)
}

export default App
