@zeniai/client-epic-state 5.2.11 → 5.2.13-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/entity/invoicing/invoicingCommonPayload.d.ts +27 -29
- package/lib/entity/invoicing/invoicingCommonPayload.js +37 -75
- package/lib/entity/invoicing/product/productPayload.d.ts +10 -0
- package/lib/entity/invoicing/product/productPayload.js +14 -2
- package/lib/epic.d.ts +3 -2
- package/lib/epic.js +12 -5
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +33 -73
- package/lib/esm/entity/invoicing/product/productPayload.js +14 -2
- package/lib/esm/epic.js +8 -1
- package/lib/esm/index.js +7 -6
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +25 -9
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +40 -0
- package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +27 -0
- package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +19 -0
- package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +19 -0
- package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +39 -0
- package/lib/esm/view/invoicing/settingsView/epics/settingsViewActionType.js +1 -0
- package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +25 -0
- package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +48 -0
- package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +25 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +41 -0
- package/lib/esm/view/recommendation/recommendationReducer.js +13 -1
- package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +52 -0
- package/lib/index.d.ts +10 -7
- package/lib/index.js +36 -28
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +12 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +25 -9
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +10 -1
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +43 -1
- package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +31 -0
- package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +23 -0
- package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +23 -0
- package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +6 -0
- package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +43 -0
- package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +5 -0
- package/lib/view/invoicing/settingsView/epics/settingsViewActionType.js +2 -0
- package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +11 -0
- package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +29 -0
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +34 -0
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +53 -0
- package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +4 -1
- package/lib/view/invoicing/settingsView/settingsViewReducer.js +26 -2
- package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +35 -0
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +43 -1
- package/lib/view/invoicing/settingsView/settingsViewState.d.ts +8 -0
- package/lib/view/recommendation/recommendationPayload.d.ts +34 -0
- package/lib/view/recommendation/recommendationReducer.d.ts +2 -1
- package/lib/view/recommendation/recommendationReducer.js +14 -2
- package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +7 -0
- package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +56 -0
- package/package.json +1 -1
- package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +0 -92
- package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +0 -12
- package/lib/view/invoicing/settingsView/settingsViewEpics.js +0 -99
|
@@ -12,4 +12,38 @@ interface FetchRecommendationPayloadWithCOT {
|
|
|
12
12
|
recommendations: RecommendationPayloadWithCOT[];
|
|
13
13
|
}
|
|
14
14
|
export type FetchRecommendationResponseWithCOT = ZeniAPIResponse<FetchRecommendationPayloadWithCOT>;
|
|
15
|
+
export type RecommendationFeedbackDimension = 'vendor' | 'category' | 'class';
|
|
16
|
+
export type RecommendationFeedbackSource = 'primary' | 'alternate' | 'shadow' | 'qbo';
|
|
17
|
+
export type RecommendationFeedbackOutcome = 'accepted' | 'override_ranked' | 'override_outside' | 'retracted';
|
|
18
|
+
export interface RecommendationFeedbackValue {
|
|
19
|
+
name: string;
|
|
20
|
+
id?: string | null;
|
|
21
|
+
integrationId?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface ShownRecommendationForFeedback {
|
|
24
|
+
rank: number;
|
|
25
|
+
source: RecommendationFeedbackSource;
|
|
26
|
+
value: RecommendationFeedbackValue;
|
|
27
|
+
confidence?: number | null;
|
|
28
|
+
cot?: string[];
|
|
29
|
+
reasoning?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface SubmitRecommendationFeedbackPayload {
|
|
32
|
+
dimension: RecommendationFeedbackDimension;
|
|
33
|
+
outcome: RecommendationFeedbackOutcome;
|
|
34
|
+
selected: RecommendationFeedbackValue & {
|
|
35
|
+
isNewEntity?: boolean;
|
|
36
|
+
};
|
|
37
|
+
transactionId: string;
|
|
38
|
+
features?: Record<string, unknown> | null;
|
|
39
|
+
lineId?: string | null;
|
|
40
|
+
matchedRank?: number | null;
|
|
41
|
+
matchedSource?: RecommendationFeedbackSource | null;
|
|
42
|
+
reasonText?: string | null;
|
|
43
|
+
recommendationSetId?: string | null;
|
|
44
|
+
retractsFeedbackId?: string | null;
|
|
45
|
+
shownRecommendations?: ShownRecommendationForFeedback[];
|
|
46
|
+
skipped?: boolean;
|
|
47
|
+
topPickSource?: RecommendationFeedbackSource | null;
|
|
48
|
+
}
|
|
15
49
|
export {};
|
|
@@ -5,6 +5,7 @@ import { TransactionID } from '../../entity/transaction/stateTypes/transactionID
|
|
|
5
5
|
import { SupportedTransaction } from '../../entity/transaction/transactionState';
|
|
6
6
|
import { ZeniAPIStatus } from '../../responsePayload';
|
|
7
7
|
import { TransactionsTab } from '../expenseAutomationView/types/transactionsViewState';
|
|
8
|
+
import { SubmitRecommendationFeedbackPayload } from './recommendationPayload';
|
|
8
9
|
import { EntityRecommendationState } from './recommendationState';
|
|
9
10
|
export type RecommendationLineUpdateFlowType = 'categorization' | 'detail';
|
|
10
11
|
type FetchEntityRecommendationsForLineUpdateCommonPayload = {
|
|
@@ -57,6 +58,6 @@ export declare const fetchEntityRecommendationsByTransactionId: import("@reduxjs
|
|
|
57
58
|
}, "recommendation/updateRecommendationForEntityFailure">, indicateReadyToInitializeRecommendation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entityIdOrName: string, entityType: EntityType], {
|
|
58
59
|
entityIdOrName: string;
|
|
59
60
|
entityType: EntityType;
|
|
60
|
-
}, "recommendation/indicateReadyToInitializeRecommendation", never, never>;
|
|
61
|
+
}, "recommendation/indicateReadyToInitializeRecommendation", never, never>, submitRecommendationFeedback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[args: SubmitRecommendationFeedbackPayload], SubmitRecommendationFeedbackPayload, "recommendation/submitRecommendationFeedback", never, never>;
|
|
61
62
|
declare const _default: import("redux").Reducer<EntityRecommendationState>;
|
|
62
63
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
|
|
4
|
+
exports.submitRecommendationFeedback = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const rootActions_1 = require("../../rootActions");
|
|
7
7
|
const recommendationState_1 = require("./recommendationState");
|
|
@@ -135,6 +135,18 @@ const recommendation = (0, toolkit_1.createSlice)({
|
|
|
135
135
|
};
|
|
136
136
|
},
|
|
137
137
|
},
|
|
138
|
+
// Fire-and-forget human feedback on a recommendation (accept, ranked
|
|
139
|
+
// override or outside override). Handled by submitRecommendationFeedbackEpic
|
|
140
|
+
// which POSTs to the accounting recommendation-feedback endpoint. No state
|
|
141
|
+
// mutation: the categorization UX must not depend on the feedback round-trip.
|
|
142
|
+
submitRecommendationFeedback: {
|
|
143
|
+
reducer() {
|
|
144
|
+
// Fire-and-forget: no state mutation; the epic performs the POST.
|
|
145
|
+
},
|
|
146
|
+
prepare(args) {
|
|
147
|
+
return { payload: args };
|
|
148
|
+
},
|
|
149
|
+
},
|
|
138
150
|
},
|
|
139
151
|
extraReducers: (builder) => {
|
|
140
152
|
builder.addCase(rootActions_1.clearAll, (draft) => {
|
|
@@ -142,7 +154,7 @@ const recommendation = (0, toolkit_1.createSlice)({
|
|
|
142
154
|
});
|
|
143
155
|
},
|
|
144
156
|
});
|
|
145
|
-
_a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation;
|
|
157
|
+
_a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.submitRecommendationFeedback = _a.submitRecommendationFeedback;
|
|
146
158
|
exports.default = recommendation.reducer;
|
|
147
159
|
const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
|
|
148
160
|
const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../reducer';
|
|
4
|
+
import { ZeniAPI } from '../../zeniAPI';
|
|
5
|
+
import { submitRecommendationFeedback } from './recommendationReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof submitRecommendationFeedback>;
|
|
7
|
+
export declare const submitRecommendationFeedbackEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitRecommendationFeedbackEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../responsePayload");
|
|
7
|
+
const recommendationReducer_1 = require("./recommendationReducer");
|
|
8
|
+
const toRequestBody = (payload) => ({
|
|
9
|
+
line_id: payload.lineId ?? null,
|
|
10
|
+
dimension: payload.dimension,
|
|
11
|
+
recommendation_set_id: payload.recommendationSetId ?? null,
|
|
12
|
+
top_pick_source: payload.topPickSource ?? null,
|
|
13
|
+
shown_recommendations: (payload.shownRecommendations ?? []).map((recommendation) => ({
|
|
14
|
+
source: recommendation.source,
|
|
15
|
+
rank: recommendation.rank,
|
|
16
|
+
value: {
|
|
17
|
+
name: recommendation.value.name,
|
|
18
|
+
id: recommendation.value.id ?? null,
|
|
19
|
+
integration_id: recommendation.value.integrationId ?? null,
|
|
20
|
+
},
|
|
21
|
+
confidence: recommendation.confidence ?? null,
|
|
22
|
+
reasoning: recommendation.reasoning ?? null,
|
|
23
|
+
cot: recommendation.cot ?? [],
|
|
24
|
+
})),
|
|
25
|
+
selected: {
|
|
26
|
+
name: payload.selected.name,
|
|
27
|
+
id: payload.selected.id ?? null,
|
|
28
|
+
integration_id: payload.selected.integrationId ?? null,
|
|
29
|
+
is_new_entity: payload.selected.isNewEntity ?? false,
|
|
30
|
+
},
|
|
31
|
+
matched_source: payload.matchedSource ?? null,
|
|
32
|
+
matched_rank: payload.matchedRank ?? null,
|
|
33
|
+
outcome: payload.outcome,
|
|
34
|
+
reason_text: payload.reasonText ?? null,
|
|
35
|
+
skipped: payload.skipped ?? false,
|
|
36
|
+
retracts_feedback_id: payload.retractsFeedbackId ?? null,
|
|
37
|
+
features: payload.features ?? null,
|
|
38
|
+
});
|
|
39
|
+
// Fire-and-forget: the epic never re-emits an action. Feedback delivery is a
|
|
40
|
+
// side-effect that must not disrupt the categorization UX, so both the
|
|
41
|
+
// success and error paths complete silently (errors are logged for debugging).
|
|
42
|
+
const submitRecommendationFeedbackEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.submitRecommendationFeedback.match), (0, operators_1.mergeMap)((action) => {
|
|
43
|
+
const { transactionId } = action.payload;
|
|
44
|
+
return zeniAPI
|
|
45
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${transactionId}/recommendation-feedback`, toRequestBody(action.payload))
|
|
46
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
47
|
+
if (!(0, responsePayload_1.isSuccessStatus)(response)) {
|
|
48
|
+
console.error('submitRecommendationFeedbackEpic: recommendation feedback was not recorded', response.status);
|
|
49
|
+
}
|
|
50
|
+
return rxjs_1.EMPTY;
|
|
51
|
+
}), (0, operators_1.catchError)((error) => {
|
|
52
|
+
console.error('submitRecommendationFeedbackEpic: failed to submit recommendation feedback', error);
|
|
53
|
+
return rxjs_1.EMPTY;
|
|
54
|
+
}));
|
|
55
|
+
}));
|
|
56
|
+
exports.submitRecommendationFeedbackEpic = submitRecommendationFeedbackEpic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.13-beta0ND",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
|
-
import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
|
|
5
|
-
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
6
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
|
|
7
|
-
import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection, } from './settingsViewReducer';
|
|
8
|
-
export const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingSettings.match), switchMap(() => {
|
|
9
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
10
|
-
return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
|
|
11
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
12
|
-
const address = response.data.address;
|
|
13
|
-
return [
|
|
14
|
-
...(address != null ? [updateAddresses([address])] : []),
|
|
15
|
-
updateInvoicingSettings(response.data),
|
|
16
|
-
];
|
|
17
|
-
}
|
|
18
|
-
return of(updateInvoicingSettingsFailure(response.status));
|
|
19
|
-
}), catchError((error) => of(updateInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Fetch settings REST API call errored out ' +
|
|
20
|
-
JSON.stringify(error))))));
|
|
21
|
-
}));
|
|
22
|
-
export const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(connectInvoicingStripe.match), mergeMap((action) => {
|
|
23
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
|
|
24
|
-
const { api_key, publishable_key, webhook_secret } = action.payload;
|
|
25
|
-
const body = {
|
|
26
|
-
api_key,
|
|
27
|
-
publishable_key,
|
|
28
|
-
...(webhook_secret != null && webhook_secret !== ''
|
|
29
|
-
? { webhook_secret }
|
|
30
|
-
: {}),
|
|
31
|
-
};
|
|
32
|
-
return zeniAPI
|
|
33
|
-
.postAndGetJSON(apiUrl, body)
|
|
34
|
-
.pipe(switchMap((response) => {
|
|
35
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
36
|
-
return of(updateInvoicingStripeConnection({
|
|
37
|
-
stripe_connected: response.data.stripe_connected,
|
|
38
|
-
publishable_key: response.data.publishable_key,
|
|
39
|
-
}), fetchInvoicingSettings());
|
|
40
|
-
}
|
|
41
|
-
return of(invoicingStripeConnectionFailure(response.status));
|
|
42
|
-
}), catchError((error) => of(invoicingStripeConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Stripe connect setup REST API call errored out ' +
|
|
43
|
-
JSON.stringify(error))))));
|
|
44
|
-
}));
|
|
45
|
-
export const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(disconnectInvoicingStripe.match), mergeMap(() => {
|
|
46
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
|
|
47
|
-
return zeniAPI
|
|
48
|
-
.deleteAndGetJSON(apiUrl)
|
|
49
|
-
.pipe(switchMap((response) => {
|
|
50
|
-
if (isSuccessResponse(response)) {
|
|
51
|
-
return of(updateInvoicingStripeConnection({
|
|
52
|
-
stripe_connected: false,
|
|
53
|
-
publishable_key: '',
|
|
54
|
-
}), fetchInvoicingSettings());
|
|
55
|
-
}
|
|
56
|
-
return of(invoicingStripeConnectionFailure(response.status));
|
|
57
|
-
}), catchError((error) => of(invoicingStripeConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Stripe disconnect REST API call errored out ' +
|
|
58
|
-
JSON.stringify(error))))));
|
|
59
|
-
}));
|
|
60
|
-
export const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveInvoicingSettings.match), mergeMap((action) => {
|
|
61
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
62
|
-
const { settings, snackbarSection } = action.payload;
|
|
63
|
-
/** `status` surfaces the platform's error text; omit it to keep the generic copy. */
|
|
64
|
-
const snackbar = (messageText, status) => snackbarSection == null
|
|
65
|
-
? []
|
|
66
|
-
: [
|
|
67
|
-
openSnackbar({
|
|
68
|
-
messageSection: snackbarSection,
|
|
69
|
-
messageText,
|
|
70
|
-
type: messageText === 'success' ? 'success' : 'error',
|
|
71
|
-
variables: apiErrorSnackbarVariables(status),
|
|
72
|
-
}),
|
|
73
|
-
];
|
|
74
|
-
return zeniAPI
|
|
75
|
-
.putAndGetJSON(apiUrl, { ...settings })
|
|
76
|
-
.pipe(switchMap((response) => {
|
|
77
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
78
|
-
return from([
|
|
79
|
-
saveInvoicingSettingsSuccess(response.data),
|
|
80
|
-
...snackbar('success'),
|
|
81
|
-
]);
|
|
82
|
-
}
|
|
83
|
-
return from([
|
|
84
|
-
saveInvoicingSettingsFailure(response.status),
|
|
85
|
-
...snackbar('failed', response.status),
|
|
86
|
-
]);
|
|
87
|
-
}), catchError((error) => from([
|
|
88
|
-
saveInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Save settings REST API call errored out ' +
|
|
89
|
-
JSON.stringify(error))),
|
|
90
|
-
...snackbar('failed'),
|
|
91
|
-
])));
|
|
92
|
-
}));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateAddresses } from '../../../entity/address/addressReducer';
|
|
4
|
-
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
5
|
-
import { RootState } from '../../../rootStateTypes';
|
|
6
|
-
import { ZeniAPI } from '../../../zeniAPI';
|
|
7
|
-
import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection } from './settingsViewReducer';
|
|
8
|
-
export type ActionType = ReturnType<typeof fetchInvoicingSettings> | ReturnType<typeof updateInvoicingSettings> | ReturnType<typeof updateInvoicingSettingsFailure> | ReturnType<typeof saveInvoicingSettings> | ReturnType<typeof saveInvoicingSettingsSuccess> | ReturnType<typeof saveInvoicingSettingsFailure> | ReturnType<typeof connectInvoicingStripe> | ReturnType<typeof disconnectInvoicingStripe> | ReturnType<typeof updateInvoicingStripeConnection> | ReturnType<typeof invoicingStripeConnectionFailure> | ReturnType<typeof updateAddresses> | ReturnType<typeof openSnackbar>;
|
|
9
|
-
export declare const fetchInvoicingSettingsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
10
|
-
export declare const connectInvoicingStripeEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
11
|
-
export declare const disconnectInvoicingStripeEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
12
|
-
export declare const saveInvoicingSettingsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveInvoicingSettingsEpic = exports.disconnectInvoicingStripeEpic = exports.connectInvoicingStripeEpic = exports.fetchInvoicingSettingsEpic = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const addressReducer_1 = require("../../../entity/address/addressReducer");
|
|
7
|
-
const snackbarApiError_1 = require("../../../entity/snackbar/snackbarApiError");
|
|
8
|
-
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
9
|
-
const responsePayload_1 = require("../../../responsePayload");
|
|
10
|
-
const settingsViewReducer_1 = require("./settingsViewReducer");
|
|
11
|
-
const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.fetchInvoicingSettings.match), (0, operators_1.switchMap)(() => {
|
|
12
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
13
|
-
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
14
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
15
|
-
const address = response.data.address;
|
|
16
|
-
return [
|
|
17
|
-
...(address != null ? [(0, addressReducer_1.updateAddresses)([address])] : []),
|
|
18
|
-
(0, settingsViewReducer_1.updateInvoicingSettings)(response.data),
|
|
19
|
-
];
|
|
20
|
-
}
|
|
21
|
-
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)(response.status));
|
|
22
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch settings REST API call errored out ' +
|
|
23
|
-
JSON.stringify(error))))));
|
|
24
|
-
}));
|
|
25
|
-
exports.fetchInvoicingSettingsEpic = fetchInvoicingSettingsEpic;
|
|
26
|
-
const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.connectInvoicingStripe.match), (0, operators_1.mergeMap)((action) => {
|
|
27
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
|
|
28
|
-
const { api_key, publishable_key, webhook_secret } = action.payload;
|
|
29
|
-
const body = {
|
|
30
|
-
api_key,
|
|
31
|
-
publishable_key,
|
|
32
|
-
...(webhook_secret != null && webhook_secret !== ''
|
|
33
|
-
? { webhook_secret }
|
|
34
|
-
: {}),
|
|
35
|
-
};
|
|
36
|
-
return zeniAPI
|
|
37
|
-
.postAndGetJSON(apiUrl, body)
|
|
38
|
-
.pipe((0, operators_1.switchMap)((response) => {
|
|
39
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
40
|
-
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
|
|
41
|
-
stripe_connected: response.data.stripe_connected,
|
|
42
|
-
publishable_key: response.data.publishable_key,
|
|
43
|
-
}), (0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
44
|
-
}
|
|
45
|
-
return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
|
|
46
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Stripe connect setup REST API call errored out ' +
|
|
47
|
-
JSON.stringify(error))))));
|
|
48
|
-
}));
|
|
49
|
-
exports.connectInvoicingStripeEpic = connectInvoicingStripeEpic;
|
|
50
|
-
const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.disconnectInvoicingStripe.match), (0, operators_1.mergeMap)(() => {
|
|
51
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
|
|
52
|
-
return zeniAPI
|
|
53
|
-
.deleteAndGetJSON(apiUrl)
|
|
54
|
-
.pipe((0, operators_1.switchMap)((response) => {
|
|
55
|
-
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
56
|
-
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
|
|
57
|
-
stripe_connected: false,
|
|
58
|
-
publishable_key: '',
|
|
59
|
-
}), (0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
60
|
-
}
|
|
61
|
-
return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
|
|
62
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Stripe disconnect REST API call errored out ' +
|
|
63
|
-
JSON.stringify(error))))));
|
|
64
|
-
}));
|
|
65
|
-
exports.disconnectInvoicingStripeEpic = disconnectInvoicingStripeEpic;
|
|
66
|
-
const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.saveInvoicingSettings.match), (0, operators_1.mergeMap)((action) => {
|
|
67
|
-
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
68
|
-
const { settings, snackbarSection } = action.payload;
|
|
69
|
-
/** `status` surfaces the platform's error text; omit it to keep the generic copy. */
|
|
70
|
-
const snackbar = (messageText, status) => snackbarSection == null
|
|
71
|
-
? []
|
|
72
|
-
: [
|
|
73
|
-
(0, snackbarReducer_1.openSnackbar)({
|
|
74
|
-
messageSection: snackbarSection,
|
|
75
|
-
messageText,
|
|
76
|
-
type: messageText === 'success' ? 'success' : 'error',
|
|
77
|
-
variables: (0, snackbarApiError_1.apiErrorSnackbarVariables)(status),
|
|
78
|
-
}),
|
|
79
|
-
];
|
|
80
|
-
return zeniAPI
|
|
81
|
-
.putAndGetJSON(apiUrl, { ...settings })
|
|
82
|
-
.pipe((0, operators_1.switchMap)((response) => {
|
|
83
|
-
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
84
|
-
return (0, rxjs_1.from)([
|
|
85
|
-
(0, settingsViewReducer_1.saveInvoicingSettingsSuccess)(response.data),
|
|
86
|
-
...snackbar('success'),
|
|
87
|
-
]);
|
|
88
|
-
}
|
|
89
|
-
return (0, rxjs_1.from)([
|
|
90
|
-
(0, settingsViewReducer_1.saveInvoicingSettingsFailure)(response.status),
|
|
91
|
-
...snackbar('failed', response.status),
|
|
92
|
-
]);
|
|
93
|
-
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
94
|
-
(0, settingsViewReducer_1.saveInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save settings REST API call errored out ' +
|
|
95
|
-
JSON.stringify(error))),
|
|
96
|
-
...snackbar('failed'),
|
|
97
|
-
])));
|
|
98
|
-
}));
|
|
99
|
-
exports.saveInvoicingSettingsEpic = saveInvoicingSettingsEpic;
|