diff --git a/src/redux/actionTypes.js b/src/redux/actionTypes.js deleted file mode 100644 index 7aabf93..0000000 --- a/src/redux/actionTypes.js +++ /dev/null @@ -1,3 +0,0 @@ -export const ADD_TODO = "ADD_TODO"; -export const TOGGLE_TODO = "TOGGLE_TODO"; -export const SET_FILTER = "SET_FILTER"; diff --git a/src/redux/actions.js b/src/redux/actions.js deleted file mode 100644 index d005235..0000000 --- a/src/redux/actions.js +++ /dev/null @@ -1,18 +0,0 @@ -import { ADD_TODO, TOGGLE_TODO, SET_FILTER } from "./actionTypes"; - -let nextTodoId = 0; - -export const addTodo = content => ({ - type: ADD_TODO, - payload: { - id: ++nextTodoId, - content - } -}); - -export const toggleTodo = id => ({ - type: TOGGLE_TODO, - payload: { id } -}); - -export const setFilter = filter => ({ type: SET_FILTER, payload: { filter } }); diff --git a/src/redux/actions/index.js b/src/redux/actions/index.js deleted file mode 100644 index 7866814..0000000 --- a/src/redux/actions/index.js +++ /dev/null @@ -1,5 +0,0 @@ -const loAction = () => ({ - type: "login", -}); - -export { loAction }; diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js deleted file mode 100644 index b78a0e8..0000000 --- a/src/redux/reducers/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { combineReducers } from "redux"; - -import todos from "./todos"; - -export default combineReducers({ todos }); diff --git a/src/redux/reducers/login.js b/src/redux/reducers/login.js deleted file mode 100644 index fc9e459..0000000 --- a/src/redux/reducers/login.js +++ /dev/null @@ -1,33 +0,0 @@ -const initialState = { - currentUser: null, - token: null, - loginMessage: null, - config: null, -}; - -const loginReducer = (state = initialState, action) => { - switch (action.type) { - case "config_loaded": - return { ...state, config: action.payload }; - case "config_load_error": - return { ...state, config: null }; - case "users_logged_in": - return { - ...state, - token: action.payload.token, - currentUser: action.payload.currentUser, - }; - case "users_login_error": - if (action.payload.error && !action.payload.error.handled) { - return { - ...state, - loginMessage: "Wrong credentials! Please try again.", - }; - } - return state; - default: - return state; - } -}; - -export default loginReducer; diff --git a/src/redux/reducers/todos.js b/src/redux/reducers/todos.js deleted file mode 100644 index 5da1d10..0000000 --- a/src/redux/reducers/todos.js +++ /dev/null @@ -1,40 +0,0 @@ -import { ADD_TODO, TOGGLE_TODO } from "../actionTypes"; - -const initialState = { - allIds: [], - byIds: {}, -}; - -export default function (state = initialState, action) { - switch (action.type) { - case ADD_TODO: { - const { id, content } = action.payload; - return { - ...state, - allIds: [...state.allIds, id], - byIds: { - ...state.byIds, - [id]: { - content, - completed: false, - }, - }, - }; - } - case TOGGLE_TODO: { - const { id } = action.payload; - return { - ...state, - byIds: { - ...state.byIds, - [id]: { - ...state.byIds[id], - completed: !state.byIds[id].completed, - }, - }, - }; - } - default: - return state; - } -} diff --git a/src/redux/selectors.js b/src/redux/selectors.js deleted file mode 100644 index b50de2c..0000000 --- a/src/redux/selectors.js +++ /dev/null @@ -1,14 +0,0 @@ -export const getTodosState = (store) => store.todos; - -export const getTodoList = (store) => - getTodosState(store) ? getTodosState(store).allIds : []; - -export const getTodoById = (store, id) => - getTodosState(store) ? { ...getTodosState(store).byIds[id], id } : {}; - -/** - * example of a slightly more complex selector - * select from store combining information from multiple reducers - */ -export const getTodos = (store) => - getTodoList(store).map((id) => getTodoById(store, id)); diff --git a/src/redux/store.js b/src/redux/store.js deleted file mode 100644 index f02d47a..0000000 --- a/src/redux/store.js +++ /dev/null @@ -1,4 +0,0 @@ -import { createStore } from "redux"; -import rootReducer from "./reducers"; - -export default createStore(rootReducer); diff --git a/src/scenario/scenarios.js b/src/scenario/scenarios.js index 160b4e5..415a64d 100644 --- a/src/scenario/scenarios.js +++ b/src/scenario/scenarios.js @@ -38,8 +38,6 @@ import DeleteDialog from "../common/dialogs/delete-dialog"; import IconButton from "../common/buttons/icon-button"; import { connect } from "react-redux"; -import { addTodo } from "../redux/actions"; -import { getTodos } from "../redux/selectors"; class Scenarios extends Component { constructor(props) { @@ -397,12 +395,6 @@ const mapStateToProps = (state) => ({ todos: getTodos(state), // Assuming you have a selector called getTodos }); -// Map the actions to the component's props -const mapDispatchToProps = { - addTodo, -}; - export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps )(Container.create(fluxContainerConverter.convert(Scenarios)));