@zeniai/client-epic-state 5.0.90-betaAR5 → 5.0.90-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.
Files changed (81) hide show
  1. package/lib/entity/approvalRule/approvalRulePayload.d.ts +5 -34
  2. package/lib/entity/approvalRule/approvalRulePayload.js +10 -145
  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 -145
  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 +7 -8
  15. package/lib/esm/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
  16. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +12 -109
  17. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  18. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  19. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +7 -11
  20. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +4 -13
  21. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -140
  22. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
  23. package/lib/esm/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +2 -8
  24. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +13 -6
  25. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +46 -8
  26. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +2 -6
  27. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +23 -12
  28. package/lib/esm/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.js +1 -5
  29. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  30. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  31. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -11
  32. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +4 -13
  33. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -80
  34. package/lib/index.d.ts +9 -10
  35. package/lib/index.js +19 -27
  36. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  37. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  38. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  39. package/lib/view/people/peopleTypes.d.ts +1 -1
  40. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.d.ts +0 -7
  41. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
  42. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +3 -14
  43. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +13 -110
  44. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +0 -16
  45. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  46. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  47. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -10
  48. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -12
  49. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -59
  50. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +17 -142
  51. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +5 -31
  52. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -8
  53. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
  54. package/lib/view/spendManagement/billPay/editBillView/epics/fetchEditBillDetailPageEpic.js +2 -8
  55. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +13 -6
  56. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +22 -0
  57. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +49 -9
  58. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +1 -5
  59. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +23 -12
  60. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +16 -0
  61. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  62. package/lib/view/spendManagement/reimbursement/editRemiView/epics/fetchEditRemiDetailPageEpic.js +1 -5
  63. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  64. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  65. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -10
  66. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +3 -12
  67. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +3 -14
  68. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +12 -81
  69. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +0 -12
  70. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  71. package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
  72. package/package.json +1 -1
  73. package/lib/entity/approvalRule/approvalRuleConflict.d.ts +0 -56
  74. package/lib/entity/approvalRule/approvalRuleConflict.js +0 -77
  75. package/lib/esm/entity/approvalRule/approvalRuleConflict.js +0 -74
  76. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -54
  77. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -61
  78. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.d.ts +0 -23
  79. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -58
  80. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.d.ts +0 -14
  81. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -65
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectRuleOverlap = detectRuleOverlap;
4
- function detectRuleOverlap({ candidateCriteria, existingRules, excludeRuleId, }) {
5
- const candidateAmount = pickAmount(candidateCriteria);
6
- const candidateVendor = pickVendor(candidateCriteria);
7
- const candidateDepartment = pickDepartment(candidateCriteria);
8
- const overlaps = [];
9
- for (const rule of existingRules) {
10
- if (rule.approvalRuleId === excludeRuleId) {
11
- continue;
12
- }
13
- if (rule.isFallback === true) {
14
- continue;
15
- }
16
- const ruleVendor = pickVendor(rule.criteria);
17
- const ruleDepartment = pickDepartment(rule.criteria);
18
- if (!areVendorCriteriaEqual(candidateVendor, ruleVendor)) {
19
- continue;
20
- }
21
- if (!areDepartmentCriteriaEqual(candidateDepartment, ruleDepartment)) {
22
- continue;
23
- }
24
- const ruleAmount = pickAmount(rule.criteria);
25
- if (amountsOverlap(candidateAmount, ruleAmount)) {
26
- overlaps.push({ conflictingRule: rule });
27
- }
28
- }
29
- return overlaps;
30
- }
31
- const pickAmount = (criteria) => criteria.find((c) => c.type === 'amount');
32
- const pickVendor = (criteria) => criteria.find((c) => c.type === 'vendor');
33
- const pickDepartment = (criteria) => criteria.find((c) => c.type === 'department');
34
- const areVendorCriteriaEqual = (a, b) => {
35
- if (a == null && b == null) {
36
- return true;
37
- }
38
- if (a == null || b == null) {
39
- return false;
40
- }
41
- if (a.operator !== b.operator) {
42
- return false;
43
- }
44
- return idsEqual(a.vendorIds, b.vendorIds);
45
- };
46
- const areDepartmentCriteriaEqual = (a, b) => {
47
- if (a == null && b == null) {
48
- return true;
49
- }
50
- if (a == null || b == null) {
51
- return false;
52
- }
53
- if (a.operator !== b.operator) {
54
- return false;
55
- }
56
- return idsEqual(a.departmentIds, b.departmentIds);
57
- };
58
- const idsEqual = (a, b) => {
59
- if (a.length !== b.length) {
60
- return false;
61
- }
62
- const aSorted = [...a].sort();
63
- const bSorted = [...b].sort();
64
- return aSorted.every((id, i) => id === bSorted[i]);
65
- };
66
- const amountsOverlap = (a, b) => {
67
- // Absent amount criteria covers the whole real line, so any
68
- // pairing involving an absent one is a guaranteed overlap.
69
- if (a == null || b == null) {
70
- return true;
71
- }
72
- const aLow = a.min?.amount ?? Number.NEGATIVE_INFINITY;
73
- const aHigh = a.max?.amount ?? Number.POSITIVE_INFINITY;
74
- const bLow = b.min?.amount ?? Number.NEGATIVE_INFINITY;
75
- const bHigh = b.max?.amount ?? Number.POSITIVE_INFINITY;
76
- return Math.max(aLow, bLow) <= Math.min(aHigh, bHigh);
77
- };
@@ -1,74 +0,0 @@
1
- export function detectRuleOverlap({ candidateCriteria, existingRules, excludeRuleId, }) {
2
- const candidateAmount = pickAmount(candidateCriteria);
3
- const candidateVendor = pickVendor(candidateCriteria);
4
- const candidateDepartment = pickDepartment(candidateCriteria);
5
- const overlaps = [];
6
- for (const rule of existingRules) {
7
- if (rule.approvalRuleId === excludeRuleId) {
8
- continue;
9
- }
10
- if (rule.isFallback === true) {
11
- continue;
12
- }
13
- const ruleVendor = pickVendor(rule.criteria);
14
- const ruleDepartment = pickDepartment(rule.criteria);
15
- if (!areVendorCriteriaEqual(candidateVendor, ruleVendor)) {
16
- continue;
17
- }
18
- if (!areDepartmentCriteriaEqual(candidateDepartment, ruleDepartment)) {
19
- continue;
20
- }
21
- const ruleAmount = pickAmount(rule.criteria);
22
- if (amountsOverlap(candidateAmount, ruleAmount)) {
23
- overlaps.push({ conflictingRule: rule });
24
- }
25
- }
26
- return overlaps;
27
- }
28
- const pickAmount = (criteria) => criteria.find((c) => c.type === 'amount');
29
- const pickVendor = (criteria) => criteria.find((c) => c.type === 'vendor');
30
- const pickDepartment = (criteria) => criteria.find((c) => c.type === 'department');
31
- const areVendorCriteriaEqual = (a, b) => {
32
- if (a == null && b == null) {
33
- return true;
34
- }
35
- if (a == null || b == null) {
36
- return false;
37
- }
38
- if (a.operator !== b.operator) {
39
- return false;
40
- }
41
- return idsEqual(a.vendorIds, b.vendorIds);
42
- };
43
- const areDepartmentCriteriaEqual = (a, b) => {
44
- if (a == null && b == null) {
45
- return true;
46
- }
47
- if (a == null || b == null) {
48
- return false;
49
- }
50
- if (a.operator !== b.operator) {
51
- return false;
52
- }
53
- return idsEqual(a.departmentIds, b.departmentIds);
54
- };
55
- const idsEqual = (a, b) => {
56
- if (a.length !== b.length) {
57
- return false;
58
- }
59
- const aSorted = [...a].sort();
60
- const bSorted = [...b].sort();
61
- return aSorted.every((id, i) => id === bSorted[i]);
62
- };
63
- const amountsOverlap = (a, b) => {
64
- // Absent amount criteria covers the whole real line, so any
65
- // pairing involving an absent one is a guaranteed overlap.
66
- if (a == null || b == null) {
67
- return true;
68
- }
69
- const aLow = a.min?.amount ?? Number.NEGATIVE_INFINITY;
70
- const aHigh = a.max?.amount ?? Number.POSITIVE_INFINITY;
71
- const bLow = b.min?.amount ?? Number.NEGATIVE_INFINITY;
72
- const bHigh = b.max?.amount ?? Number.POSITIVE_INFINITY;
73
- return Math.max(aLow, bLow) <= Math.min(aHigh, bHigh);
74
- };
@@ -1,54 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateApprovalRules } from '../../../../../entity/approvalRule/approvalRuleReducer';
4
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
6
- import { fetchBillPaySetupApproverView, reorderBillPayApprovalRules, reorderBillPayApprovalRulesFailure, reorderBillPayApprovalRulesSuccess, } from '../billPaySetupApproverViewReducer';
7
- export const reorderBillPayApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(reorderBillPayApprovalRules.match), switchMap((action) => {
8
- const { approvalRuleIds, useV3 } = action.payload;
9
- // Approval Rules 3.0 — flag-gated endpoint selection. Mirrors
10
- // the pattern used by delete + fetch epics: the v3 dev host
11
- // until the production base URL ships the v2 reorder route.
12
- const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2/reorder`;
13
- return zeniAPI
14
- .putAndGetJSON(endpoint, {
15
- rule_ids: approvalRuleIds,
16
- })
17
- .pipe(mergeMap((response) => {
18
- if (isSuccessResponse(response) && response.data != null) {
19
- const serverOrderedIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
20
- const actions = [
21
- updateApprovalRules(response.data.approval_rules),
22
- reorderBillPayApprovalRulesSuccess(serverOrderedIds),
23
- openSnackbar({
24
- messageSection: `bill_pay_approval_reorder`,
25
- messageText: 'success',
26
- type: 'success',
27
- }),
28
- ];
29
- return from(actions);
30
- }
31
- else {
32
- const recovery = [
33
- reorderBillPayApprovalRulesFailure(response.status),
34
- openSnackbar({
35
- messageSection: `bill_pay_approval_reorder`,
36
- messageText: 'failed',
37
- type: 'error',
38
- }),
39
- // Refetch to revert the optimistic order to server truth.
40
- fetchBillPaySetupApproverView(true, true, useV3),
41
- ];
42
- return from(recovery);
43
- }
44
- }), catchError((error) => from([
45
- reorderBillPayApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Reorder Bill Pay Approval Rules errored out' +
46
- JSON.stringify(error))),
47
- openSnackbar({
48
- messageSection: `bill_pay_approval_reorder`,
49
- messageText: 'failed',
50
- type: 'error',
51
- }),
52
- fetchBillPaySetupApproverView(true, true, useV3),
53
- ])));
54
- }));
@@ -1,61 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateApprovalRules } from '../../../../../entity/approvalRule/approvalRuleReducer';
4
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
6
- import { fetchRemiSetupApproverView, reorderRemiApprovalRules, reorderRemiApprovalRulesFailure, reorderRemiApprovalRulesSuccess, } from '../remiSetupApproverViewReducer';
7
- export const reorderRemiApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(reorderRemiApprovalRules.match), switchMap((action) => {
8
- const { approvalRuleIds, useV3 } = action.payload;
9
- const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2/reorder`;
10
- return zeniAPI
11
- .putAndGetJSON(endpoint, {
12
- rule_ids: approvalRuleIds,
13
- })
14
- .pipe(mergeMap((response) => {
15
- if (isSuccessResponse(response) && response.data != null) {
16
- const serverOrderedIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
17
- const actions = [
18
- updateApprovalRules(response.data.approval_rules),
19
- reorderRemiApprovalRulesSuccess(serverOrderedIds),
20
- openSnackbar({
21
- messageSection: `reimbursement_approval_reorder`,
22
- messageText: 'success',
23
- type: 'success',
24
- }),
25
- ];
26
- return from(actions);
27
- }
28
- else {
29
- return from([
30
- reorderRemiApprovalRulesFailure(response.status),
31
- openSnackbar({
32
- messageSection: `reimbursement_approval_reorder`,
33
- messageText: 'failed',
34
- type: 'error',
35
- }),
36
- // Failure-recovery refetch — match the screen connector
37
- // convention '(cacheOverride, resolveAttributeToUser,
38
- // includeImplicitActors, useV3)' rather than copying BillPay's
39
- // 3-arg shape. With the previous useV3-as-default-false the
40
- // V3 flag was being smuggled in as 'includeImplicitActors',
41
- // which silently broke V3 recovery refetches.
42
- fetchRemiSetupApproverView(true, false, false, useV3),
43
- ]);
44
- }
45
- }), catchError((error) => from([
46
- reorderRemiApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Reorder Reimbursement Approval Rules errored out' +
47
- JSON.stringify(error))),
48
- openSnackbar({
49
- messageSection: `reimbursement_approval_reorder`,
50
- messageText: 'failed',
51
- type: 'error',
52
- }),
53
- // Failure-recovery refetch — match the screen connector
54
- // convention '(cacheOverride, resolveAttributeToUser,
55
- // includeImplicitActors, useV3)' rather than copying BillPay's
56
- // 3-arg shape. With the previous useV3-as-default-false the
57
- // V3 flag was being smuggled in as 'includeImplicitActors',
58
- // which silently broke V3 recovery refetches.
59
- fetchRemiSetupApproverView(true, false, false, useV3),
60
- ])));
61
- }));
@@ -1,23 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateApprovalRules } from '../../../../../entity/approvalRule/approvalRuleReducer';
4
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
- import { RootState } from '../../../../../reducer';
6
- import { ZeniAPI } from '../../../../../zeniAPI';
7
- import { fetchBillPaySetupApproverView, reorderBillPayApprovalRules, reorderBillPayApprovalRulesFailure, reorderBillPayApprovalRulesSuccess } from '../billPaySetupApproverViewReducer';
8
- /**
9
- * Approval Rules 3.0 — list-page drag-and-drop reorder.
10
- *
11
- * PUT /bill-pay/approval-rules-v2/reorder with the new ID order in
12
- * 'rule_ids'. Returns the updated 'approval_rules' (with refreshed
13
- * priorities). The reducer optimistically updated 'approvalRuleIds'
14
- * on the trigger action, so:
15
- * - on success: dispatch the updated approval rule payloads into
16
- * the entity slice, then 'Success' to normalise the slice's
17
- * ordered ID list to whatever the server returned.
18
- * - on failure: snackbar + dispatch 'fetchBillPaySetupApproverView'
19
- * with cacheOverride to roll the optimistic state back to server
20
- * truth.
21
- */
22
- export type ActionType = ReturnType<typeof reorderBillPayApprovalRules> | ReturnType<typeof reorderBillPayApprovalRulesSuccess> | ReturnType<typeof reorderBillPayApprovalRulesFailure> | ReturnType<typeof updateApprovalRules> | ReturnType<typeof fetchBillPaySetupApproverView> | ReturnType<typeof openSnackbar>;
23
- export declare const reorderBillPayApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reorderBillPayApprovalRulesEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const approvalRuleReducer_1 = require("../../../../../entity/approvalRule/approvalRuleReducer");
7
- const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
8
- const responsePayload_1 = require("../../../../../responsePayload");
9
- const billPaySetupApproverViewReducer_1 = require("../billPaySetupApproverViewReducer");
10
- const reorderBillPayApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(billPaySetupApproverViewReducer_1.reorderBillPayApprovalRules.match), (0, operators_1.switchMap)((action) => {
11
- const { approvalRuleIds, useV3 } = action.payload;
12
- // Approval Rules 3.0 — flag-gated endpoint selection. Mirrors
13
- // the pattern used by delete + fetch epics: the v3 dev host
14
- // until the production base URL ships the v2 reorder route.
15
- const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2/reorder`;
16
- return zeniAPI
17
- .putAndGetJSON(endpoint, {
18
- rule_ids: approvalRuleIds,
19
- })
20
- .pipe((0, operators_1.mergeMap)((response) => {
21
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
22
- const serverOrderedIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
23
- const actions = [
24
- (0, approvalRuleReducer_1.updateApprovalRules)(response.data.approval_rules),
25
- (0, billPaySetupApproverViewReducer_1.reorderBillPayApprovalRulesSuccess)(serverOrderedIds),
26
- (0, snackbarReducer_1.openSnackbar)({
27
- messageSection: `bill_pay_approval_reorder`,
28
- messageText: 'success',
29
- type: 'success',
30
- }),
31
- ];
32
- return (0, rxjs_1.from)(actions);
33
- }
34
- else {
35
- const recovery = [
36
- (0, billPaySetupApproverViewReducer_1.reorderBillPayApprovalRulesFailure)(response.status),
37
- (0, snackbarReducer_1.openSnackbar)({
38
- messageSection: `bill_pay_approval_reorder`,
39
- messageText: 'failed',
40
- type: 'error',
41
- }),
42
- // Refetch to revert the optimistic order to server truth.
43
- (0, billPaySetupApproverViewReducer_1.fetchBillPaySetupApproverView)(true, true, useV3),
44
- ];
45
- return (0, rxjs_1.from)(recovery);
46
- }
47
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
48
- (0, billPaySetupApproverViewReducer_1.reorderBillPayApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Reorder Bill Pay Approval Rules errored out' +
49
- JSON.stringify(error))),
50
- (0, snackbarReducer_1.openSnackbar)({
51
- messageSection: `bill_pay_approval_reorder`,
52
- messageText: 'failed',
53
- type: 'error',
54
- }),
55
- (0, billPaySetupApproverViewReducer_1.fetchBillPaySetupApproverView)(true, true, useV3),
56
- ])));
57
- }));
58
- exports.reorderBillPayApprovalRulesEpic = reorderBillPayApprovalRulesEpic;
@@ -1,14 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateApprovalRules } from '../../../../../entity/approvalRule/approvalRuleReducer';
4
- import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
- import { RootState } from '../../../../../reducer';
6
- import { ZeniAPI } from '../../../../../zeniAPI';
7
- import { fetchRemiSetupApproverView, reorderRemiApprovalRules, reorderRemiApprovalRulesFailure, reorderRemiApprovalRulesSuccess } from '../remiSetupApproverViewReducer';
8
- /**
9
- * Approval Rules 3.0 — list-page drag-and-drop reorder for
10
- * reimbursements. Mirrors the BillPay reorder epic — see that file
11
- * for the longer rationale.
12
- */
13
- export type ActionType = ReturnType<typeof reorderRemiApprovalRules> | ReturnType<typeof reorderRemiApprovalRulesSuccess> | ReturnType<typeof reorderRemiApprovalRulesFailure> | ReturnType<typeof updateApprovalRules> | ReturnType<typeof fetchRemiSetupApproverView> | ReturnType<typeof openSnackbar>;
14
- export declare const reorderRemiApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reorderRemiApprovalRulesEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const approvalRuleReducer_1 = require("../../../../../entity/approvalRule/approvalRuleReducer");
7
- const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
8
- const responsePayload_1 = require("../../../../../responsePayload");
9
- const remiSetupApproverViewReducer_1 = require("../remiSetupApproverViewReducer");
10
- const reorderRemiApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.reorderRemiApprovalRules.match), (0, operators_1.switchMap)((action) => {
11
- const { approvalRuleIds, useV3 } = action.payload;
12
- const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2/reorder`;
13
- return zeniAPI
14
- .putAndGetJSON(endpoint, {
15
- rule_ids: approvalRuleIds,
16
- })
17
- .pipe((0, operators_1.mergeMap)((response) => {
18
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
19
- const serverOrderedIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
20
- const actions = [
21
- (0, approvalRuleReducer_1.updateApprovalRules)(response.data.approval_rules),
22
- (0, remiSetupApproverViewReducer_1.reorderRemiApprovalRulesSuccess)(serverOrderedIds),
23
- (0, snackbarReducer_1.openSnackbar)({
24
- messageSection: `reimbursement_approval_reorder`,
25
- messageText: 'success',
26
- type: 'success',
27
- }),
28
- ];
29
- return (0, rxjs_1.from)(actions);
30
- }
31
- else {
32
- return (0, rxjs_1.from)([
33
- (0, remiSetupApproverViewReducer_1.reorderRemiApprovalRulesFailure)(response.status),
34
- (0, snackbarReducer_1.openSnackbar)({
35
- messageSection: `reimbursement_approval_reorder`,
36
- messageText: 'failed',
37
- type: 'error',
38
- }),
39
- // Failure-recovery refetch — match the screen connector
40
- // convention '(cacheOverride, resolveAttributeToUser,
41
- // includeImplicitActors, useV3)' rather than copying BillPay's
42
- // 3-arg shape. With the previous useV3-as-default-false the
43
- // V3 flag was being smuggled in as 'includeImplicitActors',
44
- // which silently broke V3 recovery refetches.
45
- (0, remiSetupApproverViewReducer_1.fetchRemiSetupApproverView)(true, false, false, useV3),
46
- ]);
47
- }
48
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
49
- (0, remiSetupApproverViewReducer_1.reorderRemiApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Reorder Reimbursement Approval Rules errored out' +
50
- JSON.stringify(error))),
51
- (0, snackbarReducer_1.openSnackbar)({
52
- messageSection: `reimbursement_approval_reorder`,
53
- messageText: 'failed',
54
- type: 'error',
55
- }),
56
- // Failure-recovery refetch — match the screen connector
57
- // convention '(cacheOverride, resolveAttributeToUser,
58
- // includeImplicitActors, useV3)' rather than copying BillPay's
59
- // 3-arg shape. With the previous useV3-as-default-false the
60
- // V3 flag was being smuggled in as 'includeImplicitActors',
61
- // which silently broke V3 recovery refetches.
62
- (0, remiSetupApproverViewReducer_1.fetchRemiSetupApproverView)(true, false, false, useV3),
63
- ])));
64
- }));
65
- exports.reorderRemiApprovalRulesEpic = reorderRemiApprovalRulesEpic;