@zeniai/client-epic-state 5.0.81-betaAR3 → 5.0.81-betaAS1
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.
- package/lib/entity/approvalRule/approvalRulePayload.d.ts +5 -34
- package/lib/entity/approvalRule/approvalRulePayload.js +10 -130
- package/lib/entity/approvalRule/approvalRuleSelector.d.ts +1 -25
- package/lib/entity/approvalRule/approvalRuleSelector.js +0 -40
- package/lib/entity/approvalRule/approvalRuleState.d.ts +7 -59
- package/lib/entity/tenant/tenantPayload.d.ts +2 -0
- package/lib/entity/tenant/tenantReducer.d.ts +1 -1
- package/lib/entity/tenant/tenantReducer.js +15 -3
- package/lib/entity/tenant/tenantState.d.ts +2 -0
- package/lib/epic.d.ts +2 -1
- package/lib/epic.js +2 -1
- package/lib/esm/entity/approvalRule/approvalRulePayload.js +10 -130
- package/lib/esm/entity/approvalRule/approvalRuleSelector.js +0 -35
- package/lib/esm/entity/tenant/tenantReducer.js +14 -2
- package/lib/esm/epic.js +2 -1
- package/lib/esm/index.js +6 -7
- package/lib/esm/view/dashboard/dashboardReducer.js +1 -5
- package/lib/esm/view/dashboard/dashboardSelector.js +1 -2
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +11 -29
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -11
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -9
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +7 -11
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +4 -14
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -121
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -7
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -11
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -9
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -11
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +4 -14
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +10 -28
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/treasurySetupViewReducer.js +23 -1
- package/lib/index.d.ts +7 -8
- package/lib/index.js +32 -38
- package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.js +2 -6
- package/lib/view/dashboard/dashboardSelector.d.ts +0 -1
- package/lib/view/dashboard/dashboardSelector.js +1 -2
- package/lib/view/dashboard/dashboardState.d.ts +0 -1
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +3 -7
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +11 -29
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -11
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -9
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -10
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -13
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -48
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +17 -123
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +5 -31
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -7
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -11
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -9
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -10
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +3 -13
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +3 -7
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +10 -28
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/treasurySetupViewReducer.d.ts +1 -1
- package/lib/view/spendManagement/treasury/treasurySetUp/treasurySetupViewReducer.js +24 -2
- package/lib/view/spendManagement/treasury/treasurySetUp/treasurySetupViewState.d.ts +1 -0
- package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
- package/package.json +2 -1
|
@@ -42,7 +42,7 @@ const tenantSelector = createSelector(getTenantsByCheckInDateSelector, getCurren
|
|
|
42
42
|
export const getDashboard = createSelector(tenantSelector, getCardBalance, getCashBalance, getOperatingExpensesForLast5Periods, getRevenueForLast4Periods, getTop6Expenses, getNetBurnOrIncomeForLast4Periods, getNetBurnOrIncomeStoryCard, getCashPositionLast5Periods, getCashInCashOutLast4Periods, getInsights, getCompanyPassportView, getTasksCardReport, getBillPayCardReport, getReimbursementCardReport, apAgingSelector, arAgingSelector, getZeniAccountsPromoCard, getRewardsPlanCard, getDashboardCardsOrdered, (state) => {
|
|
43
43
|
const currentTenant = getCurrentTenant(state);
|
|
44
44
|
return getMonthEndCloseChecksViewByTenantId(state, currentTenant.tenantId);
|
|
45
|
-
}, (state) => state.tenantState, (_state, additionalExcludedReports) => additionalExcludedReports, (_state, _additionalExcludedReports, signedInUser) => signedInUser, (_state, _excluded, _signedInUser, isExpenseAutomationFeatureEnabledV2) => isExpenseAutomationFeatureEnabledV2, (_state, _excluded, _signedInUser, _enabledV2, isExpenseAutomationFeatureEnabled) => isExpenseAutomationFeatureEnabled, (_state, _excluded, _signedInUser, _enabledV2, _enabled, isTreasuryFeatureEnabled) => isTreasuryFeatureEnabled, (
|
|
45
|
+
}, (state) => state.tenantState, (_state, additionalExcludedReports) => additionalExcludedReports, (_state, _additionalExcludedReports, signedInUser) => signedInUser, (_state, _excluded, _signedInUser, isExpenseAutomationFeatureEnabledV2) => isExpenseAutomationFeatureEnabledV2, (_state, _excluded, _signedInUser, _enabledV2, isExpenseAutomationFeatureEnabled) => isExpenseAutomationFeatureEnabled, (_state, _excluded, _signedInUser, _enabledV2, _enabled, isTreasuryFeatureEnabled) => isTreasuryFeatureEnabled, (tenants, cardBalance, cashBalance, opEx, revenue, topEx, netBurnOrIncome, netBurnOrIncomeStoryCard, cashPosition, cashInCashOut, insightsView, companyPassportView, tasksCard, billPayCard, reimbursementCard, apAgingReport, arAgingReport, zeniAccountsPromoCard, rewardsPlanCard, cards, monthEndCloseChecksView, tenantState, additionalExcludedReports, signedInUser, isExpenseAutomationFeatureEnabledV2, isExpenseAutomationFeatureEnabled, isTreasuryFeatureEnabled) => {
|
|
46
46
|
const isReimbursementFeatureEnabled = tenants.currentTenant.company?.featuresActivationInfo
|
|
47
47
|
.isReimbursementFeatureEnabled;
|
|
48
48
|
const isBillPayFeatureEnabled = tenants.currentTenant.company?.featuresActivationInfo
|
|
@@ -273,6 +273,5 @@ export const getDashboard = createSelector(tenantSelector, getCardBalance, getCa
|
|
|
273
273
|
...tenants,
|
|
274
274
|
reportsInOrder,
|
|
275
275
|
cardsForDashboardUI: cardsCopy,
|
|
276
|
-
isTreasuryVideoClosed,
|
|
277
276
|
};
|
|
278
277
|
});
|
|
@@ -26,11 +26,8 @@ const billPaySetupApproverView = createSlice({
|
|
|
26
26
|
draft.fetchState = 'In-Progress';
|
|
27
27
|
draft.error = undefined;
|
|
28
28
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// v2 endpoint in the fetch epic.
|
|
32
|
-
prepare(cacheOverride = false, includeUserRoles = true, useV3 = false) {
|
|
33
|
-
return { payload: { cacheOverride, includeUserRoles, useV3 } };
|
|
29
|
+
prepare(cacheOverride = false, includeUserRoles = true) {
|
|
30
|
+
return { payload: { cacheOverride, includeUserRoles } };
|
|
34
31
|
},
|
|
35
32
|
},
|
|
36
33
|
fetchBillPaySetupApproverViewSuccess: {
|
|
@@ -115,11 +112,8 @@ const billPaySetupApproverView = createSlice({
|
|
|
115
112
|
error: undefined,
|
|
116
113
|
};
|
|
117
114
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// can pick the v1 vs v2 endpoint.
|
|
121
|
-
prepare(approvalRuleId, useV3 = false) {
|
|
122
|
-
return { payload: { approvalRuleId, useV3 } };
|
|
115
|
+
prepare(approvalRuleId) {
|
|
116
|
+
return { payload: { approvalRuleId } };
|
|
123
117
|
},
|
|
124
118
|
},
|
|
125
119
|
deleteBillPayApprovalRuleSuccess: {
|
|
@@ -151,25 +145,13 @@ const billPaySetupApproverView = createSlice({
|
|
|
151
145
|
};
|
|
152
146
|
},
|
|
153
147
|
},
|
|
154
|
-
saveBillPaySetupApproverViewUpdates
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
162
|
-
reducer(draft, _action) {
|
|
163
|
-
if (draft.billPaySetupApproverViewUpdateData != null) {
|
|
164
|
-
draft.billPaySetupApproverViewUpdateData.updateStatus = {
|
|
165
|
-
fetchState: 'In-Progress',
|
|
166
|
-
error: undefined,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
prepare(useV3) {
|
|
171
|
-
return { payload: { useV3 } };
|
|
172
|
-
},
|
|
148
|
+
saveBillPaySetupApproverViewUpdates(draft) {
|
|
149
|
+
if (draft.billPaySetupApproverViewUpdateData != null) {
|
|
150
|
+
draft.billPaySetupApproverViewUpdateData.updateStatus = {
|
|
151
|
+
fetchState: 'In-Progress',
|
|
152
|
+
error: undefined,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
173
155
|
},
|
|
174
156
|
saveBillPaySetupApproverViewUpdatesSuccess: {
|
|
175
157
|
reducer(draft, action) {
|
|
@@ -6,18 +6,9 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { deleteBillPayApprovalRule, deleteBillPayApprovalRuleFailure, deleteBillPayApprovalRuleSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
8
|
export const deleteBillPayApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteBillPayApprovalRule.match), switchMap((action) => {
|
|
9
|
-
const { approvalRuleId
|
|
10
|
-
// Approval Rules 3.0 — flag-gated endpoint selection.
|
|
11
|
-
// Explicit `=== true` keeps `strict-boolean-expressions` happy
|
|
12
|
-
// when RTK's payload type widens to `any` in some configs.
|
|
13
|
-
const endpoint = useV3 === true
|
|
14
|
-
? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
15
|
-
`https://dev.api.zeni.ai/version/approval/tarun/1.0/bill-pay/approval-rules-v2`
|
|
16
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
9
|
+
const { approvalRuleId } = action.payload;
|
|
17
10
|
return zeniAPI
|
|
18
|
-
.deleteAndGetJSON(
|
|
19
|
-
approval_rule_id: approvalRuleId,
|
|
20
|
-
})
|
|
11
|
+
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`, { approval_rule_id: approvalRuleId })
|
|
21
12
|
.pipe(mergeMap((response) => {
|
|
22
13
|
if (isSuccessResponse(response) && response.data != null) {
|
|
23
14
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -6,7 +6,7 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { fetchBillPaySetupApproverView, fetchBillPaySetupApproverViewFailure, fetchBillPaySetupApproverViewSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
8
|
export const fetchBillPaySetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBillPaySetupApproverView.match), switchMap((action) => {
|
|
9
|
-
const { cacheOverride
|
|
9
|
+
const { cacheOverride } = action.payload;
|
|
10
10
|
const { billPaySetupApproverViewState, approvalRuleState } = state$.value;
|
|
11
11
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, billPaySetupApproverViewState.approvalRuleIds);
|
|
12
12
|
if (cacheOverride === true ||
|
|
@@ -14,14 +14,9 @@ export const fetchBillPaySetupApproverViewEpic = (actions$, state$, zeniAPI) =>
|
|
|
14
14
|
billPaySetupApproverViewState.approvalRuleIds.length ||
|
|
15
15
|
(billPaySetupApproverViewState.hasValidState() === false &&
|
|
16
16
|
billPaySetupApproverViewState.fetchState !== 'In-Progress')) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const endpoint = useV3 === true
|
|
21
|
-
? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
22
|
-
`https://dev.api.zeni.ai/version/approval/tarun/1.0/bill-pay/approval-rules-v2`
|
|
23
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
24
|
-
return zeniAPI.getJSON(endpoint).pipe(mergeMap((response) => {
|
|
17
|
+
return zeniAPI
|
|
18
|
+
.getJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`)
|
|
19
|
+
.pipe(mergeMap((response) => {
|
|
25
20
|
if (isSuccessResponse(response) && response.data != null) {
|
|
26
21
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
27
22
|
const actions = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import {
|
|
3
|
+
import { getApprovalRuleById } from '../../../../../entity/approvalRule/approvalRuleSelector';
|
|
4
4
|
import { clearBillPaySetupApproverViewUpdateData, initializeBillPaySetupApproverViewUpdateData, saveBillPaySetupApproverViewUpdateData, } from '../billPaySetupApproverViewReducer';
|
|
5
5
|
export const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state$) => actions$.pipe(filter(initializeBillPaySetupApproverViewUpdateData.match), mergeMap((action) => {
|
|
6
6
|
const { approvalRuleId } = action.payload;
|
|
@@ -8,20 +8,16 @@ export const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state
|
|
|
8
8
|
if (approvalRuleId != null) {
|
|
9
9
|
const approvalRule = getApprovalRuleById(state$.value.approvalRuleState, approvalRuleId);
|
|
10
10
|
if (approvalRule != null) {
|
|
11
|
+
const criteria = approvalRule.criteria[0];
|
|
12
|
+
const range = criteria?.range;
|
|
11
13
|
const billPaySetupApproverViewUpdateData = {
|
|
12
14
|
approvalRuleId,
|
|
13
15
|
steps: approvalRule.steps,
|
|
14
16
|
criteria: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
rangeType: criteria?.rangeType,
|
|
18
|
+
rangeEntity: criteria?.rangeEntity,
|
|
19
|
+
range,
|
|
18
20
|
},
|
|
19
|
-
// Approval Rules 3.0 — seed rule-level fields so the form can
|
|
20
|
-
// round-trip them on edit. Each may be undefined on legacy rules.
|
|
21
|
-
name: approvalRule.name,
|
|
22
|
-
description: approvalRule.description,
|
|
23
|
-
separationOfDuties: approvalRule.separationOfDuties,
|
|
24
|
-
isFallback: approvalRule.isFallback,
|
|
25
21
|
};
|
|
26
22
|
fetchActions.push(clearBillPaySetupApproverViewUpdateData(), saveBillPaySetupApproverViewUpdateData(billPaySetupApproverViewUpdateData));
|
|
27
23
|
}
|
|
@@ -29,7 +25,7 @@ export const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state
|
|
|
29
25
|
else {
|
|
30
26
|
const billPaySetupApproverViewCreateData = {
|
|
31
27
|
steps: [],
|
|
32
|
-
criteria:
|
|
28
|
+
criteria: undefined,
|
|
33
29
|
};
|
|
34
30
|
fetchActions.push(clearBillPaySetupApproverViewUpdateData(), saveBillPaySetupApproverViewUpdateData(billPaySetupApproverViewCreateData));
|
|
35
31
|
}
|
|
@@ -5,25 +5,15 @@ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
|
5
5
|
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { saveBillPaySetupApproverViewUpdates, saveBillPaySetupApproverViewUpdatesFailure, saveBillPaySetupApproverViewUpdatesSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
|
-
import { toApprovalChangableInfoPayload
|
|
9
|
-
export const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveBillPaySetupApproverViewUpdates.match), switchMap((
|
|
8
|
+
import { toApprovalChangableInfoPayload } from '../types/commonPayload';
|
|
9
|
+
export const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveBillPaySetupApproverViewUpdates.match), switchMap(() => {
|
|
10
10
|
const { billPaySetupApproverViewState } = state$.value;
|
|
11
11
|
const billPaySetupApproverViewUpdateData = billPaySetupApproverViewState.billPaySetupApproverViewUpdateData;
|
|
12
12
|
if (billPaySetupApproverViewUpdateData != null &&
|
|
13
13
|
billPaySetupApproverViewUpdateData.data != null) {
|
|
14
|
-
|
|
15
|
-
// the `approval_rule_v3_config` dynamic config. `useV3` arrives
|
|
16
|
-
// on the action payload from the screen connector.
|
|
17
|
-
const { useV3 } = action.payload;
|
|
18
|
-
const payload = useV3
|
|
19
|
-
? toApprovalChangableInfoPayload(billPaySetupApproverViewUpdateData.data)
|
|
20
|
-
: toApprovalChangableInfoPayloadV1(billPaySetupApproverViewUpdateData.data);
|
|
21
|
-
const endpoint = useV3
|
|
22
|
-
? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
23
|
-
`https://dev.api.zeni.ai/version/approval/tarun/1.0/bill-pay/approval-rules-v2`
|
|
24
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
14
|
+
const payload = toApprovalChangableInfoPayload(billPaySetupApproverViewUpdateData.data);
|
|
25
15
|
return zeniAPI
|
|
26
|
-
.postAndGetJSON(
|
|
16
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`, payload)
|
|
27
17
|
.pipe(mergeMap((response) => {
|
|
28
18
|
if (isSuccessResponse(response) && response.data != null) {
|
|
29
19
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js
CHANGED
|
@@ -1,48 +1,20 @@
|
|
|
1
1
|
export const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
|
|
2
|
-
|
|
3
|
-
// amount / vendor / department; flatten it into the wire format's
|
|
4
|
-
// `conditions[]` array.
|
|
5
|
-
let criteriaPayload;
|
|
2
|
+
let criteriaPayload = [];
|
|
6
3
|
if (approverViewUpdateData.criteria != null) {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
if (vendor != null && vendor.vendorIds.length > 0) {
|
|
24
|
-
conditions.push({
|
|
25
|
-
field: 'vendor_id',
|
|
26
|
-
type: vendor.operator === 'is_not' ? 'not_in' : 'in',
|
|
27
|
-
value: vendor.vendorIds,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (department != null && department.departmentIds.length > 0) {
|
|
31
|
-
conditions.push({
|
|
32
|
-
field: 'department_id',
|
|
33
|
-
type: department.operator === 'is_not' ? 'not_in' : 'in',
|
|
34
|
-
value: department.departmentIds,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (conditions.length > 0) {
|
|
38
|
-
const currency = amount?.min ?? amount?.max ?? null;
|
|
39
|
-
criteriaPayload = {
|
|
40
|
-
conditions,
|
|
41
|
-
criteria_operator: 'and',
|
|
42
|
-
currency_code: currency?.currencyCode ?? 'USD',
|
|
43
|
-
currency_symbol: currency?.currencySymbol ?? '$',
|
|
44
|
-
};
|
|
45
|
-
}
|
|
4
|
+
const criteria = approverViewUpdateData.criteria;
|
|
5
|
+
const { rangeType, rangeEntity, range } = criteria;
|
|
6
|
+
const { min, max } = range;
|
|
7
|
+
const { currencyCode, currencySymbol } = min;
|
|
8
|
+
criteriaPayload = [
|
|
9
|
+
{
|
|
10
|
+
type: rangeType,
|
|
11
|
+
range_entity: rangeEntity,
|
|
12
|
+
min: min.amount,
|
|
13
|
+
max: max?.amount ?? null,
|
|
14
|
+
currency_code: currencyCode,
|
|
15
|
+
currency_symbol: currencySymbol,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
46
18
|
}
|
|
47
19
|
const steps = approverViewUpdateData.steps.map((step) => {
|
|
48
20
|
return {
|
|
@@ -63,87 +35,10 @@ export const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
|
|
|
63
35
|
});
|
|
64
36
|
const isUpdate = approverViewUpdateData.approvalRuleId != null;
|
|
65
37
|
const payload = {
|
|
38
|
+
criteria: criteriaPayload,
|
|
66
39
|
steps,
|
|
67
40
|
is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
|
|
68
41
|
};
|
|
69
|
-
if (criteriaPayload != null) {
|
|
70
|
-
payload.criteria = criteriaPayload;
|
|
71
|
-
}
|
|
72
|
-
// Approval Rules 3.0 — surface rule-level fields when the form set them.
|
|
73
|
-
// Send only what the user actually entered: an undefined value means
|
|
74
|
-
// "no opinion" and stays off the wire.
|
|
75
|
-
if (approverViewUpdateData.name != null) {
|
|
76
|
-
payload.name = approverViewUpdateData.name;
|
|
77
|
-
}
|
|
78
|
-
if (approverViewUpdateData.description != null) {
|
|
79
|
-
payload.description = approverViewUpdateData.description;
|
|
80
|
-
}
|
|
81
|
-
if (approverViewUpdateData.separationOfDuties != null) {
|
|
82
|
-
payload.separation_of_duties = approverViewUpdateData.separationOfDuties;
|
|
83
|
-
}
|
|
84
|
-
if (approverViewUpdateData.isFallback != null) {
|
|
85
|
-
payload.is_fallback = approverViewUpdateData.isFallback;
|
|
86
|
-
}
|
|
87
|
-
if (isUpdate) {
|
|
88
|
-
payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
|
|
89
|
-
}
|
|
90
|
-
return payload;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
|
|
94
|
-
* for the current tenant. Translates the form-side amount criteria into
|
|
95
|
-
* the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
|
|
96
|
-
* V1 backend does not understand vendor / department criteria or the
|
|
97
|
-
* rule-level 3.0 fields, so those are dropped on the wire.
|
|
98
|
-
*
|
|
99
|
-
* The form-side amount slot is always read as a `range`-style criteria
|
|
100
|
-
* here: V1 schemas only supported ranges, so an absent `min` or `max`
|
|
101
|
-
* falls back to `0` / `Number.MAX_SAFE_INTEGER`.
|
|
102
|
-
*/
|
|
103
|
-
export const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
|
|
104
|
-
const amount = approverViewUpdateData.criteria?.amount;
|
|
105
|
-
const minAmount = amount?.min;
|
|
106
|
-
const maxAmount = amount?.max;
|
|
107
|
-
const currencyCode = minAmount?.currencyCode ?? maxAmount?.currencyCode ?? 'USD';
|
|
108
|
-
const currencySymbol = minAmount?.currencySymbol ?? maxAmount?.currencySymbol ?? '$';
|
|
109
|
-
const steps = approverViewUpdateData.steps.map((step) => {
|
|
110
|
-
return {
|
|
111
|
-
action: step.action,
|
|
112
|
-
operator: step.operator,
|
|
113
|
-
actors: step.actors
|
|
114
|
-
.filter((actor) => actor.subType !== 'admin')
|
|
115
|
-
.map((actor) => {
|
|
116
|
-
return {
|
|
117
|
-
type: actor.type,
|
|
118
|
-
id: actor.userId ?? null,
|
|
119
|
-
sub_type: actor.subType ?? null,
|
|
120
|
-
id_type: actor.idType ?? null,
|
|
121
|
-
is_implicit_actor: actor.isImplicitActor ?? false,
|
|
122
|
-
};
|
|
123
|
-
}),
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
const isUpdate = approverViewUpdateData.approvalRuleId != null;
|
|
127
|
-
const payload = {
|
|
128
|
-
steps,
|
|
129
|
-
is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
|
|
130
|
-
criteria: {
|
|
131
|
-
rangeType: 'range',
|
|
132
|
-
rangeEntity: 'currency',
|
|
133
|
-
range: {
|
|
134
|
-
min: {
|
|
135
|
-
amount: minAmount?.amount ?? 0,
|
|
136
|
-
currencyCode,
|
|
137
|
-
currencySymbol,
|
|
138
|
-
},
|
|
139
|
-
max: {
|
|
140
|
-
amount: maxAmount?.amount ?? Number.MAX_SAFE_INTEGER,
|
|
141
|
-
currencyCode,
|
|
142
|
-
currencySymbol,
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
42
|
if (isUpdate) {
|
|
148
43
|
payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
|
|
149
44
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import recordGet from 'lodash/get';
|
|
2
2
|
import has from 'lodash/has';
|
|
3
|
-
import { getAmountCriteria } from '../../../../entity/approvalRule/approvalRuleSelector';
|
|
4
3
|
import { reduceFetchState } from '../../../../commonStateTypes/reduceFetchState';
|
|
5
4
|
import { getBankAccountByBankAccountId, getBankAccountsByBankAccountIds, } from '../../../../entity/bankAccount/bankAccountSelector';
|
|
6
5
|
import { getContactById, getContactsByIds, } from '../../../../entity/billPay/contact/contactSelector';
|
|
@@ -682,13 +681,9 @@ export const getDefaultWithdrawFromAccount = (state, depositAccounts, companyId,
|
|
|
682
681
|
export const checkIfCreatorIsApprover = (billAmount, approvalRules, signedInUser) => {
|
|
683
682
|
let isCreatorAlsoApprover = false;
|
|
684
683
|
const approvalRule = approvalRules.find((rule) => {
|
|
685
|
-
const
|
|
686
|
-
if (amountCriteria?.min == null) {
|
|
687
|
-
return false;
|
|
688
|
-
}
|
|
689
|
-
const { min, max } = amountCriteria;
|
|
684
|
+
const { max, min } = rule.criteria[0].range;
|
|
690
685
|
return (billAmount > min.amount &&
|
|
691
|
-
(max?.amount != null ? billAmount <= max
|
|
686
|
+
(max?.amount != null ? billAmount <= max?.amount : true));
|
|
692
687
|
});
|
|
693
688
|
if (approvalRule != null) {
|
|
694
689
|
const requireApprovalSteps = approvalRule.steps.filter((step) => step.action === 'require_approval');
|
|
@@ -6,18 +6,9 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { deleteRemiApprovalRule, deleteRemiApprovalRuleFailure, deleteRemiApprovalRuleSuccess, } from '../remiSetupApproverViewReducer';
|
|
8
8
|
export const deleteRemiApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteRemiApprovalRule.match), switchMap((action) => {
|
|
9
|
-
const { approvalRuleId
|
|
10
|
-
// Approval Rules 3.0 — flag-gated endpoint selection.
|
|
11
|
-
// Explicit `=== true` keeps `strict-boolean-expressions` happy
|
|
12
|
-
// when RTK's payload type widens to `any` in some configs.
|
|
13
|
-
const endpoint = useV3 === true
|
|
14
|
-
? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
|
|
15
|
-
`https://dev.api.zeni.ai/version/approval/tarun/1.0/reimbursements/approval-rules-v2`
|
|
16
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
|
|
9
|
+
const { approvalRuleId } = action.payload;
|
|
17
10
|
return zeniAPI
|
|
18
|
-
.deleteAndGetJSON(
|
|
19
|
-
approval_rule_id: approvalRuleId,
|
|
20
|
-
})
|
|
11
|
+
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`, { approval_rule_id: approvalRuleId })
|
|
21
12
|
.pipe(mergeMap((response) => {
|
|
22
13
|
if (isSuccessResponse(response) && response.data != null) {
|
|
23
14
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -6,7 +6,7 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { fetchRemiSetupApproverView, fetchRemiSetupApproverViewFailure, fetchRemiSetupApproverViewSuccess, } from '../remiSetupApproverViewReducer';
|
|
8
8
|
export const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchRemiSetupApproverView.match), switchMap((action) => {
|
|
9
|
-
const { cacheOverride, resolveAttributeToUser, includeImplicitActors
|
|
9
|
+
const { cacheOverride, resolveAttributeToUser, includeImplicitActors } = action.payload;
|
|
10
10
|
const { remiSetupApproverViewState, approvalRuleState } = state$.value;
|
|
11
11
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, remiSetupApproverViewState.approvalRuleIds);
|
|
12
12
|
if (cacheOverride === true ||
|
|
@@ -14,15 +14,8 @@ export const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => act
|
|
|
14
14
|
remiSetupApproverViewState.approvalRuleIds.length ||
|
|
15
15
|
(remiSetupApproverViewState.hasValidState() === false &&
|
|
16
16
|
remiSetupApproverViewState.fetchState !== 'In-Progress')) {
|
|
17
|
-
// Approval Rules 3.0 — flag-gated endpoint selection.
|
|
18
|
-
// Explicit `=== true` keeps `strict-boolean-expressions` happy
|
|
19
|
-
// when RTK's payload type widens to `any` in some configs.
|
|
20
|
-
const basePath = useV3 === true
|
|
21
|
-
? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
|
|
22
|
-
`https://dev.api.zeni.ai/version/approval/tarun/1.0/reimbursements/approval-rules-v2`
|
|
23
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
|
|
24
17
|
return zeniAPI
|
|
25
|
-
.getJSON(`${
|
|
18
|
+
.getJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules?query={"is_include_implicit_actors": ${includeImplicitActors}, "is_resolve_attribute_to_user":${resolveAttributeToUser}}`)
|
|
26
19
|
.pipe(mergeMap((response) => {
|
|
27
20
|
if (isSuccessResponse(response) && response.data != null) {
|
|
28
21
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import {
|
|
3
|
+
import { getApprovalRuleById } from '../../../../../entity/approvalRule/approvalRuleSelector';
|
|
4
4
|
import { clearRemiSetupApproverViewUpdateData, initializeRemiSetupApproverViewUpdateData, saveRemiSetupApproverViewUpdateData, } from '../remiSetupApproverViewReducer';
|
|
5
5
|
export const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$) => actions$.pipe(filter(initializeRemiSetupApproverViewUpdateData.match), mergeMap((action) => {
|
|
6
6
|
const { approvalRuleId } = action.payload;
|
|
@@ -8,20 +8,16 @@ export const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$)
|
|
|
8
8
|
if (approvalRuleId != null) {
|
|
9
9
|
const approvalRule = getApprovalRuleById(state$.value.approvalRuleState, approvalRuleId);
|
|
10
10
|
if (approvalRule != null) {
|
|
11
|
+
const criteria = approvalRule.criteria[0];
|
|
12
|
+
const range = criteria?.range;
|
|
11
13
|
const remiSetupApproverViewUpdateData = {
|
|
12
14
|
approvalRuleId,
|
|
13
15
|
steps: approvalRule.steps,
|
|
14
16
|
criteria: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
rangeType: criteria?.rangeType,
|
|
18
|
+
rangeEntity: criteria?.rangeEntity,
|
|
19
|
+
range,
|
|
18
20
|
},
|
|
19
|
-
// Approval Rules 3.0 — seed rule-level fields so the form can
|
|
20
|
-
// round-trip them on edit. Each may be undefined on legacy rules.
|
|
21
|
-
name: approvalRule.name,
|
|
22
|
-
description: approvalRule.description,
|
|
23
|
-
separationOfDuties: approvalRule.separationOfDuties,
|
|
24
|
-
isFallback: approvalRule.isFallback,
|
|
25
21
|
};
|
|
26
22
|
fetchActions.push(clearRemiSetupApproverViewUpdateData(), saveRemiSetupApproverViewUpdateData(remiSetupApproverViewUpdateData));
|
|
27
23
|
}
|
|
@@ -29,7 +25,7 @@ export const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$)
|
|
|
29
25
|
else {
|
|
30
26
|
const remiSetupApproverViewCreateData = {
|
|
31
27
|
steps: [],
|
|
32
|
-
criteria:
|
|
28
|
+
criteria: undefined,
|
|
33
29
|
};
|
|
34
30
|
fetchActions.push(clearRemiSetupApproverViewUpdateData(), saveRemiSetupApproverViewUpdateData(remiSetupApproverViewCreateData));
|
|
35
31
|
}
|
|
@@ -4,26 +4,16 @@ import { updateApprovalRules } from '../../../../../entity/approvalRule/approval
|
|
|
4
4
|
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
5
5
|
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
|
-
import { toApprovalChangableInfoPayload
|
|
7
|
+
import { toApprovalChangableInfoPayload } from '../../../billPay/billPaySetupApproverView/types/commonPayload';
|
|
8
8
|
import { saveRemiSetupApproverViewUpdates, saveRemiSetupApproverViewUpdatesFailure, saveRemiSetupApproverViewUpdatesSuccess, } from '../remiSetupApproverViewReducer';
|
|
9
|
-
export const saveRemiSetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveRemiSetupApproverViewUpdates.match), switchMap((
|
|
9
|
+
export const saveRemiSetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveRemiSetupApproverViewUpdates.match), switchMap(() => {
|
|
10
10
|
const { remiSetupApproverViewState } = state$.value;
|
|
11
11
|
const remiSetupApproverViewUpdateData = remiSetupApproverViewState.remiSetupApproverViewUpdateData;
|
|
12
12
|
if (remiSetupApproverViewUpdateData != null &&
|
|
13
13
|
remiSetupApproverViewUpdateData.data != null) {
|
|
14
|
-
|
|
15
|
-
// the `approval_rule_v3_config` dynamic config. `useV3` arrives
|
|
16
|
-
// on the action payload from the screen connector.
|
|
17
|
-
const { useV3 } = action.payload;
|
|
18
|
-
const payload = useV3
|
|
19
|
-
? toApprovalChangableInfoPayload(remiSetupApproverViewUpdateData.data)
|
|
20
|
-
: toApprovalChangableInfoPayloadV1(remiSetupApproverViewUpdateData.data);
|
|
21
|
-
const endpoint = useV3
|
|
22
|
-
? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
|
|
23
|
-
`https://dev.api.zeni.ai/version/approval/tarun/1.0/reimbursements/approval-rules-v2`
|
|
24
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
|
|
14
|
+
const payload = toApprovalChangableInfoPayload(remiSetupApproverViewUpdateData.data);
|
|
25
15
|
return zeniAPI
|
|
26
|
-
.postAndGetJSON(
|
|
16
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`, payload)
|
|
27
17
|
.pipe(mergeMap((response) => {
|
|
28
18
|
if (isSuccessResponse(response) && response.data != null) {
|
|
29
19
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -26,16 +26,12 @@ const remiSetupApproverView = createSlice({
|
|
|
26
26
|
draft.fetchState = 'In-Progress';
|
|
27
27
|
draft.error = undefined;
|
|
28
28
|
},
|
|
29
|
-
|
|
30
|
-
// (`approval_rule_v3_config` dynamic config) and picks v1 vs v2
|
|
31
|
-
// endpoint in the fetch epic.
|
|
32
|
-
prepare(cacheOverride = false, resolveAttributeToUser = false, includeImplicitActors = false, useV3 = false) {
|
|
29
|
+
prepare(cacheOverride = false, resolveAttributeToUser = false, includeImplicitActors = false) {
|
|
33
30
|
return {
|
|
34
31
|
payload: {
|
|
35
32
|
cacheOverride,
|
|
36
33
|
resolveAttributeToUser,
|
|
37
34
|
includeImplicitActors,
|
|
38
|
-
useV3,
|
|
39
35
|
},
|
|
40
36
|
};
|
|
41
37
|
},
|
|
@@ -138,11 +134,8 @@ const remiSetupApproverView = createSlice({
|
|
|
138
134
|
error: undefined,
|
|
139
135
|
};
|
|
140
136
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// can pick the v1 vs v2 endpoint.
|
|
144
|
-
prepare(approvalRuleId, useV3 = false) {
|
|
145
|
-
return { payload: { approvalRuleId, useV3 } };
|
|
137
|
+
prepare(approvalRuleId) {
|
|
138
|
+
return { payload: { approvalRuleId } };
|
|
146
139
|
},
|
|
147
140
|
},
|
|
148
141
|
deleteRemiApprovalRuleSuccess: {
|
|
@@ -174,24 +167,13 @@ const remiSetupApproverView = createSlice({
|
|
|
174
167
|
};
|
|
175
168
|
},
|
|
176
169
|
},
|
|
177
|
-
saveRemiSetupApproverViewUpdates
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
reducer(draft, _action) {
|
|
185
|
-
if (draft.remiSetupApproverViewUpdateData != null) {
|
|
186
|
-
draft.remiSetupApproverViewUpdateData.updateStatus = {
|
|
187
|
-
fetchState: 'In-Progress',
|
|
188
|
-
error: undefined,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
prepare(useV3) {
|
|
193
|
-
return { payload: { useV3 } };
|
|
194
|
-
},
|
|
170
|
+
saveRemiSetupApproverViewUpdates(draft) {
|
|
171
|
+
if (draft.remiSetupApproverViewUpdateData != null) {
|
|
172
|
+
draft.remiSetupApproverViewUpdateData.updateStatus = {
|
|
173
|
+
fetchState: 'In-Progress',
|
|
174
|
+
error: undefined,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
195
177
|
},
|
|
196
178
|
saveRemiSetupApproverViewUpdatesSuccess: {
|
|
197
179
|
reducer(draft, action) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
+
import { updateTreasuryPromoRemindMeLaterClickedForLoggedInUser } from '../../../../../entity/tenant/tenantReducer';
|
|
4
|
+
import { createZeniAPIStatus, isSuccessStatus, } from '../../../../../responsePayload';
|
|
5
|
+
import { updateTreasuryPromoRemindMeLaterClicked, updateTreasuryPromoRemindMeLaterClickedFailure, updateTreasuryPromoRemindMeLaterClickedSuccess, } from '../treasurySetupViewReducer';
|
|
6
|
+
export const updateTreasuryPromoRemindMeLaterClickedEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(updateTreasuryPromoRemindMeLaterClicked.match), switchMap(() => {
|
|
7
|
+
return zeniAPI
|
|
8
|
+
.putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user/self`, { is_treasury_promo_video_remind_me_later_clicked: true })
|
|
9
|
+
.pipe(mergeMap((response) => {
|
|
10
|
+
if (isSuccessStatus(response)) {
|
|
11
|
+
return of(updateTreasuryPromoRemindMeLaterClickedForLoggedInUser(), updateTreasuryPromoRemindMeLaterClickedSuccess());
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return of(updateTreasuryPromoRemindMeLaterClickedFailure(response.status));
|
|
15
|
+
}
|
|
16
|
+
}), catchError((error) => of(updateTreasuryPromoRemindMeLaterClickedFailure(createZeniAPIStatus('Unexpected error', 'Update treasury promo remind me later REST API call errored out' +
|
|
17
|
+
JSON.stringify(error))))));
|
|
18
|
+
}));
|