redux general changes - not relevant ATM it doesnt work

This commit is contained in:
pepper committed 2021-01-19 23:59:38 -05:00
1 parent 03ee5d6fa8
commit 9c9c584a84
3 files changed
+10 -9

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
export const ADD_ARTICLE = "ADD_ARTICLE"; export const GET_MIGRATIONS = "GET_MIGRATIONS";
export const DATA_LOADED = "DATA_LOADED"; export const DATA_LOADED = "DATA_LOADED";
export const API_ERRORED = "API_ERRORED"; export const API_ERRORED = "API_ERRORED";
+2 -2
View File
@@ -1,4 +1,4 @@
import { ADD_ARTICLE } from "../constants/action-types"; import { GET_MIGRATIONS } from "../constants/action-types";
const forbiddenWords = ["spam", "money"]; const forbiddenWords = ["spam", "money"];
@@ -6,7 +6,7 @@ export function forbiddenWordsMiddleware({ dispatch }) {
return function (next) { return function (next) {
return function (action) { return function (action) {
// do your stuff // do your stuff
if (action.type === ADD_ARTICLE) { if (action.type === GET_MIGRATIONS) {
const foundWord = forbiddenWords.filter((word) => const foundWord = forbiddenWords.filter((word) =>
action.payload.title.includes(word) action.payload.title.includes(word)
); );
+7 -6
View File
@@ -1,20 +1,21 @@
import { ADD_ARTICLE, DATA_LOADED } from "../constants/action-types"; import { GET_MIGRATIONS, DATA_LOADED } from "../constants/action-types";
const initialState = { const initialState = {
articles: [], migs: [],
remoteArticles: [], timeslots: [],
error: false,
}; };
function rootReducer(state = initialState, action) { function rootReducer(state = initialState, action) {
if (action.type === ADD_ARTICLE) { if (action.type === GET_MIGRATIONS) {
return Object.assign({}, state, { return Object.assign({}, state, {
articles: state.articles.concat(action.payload), migs: state.migs.concat(action.payload),
}); });
} }
if (action.type === DATA_LOADED) { if (action.type === DATA_LOADED) {
return Object.assign({}, state, { return Object.assign({}, state, {
remoteArticles: state.remoteArticles.concat(action.payload), timeslots: state.timeslots.concat(action.payload),
}); });
} }
return state; return state;