Skip to content

Commit 00e035b

Browse files
committed
Add consumable purchase status actions
1 parent 6f101ba commit 00e035b

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/constants/bmdashboard/consumableConstants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ export const SET_CONSUMABLES = 'SET_CONSUMABLES';
22
export const POST_UPDATE_CONSUMABLE_START = 'POST_UPDATE_CONSUMABLE_START';
33
export const POST_UPDATE_CONSUMABLE_END = 'POST_UPDATE_CONSUMABLE_END';
44
export const POST_UPDATE_CONSUMABLE_ERROR = 'POST_UPDATE_CONSUMABLE_ERROR';
5+
6+
export const UPDATE_CONSUMABLE_STATUS_START = 'UPDATE_CONSUMABLE_STATUS_START';
7+
export const UPDATE_CONSUMABLE_STATUS_END = 'UPDATE_CONSUMABLE_STATUS_END';
8+
export const UPDATE_CONSUMABLE_STATUS_ERROR = 'UPDATE_CONSUMABLE_STATUS_ERROR';
9+
510
export default SET_CONSUMABLES;

src/reducers/bmdashboard/consumablesReducer.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import {
33
POST_UPDATE_CONSUMABLE_START,
44
POST_UPDATE_CONSUMABLE_END,
55
POST_UPDATE_CONSUMABLE_ERROR,
6+
UPDATE_CONSUMABLE_STATUS_START,
7+
UPDATE_CONSUMABLE_STATUS_END,
8+
UPDATE_CONSUMABLE_STATUS_ERROR,
69
} from '../../constants/bmdashboard/consumableConstants';
710

811
const defaultState = {
@@ -17,6 +20,11 @@ const defaultState = {
1720
result: null,
1821
error: undefined,
1922
},
23+
updateConsumableStatus: {
24+
loading: false,
25+
result: null,
26+
error: undefined,
27+
},
2028
};
2129

2230
// eslint-disable-next-line import/prefer-default-export, default-param-last
@@ -58,6 +66,29 @@ export const consumablesReducer = (consumables = defaultState, action) => {
5866
consumables.updateConsumables = obj;
5967
return { ...consumables };
6068
}
69+
case UPDATE_CONSUMABLE_STATUS_START: {
70+
// eslint-disable-next-line no-param-reassign
71+
consumables.updateConsumableStatus = { loading: true, result: null, error: undefined };
72+
return { ...consumables };
73+
}
74+
case UPDATE_CONSUMABLE_STATUS_END: {
75+
// eslint-disable-next-line no-param-reassign
76+
consumables.updateConsumableStatus = {
77+
loading: false,
78+
result: action.payload,
79+
error: false,
80+
};
81+
return { ...consumables };
82+
}
83+
case UPDATE_CONSUMABLE_STATUS_ERROR: {
84+
// eslint-disable-next-line no-param-reassign
85+
consumables.updateConsumableStatus = {
86+
loading: false,
87+
result: action.payload,
88+
error: true,
89+
};
90+
return { ...consumables };
91+
}
6192
default:
6293
return consumables;
6394
}

0 commit comments

Comments
 (0)