mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 23:57:49 +01:00
use api
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"extends": ["airbnb", "prettier"],
|
||||
"extends": ["airbnb", "plugin:jest/recommended"],
|
||||
"plugins": ["jest"],
|
||||
"rules": {
|
||||
"react/jsx-filename-extension": [
|
||||
1,
|
||||
|
||||
4769
package-lock.json
generated
4769
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -6,12 +6,14 @@
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.0-13",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.1.0-10",
|
||||
"@fortawesome/react-fontawesome": "0.1.0-10",
|
||||
"cross-fetch": "^2.2.0",
|
||||
"prop-types": "^15.6.1",
|
||||
"react": "^16.3.2",
|
||||
"react-dom": "^16.3.2",
|
||||
"react-redux": "^5.0.7",
|
||||
"react-scripts": "1.1.4",
|
||||
"redux": "^4.0.0"
|
||||
"redux": "^4.0.0",
|
||||
"redux-thunk": "^2.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
||||
140
src/actions.js
140
src/actions.js
@@ -1,7 +1,15 @@
|
||||
import fetch from "cross-fetch";
|
||||
|
||||
const API_ROOT = "http://localhost:4000";
|
||||
|
||||
export const ADD_ITEM = "ADD_ITEM";
|
||||
export const REMOVE_ITEM = "REMOVE_ITEM";
|
||||
export const TOGGLE_ITEM = "TOGGLE_ITEM";
|
||||
export const SET_VISIBILITY_FILTER = "SET_VISIBILITY_FILTER";
|
||||
export const RECIEVE_TODOS = "RECIEVE_TODOS";
|
||||
export const REQUEST_TODOS = "REQUEST_TODOS";
|
||||
export const INVALIDATE_TODOS = "INVALIDATE_TODOS";
|
||||
export const VALIDATE_TODOS = "VALIDATE_TODOS";
|
||||
|
||||
export const VisibilityFilters = {
|
||||
SHOW_ALL: "SHOW_ALL",
|
||||
@@ -9,18 +17,138 @@ export const VisibilityFilters = {
|
||||
SHOW_ACTIVE: "SHOW_ACTIVE"
|
||||
};
|
||||
|
||||
export function addItem(text) {
|
||||
return { type: ADD_ITEM, text };
|
||||
export function addItem(list, text) {
|
||||
return async function(dispatch, getState) {
|
||||
dispatch(invalidateTodos(list));
|
||||
const state = getState();
|
||||
const response = await fetch(
|
||||
`${API_ROOT}/lists/${state.lists.lists[list].slug}/todos`,
|
||||
{
|
||||
body: JSON.stringify({ text }),
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
method: "POST"
|
||||
}
|
||||
);
|
||||
const json = await response.json();
|
||||
const todo = json.data;
|
||||
dispatch(addTodoToList(list, todo));
|
||||
dispatch(validateTodos(list));
|
||||
};
|
||||
}
|
||||
|
||||
export function reomveItem(id) {
|
||||
return { type: REMOVE_ITEM, id };
|
||||
function addTodoToList(list, todo) {
|
||||
return { type: ADD_ITEM, list, todo };
|
||||
}
|
||||
|
||||
export function toggleItem(id) {
|
||||
return { type: TOGGLE_ITEM, id };
|
||||
export function removeItem(list, id) {
|
||||
return async function(dispatch) {
|
||||
dispatch(invalidateTodos(list));
|
||||
const response = await fetch(`${API_ROOT}/todos/${id}`, {
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
method: "DELETE"
|
||||
});
|
||||
const json = await response.json();
|
||||
const todo = json.data;
|
||||
dispatch(removeTodoFromList(list, id));
|
||||
dispatch(validateTodos(list));
|
||||
};
|
||||
}
|
||||
|
||||
function removeTodoFromList(list, id) {
|
||||
return { type: REMOVE_ITEM, list, id };
|
||||
}
|
||||
|
||||
export function toggleItem(list, id) {
|
||||
return async function(dispatch, getState) {
|
||||
dispatch(invalidateTodos(list));
|
||||
const state = getState();
|
||||
const listObj = state.lists.lists[list];
|
||||
const todoObj = listObj.todos.find(todo => todo.id === id);
|
||||
const completed = !todoObj.completed;
|
||||
const response = await fetch(`${API_ROOT}/todos/${id}`, {
|
||||
body: JSON.stringify({ completed }),
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
method: "PATCH"
|
||||
});
|
||||
const json = await response.json();
|
||||
const todo = json.data;
|
||||
dispatch(toggleItemInList(list, id));
|
||||
dispatch(validateTodos(list));
|
||||
};
|
||||
}
|
||||
|
||||
function toggleItemInList(list, id) {
|
||||
return { type: TOGGLE_ITEM, list, id };
|
||||
}
|
||||
|
||||
export function setVisibilityFilter(filter) {
|
||||
return { type: SET_VISIBILITY_FILTER, filter };
|
||||
}
|
||||
|
||||
function requestTodos(list) {
|
||||
return { type: REQUEST_TODOS, list };
|
||||
}
|
||||
function recieveTodos(list, todos) {
|
||||
return { type: RECIEVE_TODOS, list, todos };
|
||||
}
|
||||
function invalidateTodos(list) {
|
||||
return { type: INVALIDATE_TODOS, list };
|
||||
}
|
||||
function validateTodos(list) {
|
||||
return { type: VALIDATE_TODOS, list };
|
||||
}
|
||||
|
||||
export function fetchTodos(list) {
|
||||
return async function(dispatch) {
|
||||
dispatch(requestTodos(list));
|
||||
const response = await fetch(API_ROOT + "/todos");
|
||||
const json = await response.json();
|
||||
const todos = json.data;
|
||||
dispatch(recieveTodos(list, todos));
|
||||
};
|
||||
}
|
||||
|
||||
export const ADD_LIST = "ADD_LIST";
|
||||
export const REMOVE_LIST = "REMOVE_LIST";
|
||||
export const RECIEVE_LISTS = "RECIEVE_LISTS";
|
||||
export const REQUEST_LISTS = "REQUEST_LISTS";
|
||||
export const INVALIDATE_LISTS = "INVALIDATE_LISTS";
|
||||
export const VALIDATE_LISTS = "VALIDATE_LISTS";
|
||||
export const CHANGE_LIST = "CHANGE_LIST";
|
||||
|
||||
function requestLists() {
|
||||
return { type: REQUEST_LISTS };
|
||||
}
|
||||
function recieveLists(lists) {
|
||||
return { type: RECIEVE_LISTS, lists };
|
||||
}
|
||||
function invalidateLists() {
|
||||
return { type: INVALIDATE_LISTS };
|
||||
}
|
||||
function validateLists() {
|
||||
return { type: VALIDATE_LISTS };
|
||||
}
|
||||
function changeList(list) {
|
||||
return { type: CHANGE_LIST, list };
|
||||
}
|
||||
|
||||
export function fetchLists() {
|
||||
return async function(dispatch, getState) {
|
||||
dispatch(requestLists());
|
||||
const response = await fetch(API_ROOT + "/lists");
|
||||
const json = await response.json();
|
||||
const lists = json.data;
|
||||
const listsObj = lists.reduce((obj, list) => {
|
||||
obj[list.id] = list;
|
||||
return obj;
|
||||
}, {});
|
||||
dispatch(recieveLists(listsObj));
|
||||
dispatch(changeList(listsObj[Object.keys(listsObj)[0]].id));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class Item extends React.Component {
|
||||
|
||||
Item.propTypes = {
|
||||
item: PropTypes.shape({
|
||||
id: PropTypes.number.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
text: PropTypes.string.isRequired,
|
||||
completed: PropTypes.bool.isRequired
|
||||
}).isRequired,
|
||||
|
||||
@@ -8,8 +8,8 @@ export default function ItemsContainer(props) {
|
||||
<Item
|
||||
key={item.id}
|
||||
item={item}
|
||||
onClick={() => props.onItemClick(item.id)}
|
||||
handleDelete={() => props.handleDelete(item.id)}
|
||||
onClick={() => props.onItemClick(item.list, item.id)}
|
||||
handleDelete={() => props.handleDelete(item.list, item.id)}
|
||||
/>
|
||||
));
|
||||
return <ul id="list">{items}</ul>;
|
||||
@@ -18,7 +18,7 @@ export default function ItemsContainer(props) {
|
||||
ItemsContainer.propTypes = {
|
||||
items: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
id: PropTypes.number.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
text: PropTypes.string.isRequired,
|
||||
completed: PropTypes.bool.isRequired
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@ import { addItem, VisibilityFilters } from "../actions";
|
||||
const InputContainer = props => (
|
||||
<Input
|
||||
inputBottomBorder={props.inputBottomBorder}
|
||||
onClick={text => props.dispatch(addItem(text))}
|
||||
onClick={text => props.dispatch(addItem(props.list, text))}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -31,9 +31,20 @@ InputContainer.propTypes = {
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const list = state.lists.list;
|
||||
if (!list) {
|
||||
return {
|
||||
inputBottomBorder: false
|
||||
};
|
||||
}
|
||||
const listItems = state.lists.lists[list].todos;
|
||||
if (!listItems) {
|
||||
return { list, inputBottomBorder: false };
|
||||
}
|
||||
return {
|
||||
list,
|
||||
inputBottomBorder:
|
||||
getVisibleItems(state.items, state.visibilityFilter).length !== 0
|
||||
getVisibleItems(listItems, state.visibilityFilter).length !== 0
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { connect } from "react-redux";
|
||||
import TodoList from "../components/TodoList";
|
||||
import { toggleItem, reomveItem, VisibilityFilters } from "../actions";
|
||||
import { toggleItem, removeItem, VisibilityFilters } from "../actions";
|
||||
|
||||
function getVisibleItems(items, filter) {
|
||||
switch (filter) {
|
||||
@@ -16,15 +16,31 @@ function getVisibleItems(items, filter) {
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const stub = {
|
||||
list,
|
||||
items: [],
|
||||
dirty: true
|
||||
};
|
||||
const list = state.lists.list;
|
||||
const listObj = state.lists.lists[list];
|
||||
if (!list) {
|
||||
return stub;
|
||||
}
|
||||
const listItems = state.lists.lists[list].todos;
|
||||
if (!listItems) {
|
||||
return stub;
|
||||
}
|
||||
return {
|
||||
items: getVisibleItems(state.items, state.visibilityFilter)
|
||||
list,
|
||||
items: getVisibleItems(listItems, state.visibilityFilter),
|
||||
dirty: listObj.dirty
|
||||
};
|
||||
}
|
||||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
onItemClick: id => dispatch(toggleItem(id)),
|
||||
handleDelete: id => dispatch(reomveItem(id))
|
||||
onItemClick: (list, id) => dispatch(toggleItem(list, id)),
|
||||
handleDelete: (list, id) => dispatch(removeItem(list, id))
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Provider } from "react-redux";
|
||||
import { createStore } from "redux";
|
||||
import "./index.css";
|
||||
import { createStore, applyMiddleware } from "redux";
|
||||
import App from "./App";
|
||||
import registerServiceWorker from "./registerServiceWorker";
|
||||
import todoApp from "./reducers";
|
||||
import thunk from "redux-thunk";
|
||||
import { fetchLists } from "./actions";
|
||||
|
||||
const store = createStore(todoApp);
|
||||
const store = createStore(todoApp, applyMiddleware(thunk));
|
||||
store.dispatch(fetchLists());
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
@@ -15,4 +17,5 @@ ReactDOM.render(
|
||||
</Provider>,
|
||||
document.getElementById("root")
|
||||
);
|
||||
|
||||
registerServiceWorker();
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
||||
<g fill="#61DAFB">
|
||||
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
||||
<circle cx="420.9" cy="296.5" r="45.7"/>
|
||||
<path d="M520.5 78.1z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,10 +1,10 @@
|
||||
import { combineReducers } from "redux";
|
||||
|
||||
import items from "./items";
|
||||
import lists from "./lists";
|
||||
import visibilityFilter from "./visibilityFilter";
|
||||
|
||||
const todoApp = combineReducers({
|
||||
items,
|
||||
lists,
|
||||
visibilityFilter
|
||||
});
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import { ADD_ITEM, REMOVE_ITEM, TOGGLE_ITEM } from "../actions";
|
||||
|
||||
export default function items(state = [], action) {
|
||||
switch (action.type) {
|
||||
case ADD_ITEM:
|
||||
return [
|
||||
...state,
|
||||
{
|
||||
id: Math.floor(Math.random() * 100),
|
||||
text: action.text,
|
||||
completed: false
|
||||
}
|
||||
];
|
||||
case REMOVE_ITEM:
|
||||
return state.filter(item => item.id !== action.id);
|
||||
case TOGGLE_ITEM: {
|
||||
const itemsArray = [...state];
|
||||
itemsArray.some((item, i) => {
|
||||
if (item.id === action.id) {
|
||||
const newItem = { ...item };
|
||||
newItem.completed = !item.completed;
|
||||
itemsArray[i] = newItem;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return itemsArray;
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
64
src/reducers/list.js
Normal file
64
src/reducers/list.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import {
|
||||
ADD_ITEM,
|
||||
REMOVE_ITEM,
|
||||
TOGGLE_ITEM,
|
||||
RECIEVE_TODOS,
|
||||
REQUEST_TODOS,
|
||||
INVALIDATE_TODOS,
|
||||
VALIDATE_TODOS
|
||||
} from "../actions";
|
||||
|
||||
export default function items(
|
||||
state = { dirty: true, fetching: false, todos: [] },
|
||||
action
|
||||
) {
|
||||
switch (action.type) {
|
||||
case RECIEVE_TODOS:
|
||||
return {
|
||||
...state,
|
||||
dirty: false,
|
||||
fetching: false,
|
||||
todos: action.todos
|
||||
};
|
||||
case ADD_ITEM:
|
||||
return {
|
||||
...state,
|
||||
todos: [...state.todos, action.todo]
|
||||
};
|
||||
case INVALIDATE_TODOS:
|
||||
return {
|
||||
...state,
|
||||
dirty: true
|
||||
};
|
||||
case VALIDATE_TODOS:
|
||||
return {
|
||||
...state,
|
||||
dirty: false
|
||||
};
|
||||
case REQUEST_TODOS:
|
||||
return {
|
||||
...state,
|
||||
fetching: true
|
||||
};
|
||||
case REMOVE_ITEM:
|
||||
return {
|
||||
...state,
|
||||
todos: state.todos.filter(item => item.id !== action.id)
|
||||
};
|
||||
case TOGGLE_ITEM: {
|
||||
const itemsArray = [...state.todos];
|
||||
itemsArray.some((item, i) => {
|
||||
if (item.id === action.id) {
|
||||
const newItem = { ...item };
|
||||
newItem.completed = !item.completed;
|
||||
itemsArray[i] = newItem;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return { ...state, todos: itemsArray };
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
78
src/reducers/lists.js
Normal file
78
src/reducers/lists.js
Normal file
@@ -0,0 +1,78 @@
|
||||
import {
|
||||
CHANGE_LIST,
|
||||
INVALIDATE_LISTS,
|
||||
VALIDATE_LISTS,
|
||||
REQUEST_LISTS,
|
||||
RECIEVE_TODOS,
|
||||
ADD_ITEM,
|
||||
INVALIDATE_TODOS,
|
||||
VALIDATE_TODOS,
|
||||
REQUEST_TODOS,
|
||||
REMOVE_ITEM,
|
||||
TOGGLE_ITEM,
|
||||
RECIEVE_LISTS,
|
||||
ADD_LIST,
|
||||
REMOVE_LIST
|
||||
} from "../actions";
|
||||
|
||||
import list from "./list";
|
||||
|
||||
export default function lists(
|
||||
state = { dirty: true, fetching: false, lists: {} },
|
||||
action
|
||||
) {
|
||||
switch (action.type) {
|
||||
case CHANGE_LIST:
|
||||
return { ...state, list: action.list };
|
||||
case RECIEVE_LISTS:
|
||||
return {
|
||||
...state,
|
||||
dirty: false,
|
||||
fetching: false,
|
||||
lists: action.lists
|
||||
};
|
||||
case ADD_LIST:
|
||||
return {
|
||||
...state,
|
||||
lists: { ...state.lists, [action.list.id]: action.list }
|
||||
};
|
||||
case REMOVE_LIST:
|
||||
const newLists = { ...state.lists };
|
||||
delete newLists[action.list];
|
||||
return {
|
||||
...state,
|
||||
lists: newLists
|
||||
};
|
||||
case INVALIDATE_LISTS:
|
||||
return {
|
||||
...state,
|
||||
dirty: true
|
||||
};
|
||||
case VALIDATE_LISTS:
|
||||
return {
|
||||
...state,
|
||||
dirty: false
|
||||
};
|
||||
case REQUEST_LISTS:
|
||||
return {
|
||||
...state,
|
||||
fetching: true
|
||||
};
|
||||
case RECIEVE_TODOS:
|
||||
case ADD_ITEM:
|
||||
case INVALIDATE_TODOS:
|
||||
case VALIDATE_TODOS:
|
||||
case REQUEST_TODOS:
|
||||
case REMOVE_ITEM:
|
||||
case TOGGLE_ITEM:
|
||||
return {
|
||||
...state,
|
||||
lists: {
|
||||
...state.lists,
|
||||
[action.list]: list(state.lists[action.list], action)
|
||||
}
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user