@omegabigdata/honoplay-redux-helper
Version:
honoplay-redux-helper
77 lines (72 loc) • 2.08 kB
JavaScript
import {
FETCHING_QUESTION_DIFFICULTY_LIST,
FETCH_QUESTION_DIFFICULTY_LIST_SUCCESS,
FETCH_QUESTION_DIFFICULTY_LIST_FAILED,
FETCHING_QUESTION_DIFFICULTY,
FETCH_QUESTION_DIFFICULTY_SUCCESS,
FETCH_QUESTION_DIFFICULTY_FAILED
} from '../helpers/ActionTypes/QuestionDifficulty';
const QUESTION_DIFFICULTY_LIST_INITIAL_STATE = {
isQuestionDifficultyListLoading: false,
questionDifficulties: null,
errorQuestionDifficultyList: null
};
const QUESTION_DIFFICULTY_INITIAL_STATE = {
isQuestionDifficultyLoading: false,
questionDifficulty: null,
errorQuestionDifficulty: null
};
export const questionDifficultyListReducers = (
state = QUESTION_DIFFICULTY_LIST_INITIAL_STATE,
action
) => {
switch (action.type) {
case FETCHING_QUESTION_DIFFICULTY_LIST:
return {
...state,
isQuestionDifficultyListLoading: true,
errorQuestionDifficultyList: null
};
case FETCH_QUESTION_DIFFICULTY_LIST_SUCCESS:
return {
...state,
isQuestionDifficultyListLoading: false,
questionDifficulties: action.data
};
case FETCH_QUESTION_DIFFICULTY_LIST_FAILED:
return {
...state,
isQuestionDifficultyListLoading: false,
errorQuestionDifficultyList: action.data.error
};
default:
return state;
}
};
export const questionDifficultyReducers = (
state = QUESTION_DIFFICULTY_INITIAL_STATE,
action
) => {
switch (action.type) {
case FETCHING_QUESTION_DIFFICULTY:
return {
...state,
isQuestionDifficultyLoading: true,
errorQuestionDifficulty: null
};
case FETCH_QUESTION_DIFFICULTY_SUCCESS:
return {
...state,
isQuestionDifficultyLoading: false,
questionDifficulty: action.data
};
case FETCH_QUESTION_DIFFICULTY_FAILED:
return {
...state,
isQuestionDifficultyLoading: false,
errorQuestionDifficulty: action.data.error
};
default:
return state;
}
};