1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Removed old redux store

Signed-off-by: Andrii Podriez <andrey5577990@gmail.com>
This commit is contained in:
Andrii Podriez 2024-05-21 18:13:55 +02:00 committed by iripiri
parent 6cdc000e42
commit 7728f99da3
9 changed files with 1 additions and 131 deletions

View file

@ -1,3 +0,0 @@
export const ADD_TODO = "ADD_TODO";
export const TOGGLE_TODO = "TOGGLE_TODO";
export const SET_FILTER = "SET_FILTER";

View file

@ -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 } });

View file

@ -1,5 +0,0 @@
const loAction = () => ({
type: "login",
});
export { loAction };

View file

@ -1,5 +0,0 @@
import { combineReducers } from "redux";
import todos from "./todos";
export default combineReducers({ todos });

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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));

View file

@ -1,4 +0,0 @@
import { createStore } from "redux";
import rootReducer from "./reducers";
export default createStore(rootReducer);

View file

@ -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)));