const initialState = {
'Дела': {
id: 'Дела',
title: 'Дела',
lists: [
{
id: 'Дела/Тесты',
title: 'Тесты',
todos: [
{
id: 'Дела/Тесты/Открыть',
title: 'Открыть',
activ: true
}
]
}
]
}
};
const initialState = [{
id: 1,
name: "тест1"
},
{
id: 2,
name: "тест2"
}
]
function boardReducer(state = initialState, action) {
switch (action.type) {
case 'ADD_BOARD':
return [...state, {
id: Math.random(),
name: action.payload
}]
case 'EDIT_BOARD':
return state.map((item) => item.id === action.payload.id ? { ...item.action.payload.name
} : item)
case 'DELETE_BOARD':
return state.filter((item) => item.id !== action.payload)
default:
return state
}
}