From 9c9c584a849de5e19e281837fdf0ed5768e00ba1 Mon Sep 17 00:00:00 2001 From: pepper Date: Tue, 19 Jan 2021 23:59:38 -0500 Subject: [PATCH] redux general changes - not relevant ATM it doesnt work --- src/redux/constants/action-types.js | 2 +- src/redux/middleware/index.js | 4 ++-- src/redux/reducers/index.js | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/redux/constants/action-types.js b/src/redux/constants/action-types.js index 2cd04ee..8a9b034 100644 --- a/src/redux/constants/action-types.js +++ b/src/redux/constants/action-types.js @@ -1,3 +1,3 @@ -export const ADD_ARTICLE = "ADD_ARTICLE"; +export const GET_MIGRATIONS = "GET_MIGRATIONS"; export const DATA_LOADED = "DATA_LOADED"; export const API_ERRORED = "API_ERRORED"; diff --git a/src/redux/middleware/index.js b/src/redux/middleware/index.js index c2e8e83..ce7b31a 100644 --- a/src/redux/middleware/index.js +++ b/src/redux/middleware/index.js @@ -1,4 +1,4 @@ -import { ADD_ARTICLE } from "../constants/action-types"; +import { GET_MIGRATIONS } from "../constants/action-types"; const forbiddenWords = ["spam", "money"]; @@ -6,7 +6,7 @@ export function forbiddenWordsMiddleware({ dispatch }) { return function (next) { return function (action) { // do your stuff - if (action.type === ADD_ARTICLE) { + if (action.type === GET_MIGRATIONS) { const foundWord = forbiddenWords.filter((word) => action.payload.title.includes(word) ); diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js index b0c6c83..b6ea923 100644 --- a/src/redux/reducers/index.js +++ b/src/redux/reducers/index.js @@ -1,20 +1,21 @@ -import { ADD_ARTICLE, DATA_LOADED } from "../constants/action-types"; +import { GET_MIGRATIONS, DATA_LOADED } from "../constants/action-types"; const initialState = { - articles: [], - remoteArticles: [], + migs: [], + timeslots: [], + error: false, }; function rootReducer(state = initialState, action) { - if (action.type === ADD_ARTICLE) { + if (action.type === GET_MIGRATIONS) { return Object.assign({}, state, { - articles: state.articles.concat(action.payload), + migs: state.migs.concat(action.payload), }); } if (action.type === DATA_LOADED) { return Object.assign({}, state, { - remoteArticles: state.remoteArticles.concat(action.payload), + timeslots: state.timeslots.concat(action.payload), }); } return state;