Removed REDUX

This commit is contained in:
pepper 2021-01-27 23:45:05 -05:00
parent a716fa8122
commit 9c745be436
4 changed files with 0 additions and 61 deletions

View File

@ -1,3 +0,0 @@
export const GET_MIGRATIONS = "GET_MIGRATIONS";
export const DATA_LOADED = "DATA_LOADED";
export const API_ERRORED = "API_ERRORED";

View File

@ -1,21 +0,0 @@
import { GET_MIGRATIONS } from "../constants/action-types";
const forbiddenWords = ["spam", "money"];
export function forbiddenWordsMiddleware({ dispatch }) {
return function (next) {
return function (action) {
// do your stuff
if (action.type === GET_MIGRATIONS) {
const foundWord = forbiddenWords.filter((word) =>
action.payload.title.includes(word)
);
if (foundWord.length) {
return dispatch({ type: "FOUND_BAD_WORD" });
}
}
return next(action);
};
};
}

View File

@ -1,24 +0,0 @@
import { GET_MIGRATIONS, DATA_LOADED } from "../constants/action-types";
const initialState = {
migs: [],
timeslots: [],
error: false,
};
function rootReducer(state = initialState, action) {
if (action.type === GET_MIGRATIONS) {
return Object.assign({}, state, {
migs: state.migs.concat(action.payload),
});
}
if (action.type === DATA_LOADED) {
return Object.assign({}, state, {
timeslots: state.timeslots.concat(action.payload),
});
}
return state;
}
export default rootReducer;

View File

@ -1,13 +0,0 @@
import { createStore, applyMiddleware, compose } from "redux";
import rootReducer from "../reducers";
import { forbiddenWordsMiddleware } from "../middleware";
import thunk from "redux-thunk";
const storeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
rootReducer,
storeEnhancers(applyMiddleware(forbiddenWordsMiddleware, thunk))
);
export default store;