@zeniai/client-epic-state 5.0.83 → 5.0.84-beta0ND
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/commonStateTypes/animations.d.ts +1 -1
- package/lib/commonStateTypes/animations.js +1 -0
- package/lib/entity/aiCfo/aiCfoPayload.d.ts +1 -140
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +2 -23
- package/lib/entity/aiCfo/aiCfoReducer.js +4 -332
- package/lib/entity/aiCfo/aiCfoSelector.d.ts +1 -13
- package/lib/entity/aiCfo/aiCfoSelector.js +1 -28
- package/lib/entity/aiCfo/aiCfoState.d.ts +4 -225
- package/lib/entity/aiCfo/aiCfoState.js +1 -30
- package/lib/entity/company/companyPayload.d.ts +2 -0
- package/lib/entity/company/companyPayload.js +2 -0
- package/lib/entity/company/companyStateTypes.d.ts +2 -0
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +1 -1
- package/lib/entity/monthEndCloseChecks/monthEndCloseChecksState.d.ts +1 -1
- package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
- package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +1 -3
- package/lib/entity/tenant/clearAllEpic.d.ts +2 -6
- package/lib/entity/tenant/clearAllEpic.js +0 -8
- package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/tenantPayload.d.ts +19 -0
- package/lib/entity/tenant/tenantReducer.d.ts +49 -28
- package/lib/entity/tenant/tenantReducer.js +111 -5
- package/lib/entity/tenant/tenantState.d.ts +21 -0
- package/lib/epic.d.ts +6 -11
- package/lib/epic.js +7 -11
- package/lib/esm/commonStateTypes/animations.js +1 -0
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +4 -332
- package/lib/esm/entity/aiCfo/aiCfoSelector.js +1 -26
- package/lib/esm/entity/aiCfo/aiCfoState.js +0 -27
- package/lib/esm/entity/company/companyPayload.js +2 -0
- package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +1 -3
- package/lib/esm/entity/tenant/clearAllEpic.js +0 -8
- package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
- package/lib/esm/entity/tenant/tenantReducer.js +108 -3
- package/lib/esm/epic.js +7 -11
- package/lib/esm/index.js +16 -28
- package/lib/esm/reducer.js +0 -12
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +3 -6
- package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
- package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +1 -2
- package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
- package/lib/esm/view/companyView/companyViewReducer.js +45 -1
- package/lib/esm/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +25 -0
- package/lib/esm/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +79 -0
- package/lib/esm/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
- package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +45 -0
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +168 -50
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +14 -0
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -0
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +0 -25
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +4 -16
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +0 -38
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +49 -0
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +58 -0
- package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +12 -0
- package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
- package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +71 -52
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
- package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
- package/lib/index.d.ts +19 -28
- package/lib/index.js +36 -136
- package/lib/reducer.d.ts +0 -12
- package/lib/reducer.js +0 -12
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +2 -11
- package/lib/view/aiCfoView/aiCfoViewReducer.js +3 -6
- package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +2 -5
- package/lib/view/aiCfoView/epics/createSessionEpic.js +1 -2
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +1 -8
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +2 -12
- package/lib/view/companyView/companyViewReducer.d.ts +11 -1
- package/lib/view/companyView/companyViewReducer.js +47 -3
- package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.d.ts +9 -0
- package/lib/view/companyView/epic/companyPassport/dismissCapitalizationOnboardingEpic.js +29 -0
- package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.d.ts +10 -0
- package/lib/view/companyView/epic/companyPassport/updateCapitalizationThresholdEpic.js +83 -0
- package/lib/view/companyView/types/companyPassport/companyPassportViewState.d.ts +1 -0
- package/lib/view/companyView/types/companyPassport/companyPassportViewState.js +4 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +49 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +170 -51
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +7 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +21 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +37 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +14 -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/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +1 -1
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +1 -5
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +5 -17
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +0 -27
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +1 -43
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +0 -2
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +8 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +53 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +8 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +62 -0
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +27 -0
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +15 -0
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
- package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +24 -2
- package/lib/view/spendManagement/commonSetup/setupViewReducer.js +72 -53
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +4 -0
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +2 -0
- package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +12 -0
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/package.json +1 -1
- package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +0 -277
- package/lib/entity/cardPolicy/cardPolicyPayload.js +0 -143
- package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +0 -19
- package/lib/entity/cardPolicy/cardPolicyReducer.js +0 -265
- package/lib/entity/cardPolicy/cardPolicySelector.d.ts +0 -32
- package/lib/entity/cardPolicy/cardPolicySelector.js +0 -103
- package/lib/entity/cardPolicy/cardPolicyState.d.ts +0 -205
- package/lib/entity/cardPolicy/cardPolicyState.js +0 -14
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +0 -18
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -68
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +0 -26
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -47
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +0 -25
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -39
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +0 -23
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -111
- package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +0 -130
- package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +0 -261
- package/lib/esm/entity/cardPolicy/cardPolicySelector.js +0 -79
- package/lib/esm/entity/cardPolicy/cardPolicyState.js +0 -9
- package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +0 -64
- package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +0 -43
- package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +0 -35
- package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +0 -107
- 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 -62
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -39
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -53
- 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 -13
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +0 -66
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +0 -32
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +0 -46
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +0 -45
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +0 -2
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +0 -25
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +0 -57
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +0 -15
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +0 -29
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
export const initialState = {
|
|
3
|
-
detailTemplateId: undefined,
|
|
4
|
-
detailFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
5
|
-
updateFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
6
|
-
formDraft: undefined,
|
|
7
|
-
};
|
|
8
|
-
const cardPolicyDetail = createSlice({
|
|
9
|
-
name: 'cardPolicyDetail',
|
|
10
|
-
initialState,
|
|
11
|
-
reducers: {
|
|
12
|
-
/**
|
|
13
|
-
* Kick off the `GET /cards/1.0/policy-templates/{id}` request. The
|
|
14
|
-
* accompanying epic dispatches `updateCreatedCardPolicyTemplate` on
|
|
15
|
-
* the entity slice + `updateCardPolicyFormDraft` (seeded from the
|
|
16
|
-
* template) + `updateCardPolicyDetailFetchStatus` here.
|
|
17
|
-
*/
|
|
18
|
-
fetchCardPolicyDetail: {
|
|
19
|
-
reducer(draft, action) {
|
|
20
|
-
draft.detailTemplateId = action.payload;
|
|
21
|
-
draft.detailFetchState.fetchState = 'In-Progress';
|
|
22
|
-
draft.detailFetchState.error = undefined;
|
|
23
|
-
// Reset the draft so a stale form from a previous template
|
|
24
|
-
// doesn't leak into the new edit session.
|
|
25
|
-
draft.formDraft = undefined;
|
|
26
|
-
},
|
|
27
|
-
prepare(templateId) {
|
|
28
|
-
return { payload: templateId };
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
updateCardPolicyDetailFetchStatus(draft, action) {
|
|
32
|
-
draft.detailFetchState.fetchState = action.payload.fetchState;
|
|
33
|
-
draft.detailFetchState.error = action.payload.error;
|
|
34
|
-
},
|
|
35
|
-
/**
|
|
36
|
-
* Replace (or seed) the local edit-form draft. Dispatched by the
|
|
37
|
-
* detail-fetch epic with the camelCased values pulled from the
|
|
38
|
-
* fetched template, and by the edit page itself as the user types.
|
|
39
|
-
*/
|
|
40
|
-
updateCardPolicyFormDraft(draft, action) {
|
|
41
|
-
draft.formDraft = action.payload;
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* Kick off the `PUT /cards/1.0/policy-templates/{id}` save. The
|
|
45
|
-
* epic reads the current `formDraft` from state, posts the wire
|
|
46
|
-
* body, then dispatches `updateCreatedCardPolicyTemplate` (entity)
|
|
47
|
-
* + `updateCardPolicyFetchStatus({fetchState: 'Completed'})` here.
|
|
48
|
-
*/
|
|
49
|
-
updateCardPolicy: {
|
|
50
|
-
reducer(draft,
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
-
_action) {
|
|
53
|
-
draft.updateFetchState.fetchState = 'In-Progress';
|
|
54
|
-
draft.updateFetchState.error = undefined;
|
|
55
|
-
},
|
|
56
|
-
prepare(templateId) {
|
|
57
|
-
return { payload: templateId };
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
updateCardPolicyFetchStatus(draft, action) {
|
|
61
|
-
draft.updateFetchState.fetchState = action.payload.fetchState;
|
|
62
|
-
draft.updateFetchState.error = action.payload.error;
|
|
63
|
-
},
|
|
64
|
-
clearCardPolicyDetail(draft) {
|
|
65
|
-
Object.assign(draft, initialState);
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
export const { fetchCardPolicyDetail, updateCardPolicyDetailFetchStatus, updateCardPolicyFormDraft, updateCardPolicy, updateCardPolicyFetchStatus, clearCardPolicyDetail, } = cardPolicyDetail.actions;
|
|
70
|
-
export default cardPolicyDetail.reducer;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getCardPolicyTemplateById } from '../../../../../entity/cardPolicy/cardPolicySelector';
|
|
2
|
-
export function getCardPolicyDetailView(state) {
|
|
3
|
-
const { cardPolicyDetailState, cardPolicyState } = state;
|
|
4
|
-
return {
|
|
5
|
-
templateId: cardPolicyDetailState.detailTemplateId,
|
|
6
|
-
template: cardPolicyDetailState.detailTemplateId != null
|
|
7
|
-
? getCardPolicyTemplateById(cardPolicyState, cardPolicyDetailState.detailTemplateId)
|
|
8
|
-
: undefined,
|
|
9
|
-
formDraft: cardPolicyDetailState.formDraft,
|
|
10
|
-
detailFetchState: cardPolicyDetailState.detailFetchState,
|
|
11
|
-
updateFetchState: cardPolicyDetailState.updateFetchState,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function getCardPolicyFormDraft(state) {
|
|
15
|
-
return state.cardPolicyDetailState.formDraft;
|
|
16
|
-
}
|
|
17
|
-
export function getCardPolicyDetailFetchState(state) {
|
|
18
|
-
return state.cardPolicyDetailState.detailFetchState;
|
|
19
|
-
}
|
|
20
|
-
export function getUpdateCardPolicyFetchState(state) {
|
|
21
|
-
return state.cardPolicyDetailState.updateFetchState;
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { toCardPolicyEditFormDraft, toCardPolicyTemplate, } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
4
|
-
import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessStatus, } from '../../../../../responsePayload';
|
|
6
|
-
import { fetchCardPolicyDetail, updateCardPolicyDetailFetchStatus, updateCardPolicyFormDraft, } from './cardPolicyDetailReducer';
|
|
7
|
-
/**
|
|
8
|
-
* `GET /cards/1.0/policy-templates/{id}`. Response is the same
|
|
9
|
-
* `{cards_applied, template}` envelope the create endpoint returns.
|
|
10
|
-
* We:
|
|
11
|
-
*
|
|
12
|
-
* 1. Cache the template on the entity slice (so the list page picks
|
|
13
|
-
* up any drift from the server).
|
|
14
|
-
* 2. Seed the local edit-form draft from the camelCased template so
|
|
15
|
-
* the page can render with the existing values pre-populated.
|
|
16
|
-
* 3. Flip the view lifecycle to `Completed` / `Error`.
|
|
17
|
-
*/
|
|
18
|
-
export const fetchCardPolicyDetailEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCardPolicyDetail.match),
|
|
19
|
-
// `exhaustMap` (rather than `mergeMap`) so a duplicate
|
|
20
|
-
// `fetchCardPolicyDetail` dispatched while the previous one is
|
|
21
|
-
// still in flight is dropped instead of producing a second HTTP
|
|
22
|
-
// request. The edit screen dispatches this on mount, and React 18
|
|
23
|
-
// StrictMode invokes its mount effect twice with a stale
|
|
24
|
-
// `detailFetchState` closure — without `exhaustMap` that yields
|
|
25
|
-
// two `/policy-templates/{id}` calls. (The screen also dedupes
|
|
26
|
-
// list→edit navigations via the entity-cached template, so the
|
|
27
|
-
// detail GET is only emitted on direct landings — there's no
|
|
28
|
-
// realistic cross-templateId scenario that needs cancel-and-retry
|
|
29
|
-
// semantics here.)
|
|
30
|
-
exhaustMap((action) => {
|
|
31
|
-
const templateId = action.payload;
|
|
32
|
-
return zeniAPI
|
|
33
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`)
|
|
34
|
-
.pipe(mergeMap((response) => {
|
|
35
|
-
if (isSuccessStatus(response) && response.data != null) {
|
|
36
|
-
const { template } = response.data;
|
|
37
|
-
const formDraft = toCardPolicyEditFormDraft(toCardPolicyTemplate(template));
|
|
38
|
-
const actions = [
|
|
39
|
-
updateCreatedCardPolicyTemplate(template),
|
|
40
|
-
updateCardPolicyFormDraft(formDraft),
|
|
41
|
-
updateCardPolicyDetailFetchStatus({ fetchState: 'Completed' }),
|
|
42
|
-
];
|
|
43
|
-
return from(actions);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return of(updateCardPolicyDetailFetchStatus({
|
|
47
|
-
fetchState: 'Error',
|
|
48
|
-
error: response.status,
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
}), catchError((error) => of(updateCardPolicyDetailFetchStatus({
|
|
52
|
-
fetchState: 'Error',
|
|
53
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch card-policy detail REST API call errored out' +
|
|
54
|
-
JSON.stringify(error)),
|
|
55
|
-
}))));
|
|
56
|
-
}));
|
package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { toUpdateCardPolicyTemplateRequestBody, } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
4
|
-
import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessStatus } from '../../../../../responsePayload';
|
|
6
|
-
import { updateCardPolicy, updateCardPolicyFetchStatus, } from './cardPolicyDetailReducer';
|
|
7
|
-
/**
|
|
8
|
-
* `PUT /cards/1.0/policy-templates/{id}`. Reads the current `formDraft`
|
|
9
|
-
* off the `cardPolicyDetail` slice, converts it to the snake_case wire
|
|
10
|
-
* body (same shape as create), and submits. On success the entity
|
|
11
|
-
* slice picks up the refreshed template and the view lifecycle flips
|
|
12
|
-
* to `Completed`.
|
|
13
|
-
*
|
|
14
|
-
* If the action fires before a draft is seeded (e.g. user clicks save
|
|
15
|
-
* before the detail fetch lands), we short-circuit with an Error.
|
|
16
|
-
*/
|
|
17
|
-
export const updateCardPolicyEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateCardPolicy.match), mergeMap((action) => {
|
|
18
|
-
const templateId = action.payload;
|
|
19
|
-
const formDraft = state$.value.cardPolicyDetailState.formDraft;
|
|
20
|
-
if (formDraft == null) {
|
|
21
|
-
return of(updateCardPolicyFetchStatus({
|
|
22
|
-
fetchState: 'Error',
|
|
23
|
-
error: createZeniAPIStatus('Missing form draft', `Cannot update card-policy ${templateId} — no formDraft is loaded.`),
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
const body = toUpdateCardPolicyTemplateRequestBody(formDraft);
|
|
27
|
-
return zeniAPI
|
|
28
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`, body)
|
|
29
|
-
.pipe(mergeMap((response) => {
|
|
30
|
-
if (isSuccessStatus(response) && response.data != null) {
|
|
31
|
-
const { template } = response.data;
|
|
32
|
-
const actions = [
|
|
33
|
-
updateCreatedCardPolicyTemplate(template),
|
|
34
|
-
updateCardPolicyFetchStatus({ fetchState: 'Completed' }),
|
|
35
|
-
];
|
|
36
|
-
return from(actions);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return of(updateCardPolicyFetchStatus({
|
|
40
|
-
fetchState: 'Error',
|
|
41
|
-
error: response.status,
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
}), catchError((error) => of(updateCardPolicyFetchStatus({
|
|
45
|
-
fetchState: 'Error',
|
|
46
|
-
error: createZeniAPIStatus('Unexpected Error', 'Update card-policy REST API call errored out' +
|
|
47
|
-
JSON.stringify(error)),
|
|
48
|
-
}))));
|
|
49
|
-
}));
|
package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { removeCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessStatus, } from '../../../../../responsePayload';
|
|
5
|
-
import { archiveCardPolicy, updateArchiveCardPolicyFetchStatus, } from './cardPolicyListReducer';
|
|
6
|
-
/**
|
|
7
|
-
* `DELETE /cards/1.0/policy-templates/{id}`. Modeled like
|
|
8
|
-
* `deleteBillEpic`: typed as bare `ZeniAPIResponse` (no `data` body
|
|
9
|
-
* expected) with `isSuccessStatus` driving the success branch. On
|
|
10
|
-
* success the entity slice drops the template via
|
|
11
|
-
* `removeCardPolicyTemplate(templateId)` and the view slice records
|
|
12
|
-
* `Completed` (also pruning the ID from `templateIds`).
|
|
13
|
-
*/
|
|
14
|
-
export const archiveCardPolicyEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(archiveCardPolicy.match), mergeMap((action) => {
|
|
15
|
-
const templateId = action.payload;
|
|
16
|
-
return zeniAPI
|
|
17
|
-
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${templateId}`)
|
|
18
|
-
.pipe(mergeMap((response) => {
|
|
19
|
-
if (isSuccessStatus(response)) {
|
|
20
|
-
const actions = [
|
|
21
|
-
removeCardPolicyTemplate(templateId),
|
|
22
|
-
updateArchiveCardPolicyFetchStatus({
|
|
23
|
-
fetchState: 'Completed',
|
|
24
|
-
templateId,
|
|
25
|
-
}),
|
|
26
|
-
];
|
|
27
|
-
return from(actions);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return of(updateArchiveCardPolicyFetchStatus({
|
|
31
|
-
fetchState: 'Error',
|
|
32
|
-
error: response.status,
|
|
33
|
-
templateId,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
}), catchError((error) => of(updateArchiveCardPolicyFetchStatus({
|
|
37
|
-
fetchState: 'Error',
|
|
38
|
-
error: createZeniAPIStatus('Unexpected Error', 'Archive card-policy REST API call errored out' +
|
|
39
|
-
JSON.stringify(error)),
|
|
40
|
-
templateId,
|
|
41
|
-
}))));
|
|
42
|
-
}));
|
package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
export const initialState = {
|
|
3
|
-
templateIds: [],
|
|
4
|
-
fetchState: {
|
|
5
|
-
fetchState: 'Not-Started',
|
|
6
|
-
error: undefined,
|
|
7
|
-
},
|
|
8
|
-
archiveFetchState: {
|
|
9
|
-
fetchState: 'Not-Started',
|
|
10
|
-
error: undefined,
|
|
11
|
-
},
|
|
12
|
-
archiveTargetTemplateId: undefined,
|
|
13
|
-
};
|
|
14
|
-
const cardPolicyList = createSlice({
|
|
15
|
-
name: 'cardPolicyList',
|
|
16
|
-
initialState,
|
|
17
|
-
reducers: {
|
|
18
|
-
/**
|
|
19
|
-
* Kick off the `GET /cards/1.0/policy-templates` request. The
|
|
20
|
-
* accompanying epic dispatches `updateCardPolicyTemplates(templates)`
|
|
21
|
-
* + `updateCardPolicyStats(stats)` on the entity slice and
|
|
22
|
-
* `updateCardPolicyListFetchStatus` here (also supplying the ordered
|
|
23
|
-
* `templateIds` on success).
|
|
24
|
-
*/
|
|
25
|
-
fetchCardPolicyList(draft) {
|
|
26
|
-
draft.fetchState.fetchState = 'In-Progress';
|
|
27
|
-
draft.fetchState.error = undefined;
|
|
28
|
-
},
|
|
29
|
-
updateCardPolicyListFetchStatus(draft, action) {
|
|
30
|
-
draft.fetchState.fetchState = action.payload.fetchState;
|
|
31
|
-
draft.fetchState.error = action.payload.error;
|
|
32
|
-
if (action.payload.templateIds != null) {
|
|
33
|
-
draft.templateIds = action.payload.templateIds;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Kick off the `DELETE /cards/1.0/policy-templates/{id}` request.
|
|
38
|
-
* The accompanying epic dispatches `removeCardPolicyTemplate(id)` on
|
|
39
|
-
* the entity slice on success + `updateArchiveCardPolicyFetchStatus`
|
|
40
|
-
* here. The view layer also drops the ID from `templateIds` so the
|
|
41
|
-
* list stays in sync without re-fetching.
|
|
42
|
-
*/
|
|
43
|
-
archiveCardPolicy: {
|
|
44
|
-
reducer(draft, action) {
|
|
45
|
-
draft.archiveFetchState.fetchState = 'In-Progress';
|
|
46
|
-
draft.archiveFetchState.error = undefined;
|
|
47
|
-
draft.archiveTargetTemplateId = action.payload;
|
|
48
|
-
},
|
|
49
|
-
prepare(templateId) {
|
|
50
|
-
return { payload: templateId };
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
updateArchiveCardPolicyFetchStatus(draft, action) {
|
|
54
|
-
draft.archiveFetchState.fetchState = action.payload.fetchState;
|
|
55
|
-
draft.archiveFetchState.error = action.payload.error;
|
|
56
|
-
if (action.payload.fetchState === 'Completed') {
|
|
57
|
-
if (action.payload.templateId != null) {
|
|
58
|
-
draft.templateIds = draft.templateIds.filter((id) => id !== action.payload.templateId);
|
|
59
|
-
}
|
|
60
|
-
draft.archiveTargetTemplateId = undefined;
|
|
61
|
-
}
|
|
62
|
-
else if (action.payload.fetchState === 'Error') {
|
|
63
|
-
draft.archiveTargetTemplateId = undefined;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
clearCardPolicyList(draft) {
|
|
67
|
-
Object.assign(draft, initialState);
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
export const { fetchCardPolicyList, updateCardPolicyListFetchStatus, archiveCardPolicy, updateArchiveCardPolicyFetchStatus, clearCardPolicyList, } = cardPolicyList.actions;
|
|
72
|
-
export default cardPolicyList.reducer;
|
package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getCardPolicyStats, getCardPolicyTemplatesByIds, } from '../../../../../entity/cardPolicy/cardPolicySelector';
|
|
2
|
-
export function getCardPolicyListView(state) {
|
|
3
|
-
const { cardPolicyListState, cardPolicyState } = state;
|
|
4
|
-
return {
|
|
5
|
-
templates: getCardPolicyTemplatesByIds(cardPolicyState, cardPolicyListState.templateIds),
|
|
6
|
-
templateIds: cardPolicyListState.templateIds,
|
|
7
|
-
fetchState: cardPolicyListState.fetchState,
|
|
8
|
-
archiveFetchState: cardPolicyListState.archiveFetchState,
|
|
9
|
-
archiveTargetTemplateId: cardPolicyListState.archiveTargetTemplateId,
|
|
10
|
-
stats: getCardPolicyStats(cardPolicyState),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function getCardPolicyListFetchState(state) {
|
|
14
|
-
return state.cardPolicyListState.fetchState;
|
|
15
|
-
}
|
|
16
|
-
export function getArchiveCardPolicyFetchState(state) {
|
|
17
|
-
return state.cardPolicyListState.archiveFetchState;
|
|
18
|
-
}
|
|
19
|
-
export function getCardPolicyTemplateIds(state) {
|
|
20
|
-
return state.cardPolicyListState.templateIds;
|
|
21
|
-
}
|
package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { toCardPolicyStats, toCardPolicyTemplateList, } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
4
|
-
import { updateCardPolicyStats, updateCardPolicyTemplates, } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessStatus, } from '../../../../../responsePayload';
|
|
6
|
-
import { fetchCardPolicyList, updateCardPolicyListFetchStatus, } from './cardPolicyListReducer';
|
|
7
|
-
/**
|
|
8
|
-
* `GET /cards/1.0/policy-templates`. On success the response carries
|
|
9
|
-
* both the tenant-wide `stats` block and a `templates[]` array whose
|
|
10
|
-
* rows are wrapped in `{data: {cards_applied, template}}` (the same
|
|
11
|
-
* envelope the create endpoint returns). We split the result into
|
|
12
|
-
* three actions:
|
|
13
|
-
*
|
|
14
|
-
* 1. `updateCardPolicyTemplates` — full replace of the entity map.
|
|
15
|
-
* 2. `updateCardPolicyStats` — entity-level cached stats.
|
|
16
|
-
* 3. `updateCardPolicyListFetchStatus` — view lifecycle + ordered IDs.
|
|
17
|
-
*/
|
|
18
|
-
export const fetchCardPolicyListEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCardPolicyList.match),
|
|
19
|
-
// `exhaustMap` (rather than `mergeMap`) so a duplicate
|
|
20
|
-
// `fetchCardPolicyList` dispatched while the previous one is still
|
|
21
|
-
// in flight is dropped instead of producing a second HTTP request.
|
|
22
|
-
// This guards against React 18 StrictMode, which mount-cleanup-
|
|
23
|
-
// remounts the screen's mount effect with a stale closure of
|
|
24
|
-
// `listFetchState`, causing the same effect to dispatch this
|
|
25
|
-
// action twice synchronously. Retry-after-error still works
|
|
26
|
-
// because the previous inner observable has completed by the time
|
|
27
|
-
// the user retries.
|
|
28
|
-
exhaustMap(() => {
|
|
29
|
-
return zeniAPI
|
|
30
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`)
|
|
31
|
-
.pipe(mergeMap((response) => {
|
|
32
|
-
if (isSuccessStatus(response) && response.data != null) {
|
|
33
|
-
const templates = toCardPolicyTemplateList(response.data);
|
|
34
|
-
const stats = toCardPolicyStats(response.data.stats);
|
|
35
|
-
const actions = [
|
|
36
|
-
updateCardPolicyTemplates(templates),
|
|
37
|
-
updateCardPolicyStats(stats),
|
|
38
|
-
updateCardPolicyListFetchStatus({
|
|
39
|
-
fetchState: 'Completed',
|
|
40
|
-
templateIds: templates.map((t) => t.templateId),
|
|
41
|
-
}),
|
|
42
|
-
];
|
|
43
|
-
return from(actions);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return of(updateCardPolicyListFetchStatus({
|
|
47
|
-
fetchState: 'Error',
|
|
48
|
-
error: response.status,
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
}), catchError((error) => of(updateCardPolicyListFetchStatus({
|
|
52
|
-
fetchState: 'Error',
|
|
53
|
-
error: createZeniAPIStatus('Unexpected Error', 'Fetch card-policy list REST API call errored out' +
|
|
54
|
-
JSON.stringify(error)),
|
|
55
|
-
}))));
|
|
56
|
-
}));
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
export const initialState = {
|
|
3
|
-
createCardPolicyTemplateRequestState: {
|
|
4
|
-
fetchState: 'Not-Started',
|
|
5
|
-
error: undefined,
|
|
6
|
-
},
|
|
7
|
-
lastCreatedCardPolicyTemplateIds: [],
|
|
8
|
-
lastCreateCardPolicyTemplateErrors: [],
|
|
9
|
-
};
|
|
10
|
-
const createCardPolicy = createSlice({
|
|
11
|
-
name: 'createCardPolicy',
|
|
12
|
-
initialState,
|
|
13
|
-
reducers: {
|
|
14
|
-
/**
|
|
15
|
-
* Kick off the bulk `POST /cards/1.0/policy-templates` request.
|
|
16
|
-
* Single-create callers pass a length-1 `templates` array; AI CFO
|
|
17
|
-
* multi-policy callers pass N entries in one round-trip. Setting the
|
|
18
|
-
* request state to `In-Progress` synchronously here matches how every
|
|
19
|
-
* other "create" slice in this repo wires its kickoff (see
|
|
20
|
-
* `issueChargeCards`, `fetchChargeCardConfig`, etc.).
|
|
21
|
-
*
|
|
22
|
-
* The accompanying epic listens for this action, performs the POST,
|
|
23
|
-
* dispatches one `updateCreatedCardPolicyTemplate` on the entity
|
|
24
|
-
* slice per row returned in `templates_created`, and dispatches
|
|
25
|
-
* `updateCreateCardPolicyTemplateRequestState` here to flip the
|
|
26
|
-
* lifecycle to `Completed` (with the created ids + any per-item
|
|
27
|
-
* errors) or `Error` (transport-level failure).
|
|
28
|
-
*/
|
|
29
|
-
createCardPolicyTemplates: {
|
|
30
|
-
reducer(draft, action) {
|
|
31
|
-
draft.createCardPolicyTemplateRequestState.fetchState = 'In-Progress';
|
|
32
|
-
draft.createCardPolicyTemplateRequestState.error = undefined;
|
|
33
|
-
draft.lastCreatedCardPolicyTemplateIds = [];
|
|
34
|
-
draft.lastCreateCardPolicyTemplateErrors = [];
|
|
35
|
-
// Mirror `lastIssueSourceChatSessionId` on the cards side: the list
|
|
36
|
-
// screen and AI CFO drawer both consult this to decide whether the
|
|
37
|
-
// in-flight create belongs to the active AI CFO conversation.
|
|
38
|
-
draft.lastCreateCardPolicySourceChatSessionId =
|
|
39
|
-
action.payload.sourceChatSessionId;
|
|
40
|
-
},
|
|
41
|
-
prepare(request) {
|
|
42
|
-
return { payload: request };
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
updateCreateCardPolicyTemplateRequestState(draft, action) {
|
|
46
|
-
draft.createCardPolicyTemplateRequestState.fetchState =
|
|
47
|
-
action.payload.fetchState;
|
|
48
|
-
draft.createCardPolicyTemplateRequestState.error = action.payload.error;
|
|
49
|
-
if (action.payload.templateIds != null) {
|
|
50
|
-
draft.lastCreatedCardPolicyTemplateIds = action.payload.templateIds;
|
|
51
|
-
}
|
|
52
|
-
if (action.payload.perItemErrors != null) {
|
|
53
|
-
draft.lastCreateCardPolicyTemplateErrors = action.payload.perItemErrors;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
clearCreateCardPolicy(draft) {
|
|
57
|
-
Object.assign(draft, initialState);
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
export const { createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState, clearCreateCardPolicy, } = createCardPolicy.actions;
|
|
62
|
-
export default createCardPolicy.reducer;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export function getCreateCardPolicyTemplateRequestState(state) {
|
|
2
|
-
return state.createCardPolicyTemplateRequestState;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* All template ids created by the most recent successful bulk submit
|
|
6
|
-
* (in BE return order). Empty array before any submit or after
|
|
7
|
-
* `clearCreateCardPolicy`. Multi-policy AI CFO submit reads this; the
|
|
8
|
-
* single-policy `getLastCreatedCardPolicyTemplateId` selector below is a
|
|
9
|
-
* convenience for the manual-create routing flow.
|
|
10
|
-
*/
|
|
11
|
-
export function getLastCreatedCardPolicyTemplateIds(state) {
|
|
12
|
-
return state.lastCreatedCardPolicyTemplateIds;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Convenience selector returning the first id of the most recent submit
|
|
16
|
-
* — kept ergonomic for the single-create page's "navigate to detail on
|
|
17
|
-
* success" logic, which only ever creates one template. Returns
|
|
18
|
-
* `undefined` when no submit has succeeded or when the list is empty.
|
|
19
|
-
*/
|
|
20
|
-
export function getLastCreatedCardPolicyTemplateId(state) {
|
|
21
|
-
return state.lastCreatedCardPolicyTemplateIds[0];
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Per-item errors returned by the bulk POST when one or more templates
|
|
25
|
-
* failed to persist. Empty on full success; populated on partial success
|
|
26
|
-
* so the UI can render a "N of M created" banner alongside the navigate /
|
|
27
|
-
* close behaviour driven by the lifecycle selector.
|
|
28
|
-
*/
|
|
29
|
-
export function getLastCreateCardPolicyTemplateErrors(state) {
|
|
30
|
-
return state.lastCreateCardPolicyTemplateErrors;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Chat session id that triggered the most recent bulk create — used by the
|
|
34
|
-
* card policy list screen and the AI CFO drawer to scope "creating…" and
|
|
35
|
-
* "created" placeholders to the active conversation.
|
|
36
|
-
*/
|
|
37
|
-
export function getLastCreateCardPolicySourceChatSessionId(state) {
|
|
38
|
-
return state.lastCreateCardPolicySourceChatSessionId;
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { updateCreatedCardPolicyTemplate } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { toBulkCreateCardPolicyTemplateError, toCreateCardPolicyTemplatesRequestBody, } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
5
|
-
import { createZeniAPIStatus, isSuccessStatus } from '../../../../../responsePayload';
|
|
6
|
-
import { createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState, } from './createCardPolicyReducer';
|
|
7
|
-
/**
|
|
8
|
-
* `POST /cards/1.0/policy-templates` (bulk). Builds the bulk wire body
|
|
9
|
-
* from the camelCased action payload, sends one round-trip, and on
|
|
10
|
-
* success fans out:
|
|
11
|
-
* - one `updateCreatedCardPolicyTemplate` on the entity slice per row
|
|
12
|
-
* in `templates_created` (so the entity store is hydrated with every
|
|
13
|
-
* created template), and
|
|
14
|
-
* - one `updateCreateCardPolicyTemplateRequestState` with the ordered
|
|
15
|
-
* id list + per-item errors so the view can render partial-success
|
|
16
|
-
* UX without re-touching the wire types.
|
|
17
|
-
*
|
|
18
|
-
* Partial success (`errors.length > 0` with at least one template
|
|
19
|
-
* created) is still treated as `Completed` — the lifecycle is binary
|
|
20
|
-
* and the per-item errors live on the slice for the UI to inspect.
|
|
21
|
-
* Hard failures (non-success `status` or thrown errors) map to `Error`
|
|
22
|
-
* the same way they did pre-bulk.
|
|
23
|
-
*/
|
|
24
|
-
export const createCardPolicyTemplatesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(createCardPolicyTemplates.match), mergeMap((action) => {
|
|
25
|
-
const body = toCreateCardPolicyTemplatesRequestBody(action.payload);
|
|
26
|
-
return zeniAPI
|
|
27
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`, body)
|
|
28
|
-
.pipe(mergeMap((response) => {
|
|
29
|
-
if (isSuccessStatus(response) && response.data != null) {
|
|
30
|
-
const { templates_created, errors } = response.data;
|
|
31
|
-
const createdTemplates = templates_created.map((row) => row.template);
|
|
32
|
-
const actions = [
|
|
33
|
-
...createdTemplates.map((template) => updateCreatedCardPolicyTemplate(template)),
|
|
34
|
-
updateCreateCardPolicyTemplateRequestState({
|
|
35
|
-
fetchState: 'Completed',
|
|
36
|
-
perItemErrors: (errors ?? []).map(toBulkCreateCardPolicyTemplateError),
|
|
37
|
-
templateIds: createdTemplates.map((template) => template.template_id),
|
|
38
|
-
}),
|
|
39
|
-
];
|
|
40
|
-
return from(actions);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return of(updateCreateCardPolicyTemplateRequestState({
|
|
44
|
-
fetchState: 'Error',
|
|
45
|
-
error: response.status,
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
}), catchError((error) => of(updateCreateCardPolicyTemplateRequestState({
|
|
49
|
-
fetchState: 'Error',
|
|
50
|
-
error: createZeniAPIStatus('Unexpected Error', 'Create card-policy templates REST API call errored out' +
|
|
51
|
-
JSON.stringify(error)),
|
|
52
|
-
}))));
|
|
53
|
-
}));
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, exhaustMap, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import { fetchCardPolicyMccCategories, updateCardPolicyMccCategories, updateCardPolicyMccCategoriesFailure, } from '../../../../../entity/cardPolicy/cardPolicyReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessStatus, } from '../../../../../responsePayload';
|
|
5
|
-
export const fetchCardPolicyMccCategoriesEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCardPolicyMccCategories.match),
|
|
6
|
-
// `exhaustMap` (rather than `mergeMap`) so a duplicate
|
|
7
|
-
// `fetchCardPolicyMccCategories` dispatched while the previous one
|
|
8
|
-
// is still in flight is dropped instead of producing a second HTTP
|
|
9
|
-
// request. Both the Create and Edit policy screens dispatch this
|
|
10
|
-
// on mount, and React 18 StrictMode invokes their mount effect
|
|
11
|
-
// twice with a stale `mccCategoriesFetchState` closure — without
|
|
12
|
-
// `exhaustMap` that yields two `/cards/mcc-codes` calls.
|
|
13
|
-
exhaustMap(() => {
|
|
14
|
-
return zeniAPI
|
|
15
|
-
.getJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/mcc-codes`)
|
|
16
|
-
.pipe(mergeMap((response) => {
|
|
17
|
-
if (isSuccessStatus(response) && response.data != null) {
|
|
18
|
-
return from([updateCardPolicyMccCategories(response.data)]);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return of(updateCardPolicyMccCategoriesFailure(response.status));
|
|
22
|
-
}
|
|
23
|
-
}), catchError((error) => of(updateCardPolicyMccCategoriesFailure(createZeniAPIStatus('Unexpected Error', 'Fetch card policy MCC categories REST API call errored out' +
|
|
24
|
-
JSON.stringify(error))))));
|
|
25
|
-
}));
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FetchState } from '../../../../../commonStateTypes/common';
|
|
2
|
-
import { CreateCardPolicyTemplateRequest } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
3
|
-
import { ZeniAPIStatus } from '../../../../../responsePayload';
|
|
4
|
-
import { CardPolicyDetailState } from './cardPolicyDetailState';
|
|
5
|
-
export declare const initialState: CardPolicyDetailState;
|
|
6
|
-
export declare const fetchCardPolicyDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[templateId: string], string, "cardPolicyDetail/fetchCardPolicyDetail", never, never>, updateCardPolicyDetailFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
7
|
-
fetchState: FetchState;
|
|
8
|
-
error?: ZeniAPIStatus;
|
|
9
|
-
}, "cardPolicyDetail/updateCardPolicyDetailFetchStatus">, updateCardPolicyFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<CreateCardPolicyTemplateRequest, "cardPolicyDetail/updateCardPolicyFormDraft">, updateCardPolicy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[templateId: string], string, "cardPolicyDetail/updateCardPolicy", never, never>, updateCardPolicyFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
10
|
-
fetchState: FetchState;
|
|
11
|
-
error?: ZeniAPIStatus;
|
|
12
|
-
}, "cardPolicyDetail/updateCardPolicyFetchStatus">, clearCardPolicyDetail: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"cardPolicyDetail/clearCardPolicyDetail">;
|
|
13
|
-
declare const _default: import("redux").Reducer<CardPolicyDetailState>;
|
|
14
|
-
export default _default;
|