@zeniai/client-epic-state 5.0.82-betaAS1 → 5.0.83-betaRR0
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 +140 -1
- package/lib/entity/aiCfo/aiCfoReducer.d.ts +23 -2
- package/lib/entity/aiCfo/aiCfoReducer.js +328 -5
- package/lib/entity/aiCfo/aiCfoSelector.d.ts +13 -1
- package/lib/entity/aiCfo/aiCfoSelector.js +28 -1
- package/lib/entity/aiCfo/aiCfoState.d.ts +225 -4
- package/lib/entity/aiCfo/aiCfoState.js +30 -1
- package/lib/entity/cardPolicy/cardPolicyPayload.d.ts +277 -0
- package/lib/entity/cardPolicy/cardPolicyPayload.js +143 -0
- package/lib/entity/cardPolicy/cardPolicyReducer.d.ts +19 -0
- package/lib/entity/cardPolicy/cardPolicyReducer.js +175 -0
- package/lib/entity/cardPolicy/cardPolicySelector.d.ts +32 -0
- package/lib/entity/cardPolicy/cardPolicySelector.js +99 -0
- package/lib/entity/cardPolicy/cardPolicyState.d.ts +205 -0
- package/lib/entity/cardPolicy/cardPolicyState.js +14 -0
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.d.ts +18 -0
- package/lib/entity/cardPolicy/extractPolicyDocumentEpic.js +68 -0
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.d.ts +26 -0
- package/lib/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +47 -0
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.d.ts +25 -0
- package/lib/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +39 -0
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.d.ts +23 -0
- package/lib/entity/cardPolicy/policyRecommendationFromUploadEpic.js +104 -0
- 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 +3 -0
- package/lib/entity/tenant/clearAllEpic.d.ts +6 -2
- package/lib/entity/tenant/clearAllEpic.js +8 -0
- package/lib/entity/tenant/tenantPayload.d.ts +0 -3
- package/lib/entity/tenant/tenantReducer.d.ts +1 -1
- package/lib/entity/tenant/tenantReducer.js +3 -23
- package/lib/entity/tenant/tenantState.d.ts +0 -3
- package/lib/epic.d.ts +11 -3
- package/lib/epic.js +11 -3
- package/lib/esm/entity/aiCfo/aiCfoReducer.js +328 -5
- package/lib/esm/entity/aiCfo/aiCfoSelector.js +26 -1
- package/lib/esm/entity/aiCfo/aiCfoState.js +27 -0
- package/lib/esm/entity/cardPolicy/cardPolicyPayload.js +130 -0
- package/lib/esm/entity/cardPolicy/cardPolicyReducer.js +171 -0
- package/lib/esm/entity/cardPolicy/cardPolicySelector.js +75 -0
- package/lib/esm/entity/cardPolicy/cardPolicyState.js +9 -0
- package/lib/esm/entity/cardPolicy/extractPolicyDocumentEpic.js +64 -0
- package/lib/esm/entity/cardPolicy/fetchCardPolicyVendorOptionsEpic.js +43 -0
- package/lib/esm/entity/cardPolicy/policyDocumentExtractionToRecommendationBridgeEpic.js +35 -0
- package/lib/esm/entity/cardPolicy/policyRecommendationFromUploadEpic.js +100 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/esm/entity/tenant/clearAllEpic.js +8 -0
- package/lib/esm/entity/tenant/tenantReducer.js +2 -22
- package/lib/esm/epic.js +11 -3
- package/lib/esm/index.js +29 -11
- package/lib/esm/reducer.js +12 -0
- package/lib/esm/view/aiCfoView/aiCfoViewReducer.js +6 -3
- package/lib/esm/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
- package/lib/esm/view/aiCfoView/epics/createSessionEpic.js +2 -1
- package/lib/esm/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
- package/lib/esm/view/dashboard/dashboardReducer.js +5 -1
- package/lib/esm/view/dashboard/dashboardSelector.js +2 -1
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +70 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +22 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +56 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +49 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +42 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +72 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +21 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +56 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +45 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +39 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +53 -0
- package/lib/esm/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +25 -0
- package/lib/esm/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +25 -0
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.js +1 -0
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +62 -0
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +47 -0
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +2 -2
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +62 -4
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +61 -0
- package/lib/esm/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +69 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/treasurySetupViewReducer.js +1 -45
- package/lib/index.d.ts +28 -11
- package/lib/index.js +154 -29
- package/lib/reducer.d.ts +12 -0
- package/lib/reducer.js +12 -0
- package/lib/view/aiCfoView/aiCfoViewReducer.d.ts +11 -2
- package/lib/view/aiCfoView/aiCfoViewReducer.js +6 -3
- package/lib/view/aiCfoView/epics/createSessionAndSubmitEpic.js +5 -2
- package/lib/view/aiCfoView/epics/createSessionEpic.js +2 -1
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.d.ts +8 -1
- package/lib/view/aiCfoView/epics/fetchSuggestedQuestionsEpic.js +12 -2
- package/lib/view/dashboard/dashboardReducer.d.ts +1 -1
- package/lib/view/dashboard/dashboardReducer.js +6 -2
- package/lib/view/dashboard/dashboardSelector.d.ts +1 -0
- package/lib/view/dashboard/dashboardSelector.js +2 -1
- package/lib/view/dashboard/dashboardState.d.ts +1 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/reconciliationViewState.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/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.d.ts +14 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailReducer.js +74 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.d.ts +21 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailSelector.js +28 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.d.ts +25 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/cardPolicyDetailState.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/fetchCardPolicyDetailEpic.js +60 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.d.ts +18 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyDetail/updateCardPolicyEpic.js +53 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.d.ts +16 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/archiveCardPolicyEpic.js +46 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListReducer.js +76 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.d.ts +21 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListSelector.js +27 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/cardPolicyListState.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.d.ts +19 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/cardPolicyList/fetchCardPolicyListEpic.js +60 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.d.ts +13 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyReducer.js +49 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.d.ts +32 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicySelector.js +46 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts +45 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.js +2 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.d.ts +25 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyTemplateEpic.js +57 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.d.ts +15 -0
- package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/fetchCardPolicyMccCategoriesEpic.js +29 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +14 -0
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +27 -1
- package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.d.ts +79 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.js +2 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.d.ts +25 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js +66 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.d.ts +26 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/deriveAiCardRowsFromTeams.js +51 -0
- 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 +12 -2
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +63 -5
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +42 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +68 -1
- package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +18 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.d.ts +11 -0
- package/lib/view/spendManagement/chargeCards/issueChargeCard/toIssueChargeCardLocalDataFromDraft.js +73 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/treasurySetupViewReducer.d.ts +1 -1
- package/lib/view/spendManagement/treasury/treasurySetUp/treasurySetupViewReducer.js +2 -46
- package/lib/view/spendManagement/treasury/treasurySetUp/treasurySetupViewState.d.ts +0 -2
- package/lib/view/taskManager/taskListView/taskListReducer.d.ts +1 -1
- package/package.json +1 -1
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -18
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -18
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +0 -8
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +0 -22
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +0 -8
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +0 -22
package/lib/view/spendManagement/chargeCards/cardPolicy/createCardPolicy/createCardPolicyState.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
|
|
2
|
+
import { BulkCreateCardPolicyTemplateError } from '../../../../../entity/cardPolicy/cardPolicyPayload';
|
|
3
|
+
/**
|
|
4
|
+
* View-side scaffolding for the Card Policy "create" flow.
|
|
5
|
+
*
|
|
6
|
+
* `POST /cards/1.0/policy-templates` is now a bulk endpoint — both the
|
|
7
|
+
* manual create page and the AI CFO submit pass an array of templates
|
|
8
|
+
* (single-element today; multi-element when AI CFO multi-policy review
|
|
9
|
+
* lands). The slice tracks one request lifecycle for the whole submit
|
|
10
|
+
* and captures the per-template ids + errors on success.
|
|
11
|
+
*
|
|
12
|
+
* List + edit lifecycles live in sibling slices (`cardPolicyList`,
|
|
13
|
+
* `cardPolicyDetail`); MCC categories used by the create form live on
|
|
14
|
+
* the entity slice (shared with the AI-CFO flow) and are fetched via the
|
|
15
|
+
* co-located `fetchCardPolicyMccCategoriesEpic`.
|
|
16
|
+
*/
|
|
17
|
+
export interface CreateCardPolicyState {
|
|
18
|
+
createCardPolicyTemplateRequestState: FetchStateAndError;
|
|
19
|
+
/**
|
|
20
|
+
* Per-item failures returned alongside `templates_created` on the bulk
|
|
21
|
+
* response. Empty on full success; populated on partial success so the
|
|
22
|
+
* UI can render a "N of M created" banner. Cleared when a new submit
|
|
23
|
+
* starts and by `clearCreateCardPolicy`.
|
|
24
|
+
*/
|
|
25
|
+
lastCreateCardPolicyTemplateErrors: BulkCreateCardPolicyTemplateError[];
|
|
26
|
+
/**
|
|
27
|
+
* `templateId`s of the templates created by the most recent successful
|
|
28
|
+
* bulk submit, in the order they were returned by the BE. Empty when no
|
|
29
|
+
* submit has succeeded yet or after `clearCreateCardPolicy`.
|
|
30
|
+
*
|
|
31
|
+
* For the single-policy case this holds exactly one id; the
|
|
32
|
+
* `getLastCreatedCardPolicyTemplateId` selector returns `[0]` for
|
|
33
|
+
* ergonomic single-create routing.
|
|
34
|
+
*/
|
|
35
|
+
lastCreatedCardPolicyTemplateIds: ID[];
|
|
36
|
+
/**
|
|
37
|
+
* Chat session id from `sourceChatSessionId` on the most recent
|
|
38
|
+
* `createCardPolicyTemplates` dispatch — i.e. the AI CFO conversation
|
|
39
|
+
* that triggered the bulk create. Lets the policy list and AI CFO
|
|
40
|
+
* drawer correlate an in-flight create back to its originating session.
|
|
41
|
+
* `undefined` when the most recent submit came from the manual create
|
|
42
|
+
* screen (which omits `sourceChatSessionId`).
|
|
43
|
+
*/
|
|
44
|
+
lastCreateCardPolicySourceChatSessionId?: ID;
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { createCardPolicyTemplates, updateCreateCardPolicyTemplateRequestState } from './createCardPolicyReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof createCardPolicyTemplates> | ReturnType<typeof updateCreatedCardPolicyTemplate> | ReturnType<typeof updateCreateCardPolicyTemplateRequestState>;
|
|
8
|
+
/**
|
|
9
|
+
* `POST /cards/1.0/policy-templates` (bulk). Builds the bulk wire body
|
|
10
|
+
* from the camelCased action payload, sends one round-trip, and on
|
|
11
|
+
* success fans out:
|
|
12
|
+
* - one `updateCreatedCardPolicyTemplate` on the entity slice per row
|
|
13
|
+
* in `templates_created` (so the entity store is hydrated with every
|
|
14
|
+
* created template), and
|
|
15
|
+
* - one `updateCreateCardPolicyTemplateRequestState` with the ordered
|
|
16
|
+
* id list + per-item errors so the view can render partial-success
|
|
17
|
+
* UX without re-touching the wire types.
|
|
18
|
+
*
|
|
19
|
+
* Partial success (`errors.length > 0` with at least one template
|
|
20
|
+
* created) is still treated as `Completed` — the lifecycle is binary
|
|
21
|
+
* and the per-item errors live on the slice for the UI to inspect.
|
|
22
|
+
* Hard failures (non-success `status` or thrown errors) map to `Error`
|
|
23
|
+
* the same way they did pre-bulk.
|
|
24
|
+
*/
|
|
25
|
+
export declare const createCardPolicyTemplatesEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCardPolicyTemplatesEpic = 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
|
+
/**
|
|
11
|
+
* `POST /cards/1.0/policy-templates` (bulk). Builds the bulk wire body
|
|
12
|
+
* from the camelCased action payload, sends one round-trip, and on
|
|
13
|
+
* success fans out:
|
|
14
|
+
* - one `updateCreatedCardPolicyTemplate` on the entity slice per row
|
|
15
|
+
* in `templates_created` (so the entity store is hydrated with every
|
|
16
|
+
* created template), and
|
|
17
|
+
* - one `updateCreateCardPolicyTemplateRequestState` with the ordered
|
|
18
|
+
* id list + per-item errors so the view can render partial-success
|
|
19
|
+
* UX without re-touching the wire types.
|
|
20
|
+
*
|
|
21
|
+
* Partial success (`errors.length > 0` with at least one template
|
|
22
|
+
* created) is still treated as `Completed` — the lifecycle is binary
|
|
23
|
+
* and the per-item errors live on the slice for the UI to inspect.
|
|
24
|
+
* Hard failures (non-success `status` or thrown errors) map to `Error`
|
|
25
|
+
* the same way they did pre-bulk.
|
|
26
|
+
*/
|
|
27
|
+
const createCardPolicyTemplatesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(createCardPolicyReducer_1.createCardPolicyTemplates.match), (0, operators_1.mergeMap)((action) => {
|
|
28
|
+
const body = (0, cardPolicyPayload_1.toCreateCardPolicyTemplatesRequestBody)(action.payload);
|
|
29
|
+
return zeniAPI
|
|
30
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`, body)
|
|
31
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
32
|
+
if ((0, responsePayload_1.isSuccessStatus)(response) && response.data != null) {
|
|
33
|
+
const { templates_created, errors } = response.data;
|
|
34
|
+
const createdTemplates = templates_created.map((row) => row.template);
|
|
35
|
+
const actions = [
|
|
36
|
+
...createdTemplates.map((template) => (0, cardPolicyReducer_1.updateCreatedCardPolicyTemplate)(template)),
|
|
37
|
+
(0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
38
|
+
fetchState: 'Completed',
|
|
39
|
+
perItemErrors: (errors ?? []).map(cardPolicyPayload_1.toBulkCreateCardPolicyTemplateError),
|
|
40
|
+
templateIds: createdTemplates.map((template) => template.template_id),
|
|
41
|
+
}),
|
|
42
|
+
];
|
|
43
|
+
return (0, rxjs_1.from)(actions);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return (0, rxjs_1.of)((0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
47
|
+
fetchState: 'Error',
|
|
48
|
+
error: response.status,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, createCardPolicyReducer_1.updateCreateCardPolicyTemplateRequestState)({
|
|
52
|
+
fetchState: 'Error',
|
|
53
|
+
error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Create card-policy templates REST API call errored out' +
|
|
54
|
+
JSON.stringify(error)),
|
|
55
|
+
}))));
|
|
56
|
+
}));
|
|
57
|
+
exports.createCardPolicyTemplatesEpic = createCardPolicyTemplatesEpic;
|
|
@@ -0,0 +1,15 @@
|
|
|
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>;
|
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
|
@@ -61,7 +61,7 @@ export declare const initialCreditAcc: CreditAccount;
|
|
|
61
61
|
export declare const initialDebitCardSummaries: DebitCardSummaries;
|
|
62
62
|
export declare const initialResendRevokeCardInvite: ResendRevokeCardInvite;
|
|
63
63
|
export declare const initialCreditAccountRepayment: CreditAccountRepayment;
|
|
64
|
-
export declare const toChargeCardSortKeyType: (v: string) => "status" | "
|
|
64
|
+
export declare const toChargeCardSortKeyType: (v: string) => "status" | "department" | "accountType" | "owner" | "cardName" | "limit" | "cardType" | "utilisation";
|
|
65
65
|
export declare type ChargeCardViewSortKey = ReturnType<typeof toChargeCardSortKeyType>;
|
|
66
66
|
export declare const ALL_CASHBACK_SORT_KEYS: readonly ["month", "cashback"];
|
|
67
67
|
export declare const toCashbackSortKeyType: (v: string) => "month" | "cashback";
|
|
@@ -54,7 +54,21 @@ export interface MyPendingActivationChargeCardListSelectorView extends SelectorV
|
|
|
54
54
|
export interface ChargeCardListWithShippingAddressSelectorView extends SelectorView {
|
|
55
55
|
cards: ChargeCardWithUserAndShippingAddress[];
|
|
56
56
|
}
|
|
57
|
+
export interface AllChargeCardsWithUserSelectorView extends SelectorView {
|
|
58
|
+
cards: ChargeCardWithUser[];
|
|
59
|
+
}
|
|
57
60
|
export declare const getChargeCardListView: (state: RootState, includeCreditAccountDebitSummaryAndCashbackInfo: boolean, isDebitCardEnabled: boolean, isCreditCardEnabled: boolean) => ChargeCardListSelectorView;
|
|
61
|
+
/**
|
|
62
|
+
* Returns every enriched `ChargeCardWithUser` for the tenant, without
|
|
63
|
+
* applying the cards-list screen's `searchText` filter or its column
|
|
64
|
+
* `sortKey/sortOrder`. Used by surfaces that need the raw card universe
|
|
65
|
+
* decoupled from whatever the user has typed/sorted on the cards list
|
|
66
|
+
* (e.g. the Card Policy "Apply to Cards" picker, which owns its own
|
|
67
|
+
* search + sort UI). The list-screen's filter/sort state is intentionally
|
|
68
|
+
* left untouched so revisits to the cards list still restore the user's
|
|
69
|
+
* search.
|
|
70
|
+
*/
|
|
71
|
+
export declare const getAllChargeCardsWithUser: (state: RootState) => AllChargeCardsWithUserSelectorView;
|
|
58
72
|
export declare const getMyPendingActivationChargeCardListView: (state: RootState) => MyPendingActivationChargeCardListSelectorView;
|
|
59
73
|
export declare const getMyRequestOnHoldChargeCardListWithShippingAddress: (state: RootState) => ChargeCardListWithShippingAddressSelectorView;
|
|
60
74
|
/**
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getChargeCardBulkActionView = exports.getChargeCardRowActionView = exports.getChargeCardRecurringExpensesByCardIds = exports.getDebitCardSummary = exports.getDebitCardList = exports.getDepositAccountListWithDebitCardIssued = exports.getCreditAccountDetails = exports.anyCardOnHold = exports.getMyRequestOnHoldChargeCardListWithShippingAddress = exports.getMyPendingActivationChargeCardListView = exports.getChargeCardListView = void 0;
|
|
6
|
+
exports.getChargeCardBulkActionView = exports.getChargeCardRowActionView = exports.getChargeCardRecurringExpensesByCardIds = exports.getDebitCardSummary = exports.getDebitCardList = exports.getDepositAccountListWithDebitCardIssued = exports.getCreditAccountDetails = exports.anyCardOnHold = exports.getMyRequestOnHoldChargeCardListWithShippingAddress = exports.getMyPendingActivationChargeCardListView = exports.getAllChargeCardsWithUser = exports.getChargeCardListView = void 0;
|
|
7
7
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
8
8
|
const orderBy_1 = __importDefault(require("lodash/orderBy"));
|
|
9
9
|
const sortOrderPayload_1 = require("../../../../commonPayloadTypes/sortOrderPayload");
|
|
@@ -94,6 +94,32 @@ const getChargeCardListView = (state, includeCreditAccountDebitSummaryAndCashbac
|
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
96
|
exports.getChargeCardListView = getChargeCardListView;
|
|
97
|
+
/**
|
|
98
|
+
* Returns every enriched `ChargeCardWithUser` for the tenant, without
|
|
99
|
+
* applying the cards-list screen's `searchText` filter or its column
|
|
100
|
+
* `sortKey/sortOrder`. Used by surfaces that need the raw card universe
|
|
101
|
+
* decoupled from whatever the user has typed/sorted on the cards list
|
|
102
|
+
* (e.g. the Card Policy "Apply to Cards" picker, which owns its own
|
|
103
|
+
* search + sort UI). The list-screen's filter/sort state is intentionally
|
|
104
|
+
* left untouched so revisits to the cards list still restore the user's
|
|
105
|
+
* search.
|
|
106
|
+
*/
|
|
107
|
+
const getAllChargeCardsWithUser = (state) => {
|
|
108
|
+
const { chargeCardListState, chargeCardState, chargeCardConfigState } = state;
|
|
109
|
+
const cards = (0, chargeCardSelector_1.getChargeCardsByIds)(chargeCardState, chargeCardListState.cardIds);
|
|
110
|
+
const chargeCardsWithUser = getChargeCardsWithUser(cards, state);
|
|
111
|
+
const fetchState = (0, reduceFetchState_1.reduceFetchState)([
|
|
112
|
+
chargeCardListState,
|
|
113
|
+
chargeCardConfigState,
|
|
114
|
+
]).fetchState;
|
|
115
|
+
return {
|
|
116
|
+
fetchState,
|
|
117
|
+
error: chargeCardListState.error,
|
|
118
|
+
cards: chargeCardsWithUser,
|
|
119
|
+
version: '1.0',
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
exports.getAllChargeCardsWithUser = getAllChargeCardsWithUser;
|
|
97
123
|
const getMyPendingActivationChargeCardListView = (state) => {
|
|
98
124
|
const { tenantState, chargeCardListState, chargeCardState } = state;
|
|
99
125
|
const cards = (0, chargeCardSelector_1.getChargeCardsByIds)(chargeCardState, chargeCardListState.cardIds);
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/aiCardCreationFormDraftTypes.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ID } from '../../../../commonStateTypes/common';
|
|
2
|
+
import { CardsCardKind, CardsCreationInitialData } from '../../../../entity/aiCfo/aiCfoState';
|
|
3
|
+
import { User } from '../../../../entity/user/userState';
|
|
4
|
+
/**
|
|
5
|
+
* AI CFO card-creation form draft state — the canonical source of
|
|
6
|
+
* truth for the `CardsCreationInteractiveForm` component (rule #4).
|
|
7
|
+
*
|
|
8
|
+
* The web-components form is a pure renderer that hydrates from
|
|
9
|
+
* `IssueChargeCardState.aiCardCreationFormDraft` and emits every
|
|
10
|
+
* change back via `onFormChange` → `updateAiCardCreationFormDraft`.
|
|
11
|
+
*
|
|
12
|
+
* The AI-payload-side types (`CardsCardKind`, `CardsCardOption`,
|
|
13
|
+
* `CardNameOption`, `CardsCreationInitialData`, etc.) are defined on
|
|
14
|
+
* `entity/aiCfo/aiCfoState.ts` and consumed directly from there — this
|
|
15
|
+
* file only declares the FE-side form draft shapes and the companion
|
|
16
|
+
* seed context the reducer keeps for re-derivation.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Step-1 row: a single team the user can opt in/out of via a checkbox.
|
|
20
|
+
*
|
|
21
|
+
* Mirrors the AI's `teamRows[i]` payload field-for-field plus the
|
|
22
|
+
* `isChecked` toggle, with FE display strings (`value`, `rightLabel`)
|
|
23
|
+
* resolved from the AI's `avgMonthlySpend` / `recommendedLimit`.
|
|
24
|
+
*/
|
|
25
|
+
export interface CardsTeamRow {
|
|
26
|
+
cardKind: CardsCardKind;
|
|
27
|
+
id: string;
|
|
28
|
+
isChecked: boolean;
|
|
29
|
+
label: string;
|
|
30
|
+
/** Right column primary value, e.g. "$20,000". */
|
|
31
|
+
rightLabel: string;
|
|
32
|
+
/** Middle column primary value, e.g. "$18,400". */
|
|
33
|
+
value: string;
|
|
34
|
+
rightSubLabel?: string;
|
|
35
|
+
subLabel?: string;
|
|
36
|
+
subValue?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Owner field value held in the form state. Mirrors `UserSingleSelectField`
|
|
40
|
+
* which wants both the universe of users and the currently selected user
|
|
41
|
+
* collocated with the field value.
|
|
42
|
+
*/
|
|
43
|
+
export interface CardsOwnerFieldValue {
|
|
44
|
+
allUsers: User[];
|
|
45
|
+
selectedUser?: User;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Step-2 row: the configured card for one of the teams the user kept
|
|
49
|
+
* in step 1. `cardOptionId` references one of the
|
|
50
|
+
* `CardsCreationInitialData.cardOptions`.
|
|
51
|
+
*/
|
|
52
|
+
export interface CardsCardRow {
|
|
53
|
+
cardKind: CardsCardKind;
|
|
54
|
+
cardOptionId: string;
|
|
55
|
+
id: string;
|
|
56
|
+
label: string;
|
|
57
|
+
owner: CardsOwnerFieldValue;
|
|
58
|
+
recommendedLimit?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Canonical CES shape for the AI card-creation form. The web-components
|
|
62
|
+
* `CardsCreationInteractiveForm` hydrates RHF from this object and emits
|
|
63
|
+
* every change back through `onFormChange`.
|
|
64
|
+
*/
|
|
65
|
+
export interface CardsFormDraft {
|
|
66
|
+
cardRows: CardsCardRow[];
|
|
67
|
+
teamRows: CardsTeamRow[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Seed context retained on the slice so subsequent `updateAiCardCreationFormDraft`
|
|
71
|
+
* dispatches can re-derive step-2 rows from step-1 selections without the
|
|
72
|
+
* component re-passing the full universe each time.
|
|
73
|
+
*/
|
|
74
|
+
export interface AiCardCreationFormDraftSeedContext {
|
|
75
|
+
allUsers: User[];
|
|
76
|
+
mode: CardsCreationInitialData['mode'];
|
|
77
|
+
suggestedOwnerUserIdByTeamId: Record<ID, string | undefined>;
|
|
78
|
+
defaultCardOptionId?: string;
|
|
79
|
+
}
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CardsCreationInitialData } from '../../../../entity/aiCfo/aiCfoState';
|
|
2
|
+
import { User } from '../../../../entity/user/userState';
|
|
3
|
+
import { AiCardCreationFormDraftSeedContext, CardsFormDraft } from './aiCardCreationFormDraftTypes';
|
|
4
|
+
export interface BuildAiCardCreationFormDraftSeedArgs {
|
|
5
|
+
allUsers: User[];
|
|
6
|
+
initialData: CardsCreationInitialData;
|
|
7
|
+
}
|
|
8
|
+
export interface BuildAiCardCreationFormDraftSeedResult {
|
|
9
|
+
context: AiCardCreationFormDraftSeedContext;
|
|
10
|
+
draft: CardsFormDraft;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the initial `CardsFormDraft` + companion seed context for a
|
|
14
|
+
* fresh AI card-creation session. Used by the `seedAiCardCreationFormDraft`
|
|
15
|
+
* reducer.
|
|
16
|
+
*
|
|
17
|
+
* Branches on `initialData.mode`:
|
|
18
|
+
* - `review`: step-1 team rows start fully checked. Step-2 `cardRows`
|
|
19
|
+
* is left empty — `deriveAiCardRowsFromTeams` materializes it on
|
|
20
|
+
* subsequent `updateAiCardCreationFormDraft` dispatches.
|
|
21
|
+
* - `create`: no step-1 list — seed `cardRows` directly from the AI's
|
|
22
|
+
* suggested cards (resolving owners via `allUsers`) and leave
|
|
23
|
+
* `teamRows` empty.
|
|
24
|
+
*/
|
|
25
|
+
export declare const buildAiCardCreationFormDraftSeed: ({ initialData, allUsers, }: BuildAiCardCreationFormDraftSeedArgs) => BuildAiCardCreationFormDraftSeedResult;
|
package/lib/view/spendManagement/chargeCards/issueChargeCard/buildAiCardCreationFormDraftSeed.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAiCardCreationFormDraftSeed = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Build the initial `CardsFormDraft` + companion seed context for a
|
|
6
|
+
* fresh AI card-creation session. Used by the `seedAiCardCreationFormDraft`
|
|
7
|
+
* reducer.
|
|
8
|
+
*
|
|
9
|
+
* Branches on `initialData.mode`:
|
|
10
|
+
* - `review`: step-1 team rows start fully checked. Step-2 `cardRows`
|
|
11
|
+
* is left empty — `deriveAiCardRowsFromTeams` materializes it on
|
|
12
|
+
* subsequent `updateAiCardCreationFormDraft` dispatches.
|
|
13
|
+
* - `create`: no step-1 list — seed `cardRows` directly from the AI's
|
|
14
|
+
* suggested cards (resolving owners via `allUsers`) and leave
|
|
15
|
+
* `teamRows` empty.
|
|
16
|
+
*/
|
|
17
|
+
const buildAiCardCreationFormDraftSeed = ({ initialData, allUsers, }) => {
|
|
18
|
+
const context = {
|
|
19
|
+
allUsers,
|
|
20
|
+
defaultCardOptionId: initialData.cardOptions[0]?.id,
|
|
21
|
+
mode: initialData.mode,
|
|
22
|
+
suggestedOwnerUserIdByTeamId: initialData.suggestedOwnerUserIdByTeamId,
|
|
23
|
+
};
|
|
24
|
+
if (initialData.mode === 'create') {
|
|
25
|
+
return {
|
|
26
|
+
context,
|
|
27
|
+
draft: {
|
|
28
|
+
teamRows: [],
|
|
29
|
+
cardRows: initialData.cardRows.map((seed) => buildCardRowFromSeed(seed, allUsers)),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const teamRows = initialData.teamRows.map((row) => ({
|
|
34
|
+
cardKind: row.cardKind,
|
|
35
|
+
id: row.id,
|
|
36
|
+
isChecked: true,
|
|
37
|
+
label: row.label,
|
|
38
|
+
value: row.avgMonthlySpend,
|
|
39
|
+
rightLabel: row.recommendedLimit,
|
|
40
|
+
rightSubLabel: row.recommendedLimitCadence,
|
|
41
|
+
}));
|
|
42
|
+
return {
|
|
43
|
+
context,
|
|
44
|
+
draft: {
|
|
45
|
+
teamRows,
|
|
46
|
+
cardRows: [],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
exports.buildAiCardCreationFormDraftSeed = buildAiCardCreationFormDraftSeed;
|
|
51
|
+
const buildCardRowFromSeed = (seed, allUsers) => {
|
|
52
|
+
const selectedUser = seed.suggestedOwnerUserId != null
|
|
53
|
+
? allUsers.find((user) => user.userId === seed.suggestedOwnerUserId)
|
|
54
|
+
: undefined;
|
|
55
|
+
return {
|
|
56
|
+
cardKind: seed.cardKind,
|
|
57
|
+
id: seed.id,
|
|
58
|
+
label: seed.label,
|
|
59
|
+
cardOptionId: seed.cardOptionId,
|
|
60
|
+
owner: {
|
|
61
|
+
allUsers,
|
|
62
|
+
selectedUser,
|
|
63
|
+
},
|
|
64
|
+
recommendedLimit: seed.recommendedLimit,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { User } from '../../../../entity/user/userState';
|
|
2
|
+
import { CardsCardRow, CardsTeamRow } from './aiCardCreationFormDraftTypes';
|
|
3
|
+
export interface DeriveAiCardRowsFromTeamsArgs {
|
|
4
|
+
allUsers: User[];
|
|
5
|
+
/** First card option id; used as the per-row default when nothing else applies. */
|
|
6
|
+
defaultCardOptionId: string | undefined;
|
|
7
|
+
/** Map of teamId -> suggested owner userId surfaced by the AI. */
|
|
8
|
+
suggestedOwnerUserIdByTeamId: Record<string, string | undefined>;
|
|
9
|
+
teamRows: CardsTeamRow[];
|
|
10
|
+
/** Existing step-2 rows; preserved row-for-row when the team is still checked. */
|
|
11
|
+
prevCardRows?: CardsCardRow[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Derive the step-2 `cardRows` from the user's step-1 team selection.
|
|
15
|
+
*
|
|
16
|
+
* Behaviour:
|
|
17
|
+
* - One output row per `teamRow.isChecked === true`, in the same order.
|
|
18
|
+
* - When a team is still checked AND we have a previous row for it, the
|
|
19
|
+
* previous row is preserved verbatim — so user edits made in step 2
|
|
20
|
+
* aren't blown away when an upstream watchHandler re-derives.
|
|
21
|
+
* - Newly-included teams fall back to:
|
|
22
|
+
* - `cardOptionId = defaultCardOptionId`
|
|
23
|
+
* - `selectedUser = the User whose userId === suggestedOwnerUserIdByTeamId[teamId]`
|
|
24
|
+
* - `recommendedLimit = numeric parse of `teamRow.rightLabel` (e.g. "$20,000")`
|
|
25
|
+
*/
|
|
26
|
+
export declare const deriveAiCardRowsFromTeams: ({ teamRows, prevCardRows, allUsers, defaultCardOptionId, suggestedOwnerUserIdByTeamId, }: DeriveAiCardRowsFromTeamsArgs) => CardsCardRow[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveAiCardRowsFromTeams = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Derive the step-2 `cardRows` from the user's step-1 team selection.
|
|
6
|
+
*
|
|
7
|
+
* Behaviour:
|
|
8
|
+
* - One output row per `teamRow.isChecked === true`, in the same order.
|
|
9
|
+
* - When a team is still checked AND we have a previous row for it, the
|
|
10
|
+
* previous row is preserved verbatim — so user edits made in step 2
|
|
11
|
+
* aren't blown away when an upstream watchHandler re-derives.
|
|
12
|
+
* - Newly-included teams fall back to:
|
|
13
|
+
* - `cardOptionId = defaultCardOptionId`
|
|
14
|
+
* - `selectedUser = the User whose userId === suggestedOwnerUserIdByTeamId[teamId]`
|
|
15
|
+
* - `recommendedLimit = numeric parse of `teamRow.rightLabel` (e.g. "$20,000")`
|
|
16
|
+
*/
|
|
17
|
+
const deriveAiCardRowsFromTeams = ({ teamRows, prevCardRows = [], allUsers, defaultCardOptionId, suggestedOwnerUserIdByTeamId, }) => {
|
|
18
|
+
const prevById = new Map(prevCardRows.map((row) => [row.id, row]));
|
|
19
|
+
const userById = new Map(allUsers.map((user) => [user.userId, user]));
|
|
20
|
+
return teamRows
|
|
21
|
+
.filter((row) => row.isChecked)
|
|
22
|
+
.map((teamRow) => {
|
|
23
|
+
const previous = prevById.get(teamRow.id);
|
|
24
|
+
if (previous != null) {
|
|
25
|
+
return previous;
|
|
26
|
+
}
|
|
27
|
+
const suggestedUserId = suggestedOwnerUserIdByTeamId[teamRow.id];
|
|
28
|
+
const selectedUser = suggestedUserId != null ? userById.get(suggestedUserId) : undefined;
|
|
29
|
+
return {
|
|
30
|
+
cardKind: teamRow.cardKind,
|
|
31
|
+
id: teamRow.id,
|
|
32
|
+
label: teamRow.label,
|
|
33
|
+
cardOptionId: defaultCardOptionId ?? '',
|
|
34
|
+
owner: {
|
|
35
|
+
allUsers,
|
|
36
|
+
selectedUser,
|
|
37
|
+
},
|
|
38
|
+
recommendedLimit: parseLimitToFloat(teamRow.rightLabel),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.deriveAiCardRowsFromTeams = deriveAiCardRowsFromTeams;
|
|
43
|
+
// Best-effort numeric parse of an AI-provided limit string like "$20,000".
|
|
44
|
+
const parseLimitToFloat = (raw) => {
|
|
45
|
+
const cleaned = raw.replace(/[^0-9.-]/g, '');
|
|
46
|
+
if (cleaned.length === 0) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const parsed = Number(cleaned);
|
|
50
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
51
|
+
};
|
|
@@ -8,6 +8,6 @@ import { updateUserRoles } from '../../../../entity/userRole/userRoleReducer';
|
|
|
8
8
|
import { RootState } from '../../../../reducer';
|
|
9
9
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
10
10
|
import { updateChargeCardList } from '../chargeCardList/chargeCardListReducer';
|
|
11
|
-
import { issueChargeCardSuccessOrFailure, issueChargeCards, updateChargeCardCount, updateDebitCardCount, updateLastSelfIssuedDebitCardId } from './issueChargeCardReducer';
|
|
12
|
-
export type ActionType = ReturnType<typeof issueChargeCards> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateChargeCardCount> | ReturnType<typeof updateDebitCardCount> | ReturnType<typeof updateLastSelfIssuedDebitCardId> | ReturnType<typeof issueChargeCardSuccessOrFailure> | ReturnType<typeof updateAddresses>;
|
|
11
|
+
import { issueChargeCardSuccessOrFailure, issueChargeCards, updateChargeCardCount, updateDebitCardCount, updateLastIssuedCardIds, updateLastSelfIssuedDebitCardId } from './issueChargeCardReducer';
|
|
12
|
+
export type ActionType = ReturnType<typeof issueChargeCards> | ReturnType<typeof updateChargeCards> | ReturnType<typeof updateAllUsers> | ReturnType<typeof updateUserRoles> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateChargeCardList> | ReturnType<typeof updateChargeCardCount> | ReturnType<typeof updateDebitCardCount> | ReturnType<typeof updateLastSelfIssuedDebitCardId> | ReturnType<typeof updateLastIssuedCardIds> | ReturnType<typeof issueChargeCardSuccessOrFailure> | ReturnType<typeof updateAddresses>;
|
|
13
13
|
export declare const issueChargeCardEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -90,7 +90,7 @@ const issueChargeCardEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, ope
|
|
|
90
90
|
actions.push((0, chargeCardReducer_1.updateChargeCards)(issuedCards), (0, userReducer_1.updateAllUsers)({ users: response.data.users }), (0, userRoleReducer_1.updateUserRoles)(response.data.user_roles), (0, chargeCardListReducer_1.updateChargeCardList)({
|
|
91
91
|
chargeCardListPayload: response.data,
|
|
92
92
|
keepExistingListItems: true,
|
|
93
|
-
}), (0, addressReducer_1.updateAddresses)(response.data.addresses), (0, issueChargeCardReducer_1.updateChargeCardCount)(response.data?.cards_count_by_user_id ?? []), (0, issueChargeCardReducer_1.updateDebitCardCount)(response.data?.debit_cards_count_by_deposit_account_id ?? {}), (0, issueChargeCardReducer_1.issueChargeCardSuccessOrFailure)({ fetchState: 'Completed' }));
|
|
93
|
+
}), (0, addressReducer_1.updateAddresses)(response.data.addresses), (0, issueChargeCardReducer_1.updateChargeCardCount)(response.data?.cards_count_by_user_id ?? []), (0, issueChargeCardReducer_1.updateDebitCardCount)(response.data?.debit_cards_count_by_deposit_account_id ?? {}), (0, issueChargeCardReducer_1.updateLastIssuedCardIds)(issuedCards.map((card) => card.card_id)), (0, issueChargeCardReducer_1.issueChargeCardSuccessOrFailure)({ fetchState: 'Completed' }));
|
|
94
94
|
if (issuedCards.length === 1 &&
|
|
95
95
|
(issuedCards[0].card_type.code ===
|
|
96
96
|
'business_virtual_debit_card' ||
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { FetchState, ID } from '../../../../commonStateTypes/common';
|
|
2
|
+
import { CardsCreationInitialData } from '../../../../entity/aiCfo/aiCfoState';
|
|
2
3
|
import { CardCodeType } from '../../../../entity/chargeCard/chargeCard';
|
|
3
4
|
import { DepositAccountWithLimitPayload } from '../../../../entity/depositAccount/depositAccountPayload';
|
|
5
|
+
import { User } from '../../../../entity/user/userState';
|
|
4
6
|
import { ZeniAPIStatus } from '../../../../responsePayload';
|
|
5
7
|
import { ActiveChargeCardCountPayload, ActiveDebitCardCountByUserIdPayload } from '../../../userListView/userListViewPayload';
|
|
8
|
+
import { CardsFormDraft } from './aiCardCreationFormDraftTypes';
|
|
6
9
|
import { IssueChargeCardLocalData, IssueChargeCardState } from './issueChargeCardState';
|
|
7
10
|
export declare const initialState: IssueChargeCardState;
|
|
8
|
-
export declare const issueChargeCards: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[
|
|
11
|
+
export declare const issueChargeCards: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload?: {
|
|
12
|
+
sourceChatSessionId?: ID;
|
|
13
|
+
} | undefined], {
|
|
14
|
+
sourceChatSessionId?: ID;
|
|
15
|
+
}, "issueChargeCard/issueChargeCards", never, never>, updateChargeCardsLocalStore: import("@reduxjs/toolkit").ActionCreatorWithPayload<IssueChargeCardLocalData[], "issueChargeCard/updateChargeCardsLocalStore">, updateLastSelfIssuedDebitCardId: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "issueChargeCard/updateLastSelfIssuedDebitCardId">, updateLastIssuedCardIds: import("@reduxjs/toolkit").ActionCreatorWithPayload<string[], "issueChargeCard/updateLastIssuedCardIds">, issueChargeCardSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
9
16
|
fetchState: FetchState;
|
|
10
17
|
error?: ZeniAPIStatus;
|
|
11
18
|
}, "issueChargeCard/issueChargeCardSuccessOrFailure">, resetIssueChargeCardForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/resetIssueChargeCardForm">, updateCustomAddressId: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
@@ -19,6 +26,9 @@ export declare const issueChargeCards: import("@reduxjs/toolkit").ActionCreatorW
|
|
|
19
26
|
}, "issueChargeCard/fetchIssueCardPage", never, never>, updateDepositAccountsInCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<DepositAccountWithLimitPayload[], "issueChargeCard/updateDepositAccountsInCards">, fetchDepositAccountListForCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/fetchDepositAccountListForCards">, updateDepositAccountListForCardsFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
20
27
|
fetchState: FetchState;
|
|
21
28
|
error?: ZeniAPIStatus;
|
|
22
|
-
}, "issueChargeCard/updateDepositAccountListForCardsFetchStatus">,
|
|
29
|
+
}, "issueChargeCard/updateDepositAccountListForCardsFetchStatus">, seedAiCardCreationFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[allUsers: User[], initialData: CardsCreationInitialData], {
|
|
30
|
+
allUsers: User[];
|
|
31
|
+
initialData: CardsCreationInitialData;
|
|
32
|
+
}, "issueChargeCard/seedAiCardCreationFormDraft", never, never>, updateAiCardCreationFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<CardsFormDraft, "issueChargeCard/updateAiCardCreationFormDraft">, clearAiCardCreationFormDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/clearAiCardCreationFormDraft">, clearIssueChargeCard: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"issueChargeCard/clearIssueChargeCard">;
|
|
23
33
|
declare const _default: import("redux").Reducer<IssueChargeCardState>;
|
|
24
34
|
export default _default;
|