mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
21 lines
417 B
JavaScript
21 lines
417 B
JavaScript
const todos = (state = [], action) => {
|
|
if (action.type == "ADD_TODO") {
|
|
return [
|
|
...state,
|
|
{
|
|
id: action.id,
|
|
text: action.text,
|
|
completed: false,
|
|
},
|
|
]
|
|
} else if (action.type == "TOGGLE_TODO") {
|
|
return state.map(todo =>
|
|
todo.id === action.id ? { ...todo, completed: !todo.completed } : todo,
|
|
)
|
|
} else {
|
|
return state
|
|
}
|
|
}
|
|
|
|
export default todos
|