|
@@ -10,20 +10,37 @@ const RESOLVED = 'RESOLVED';
|
|
|
const REJECTED = 'REJECTED';
|
|
|
|
|
|
const promiseReducer = (state, action) => {
|
|
|
- if (action.type === LOGIN || action.type === LOGOUT) {
|
|
|
- return {}
|
|
|
- }
|
|
|
- if (action.type === PROMISE) {
|
|
|
- return{
|
|
|
- ...state,
|
|
|
- [action.name]: {
|
|
|
- status: action.status,
|
|
|
- payload: (action.status === PENDING && state[action.name] && state[action.name].payload) || action.payload, // зачем эта проверка?
|
|
|
- error: action.error
|
|
|
+// if (action.type === LOGIN || action.type === LOGOUT) {
|
|
|
+// return {}
|
|
|
+// }
|
|
|
+// if (action.type === PROMISE) {
|
|
|
+// return{
|
|
|
+// ...state,
|
|
|
+// [action.name]: {
|
|
|
+// status: action.status,
|
|
|
+// payload: (action.status === PENDING && state[action.name] && state[action.name].payload) || action.payload, // зачем эта проверка?
|
|
|
+// error: action.error
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return state
|
|
|
+ switch(action.type) {
|
|
|
+ case LOGIN:
|
|
|
+ return {};
|
|
|
+ case LOGOUT:
|
|
|
+ return {};
|
|
|
+ case PROMISE:
|
|
|
+ return{
|
|
|
+ ...state,
|
|
|
+ [action.name]: {
|
|
|
+ status: action.status,
|
|
|
+ payload: (action.status === PENDING && state[action.name] && state[action.name].payload) || action.payload, // зачем эта проверка?
|
|
|
+ error: action.error
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ default:
|
|
|
+ return state;
|
|
|
}
|
|
|
-return state
|
|
|
}
|
|
|
|
|
|
const actionPromise = (name, promise) => {
|