@zeniai/client-epic-state 5.0.65-betaRR6 → 5.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/aiCfo/aiCfoSuggestedQuestionsPageContext.d.ts +1 -1
- package/lib/entity/aiCfo/aiCfoPayload.d.ts +1 -168
- package/lib/entity/aiCfo/aiCfoReducer.js +2 -186
- package/lib/entity/aiCfo/aiCfoState.d.ts +4 -164
- package/lib/entity/aiCfo/aiCfoState.js +1 -10
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
- package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -2
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
- package/lib/entity/tenant/clearAllEpic.js +0 -8
- package/lib/epic.d.ts +1 -9
- package/lib/epic.js +1 -9
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +3 -187
- package/lib/esm/entity/aiCfo/aiCfoState.js +0 -7
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
- package/lib/esm/epic.js +1 -9
- package/lib/esm/index.js +3 -17
- package/lib/esm/reducer.js +0 -12
- package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
- package/lib/index.d.ts +3 -16
- package/lib/index.js +11 -99
- package/lib/reducer.d.ts +0 -12
- package/lib/reducer.js +0 -12
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +0 -7
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
- package/lib/view/companyHealthMetricView/companyHealthMetricViewSelector.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/missingReceiptsViewState.d.ts +2 -2
- package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -1
- package/lib/view/onboardingView/cockpitView/types/onboardingCockpitViewTypes.d.ts +1 -1
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +0 -14
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +1 -27
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/package.json +1 -1
- package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -176
- package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -112
- package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -13
- package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -203
- package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -28
- package/lib/entity/cardPolicy/cardPolicySelector.js +0 -86
- package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -172
- package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -54
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
- package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -101
- package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -199
- package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -66
- package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
- package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -50
- package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -70
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -22
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -56
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -49
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -42
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -72
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -21
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -56
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -50
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -6
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -34
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -25
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +0 -14
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +0 -74
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +0 -21
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +0 -28
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +0 -25
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +0 -60
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +0 -18
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +0 -53
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +0 -16
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +0 -46
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +0 -76
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +0 -21
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +0 -27
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +0 -19
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +0 -60
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +0 -12
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -54
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -4
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -10
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -8
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -38
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateCardPolicyEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const cardPolicyPayload_1 = require("../../../../../entity/cardPolicy/cardPolicyPayload");
|
|
7
|
-
const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
9
|
-
const cardPolicyDetailReducer_1 = require("./cardPolicyDetailReducer");
|
|
10
|
-
/**
|
|
11
|
-
* `PUT /cards/1.0/policy-templates/{id}`. Reads the current `formDraft`
|
|
12
|
-
* off the `cardPolicyDetail` slice, converts it to the snake_case wire
|
|
13
|
-
* body (same shape as create), and submits. On success the entity
|
|
14
|
-
* slice picks up the refreshed template and the view lifecycle flips
|
|
15
|
-
* to `Completed`.
|
|
16
|
-
*
|
|
17
|
-
* If the action fires before a draft is seeded (e.g. user clicks save
|
|
18
|
-
* before the detail fetch lands), we short-circuit with an Error.
|
|
19
|
-
*/
|
|
20
|
-
const updateCardPolicyEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyDetailReducer_1.updateCardPolicy.match), (0, operators_1.mergeMap)((action) => {
|
|
21
|
-
const templateId = action.payload;
|
|
22
|
-
const formDraft = state$.value.cardPolicyDetailState.formDraft;
|
|
23
|
-
if (formDraft == null) {
|
|
24
|
-
return (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({
|
|
25
|
-
fetchState: 'Error',
|
|
26
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Missing form draft', `Cannot update card-policy ${templateId} — no formDraft is loaded.`),
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
const body = (0, cardPolicyPayload_1.toUpdateCardPolicyTemplateRequestBody)(formDraft);
|
|
30
|
-
return zeniAPI
|
|
31
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`, body)
|
|
32
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
33
|
-
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
34
|
-
const { template } = response.data;
|
|
35
|
-
const actions = [
|
|
36
|
-
(0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template),
|
|
37
|
-
(0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({ fetchState: 'Completed' }),
|
|
38
|
-
];
|
|
39
|
-
return (0, rxjs_1.from)(actions);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({
|
|
43
|
-
fetchState: 'Error',
|
|
44
|
-
error: response.status,
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyDetailReducer_1.updateCardPolicyFetchStatus)({
|
|
48
|
-
fetchState: 'Error',
|
|
49
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Update card-policy REST API call errored out' +
|
|
50
|
-
JSON.stringify(error)),
|
|
51
|
-
}))));
|
|
52
|
-
}));
|
|
53
|
-
exports.updateCardPolicyEpic = updateCardPolicyEpic;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { removeCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { RootState } from '../../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
-
import { archiveCardPolicy, updateArchiveCardPolicyFetchStatus } from './cardPolicyListReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof archiveCardPolicy> | ReturnType<typeof removeCardPolicyTemplate> | ReturnType<typeof updateArchiveCardPolicyFetchStatus>;
|
|
8
|
-
/**
|
|
9
|
-
* `DELETE /cards/1.0/policy-templates/{id}`. Modeled like
|
|
10
|
-
* `deleteBillEpic`: typed as bare `ZeniAPIResponse` (no `data` body
|
|
11
|
-
* expected) with `isSuccessStatus` driving the success branch. On
|
|
12
|
-
* success the entity slice drops the template via
|
|
13
|
-
* `removeCardPolicyTemplate(templateId)` and the view slice records
|
|
14
|
-
* `Completed` (also pruning the ID from `templateIds`).
|
|
15
|
-
*/
|
|
16
|
-
export declare const archiveCardPolicyEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.archiveCardPolicyEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
8
|
-
const cardPolicyListReducer_1 = require("./cardPolicyListReducer");
|
|
9
|
-
/**
|
|
10
|
-
* `DELETE /cards/1.0/policy-templates/{id}`. Modeled like
|
|
11
|
-
* `deleteBillEpic`: typed as bare `ZeniAPIResponse` (no `data` body
|
|
12
|
-
* expected) with `isSuccessStatus` driving the success branch. On
|
|
13
|
-
* success the entity slice drops the template via
|
|
14
|
-
* `removeCardPolicyTemplate(templateId)` and the view slice records
|
|
15
|
-
* `Completed` (also pruning the ID from `templateIds`).
|
|
16
|
-
*/
|
|
17
|
-
const archiveCardPolicyEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyListReducer_1.archiveCardPolicy.match), (0, operators_1.mergeMap)((action) => {
|
|
18
|
-
const templateId = action.payload;
|
|
19
|
-
return zeniAPI
|
|
20
|
-
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`)
|
|
21
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
22
|
-
if ((0, responsePayload_1.isSuccessStatus)(response)) {
|
|
23
|
-
const actions = [
|
|
24
|
-
(0, cardPolicyReducer_1.removeCardPolicyTemplate)(templateId),
|
|
25
|
-
(0, cardPolicyListReducer_1.updateArchiveCardPolicyFetchStatus)({
|
|
26
|
-
fetchState: 'Completed',
|
|
27
|
-
templateId,
|
|
28
|
-
}),
|
|
29
|
-
];
|
|
30
|
-
return (0, rxjs_1.from)(actions);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return (0, rxjs_1.of)((0, cardPolicyListReducer_1.updateArchiveCardPolicyFetchStatus)({
|
|
34
|
-
fetchState: 'Error',
|
|
35
|
-
error: response.status,
|
|
36
|
-
templateId,
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyListReducer_1.updateArchiveCardPolicyFetchStatus)({
|
|
40
|
-
fetchState: 'Error',
|
|
41
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Archive card-policy REST API call errored out' +
|
|
42
|
-
JSON.stringify(error)),
|
|
43
|
-
templateId,
|
|
44
|
-
}))));
|
|
45
|
-
}));
|
|
46
|
-
exports.archiveCardPolicyEpic = archiveCardPolicyEpic;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FetchState, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
import { ZeniAPIStatus } from '../../../../../responsePayload';
|
|
3
|
-
import { CardPolicyListState } from './cardPolicyListState';
|
|
4
|
-
export declare const initialState: CardPolicyListState;
|
|
5
|
-
export declare const fetchCardPolicyList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicyList/fetchCardPolicyList">, updateCardPolicyListFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
6
|
-
fetchState: FetchState;
|
|
7
|
-
error?: ZeniAPIStatus;
|
|
8
|
-
templateIds?: ID[];
|
|
9
|
-
}, "cardPolicyList/updateCardPolicyListFetchStatus">, archiveCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[templateId: string], string, "cardPolicyList/archiveCardPolicy", never, never>, updateArchiveCardPolicyFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
10
|
-
fetchState: FetchState;
|
|
11
|
-
error?: ZeniAPIStatus;
|
|
12
|
-
templateId?: ID;
|
|
13
|
-
}, "cardPolicyList/updateArchiveCardPolicyFetchStatus">, clearCardPolicyList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicyList/clearCardPolicyList">;
|
|
14
|
-
declare const _default: import("redux").Reducer<CardPolicyListState>;
|
|
15
|
-
export default _default;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearCardPolicyList = exports.updateArchiveCardPolicyFetchStatus = exports.archiveCardPolicy = exports.updateCardPolicyListFetchStatus = exports.fetchCardPolicyList = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
exports.initialState = {
|
|
7
|
-
templateIds: [],
|
|
8
|
-
fetchState: {
|
|
9
|
-
fetchState: 'Not-Started',
|
|
10
|
-
error: undefined,
|
|
11
|
-
},
|
|
12
|
-
archiveFetchState: {
|
|
13
|
-
fetchState: 'Not-Started',
|
|
14
|
-
error: undefined,
|
|
15
|
-
},
|
|
16
|
-
archiveTargetTemplateId: undefined,
|
|
17
|
-
};
|
|
18
|
-
const cardPolicyList = (0, toolkit_1.createSlice)({
|
|
19
|
-
name: 'cardPolicyList',
|
|
20
|
-
initialState: exports.initialState,
|
|
21
|
-
reducers: {
|
|
22
|
-
/**
|
|
23
|
-
* Kick off the `GET /cards/1.0/policy-templates` request. The
|
|
24
|
-
* accompanying epic dispatches `updateCardPolicyTemplates(templates)`
|
|
25
|
-
* + `updateCardPolicyStats(stats)` on the entity slice and
|
|
26
|
-
* `updateCardPolicyListFetchStatus` here (also supplying the ordered
|
|
27
|
-
* `templateIds` on success).
|
|
28
|
-
*/
|
|
29
|
-
fetchCardPolicyList(draft) {
|
|
30
|
-
draft.fetchState.fetchState = 'In-Progress';
|
|
31
|
-
draft.fetchState.error = undefined;
|
|
32
|
-
},
|
|
33
|
-
updateCardPolicyListFetchStatus(draft, action) {
|
|
34
|
-
draft.fetchState.fetchState = action.payload.fetchState;
|
|
35
|
-
draft.fetchState.error = action.payload.error;
|
|
36
|
-
if (action.payload.templateIds != null) {
|
|
37
|
-
draft.templateIds = action.payload.templateIds;
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
/**
|
|
41
|
-
* Kick off the `DELETE /cards/1.0/policy-templates/{id}` request.
|
|
42
|
-
* The accompanying epic dispatches `removeCardPolicyTemplate(id)` on
|
|
43
|
-
* the entity slice on success + `updateArchiveCardPolicyFetchStatus`
|
|
44
|
-
* here. The view layer also drops the ID from `templateIds` so the
|
|
45
|
-
* list stays in sync without re-fetching.
|
|
46
|
-
*/
|
|
47
|
-
archiveCardPolicy: {
|
|
48
|
-
reducer(draft, action) {
|
|
49
|
-
draft.archiveFetchState.fetchState = 'In-Progress';
|
|
50
|
-
draft.archiveFetchState.error = undefined;
|
|
51
|
-
draft.archiveTargetTemplateId = action.payload;
|
|
52
|
-
},
|
|
53
|
-
prepare(templateId) {
|
|
54
|
-
return { payload: templateId };
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
updateArchiveCardPolicyFetchStatus(draft, action) {
|
|
58
|
-
draft.archiveFetchState.fetchState = action.payload.fetchState;
|
|
59
|
-
draft.archiveFetchState.error = action.payload.error;
|
|
60
|
-
if (action.payload.fetchState === 'Completed') {
|
|
61
|
-
if (action.payload.templateId != null) {
|
|
62
|
-
draft.templateIds = draft.templateIds.filter((id) => id !== action.payload.templateId);
|
|
63
|
-
}
|
|
64
|
-
draft.archiveTargetTemplateId = undefined;
|
|
65
|
-
}
|
|
66
|
-
else if (action.payload.fetchState === 'Error') {
|
|
67
|
-
draft.archiveTargetTemplateId = undefined;
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
clearCardPolicyList(draft) {
|
|
71
|
-
Object.assign(draft, exports.initialState);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
_a = cardPolicyList.actions, exports.fetchCardPolicyList = _a.fetchCardPolicyList, exports.updateCardPolicyListFetchStatus = _a.updateCardPolicyListFetchStatus, exports.archiveCardPolicy = _a.archiveCardPolicy, exports.updateArchiveCardPolicyFetchStatus = _a.updateArchiveCardPolicyFetchStatus, exports.clearCardPolicyList = _a.clearCardPolicyList;
|
|
76
|
-
exports.default = cardPolicyList.reducer;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
import { CardPolicyStats, CardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyState';
|
|
3
|
-
import { RootState } from '../../../../../reducer';
|
|
4
|
-
/**
|
|
5
|
-
* Composite view returned by `getCardPolicyListView` — the only public
|
|
6
|
-
* shape the Card Policy list page should consume. Mirrors how
|
|
7
|
-
* `chargeCardListSelector` joins the view ID list with the entity store
|
|
8
|
-
* and exposes ancillary lifecycle slots in a single object.
|
|
9
|
-
*/
|
|
10
|
-
export interface CardPolicyListSelectorView {
|
|
11
|
-
archiveFetchState: FetchStateAndError;
|
|
12
|
-
fetchState: FetchStateAndError;
|
|
13
|
-
templateIds: ID[];
|
|
14
|
-
templates: CardPolicyTemplate[];
|
|
15
|
-
archiveTargetTemplateId?: ID;
|
|
16
|
-
stats?: CardPolicyStats;
|
|
17
|
-
}
|
|
18
|
-
export declare function getCardPolicyListView(state: RootState): CardPolicyListSelectorView;
|
|
19
|
-
export declare function getCardPolicyListFetchState(state: RootState): FetchStateAndError;
|
|
20
|
-
export declare function getArchiveCardPolicyFetchState(state: RootState): FetchStateAndError;
|
|
21
|
-
export declare function getCardPolicyTemplateIds(state: RootState): ID[];
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCardPolicyListView = getCardPolicyListView;
|
|
4
|
-
exports.getCardPolicyListFetchState = getCardPolicyListFetchState;
|
|
5
|
-
exports.getArchiveCardPolicyFetchState = getArchiveCardPolicyFetchState;
|
|
6
|
-
exports.getCardPolicyTemplateIds = getCardPolicyTemplateIds;
|
|
7
|
-
const cardPolicySelector_1 = require("../../../../../entity/cardPolicy/cardPolicySelector");
|
|
8
|
-
function getCardPolicyListView(state) {
|
|
9
|
-
const { cardPolicyListState, cardPolicyState } = state;
|
|
10
|
-
return {
|
|
11
|
-
templates: (0, cardPolicySelector_1.getCardPolicyTemplatesByIds)(cardPolicyState, cardPolicyListState.templateIds),
|
|
12
|
-
templateIds: cardPolicyListState.templateIds,
|
|
13
|
-
fetchState: cardPolicyListState.fetchState,
|
|
14
|
-
archiveFetchState: cardPolicyListState.archiveFetchState,
|
|
15
|
-
archiveTargetTemplateId: cardPolicyListState.archiveTargetTemplateId,
|
|
16
|
-
stats: (0, cardPolicySelector_1.getCardPolicyStats)(cardPolicyState),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function getCardPolicyListFetchState(state) {
|
|
20
|
-
return state.cardPolicyListState.fetchState;
|
|
21
|
-
}
|
|
22
|
-
function getArchiveCardPolicyFetchState(state) {
|
|
23
|
-
return state.cardPolicyListState.archiveFetchState;
|
|
24
|
-
}
|
|
25
|
-
function getCardPolicyTemplateIds(state) {
|
|
26
|
-
return state.cardPolicyListState.templateIds;
|
|
27
|
-
}
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
/**
|
|
3
|
-
* View-side state for the Card Policy list page. Mirrors the
|
|
4
|
-
* `chargeCardList` pattern: server-order ID list + sibling
|
|
5
|
-
* `FetchStateAndError` slots for each long-running mutation the page
|
|
6
|
-
* owns. The actual `CardPolicyTemplate` objects (and tenant-wide stats)
|
|
7
|
-
* live on the `cardPolicy` entity slice so any reader can join via
|
|
8
|
-
* `getCardPolicyTemplatesByIds` / `getCardPolicyStats`.
|
|
9
|
-
*/
|
|
10
|
-
export interface CardPolicyListState {
|
|
11
|
-
/** Lifecycle for the `DELETE /policy-templates/{id}` request. */
|
|
12
|
-
archiveFetchState: FetchStateAndError;
|
|
13
|
-
/** Lifecycle for the `GET /policy-templates` request. */
|
|
14
|
-
fetchState: FetchStateAndError;
|
|
15
|
-
/** Ordered list of template IDs as returned by the list endpoint. */
|
|
16
|
-
templateIds: ID[];
|
|
17
|
-
/** ID of the template currently being archived (cleared on completion). */
|
|
18
|
-
archiveTargetTemplateId?: ID;
|
|
19
|
-
}
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateCardPolicyStats, updateCardPolicyTemplates } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { RootState } from '../../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
-
import { fetchCardPolicyList, updateCardPolicyListFetchStatus } from './cardPolicyListReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchCardPolicyList> | ReturnType<typeof updateCardPolicyTemplates> | ReturnType<typeof updateCardPolicyStats> | ReturnType<typeof updateCardPolicyListFetchStatus>;
|
|
8
|
-
/**
|
|
9
|
-
* `GET /cards/1.0/policy-templates`. On success the response carries
|
|
10
|
-
* both the tenant-wide `stats` block and a `templates[]` array whose
|
|
11
|
-
* rows are wrapped in `{data: {cards_applied, template}}` (the same
|
|
12
|
-
* envelope the create endpoint returns). We split the result into
|
|
13
|
-
* three actions:
|
|
14
|
-
*
|
|
15
|
-
* 1. `updateCardPolicyTemplates` — full replace of the entity map.
|
|
16
|
-
* 2. `updateCardPolicyStats` — entity-level cached stats.
|
|
17
|
-
* 3. `updateCardPolicyListFetchStatus` — view lifecycle + ordered IDs.
|
|
18
|
-
*/
|
|
19
|
-
export declare const fetchCardPolicyListEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchCardPolicyListEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const cardPolicyPayload_1 = require("../../../../../entity/cardPolicy/cardPolicyPayload");
|
|
7
|
-
const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
|
|
8
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
9
|
-
const cardPolicyListReducer_1 = require("./cardPolicyListReducer");
|
|
10
|
-
/**
|
|
11
|
-
* `GET /cards/1.0/policy-templates`. On success the response carries
|
|
12
|
-
* both the tenant-wide `stats` block and a `templates[]` array whose
|
|
13
|
-
* rows are wrapped in `{data: {cards_applied, template}}` (the same
|
|
14
|
-
* envelope the create endpoint returns). We split the result into
|
|
15
|
-
* three actions:
|
|
16
|
-
*
|
|
17
|
-
* 1. `updateCardPolicyTemplates` — full replace of the entity map.
|
|
18
|
-
* 2. `updateCardPolicyStats` — entity-level cached stats.
|
|
19
|
-
* 3. `updateCardPolicyListFetchStatus` — view lifecycle + ordered IDs.
|
|
20
|
-
*/
|
|
21
|
-
const fetchCardPolicyListEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyListReducer_1.fetchCardPolicyList.match),
|
|
22
|
-
// `exhaustMap` (rather than `mergeMap`) so a duplicate
|
|
23
|
-
// `fetchCardPolicyList` dispatched while the previous one is still
|
|
24
|
-
// in flight is dropped instead of producing a second HTTP request.
|
|
25
|
-
// This guards against React 18 StrictMode, which mount-cleanup-
|
|
26
|
-
// remounts the screen's mount effect with a stale closure of
|
|
27
|
-
// `listFetchState`, causing the same effect to dispatch this
|
|
28
|
-
// action twice synchronously. Retry-after-error still works
|
|
29
|
-
// because the previous inner observable has completed by the time
|
|
30
|
-
// the user retries.
|
|
31
|
-
(0, operators_1.exhaustMap)(() => {
|
|
32
|
-
return zeniAPI
|
|
33
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`)
|
|
34
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
35
|
-
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
36
|
-
const templates = (0, cardPolicyPayload_1.toCardPolicyTemplateList)(response.data);
|
|
37
|
-
const stats = (0, cardPolicyPayload_1.toCardPolicyStats)(response.data.stats);
|
|
38
|
-
const actions = [
|
|
39
|
-
(0, cardPolicyReducer_1.updateCardPolicyTemplates)(templates),
|
|
40
|
-
(0, cardPolicyReducer_1.updateCardPolicyStats)(stats),
|
|
41
|
-
(0, cardPolicyListReducer_1.updateCardPolicyListFetchStatus)({
|
|
42
|
-
fetchState: 'Completed',
|
|
43
|
-
templateIds: templates.map((t) => t.templateId),
|
|
44
|
-
}),
|
|
45
|
-
];
|
|
46
|
-
return (0, rxjs_1.from)(actions);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return (0, rxjs_1.of)((0, cardPolicyListReducer_1.updateCardPolicyListFetchStatus)({
|
|
50
|
-
fetchState: 'Error',
|
|
51
|
-
error: response.status,
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyListReducer_1.updateCardPolicyListFetchStatus)({
|
|
55
|
-
fetchState: 'Error',
|
|
56
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch card-policy list REST API call errored out' +
|
|
57
|
-
JSON.stringify(error)),
|
|
58
|
-
}))));
|
|
59
|
-
}));
|
|
60
|
-
exports.fetchCardPolicyListEpic = fetchCardPolicyListEpic;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FetchState, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
3
|
-
import { ZeniAPIStatus } from '../../../../../responsePayload';
|
|
4
|
-
import { CreateCardPolicyState } from './createCardPolicyState';
|
|
5
|
-
export declare const initialState: CreateCardPolicyState;
|
|
6
|
-
export declare const createCardPolicyTemplate: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[request: CreateCardPolicyTemplateRequest], CreateCardPolicyTemplateRequest, "createCardPolicy/createCardPolicyTemplate", never, never>, updateCreateCardPolicyTemplateRequestState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
7
|
-
fetchState: FetchState;
|
|
8
|
-
error?: ZeniAPIStatus;
|
|
9
|
-
templateId?: ID;
|
|
10
|
-
}, "createCardPolicy/updateCreateCardPolicyTemplateRequestState">, clearCreateCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"createCardPolicy/clearCreateCardPolicy">;
|
|
11
|
-
declare const _default: import("redux").Reducer<CreateCardPolicyState>;
|
|
12
|
-
export default _default;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.clearCreateCardPolicy = exports.updateCreateCardPolicyTemplateRequestState = exports.createCardPolicyTemplate = exports.initialState = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
exports.initialState = {
|
|
7
|
-
createCardPolicyTemplateRequestState: {
|
|
8
|
-
fetchState: 'Not-Started',
|
|
9
|
-
error: undefined,
|
|
10
|
-
},
|
|
11
|
-
lastCreatedCardPolicyTemplateId: undefined,
|
|
12
|
-
};
|
|
13
|
-
const createCardPolicy = (0, toolkit_1.createSlice)({
|
|
14
|
-
name: 'createCardPolicy',
|
|
15
|
-
initialState: exports.initialState,
|
|
16
|
-
reducers: {
|
|
17
|
-
/**
|
|
18
|
-
* Kick off the `POST /cards/1.0/policy-templates` request. Setting
|
|
19
|
-
* the request state to `In-Progress` synchronously here matches how
|
|
20
|
-
* every other "create" slice in this repo wires its kickoff
|
|
21
|
-
* (see `issueChargeCards`, `fetchChargeCardConfig`, etc.).
|
|
22
|
-
*
|
|
23
|
-
* The accompanying epic listens for this action, performs the POST,
|
|
24
|
-
* dispatches `updateCreatedCardPolicyTemplate` on the entity slice,
|
|
25
|
-
* and dispatches `updateCreateCardPolicyTemplateRequestState` here to
|
|
26
|
-
* flip the lifecycle to `Completed` or `Error`.
|
|
27
|
-
*/
|
|
28
|
-
createCardPolicyTemplate: {
|
|
29
|
-
reducer(draft,
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
|
-
_action) {
|
|
32
|
-
draft.createCardPolicyTemplateRequestState.fetchState = 'In-Progress';
|
|
33
|
-
draft.createCardPolicyTemplateRequestState.error = undefined;
|
|
34
|
-
draft.lastCreatedCardPolicyTemplateId = undefined;
|
|
35
|
-
},
|
|
36
|
-
prepare(request) {
|
|
37
|
-
return { payload: request };
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
updateCreateCardPolicyTemplateRequestState(draft, action) {
|
|
41
|
-
draft.createCardPolicyTemplateRequestState.fetchState =
|
|
42
|
-
action.payload.fetchState;
|
|
43
|
-
draft.createCardPolicyTemplateRequestState.error = action.payload.error;
|
|
44
|
-
if (action.payload.templateId != null) {
|
|
45
|
-
draft.lastCreatedCardPolicyTemplateId = action.payload.templateId;
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
clearCreateCardPolicy(draft) {
|
|
49
|
-
Object.assign(draft, exports.initialState);
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
_a = createCardPolicy.actions, exports.createCardPolicyTemplate = _a.createCardPolicyTemplate, exports.updateCreateCardPolicyTemplateRequestState = _a.updateCreateCardPolicyTemplateRequestState, exports.clearCreateCardPolicy = _a.clearCreateCardPolicy;
|
|
54
|
-
exports.default = createCardPolicy.reducer;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
import { CreateCardPolicyState } from './createCardPolicyState';
|
|
3
|
-
export declare function getCreateCardPolicyTemplateRequestState(state: CreateCardPolicyState): FetchStateAndError;
|
|
4
|
-
export declare function getLastCreatedCardPolicyTemplateId(state: CreateCardPolicyState): ID | undefined;
|
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCreateCardPolicyTemplateRequestState = getCreateCardPolicyTemplateRequestState;
|
|
4
|
-
exports.getLastCreatedCardPolicyTemplateId = getLastCreatedCardPolicyTemplateId;
|
|
5
|
-
function getCreateCardPolicyTemplateRequestState(state) {
|
|
6
|
-
return state.createCardPolicyTemplateRequestState;
|
|
7
|
-
}
|
|
8
|
-
function getLastCreatedCardPolicyTemplateId(state) {
|
|
9
|
-
return state.lastCreatedCardPolicyTemplateId;
|
|
10
|
-
}
|
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
-
/**
|
|
3
|
-
* View-side scaffolding for the manual Card Policy "create" flow.
|
|
4
|
-
*
|
|
5
|
-
* Mirrors `issueChargeCard` in spirit — kicks off a one-shot POST and
|
|
6
|
-
* tracks the request lifecycle. List + edit lifecycles live in sibling
|
|
7
|
-
* slices (`cardPolicyList`, `cardPolicyDetail`); MCC categories used by
|
|
8
|
-
* the create form live on the entity slice (shared with the AI-CFO flow)
|
|
9
|
-
* and are fetched via the co-located `fetchCardPolicyMccCategoriesEpic`.
|
|
10
|
-
*/
|
|
11
|
-
export interface CreateCardPolicyState {
|
|
12
|
-
createCardPolicyTemplateRequestState: FetchStateAndError;
|
|
13
|
-
/** `templateId` of the most recently created template — populated on success. */
|
|
14
|
-
lastCreatedCardPolicyTemplateId?: ID;
|
|
15
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { RootState } from '../../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
-
import { createCardPolicyTemplate, updateCreateCardPolicyTemplateRequestState } from './createCardPolicyReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof createCardPolicyTemplate> | ReturnType<typeof updateCreatedCardPolicyTemplate> | ReturnType<typeof updateCreateCardPolicyTemplateRequestState>;
|
|
8
|
-
export declare const createCardPolicyTemplateEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCardPolicyTemplateEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
|
|
7
|
-
const cardPolicyPayload_1 = require("../../../../../entity/cardPolicy/cardPolicyPayload");
|
|
8
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
9
|
-
const createCardPolicyReducer_1 = require("./createCardPolicyReducer");
|
|
10
|
-
const createCardPolicyTemplateEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createCardPolicyReducer_1.createCardPolicyTemplate.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
-
const body = (0, cardPolicyPayload_1.toCreateCardPolicyTemplateRequestBody)(action.payload);
|
|
12
|
-
return zeniAPI
|
|
13
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`, body)
|
|
14
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
15
|
-
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
16
|
-
const { template } = response.data;
|
|
17
|
-
const actions = [
|
|
18
|
-
(0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template),
|
|
19
|
-
(0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
20
|
-
fetchState: 'Completed',
|
|
21
|
-
templateId: template.template_id,
|
|
22
|
-
}),
|
|
23
|
-
];
|
|
24
|
-
return (0, rxjs_1.from)(actions);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return (0, rxjs_1.of)((0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
28
|
-
fetchState: 'Error',
|
|
29
|
-
error: response.status,
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
33
|
-
fetchState: 'Error',
|
|
34
|
-
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create card-policy template REST API call errored out' +
|
|
35
|
-
JSON.stringify(error)),
|
|
36
|
-
}))));
|
|
37
|
-
}));
|
|
38
|
-
exports.createCardPolicyTemplateEpic = createCardPolicyTemplateEpic;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { fetchCardPolicyMccCategories, updateCardPolicyMccCategories, updateCardPolicyMccCategoriesFailure } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { RootState } from '../../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
-
/**
|
|
7
|
-
* MCC categories are reference data shared between the manual create
|
|
8
|
-
* flow and the AI-CFO `card_policy` form. The slice fields live on the
|
|
9
|
-
* `entity/cardPolicy` slice (so any consumer can read them without
|
|
10
|
-
* re-fetching); only the fetch lifecycle lives in `createCardPolicy/`
|
|
11
|
-
* because the manual create page is currently the only producer of the
|
|
12
|
-
* `fetchCardPolicyMccCategories` action.
|
|
13
|
-
*/
|
|
14
|
-
export type ActionType = ReturnType<typeof fetchCardPolicyMccCategories> | ReturnType<typeof updateCardPolicyMccCategories> | ReturnType<typeof updateCardPolicyMccCategoriesFailure>;
|
|
15
|
-
export declare const fetchCardPolicyMccCategoriesEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchCardPolicyMccCategoriesEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const cardPolicyReducer_1 = require("../../../../../entity/cardPolicy/cardPolicyReducer");
|
|
7
|
-
const responsePayload_1 = require("../../../../../responsePayload");
|
|
8
|
-
const fetchCardPolicyMccCategoriesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(cardPolicyReducer_1.fetchCardPolicyMccCategories.match),
|
|
9
|
-
// `exhaustMap` (rather than `mergeMap`) so a duplicate
|
|
10
|
-
// `fetchCardPolicyMccCategories` dispatched while the previous one
|
|
11
|
-
// is still in flight is dropped instead of producing a second HTTP
|
|
12
|
-
// request. Both the Create and Edit policy screens dispatch this
|
|
13
|
-
// on mount, and React 18 StrictMode invokes their mount effect
|
|
14
|
-
// twice with a stale `mccCategoriesFetchState` closure — without
|
|
15
|
-
// `exhaustMap` that yields two `/cards/mcc-codes` calls.
|
|
16
|
-
(0, operators_1.exhaustMap)(() => {
|
|
17
|
-
return zeniAPI
|
|
18
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/mcc-codes`)
|
|
19
|
-
.pipe((0, operators_1.mergeMap)((response) => {
|
|
20
|
-
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
21
|
-
return (0, rxjs_1.from)([(0, cardPolicyReducer_1.updateCardPolicyMccCategories)(response.data)]);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
return (0, rxjs_1.of)((0, cardPolicyReducer_1.updateCardPolicyMccCategoriesFailure)(response.status));
|
|
25
|
-
}
|
|
26
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, cardPolicyReducer_1.updateCardPolicyMccCategoriesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch card policy MCC categories REST API call errored out' +
|
|
27
|
-
JSON.stringify(error))))));
|
|
28
|
-
}));
|
|
29
|
-
exports.fetchCardPolicyMccCategoriesEpic = fetchCardPolicyMccCategoriesEpic;
|