redux general changes - not relevant ATM it doesnt work
This commit is contained in:
parent
03ee5d6fa8
commit
9c9c584a84
@ -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";
|
||||||
|
|||||||
@ -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)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user