@zeniai/client-epic-state 4.11.2 → 4.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,9 +2,9 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RootState } from '../../../../reducer';
|
|
4
4
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
-
import { fetchChargeCardList, updateChargeCardList, updateChargeCardListFailure } from './chargeCardListReducer';
|
|
5
|
+
import { fetchChargeCardList, updateChargeCardList, updateChargeCardListFailure, updateChargeCardListUIState } from './chargeCardListReducer';
|
|
6
6
|
import { updateChargeCards } from '../../../../entity/chargeCard/chargeCardReducer';
|
|
7
7
|
import { updateAllUsers } from '../../../../entity/user/userReducer';
|
|
8
8
|
import { updateUserRoles } from '../../../../entity/userRole/userRoleReducer';
|
|
9
|
-
export declare type ActionType = ReturnType<typeof fetchChargeCardList> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateChargeCardListFailure>;
|
|
10
|
-
export declare const fetchChargeCardListEpic: (actions$: ActionsObservable<ActionType>,
|
|
9
|
+
export declare type ActionType = ReturnType<typeof fetchChargeCardList> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateChargeCardListUIState> | ReturnType<typeof updateChargeCardListFailure>;
|
|
10
|
+
export declare const fetchChargeCardListEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -8,12 +8,20 @@ const chargeCardListReducer_1 = require("./chargeCardListReducer");
|
|
|
8
8
|
const chargeCardReducer_1 = require("../../../../entity/chargeCard/chargeCardReducer");
|
|
9
9
|
const userReducer_1 = require("../../../../entity/user/userReducer");
|
|
10
10
|
const userRoleReducer_1 = require("../../../../entity/userRole/userRoleReducer");
|
|
11
|
-
const
|
|
11
|
+
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
12
|
+
const fetchChargeCardListEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(chargeCardListReducer_1.fetchChargeCardList.match), (0, operators_1.switchMap)(() => {
|
|
12
13
|
return zeniAPI
|
|
13
14
|
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards?query=${encodeURIComponent(`{"is_include_total_cash_back":true, "is_include_unassigned_credit": true}`)}`)
|
|
14
15
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
15
16
|
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
16
|
-
|
|
17
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
|
|
18
|
+
const isChargeCardUser = currentTenant.userRole.includes('charge_card_user');
|
|
19
|
+
const actions = [];
|
|
20
|
+
if (isChargeCardUser) {
|
|
21
|
+
actions.push((0, chargeCardListReducer_1.updateChargeCardListUIState)({ uiState: { sortKey: 'cardName' } }));
|
|
22
|
+
}
|
|
23
|
+
actions.push((0, chargeCardReducer_1.updateChargeCards)(response.data.cards), (0, userReducer_1.updateAllUsers)({ users: response.data.users }), (0, userRoleReducer_1.updateUserRoles)(response.data.user_roles), (0, chargeCardListReducer_1.updateChargeCardList)({ chargeCardListPayload: response.data }));
|
|
24
|
+
return (0, rxjs_1.from)(actions);
|
|
17
25
|
}
|
|
18
26
|
else {
|
|
19
27
|
return (0, rxjs_1.of)((0, chargeCardListReducer_1.updateChargeCardListFailure)(response.status));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.3",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|