@zeniai/client-epic-state 5.0.90-betaAR4 → 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 (77) 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 -102
  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 -120
  22. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
  23. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +13 -6
  24. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +46 -8
  25. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +2 -6
  26. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +23 -12
  27. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  28. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  29. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -11
  30. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +4 -13
  31. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -76
  32. package/lib/index.d.ts +9 -10
  33. package/lib/index.js +19 -27
  34. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  35. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  36. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  37. package/lib/view/people/peopleTypes.d.ts +1 -1
  38. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.d.ts +0 -7
  39. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
  40. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +3 -14
  41. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +13 -103
  42. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +0 -16
  43. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
  44. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
  45. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -10
  46. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -12
  47. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -59
  48. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +17 -122
  49. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +5 -31
  50. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -8
  51. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
  52. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +13 -6
  53. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +22 -0
  54. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +49 -9
  55. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +1 -5
  56. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +23 -12
  57. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +16 -0
  58. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  59. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
  60. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
  61. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -10
  62. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +3 -12
  63. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +3 -14
  64. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +12 -77
  65. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +0 -12
  66. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  67. package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
  68. package/package.json +1 -1
  69. package/lib/entity/approvalRule/approvalRuleConflict.d.ts +0 -56
  70. package/lib/entity/approvalRule/approvalRuleConflict.js +0 -77
  71. package/lib/esm/entity/approvalRule/approvalRuleConflict.js +0 -74
  72. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -54
  73. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -49
  74. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.d.ts +0 -23
  75. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -58
  76. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.d.ts +0 -14
  77. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -53
@@ -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,49 +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
- fetchRemiSetupApproverView(true, true, useV3),
37
- ]);
38
- }
39
- }), catchError((error) => from([
40
- reorderRemiApprovalRulesFailure(createZeniAPIStatus('Unexpected Error', 'Reorder Reimbursement Approval Rules errored out' +
41
- JSON.stringify(error))),
42
- openSnackbar({
43
- messageSection: `reimbursement_approval_reorder`,
44
- messageText: 'failed',
45
- type: 'error',
46
- }),
47
- fetchRemiSetupApproverView(true, true, useV3),
48
- ])));
49
- }));
@@ -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,53 +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
- (0, remiSetupApproverViewReducer_1.fetchRemiSetupApproverView)(true, true, useV3),
40
- ]);
41
- }
42
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
43
- (0, remiSetupApproverViewReducer_1.reorderRemiApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Reorder Reimbursement Approval Rules errored out' +
44
- JSON.stringify(error))),
45
- (0, snackbarReducer_1.openSnackbar)({
46
- messageSection: `reimbursement_approval_reorder`,
47
- messageText: 'failed',
48
- type: 'error',
49
- }),
50
- (0, remiSetupApproverViewReducer_1.fetchRemiSetupApproverView)(true, true, useV3),
51
- ])));
52
- }));
53
- exports.reorderRemiApprovalRulesEpic = reorderRemiApprovalRulesEpic;