@zeniai/client-epic-state 5.0.85-betaAR1 → 5.0.85-betaAR2

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.
Files changed (62) hide show
  1. package/lib/entity/approvalRule/approvalRulePayload.d.ts +5 -34
  2. package/lib/entity/approvalRule/approvalRulePayload.js +10 -130
  3. package/lib/entity/approvalRule/approvalRuleSelector.d.ts +1 -25
  4. package/lib/entity/approvalRule/approvalRuleSelector.js +0 -40
  5. package/lib/entity/approvalRule/approvalRuleState.d.ts +7 -59
  6. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  7. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  8. package/lib/epic.d.ts +1 -3
  9. package/lib/epic.js +1 -3
  10. package/lib/esm/entity/approvalRule/approvalRulePayload.js +10 -130
  11. package/lib/esm/entity/approvalRule/approvalRuleSelector.js +0 -35
  12. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
  13. package/lib/esm/epic.js +1 -3
  14. package/lib/esm/index.js +5 -7
  15. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +12 -74
  16. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  17. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  18. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +7 -11
  19. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +4 -13
  20. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -122
  21. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -7
  22. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  23. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  24. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -11
  25. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +4 -13
  26. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -63
  27. package/lib/index.d.ts +6 -8
  28. package/lib/index.js +16 -26
  29. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  30. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  31. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  32. package/lib/view/people/peopleTypes.d.ts +1 -1
  33. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +3 -14
  34. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +13 -75
  35. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +0 -8
  36. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  37. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  38. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -10
  39. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -12
  40. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -50
  41. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +17 -124
  42. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +5 -31
  43. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -7
  44. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  45. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  46. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  47. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -10
  48. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +3 -12
  49. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +3 -14
  50. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +12 -64
  51. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +0 -5
  52. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  53. package/package.json +1 -1
  54. package/lib/entity/approvalRule/approvalRuleConflict.d.ts +0 -56
  55. package/lib/entity/approvalRule/approvalRuleConflict.js +0 -77
  56. package/lib/esm/entity/approvalRule/approvalRuleConflict.js +0 -74
  57. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -54
  58. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -49
  59. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.d.ts +0 -23
  60. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -58
  61. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.d.ts +0 -14
  62. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -53
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearBillPaySetupApproverView = exports.setListeningToPusherEvent = exports.clearBillPaySetupApproverViewUpdateData = exports.saveBillPaySetupApproverViewUpdateData = exports.initializeBillPaySetupApproverViewUpdateData = exports.saveBillPaySetupApproverViewUpdatesFailure = exports.saveBillPaySetupApproverViewUpdatesSuccess = exports.saveBillPaySetupApproverViewUpdates = exports.reorderBillPayApprovalRulesFailure = exports.reorderBillPayApprovalRulesSuccess = exports.reorderBillPayApprovalRules = exports.deleteBillPayApprovalRuleFailure = exports.deleteBillPayApprovalRuleSuccess = exports.deleteBillPayApprovalRule = exports.fetchBillPayApproversListFailure = exports.fetchBillPayApproversListSuccess = exports.fetchBillPayApproversList = exports.fetchBillPayApproversDetails = exports.fetchBillPaySetupApproverViewFailure = exports.fetchBillPaySetupApproverViewSuccess = exports.fetchBillPaySetupApproverView = exports.initialState = void 0;
4
+ exports.clearBillPaySetupApproverView = exports.setListeningToPusherEvent = exports.clearBillPaySetupApproverViewUpdateData = exports.saveBillPaySetupApproverViewUpdateData = exports.initializeBillPaySetupApproverViewUpdateData = exports.saveBillPaySetupApproverViewUpdatesFailure = exports.saveBillPaySetupApproverViewUpdatesSuccess = exports.saveBillPaySetupApproverViewUpdates = exports.deleteBillPayApprovalRuleFailure = exports.deleteBillPayApprovalRuleSuccess = exports.deleteBillPayApprovalRule = exports.fetchBillPayApproversListFailure = exports.fetchBillPayApproversListSuccess = exports.fetchBillPayApproversList = exports.fetchBillPayApproversDetails = exports.fetchBillPaySetupApproverViewFailure = exports.fetchBillPaySetupApproverViewSuccess = exports.fetchBillPaySetupApproverView = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  exports.initialState = {
7
7
  fetchState: 'Not-Started',
@@ -17,7 +17,6 @@ exports.initialState = {
17
17
  newApprovalRuleId: undefined,
18
18
  approvalRulesDeleteStatusById: {},
19
19
  billPaySetupApproverViewUpdateData: undefined,
20
- reorderStatus: { fetchState: 'Not-Started', error: undefined },
21
20
  hasValidState() {
22
21
  return this.fetchState === 'Completed';
23
22
  },
@@ -31,11 +30,8 @@ const billPaySetupApproverView = (0, toolkit_1.createSlice)({
31
30
  draft.fetchState = 'In-Progress';
32
31
  draft.error = undefined;
33
32
  },
34
- // Approval Rules 3.0 `useV3` arrives from the screen connector
35
- // (`approval_rule_v3_config` dynamic config) and picks the v1 vs
36
- // v2 endpoint in the fetch epic.
37
- prepare(cacheOverride = false, includeUserRoles = true, useV3 = false) {
38
- return { payload: { cacheOverride, includeUserRoles, useV3 } };
33
+ prepare(cacheOverride = false, includeUserRoles = true) {
34
+ return { payload: { cacheOverride, includeUserRoles } };
39
35
  },
40
36
  },
41
37
  fetchBillPaySetupApproverViewSuccess: {
@@ -120,11 +116,8 @@ const billPaySetupApproverView = (0, toolkit_1.createSlice)({
120
116
  error: undefined,
121
117
  };
122
118
  },
123
- // Approval Rules 3.0 — `useV3` flows from the screen connector
124
- // (`approval_rule_v3_config` dynamic config) so the delete epic
125
- // can pick the v1 vs v2 endpoint.
126
- prepare(approvalRuleId, useV3 = false) {
127
- return { payload: { approvalRuleId, useV3 } };
119
+ prepare(approvalRuleId) {
120
+ return { payload: { approvalRuleId } };
128
121
  },
129
122
  },
130
123
  deleteBillPayApprovalRuleSuccess: {
@@ -156,68 +149,13 @@ const billPaySetupApproverView = (0, toolkit_1.createSlice)({
156
149
  };
157
150
  },
158
151
  },
159
- /**
160
- * Approval Rules 3.0 list-page drag-and-drop reorder.
161
- *
162
- * The trigger action carries the desired ordering as an ID list.
163
- * The reducer optimistically replaces 'approvalRuleIds' so the
164
- * list page renders the new order immediately; the epic then
165
- * fires the PUT and either confirms (success — pulls updated
166
- * priorities from the response) or recovers (failure — refetches
167
- * the view so we don't strand a stale local order).
168
- */
169
- reorderBillPayApprovalRules: {
170
- reducer(draft, action) {
171
- const { approvalRuleIds } = action.payload;
172
- draft.reorderStatus = { fetchState: 'In-Progress', error: undefined };
173
- // Optimistic: render new order immediately. On failure, the
174
- // epic dispatches fetchBillPaySetupApproverView to restore.
175
- draft.approvalRuleIds = approvalRuleIds;
176
- },
177
- prepare(approvalRuleIds, useV3 = false) {
178
- return { payload: { approvalRuleIds, useV3 } };
179
- },
180
- },
181
- reorderBillPayApprovalRulesSuccess: {
182
- reducer(draft, action) {
183
- const { approvalRuleIds } = action.payload;
184
- draft.reorderStatus = { fetchState: 'Completed', error: undefined };
185
- // The API response is authoritative — overwrite with the
186
- // server's reported order in case it normalised anything.
187
- draft.approvalRuleIds = approvalRuleIds;
188
- },
189
- prepare(approvalRuleIds) {
190
- return { payload: { approvalRuleIds } };
191
- },
192
- },
193
- reorderBillPayApprovalRulesFailure: {
194
- reducer(draft, action) {
195
- const { status } = action.payload;
196
- draft.reorderStatus = { fetchState: 'Error', error: status };
197
- },
198
- prepare(status) {
199
- return { payload: { status } };
200
- },
201
- },
202
- saveBillPaySetupApproverViewUpdates: {
203
- // Approval Rules 3.0 — `useV3` is sourced from the
204
- // `approval_rule_v3_config` dynamic config in the screen
205
- // connector. The reducer doesn't read it (the field only
206
- // matters in the save epic), but it must be declared so the
207
- // action's payload type is correctly inferred for downstream
208
- // consumers.
209
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
210
- reducer(draft, _action) {
211
- if (draft.billPaySetupApproverViewUpdateData != null) {
212
- draft.billPaySetupApproverViewUpdateData.updateStatus = {
213
- fetchState: 'In-Progress',
214
- error: undefined,
215
- };
216
- }
217
- },
218
- prepare(useV3) {
219
- return { payload: { useV3 } };
220
- },
152
+ saveBillPaySetupApproverViewUpdates(draft) {
153
+ if (draft.billPaySetupApproverViewUpdateData != null) {
154
+ draft.billPaySetupApproverViewUpdateData.updateStatus = {
155
+ fetchState: 'In-Progress',
156
+ error: undefined,
157
+ };
158
+ }
221
159
  },
222
160
  saveBillPaySetupApproverViewUpdatesSuccess: {
223
161
  reducer(draft, action) {
@@ -306,5 +244,5 @@ const billPaySetupApproverView = (0, toolkit_1.createSlice)({
306
244
  },
307
245
  },
308
246
  });
309
- _a = billPaySetupApproverView.actions, exports.fetchBillPaySetupApproverView = _a.fetchBillPaySetupApproverView, exports.fetchBillPaySetupApproverViewSuccess = _a.fetchBillPaySetupApproverViewSuccess, exports.fetchBillPaySetupApproverViewFailure = _a.fetchBillPaySetupApproverViewFailure, exports.fetchBillPayApproversDetails = _a.fetchBillPayApproversDetails, exports.fetchBillPayApproversList = _a.fetchBillPayApproversList, exports.fetchBillPayApproversListSuccess = _a.fetchBillPayApproversListSuccess, exports.fetchBillPayApproversListFailure = _a.fetchBillPayApproversListFailure, exports.deleteBillPayApprovalRule = _a.deleteBillPayApprovalRule, exports.deleteBillPayApprovalRuleSuccess = _a.deleteBillPayApprovalRuleSuccess, exports.deleteBillPayApprovalRuleFailure = _a.deleteBillPayApprovalRuleFailure, exports.reorderBillPayApprovalRules = _a.reorderBillPayApprovalRules, exports.reorderBillPayApprovalRulesSuccess = _a.reorderBillPayApprovalRulesSuccess, exports.reorderBillPayApprovalRulesFailure = _a.reorderBillPayApprovalRulesFailure, exports.saveBillPaySetupApproverViewUpdates = _a.saveBillPaySetupApproverViewUpdates, exports.saveBillPaySetupApproverViewUpdatesSuccess = _a.saveBillPaySetupApproverViewUpdatesSuccess, exports.saveBillPaySetupApproverViewUpdatesFailure = _a.saveBillPaySetupApproverViewUpdatesFailure, exports.initializeBillPaySetupApproverViewUpdateData = _a.initializeBillPaySetupApproverViewUpdateData, exports.saveBillPaySetupApproverViewUpdateData = _a.saveBillPaySetupApproverViewUpdateData, exports.clearBillPaySetupApproverViewUpdateData = _a.clearBillPaySetupApproverViewUpdateData, exports.setListeningToPusherEvent = _a.setListeningToPusherEvent, exports.clearBillPaySetupApproverView = _a.clearBillPaySetupApproverView;
247
+ _a = billPaySetupApproverView.actions, exports.fetchBillPaySetupApproverView = _a.fetchBillPaySetupApproverView, exports.fetchBillPaySetupApproverViewSuccess = _a.fetchBillPaySetupApproverViewSuccess, exports.fetchBillPaySetupApproverViewFailure = _a.fetchBillPaySetupApproverViewFailure, exports.fetchBillPayApproversDetails = _a.fetchBillPayApproversDetails, exports.fetchBillPayApproversList = _a.fetchBillPayApproversList, exports.fetchBillPayApproversListSuccess = _a.fetchBillPayApproversListSuccess, exports.fetchBillPayApproversListFailure = _a.fetchBillPayApproversListFailure, exports.deleteBillPayApprovalRule = _a.deleteBillPayApprovalRule, exports.deleteBillPayApprovalRuleSuccess = _a.deleteBillPayApprovalRuleSuccess, exports.deleteBillPayApprovalRuleFailure = _a.deleteBillPayApprovalRuleFailure, exports.saveBillPaySetupApproverViewUpdates = _a.saveBillPaySetupApproverViewUpdates, exports.saveBillPaySetupApproverViewUpdatesSuccess = _a.saveBillPaySetupApproverViewUpdatesSuccess, exports.saveBillPaySetupApproverViewUpdatesFailure = _a.saveBillPaySetupApproverViewUpdatesFailure, exports.initializeBillPaySetupApproverViewUpdateData = _a.initializeBillPaySetupApproverViewUpdateData, exports.saveBillPaySetupApproverViewUpdateData = _a.saveBillPaySetupApproverViewUpdateData, exports.clearBillPaySetupApproverViewUpdateData = _a.clearBillPaySetupApproverViewUpdateData, exports.setListeningToPusherEvent = _a.setListeningToPusherEvent, exports.clearBillPaySetupApproverView = _a.clearBillPaySetupApproverView;
310
248
  exports.default = billPaySetupApproverView.reducer;
@@ -9,14 +9,6 @@ export interface BillPaySetupApproverViewState extends FetchedState {
9
9
  attributes: AttributeType[];
10
10
  fetchStatus: FetchStateAndError;
11
11
  };
12
- /**
13
- * Tracks the in-flight status of the list-page reorder PUT
14
- * (approval-rules-v2/reorder). The reducer optimistically updates
15
- * 'approvalRuleIds' on the trigger action; on Failure the epic
16
- * dispatches 'fetchBillPaySetupApproverView' to revert to server
17
- * truth.
18
- */
19
- reorderStatus: FetchStateAndError;
20
12
  affectedEntityIds?: ID[];
21
13
  billPaySetupApproverViewUpdateData?: ApproverViewUpdateData;
22
14
  listeningToPusherEvent?: boolean;
@@ -9,17 +9,9 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const billPaySetupApproverViewReducer_1 = require("../billPaySetupApproverViewReducer");
11
11
  const deleteBillPayApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(billPaySetupApproverViewReducer_1.deleteBillPayApprovalRule.match), (0, operators_1.switchMap)((action) => {
12
- const { approvalRuleId, useV3 } = action.payload;
13
- // Approval Rules 3.0 — flag-gated endpoint selection.
14
- // Explicit `=== true` keeps `strict-boolean-expressions` happy
15
- // when RTK's payload type widens to `any` in some configs.
16
- const endpoint = useV3 === true
17
- ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
18
- : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
12
+ const { approvalRuleId } = action.payload;
19
13
  return zeniAPI
20
- .deleteAndGetJSON(endpoint, {
21
- approval_rule_id: approvalRuleId,
22
- })
14
+ .deleteAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`, { approval_rule_id: approvalRuleId })
23
15
  .pipe((0, operators_1.mergeMap)((response) => {
24
16
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
25
17
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
@@ -9,7 +9,7 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const billPaySetupApproverViewReducer_1 = require("../billPaySetupApproverViewReducer");
11
11
  const fetchBillPaySetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(billPaySetupApproverViewReducer_1.fetchBillPaySetupApproverView.match), (0, operators_1.switchMap)((action) => {
12
- const { cacheOverride, useV3 } = action.payload;
12
+ const { cacheOverride } = action.payload;
13
13
  const { billPaySetupApproverViewState, approvalRuleState } = state$.value;
14
14
  const approvalRules = (0, approvalRuleSelector_1.getApprovalRulesByIds)(approvalRuleState, billPaySetupApproverViewState.approvalRuleIds);
15
15
  if (cacheOverride === true ||
@@ -17,13 +17,9 @@ const fetchBillPaySetupApproverViewEpic = (actions$, state$, zeniAPI) => actions
17
17
  billPaySetupApproverViewState.approvalRuleIds.length ||
18
18
  (billPaySetupApproverViewState.hasValidState() === false &&
19
19
  billPaySetupApproverViewState.fetchState !== 'In-Progress')) {
20
- // Approval Rules 3.0 — flag-gated endpoint selection.
21
- // Explicit `=== true` keeps `strict-boolean-expressions` happy
22
- // when RTK's payload type widens to `any` in some configs.
23
- const endpoint = useV3 === true
24
- ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
25
- : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
26
- return zeniAPI.getJSON(endpoint).pipe((0, operators_1.mergeMap)((response) => {
20
+ return zeniAPI
21
+ .getJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`)
22
+ .pipe((0, operators_1.mergeMap)((response) => {
27
23
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
28
24
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
29
25
  const actions = [
@@ -11,20 +11,16 @@ const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state$) => a
11
11
  if (approvalRuleId != null) {
12
12
  const approvalRule = (0, approvalRuleSelector_1.getApprovalRuleById)(state$.value.approvalRuleState, approvalRuleId);
13
13
  if (approvalRule != null) {
14
+ const criteria = approvalRule.criteria[0];
15
+ const range = criteria?.range;
14
16
  const billPaySetupApproverViewUpdateData = {
15
17
  approvalRuleId,
16
18
  steps: approvalRule.steps,
17
19
  criteria: {
18
- amount: (0, approvalRuleSelector_1.getAmountCriteria)(approvalRule.criteria),
19
- vendor: (0, approvalRuleSelector_1.getVendorCriteria)(approvalRule.criteria),
20
- department: (0, approvalRuleSelector_1.getDepartmentCriteria)(approvalRule.criteria),
20
+ rangeType: criteria?.rangeType,
21
+ rangeEntity: criteria?.rangeEntity,
22
+ range,
21
23
  },
22
- // Approval Rules 3.0 — seed rule-level fields so the form can
23
- // round-trip them on edit. Each may be undefined on legacy rules.
24
- name: approvalRule.name,
25
- description: approvalRule.description,
26
- separationOfDuties: approvalRule.separationOfDuties,
27
- isFallback: approvalRule.isFallback,
28
24
  };
29
25
  fetchActions.push((0, billPaySetupApproverViewReducer_1.clearBillPaySetupApproverViewUpdateData)(), (0, billPaySetupApproverViewReducer_1.saveBillPaySetupApproverViewUpdateData)(billPaySetupApproverViewUpdateData));
30
26
  }
@@ -32,7 +28,7 @@ const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state$) => a
32
28
  else {
33
29
  const billPaySetupApproverViewCreateData = {
34
30
  steps: [],
35
- criteria: {},
31
+ criteria: undefined,
36
32
  };
37
33
  fetchActions.push((0, billPaySetupApproverViewReducer_1.clearBillPaySetupApproverViewUpdateData)(), (0, billPaySetupApproverViewReducer_1.saveBillPaySetupApproverViewUpdateData)(billPaySetupApproverViewCreateData));
38
34
  }
@@ -9,23 +9,14 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const billPaySetupApproverViewReducer_1 = require("../billPaySetupApproverViewReducer");
11
11
  const commonPayload_1 = require("../types/commonPayload");
12
- const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(billPaySetupApproverViewReducer_1.saveBillPaySetupApproverViewUpdates.match), (0, operators_1.switchMap)((action) => {
12
+ const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(billPaySetupApproverViewReducer_1.saveBillPaySetupApproverViewUpdates.match), (0, operators_1.switchMap)(() => {
13
13
  const { billPaySetupApproverViewState } = state$.value;
14
14
  const billPaySetupApproverViewUpdateData = billPaySetupApproverViewState.billPaySetupApproverViewUpdateData;
15
15
  if (billPaySetupApproverViewUpdateData != null &&
16
16
  billPaySetupApproverViewUpdateData.data != null) {
17
- // Approval Rules 3.0 — gate URL + write-side payload mapper on
18
- // the `approval_rule_v3_config` dynamic config. `useV3` arrives
19
- // on the action payload from the screen connector.
20
- const { useV3 } = action.payload;
21
- const payload = useV3
22
- ? (0, commonPayload_1.toApprovalChangableInfoPayload)(billPaySetupApproverViewUpdateData.data)
23
- : (0, commonPayload_1.toApprovalChangableInfoPayloadV1)(billPaySetupApproverViewUpdateData.data);
24
- const endpoint = useV3
25
- ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
26
- : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
17
+ const payload = (0, commonPayload_1.toApprovalChangableInfoPayload)(billPaySetupApproverViewUpdateData.data);
27
18
  return zeniAPI
28
- .postAndGetJSON(endpoint, payload)
19
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`, payload)
29
20
  .pipe((0, operators_1.mergeMap)((response) => {
30
21
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
31
22
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
@@ -14,58 +14,9 @@ interface ApproverViewStepPayload extends Omit<StepPayload, 'actors'> {
14
14
  }
15
15
  interface ApprovalUpdatableInfoPayload {
16
16
  approval_rule_id: ID;
17
- criteria: CriteriaPayload;
17
+ criteria: CriteriaPayload[];
18
18
  is_applicable_on_pending_approval_entity: boolean;
19
19
  steps: ApproverViewStepPayload[];
20
- description?: string;
21
- is_fallback?: boolean;
22
- is_separation_of_duty_enabled?: boolean;
23
- /**
24
- * Approval Rules 3.0 — rule-level wire fields. The backend accepts these
25
- * as optional today; once 3.0 ships they become first-class. The SoD
26
- * field name matches the GET response shape (confirmed with backend),
27
- * so the same identifier flows both directions on the wire.
28
- */
29
- name?: string;
30
- }
31
- /**
32
- * V1 / pre-3.0 wire shape. Kept so the rollback flag (gated by
33
- * `approval_rule_v3_config` dynamic config) can target the original
34
- * `/approval-rules` endpoint with the legacy `{rangeType, rangeEntity, range}`
35
- * criteria. None of the 3.0 rule-level fields are sent.
36
- */
37
- interface ApprovalUpdatableInfoPayloadV1 {
38
- criteria: {
39
- range: {
40
- max: {
41
- amount: number;
42
- currencyCode: string;
43
- currencySymbol: string;
44
- };
45
- min: {
46
- amount: number;
47
- currencyCode: string;
48
- currencySymbol: string;
49
- };
50
- };
51
- rangeEntity: 'currency';
52
- rangeType: 'range';
53
- };
54
- is_applicable_on_pending_approval_entity: boolean;
55
- steps: ApproverViewStepPayload[];
56
- approval_rule_id?: ID;
57
20
  }
58
21
  export declare const toApprovalChangableInfoPayload: (approverViewUpdateData: ApprovalRuleUpdateData | ApprovalRuleCreateData) => Partial<ApprovalUpdatableInfoPayload>;
59
- /**
60
- * V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
61
- * for the current tenant. Translates the form-side amount criteria into
62
- * the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
63
- * V1 backend does not understand vendor / department criteria or the
64
- * rule-level 3.0 fields, so those are dropped on the wire.
65
- *
66
- * The form-side amount slot is always read as a `range`-style criteria
67
- * here: V1 schemas only supported ranges, so an absent `min` or `max`
68
- * falls back to `0` / `Number.MAX_SAFE_INTEGER`.
69
- */
70
- export declare const toApprovalChangableInfoPayloadV1: (approverViewUpdateData: ApprovalRuleUpdateData | ApprovalRuleCreateData) => Partial<ApprovalUpdatableInfoPayloadV1>;
71
22
  export {};
@@ -1,51 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toApprovalChangableInfoPayloadV1 = exports.toApprovalChangableInfoPayload = void 0;
3
+ exports.toApprovalChangableInfoPayload = void 0;
4
4
  const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
5
- // Form-side criteria is a structured object with optional slots for
6
- // amount / vendor / department; flatten it into the wire format's
7
- // `conditions[]` array.
8
- let criteriaPayload;
5
+ let criteriaPayload = [];
9
6
  if (approverViewUpdateData.criteria != null) {
10
- const { amount, vendor, department } = approverViewUpdateData.criteria;
11
- const conditions = [];
12
- if (amount?.min != null) {
13
- conditions.push({
14
- field: 'amount',
15
- type: 'gte',
16
- value: amount.min.amount,
17
- });
18
- }
19
- if (amount?.max != null) {
20
- conditions.push({
21
- field: 'amount',
22
- type: 'lte',
23
- value: amount.max.amount,
24
- });
25
- }
26
- if (vendor != null && vendor.vendorIds.length > 0) {
27
- conditions.push({
28
- field: 'vendor_id',
29
- type: vendor.operator === 'is_not' ? 'not_in' : 'in',
30
- value: vendor.vendorIds,
31
- });
32
- }
33
- if (department != null && department.departmentIds.length > 0) {
34
- conditions.push({
35
- field: 'department_id',
36
- type: department.operator === 'is_not' ? 'not_in' : 'in',
37
- value: department.departmentIds,
38
- });
39
- }
40
- if (conditions.length > 0) {
41
- const currency = amount?.min ?? amount?.max ?? null;
42
- criteriaPayload = {
43
- conditions,
44
- criteria_operator: 'and',
45
- currency_code: currency?.currencyCode ?? 'USD',
46
- currency_symbol: currency?.currencySymbol ?? '$',
47
- };
48
- }
7
+ const criteria = approverViewUpdateData.criteria;
8
+ const { rangeType, rangeEntity, range } = criteria;
9
+ const { min, max } = range;
10
+ const { currencyCode, currencySymbol } = min;
11
+ criteriaPayload = [
12
+ {
13
+ type: rangeType,
14
+ range_entity: rangeEntity,
15
+ min: min.amount,
16
+ max: max?.amount ?? null,
17
+ currency_code: currencyCode,
18
+ currency_symbol: currencySymbol,
19
+ },
20
+ ];
49
21
  }
50
22
  const steps = approverViewUpdateData.steps.map((step) => {
51
23
  return {
@@ -66,92 +38,13 @@ const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
66
38
  });
67
39
  const isUpdate = approverViewUpdateData.approvalRuleId != null;
68
40
  const payload = {
41
+ criteria: criteriaPayload,
69
42
  steps,
70
43
  is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
71
44
  };
72
- if (criteriaPayload != null) {
73
- payload.criteria = criteriaPayload;
74
- }
75
- // Approval Rules 3.0 — surface rule-level fields when the form set them.
76
- // Send only what the user actually entered: an undefined value means
77
- // "no opinion" and stays off the wire.
78
- if (approverViewUpdateData.name != null) {
79
- payload.name = approverViewUpdateData.name;
80
- }
81
- if (approverViewUpdateData.description != null) {
82
- payload.description = approverViewUpdateData.description;
83
- }
84
- if (approverViewUpdateData.separationOfDuties != null) {
85
- payload.is_separation_of_duty_enabled =
86
- approverViewUpdateData.separationOfDuties;
87
- }
88
- if (approverViewUpdateData.isFallback != null) {
89
- payload.is_fallback = approverViewUpdateData.isFallback;
90
- }
91
45
  if (isUpdate) {
92
46
  payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
93
47
  }
94
48
  return payload;
95
49
  };
96
50
  exports.toApprovalChangableInfoPayload = toApprovalChangableInfoPayload;
97
- /**
98
- * V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
99
- * for the current tenant. Translates the form-side amount criteria into
100
- * the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
101
- * V1 backend does not understand vendor / department criteria or the
102
- * rule-level 3.0 fields, so those are dropped on the wire.
103
- *
104
- * The form-side amount slot is always read as a `range`-style criteria
105
- * here: V1 schemas only supported ranges, so an absent `min` or `max`
106
- * falls back to `0` / `Number.MAX_SAFE_INTEGER`.
107
- */
108
- const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
109
- const amount = approverViewUpdateData.criteria?.amount;
110
- const minAmount = amount?.min;
111
- const maxAmount = amount?.max;
112
- const currencyCode = minAmount?.currencyCode ?? maxAmount?.currencyCode ?? 'USD';
113
- const currencySymbol = minAmount?.currencySymbol ?? maxAmount?.currencySymbol ?? '$';
114
- const steps = approverViewUpdateData.steps.map((step) => {
115
- return {
116
- action: step.action,
117
- operator: step.operator,
118
- actors: step.actors
119
- .filter((actor) => actor.subType !== 'admin')
120
- .map((actor) => {
121
- return {
122
- type: actor.type,
123
- id: actor.userId ?? null,
124
- sub_type: actor.subType ?? null,
125
- id_type: actor.idType ?? null,
126
- is_implicit_actor: actor.isImplicitActor ?? false,
127
- };
128
- }),
129
- };
130
- });
131
- const isUpdate = approverViewUpdateData.approvalRuleId != null;
132
- const payload = {
133
- steps,
134
- is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
135
- criteria: {
136
- rangeType: 'range',
137
- rangeEntity: 'currency',
138
- range: {
139
- min: {
140
- amount: minAmount?.amount ?? 0,
141
- currencyCode,
142
- currencySymbol,
143
- },
144
- max: {
145
- amount: maxAmount?.amount ?? Number.MAX_SAFE_INTEGER,
146
- currencyCode,
147
- currencySymbol,
148
- },
149
- },
150
- },
151
- };
152
- if (isUpdate) {
153
- payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
154
- }
155
- return payload;
156
- };
157
- exports.toApprovalChangableInfoPayloadV1 = toApprovalChangableInfoPayloadV1;
@@ -1,45 +1,19 @@
1
1
  import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
2
- import { AmountCriteria, DepartmentCriteria, Step, VendorCriteria } from '../../../../../entity/approvalRule/approvalRuleState';
2
+ import { Criteria, Step } from '../../../../../entity/approvalRule/approvalRuleState';
3
3
  export type ApprovalUpdateActionType = 'approval_create' | 'approval_update';
4
4
  export interface ApproverViewUpdateData {
5
5
  type: ApprovalUpdateActionType;
6
6
  updateStatus: FetchStateAndError;
7
7
  data?: ApprovalRuleUpdateData | ApprovalRuleCreateData;
8
8
  }
9
- /**
10
- * Form-side criteria shape used by the rule create/edit form.
11
- *
12
- * Each condition kind gets its own optional slot, mirroring how the UI
13
- * edits them as distinct rows. At most one of each kind is present; this
14
- * matches the design constraint that each condition type can be added once.
15
- */
16
- export interface ApprovalRuleFormCriteria {
17
- amount?: AmountCriteria;
18
- department?: DepartmentCriteria;
19
- vendor?: VendorCriteria;
20
- }
21
- /**
22
- * Rule-level fields shared by both create and update flows.
23
- *
24
- * These come from the 3.0 design: the form now owns a name, an optional
25
- * description, an optional Separation-of-Duties toggle, and a flag that
26
- * marks the rule as the org-wide fallback rule. They live alongside
27
- * criteria/steps but are not part of either.
28
- */
29
- export interface ApprovalRuleFormBase {
30
- description?: string;
31
- isFallback?: boolean;
32
- name?: string;
33
- separationOfDuties?: boolean;
34
- }
35
- export interface ApprovalRuleUpdateData extends ApprovalRuleFormBase {
9
+ export interface ApprovalRuleUpdateData {
36
10
  approvalRuleId: ID;
37
- criteria: ApprovalRuleFormCriteria;
11
+ criteria: Criteria;
38
12
  steps: Step[];
39
13
  isApplicableOnPendingApprovalEntity?: boolean;
40
14
  }
41
- export interface ApprovalRuleCreateData extends ApprovalRuleFormBase {
42
- criteria: ApprovalRuleFormCriteria;
15
+ export interface ApprovalRuleCreateData {
16
+ criteria: Criteria;
43
17
  steps: Step[];
44
18
  isApplicableOnPendingApprovalEntity?: boolean;
45
19
  }
@@ -9,7 +9,6 @@ exports.getPaymentSection = getPaymentSection;
9
9
  exports.toPaymentToOption = toPaymentToOption;
10
10
  const get_1 = __importDefault(require("lodash/get"));
11
11
  const has_1 = __importDefault(require("lodash/has"));
12
- const approvalRuleSelector_1 = require("../../../../entity/approvalRule/approvalRuleSelector");
13
12
  const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
14
13
  const bankAccountSelector_1 = require("../../../../entity/bankAccount/bankAccountSelector");
15
14
  const contactSelector_1 = require("../../../../entity/billPay/contact/contactSelector");
@@ -699,13 +698,9 @@ exports.getDefaultWithdrawFromAccount = getDefaultWithdrawFromAccount;
699
698
  const checkIfCreatorIsApprover = (billAmount, approvalRules, signedInUser) => {
700
699
  let isCreatorAlsoApprover = false;
701
700
  const approvalRule = approvalRules.find((rule) => {
702
- const amountCriteria = (0, approvalRuleSelector_1.getAmountCriteria)(rule.criteria);
703
- if (amountCriteria?.min == null) {
704
- return false;
705
- }
706
- const { min, max } = amountCriteria;
701
+ const { max, min } = rule.criteria[0].range;
707
702
  return (billAmount > min.amount &&
708
- (max?.amount != null ? billAmount <= max.amount : true));
703
+ (max?.amount != null ? billAmount <= max?.amount : true));
709
704
  });
710
705
  if (approvalRule != null) {
711
706
  const requireApprovalSteps = approvalRule.steps.filter((step) => step.action === 'require_approval');
@@ -61,7 +61,7 @@ export declare const initialCreditAcc: CreditAccount;
61
61
  export declare const initialDebitCardSummaries: DebitCardSummaries;
62
62
  export declare const initialResendRevokeCardInvite: ResendRevokeCardInvite;
63
63
  export declare const initialCreditAccountRepayment: CreditAccountRepayment;
64
- export declare const toChargeCardSortKeyType: (v: string) => "status" | "department" | "accountType" | "owner" | "cardName" | "limit" | "cardType" | "utilisation";
64
+ export declare const toChargeCardSortKeyType: (v: string) => "status" | "accountType" | "owner" | "cardName" | "limit" | "department" | "cardType" | "utilisation";
65
65
  export declare type ChargeCardViewSortKey = ReturnType<typeof toChargeCardSortKeyType>;
66
66
  export declare const ALL_CASHBACK_SORT_KEYS: readonly ["month", "cashback"];
67
67
  export declare const toCashbackSortKeyType: (v: string) => "month" | "cashback";
@@ -9,17 +9,9 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const remiSetupApproverViewReducer_1 = require("../remiSetupApproverViewReducer");
11
11
  const deleteRemiApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.deleteRemiApprovalRule.match), (0, operators_1.switchMap)((action) => {
12
- const { approvalRuleId, useV3 } = action.payload;
13
- // Approval Rules 3.0 — flag-gated endpoint selection.
14
- // Explicit `=== true` keeps `strict-boolean-expressions` happy
15
- // when RTK's payload type widens to `any` in some configs.
16
- const endpoint = useV3 === true
17
- ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
18
- : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
12
+ const { approvalRuleId } = action.payload;
19
13
  return zeniAPI
20
- .deleteAndGetJSON(endpoint, {
21
- approval_rule_id: approvalRuleId,
22
- })
14
+ .deleteAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`, { approval_rule_id: approvalRuleId })
23
15
  .pipe((0, operators_1.mergeMap)((response) => {
24
16
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
25
17
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
@@ -9,7 +9,7 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const remiSetupApproverViewReducer_1 = require("../remiSetupApproverViewReducer");
11
11
  const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.fetchRemiSetupApproverView.match), (0, operators_1.switchMap)((action) => {
12
- const { cacheOverride, resolveAttributeToUser, includeImplicitActors, useV3, } = action.payload;
12
+ const { cacheOverride, resolveAttributeToUser, includeImplicitActors } = action.payload;
13
13
  const { remiSetupApproverViewState, approvalRuleState } = state$.value;
14
14
  const approvalRules = (0, approvalRuleSelector_1.getApprovalRulesByIds)(approvalRuleState, remiSetupApproverViewState.approvalRuleIds);
15
15
  if (cacheOverride === true ||
@@ -17,14 +17,8 @@ const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.p
17
17
  remiSetupApproverViewState.approvalRuleIds.length ||
18
18
  (remiSetupApproverViewState.hasValidState() === false &&
19
19
  remiSetupApproverViewState.fetchState !== 'In-Progress')) {
20
- // Approval Rules 3.0 — flag-gated endpoint selection.
21
- // Explicit `=== true` keeps `strict-boolean-expressions` happy
22
- // when RTK's payload type widens to `any` in some configs.
23
- const basePath = useV3 === true
24
- ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
25
- : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
26
20
  return zeniAPI
27
- .getJSON(`${basePath}?query={"is_include_implicit_actors": ${includeImplicitActors}, "is_resolve_attribute_to_user":${resolveAttributeToUser}}`)
21
+ .getJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules?query={"is_include_implicit_actors": ${includeImplicitActors}, "is_resolve_attribute_to_user":${resolveAttributeToUser}}`)
28
22
  .pipe((0, operators_1.mergeMap)((response) => {
29
23
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
30
24
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);