Skip to content

Commit

Permalink
Adds resource hub reducers
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandihamza committed Jul 22, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent dfce1f2 commit d8667d9
Showing 2 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/state/reducers/index.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import feedbackReducer from './feedback';
import marketplaceReducer from './marketplace';
import interviewReducer from './interview';
import chatReducer from './chat';
import resourceHubReducer from './resourceHub';

const appReducer = combineReducers({
userReducer,
@@ -19,6 +20,7 @@ const appReducer = combineReducers({
marketplaceReducer,
interviewReducer,
chatReducer,
resourceHubReducer,
});

const rootReducer = (state, action) => {
60 changes: 60 additions & 0 deletions src/state/reducers/resourceHub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as types from '../actions/resourceHubActions';

const initialState = {
resources: null,
isLoading: false,
error: null,
submitResource: null,
updateResource: null,
};

function resourceHubReducer(state = initialState, action) {
switch (action.type) {
case types.GET_RESOURCE_START:
return {
...state,
isLoading: true,
};

case types.GET_RESOURCE_SUCCESS:
return {
...state,
isLoading: false,
resources: action.payload,
};

case types.GET_RESOURCE_ERROR:
return { ...state, error: action.payload, isLoading: false };

case types.SUBMIT_RESOURCE_START:
return { ...state, submitResource: action.payload };

case types.SUBMIT_RESOURCE_ERROR:
return { ...state, error: action.payload, isLoading: false };

case types.SUBMIT_RESOURCE_SUCCESS:
return {
...state,
isLoading: false,
resource: action.payload,
};

case types.UPDATE_RESOURCE_START:
return { ...state, updateResource: action.payload };

case types.UPDATE_RESOURCE_ERROR:
return { ...state, error: action.payload, isLoading: false };

case types.UPDATE_RESOURCE_SUCCESS:
return {
...state,
isLoading: false,
resource: action.payload,
};

default:
return state;
}
}

export default resourceHubReducer;

0 comments on commit d8667d9

Please sign in to comment.