Removed REDUX
This commit is contained in:
parent
a716fa8122
commit
9c745be436
@ -1,3 +0,0 @@
|
||||
export const GET_MIGRATIONS = "GET_MIGRATIONS";
|
||||
export const DATA_LOADED = "DATA_LOADED";
|
||||
export const API_ERRORED = "API_ERRORED";
|
||||
@ -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);
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -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;
|
||||
@ -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;
|
||||
Reference in New Issue
Block a user