Ankilan/src/reducers/api-reducer.js

40 lines
856 B
JavaScript
Raw Normal View History

import {
SET_AVAILABLE_API,
2020-03-20 15:19:09 +00:00
SET_PARSED_DICTIONARY,
SET_YANDEX_DICTIONARY_RESPONSE,
} from '../constants/api-constants';
2020-03-13 20:45:31 +00:00
const initialState = {
word: '',
translatedObject: {},
wordSoundLink: '',
availableApi: {},
availableApiName: '',
yandexDictionaryInfo: [],
2020-03-18 19:58:12 +00:00
parsedDictionary: {},
2020-03-13 20:45:31 +00:00
};
2020-03-05 22:16:34 +00:00
const apiReducer = (state = initialState, action) => {
switch (action.type) {
case SET_YANDEX_DICTIONARY_RESPONSE:
return {
...state,
yandexDictionaryInfo: action.payload,
};
case SET_AVAILABLE_API:
return {
...state,
availableApi: action.payload,
availableApiName: action.payload.source,
};
2020-03-20 15:19:09 +00:00
case SET_PARSED_DICTIONARY:
return {
...state,
parsedDictionary: action.payload,
};
2020-03-05 22:16:34 +00:00
default:
return state;
}
};
export default apiReducer;