@zeniai/client-epic-state 5.2.11 → 5.2.12
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 +1 -1
- package/lib/epic.js +10 -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 +6 -1
- package/lib/esm/index.js +5 -4
- 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/index.d.ts +7 -5
- package/lib/index.js +13 -6
- 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/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
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
1
2
|
import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
|
|
2
3
|
import { InvoicingDunningActionOption, InvoicingNamedOption, InvoicingQboAccountMappingKindOption, InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
4
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
4
5
|
import { RootState } from '../../../rootStateTypes';
|
|
6
|
+
import { InvoicingQboConnection, InvoicingQboSyncHealth } from '../invoicingQboView/invoicingQboViewPayload';
|
|
7
|
+
import { InvoicingAccountingOption } from '../invoicingQboView/invoicingQboViewSelector';
|
|
5
8
|
import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
|
|
9
|
+
import { InvoicingQboSettingsLocalData } from './invoicingQboSettingsFormConfig';
|
|
6
10
|
/**
|
|
7
11
|
* Shared primitive: the raw invoicing settings. Consumed internally by other
|
|
8
12
|
* CES selectors (create-invoice, customer-detail, overview) and by non-settings
|
|
@@ -83,6 +87,37 @@ export interface InvoicingSettingsHubView {
|
|
|
83
87
|
* and QBO slices read here are only fetched once a settings screen is mounted.
|
|
84
88
|
*/
|
|
85
89
|
export declare const getInvoicingSettingsHubView: (state: RootState) => InvoicingSettingsHubView;
|
|
90
|
+
export interface InvoicingQboSettingsFormView {
|
|
91
|
+
accountMappingKindOptions: InvoicingQboAccountMappingKindOption[];
|
|
92
|
+
/** Accounts for the mapping dropdowns, narrowed per kind by the page. */
|
|
93
|
+
accounts: InvoicingAccountingOption[];
|
|
94
|
+
backfillState: FetchStateAndError;
|
|
95
|
+
/** So the screen can fetch only what is missing, without reading the slices. */
|
|
96
|
+
configFetchState: FetchState;
|
|
97
|
+
customerMatchingOptions: InvoicingNamedOption[];
|
|
98
|
+
isLoading: boolean;
|
|
99
|
+
/** The persisted sync toggle — the backfill guard checks that, not the draft. */
|
|
100
|
+
isSyncEnabledSaved: boolean;
|
|
101
|
+
/** The draft the page edits, seeded from the settings response. */
|
|
102
|
+
localData: InvoicingQboSettingsLocalData;
|
|
103
|
+
nestedAccountHierarchy: NestedAccountHierarchyForReport[];
|
|
104
|
+
retryFetchStateByTaskId: Record<string, FetchStateAndError>;
|
|
105
|
+
saveState: FetchStateAndError;
|
|
106
|
+
settingsFetchState: FetchState;
|
|
107
|
+
syncStatusOptions: InvoicingNamedOption[];
|
|
108
|
+
connection?: InvoicingQboConnection;
|
|
109
|
+
syncHealth?: InvoicingQboSyncHealth;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Bundled view for the QBO configuration page: the draft it edits, the accounts
|
|
113
|
+
* and option lists its dropdowns render, the connection and sync health it
|
|
114
|
+
* reports, and the fetch states that decide between skeleton, form and error.
|
|
115
|
+
*
|
|
116
|
+
* `localData` is the draft once the user has edited, and the settings response
|
|
117
|
+
* before that — so the page has one field to read and CES owns when it becomes
|
|
118
|
+
* available, rather than the page copying settings into local state.
|
|
119
|
+
*/
|
|
120
|
+
export declare const getInvoicingQboSettingsFormView: (state: RootState) => InvoicingQboSettingsFormView;
|
|
86
121
|
export interface InvoicingBrandingFormView {
|
|
87
122
|
dateFormatOptions: InvoicingNamedOption[];
|
|
88
123
|
localData: InvoicingBrandingFormLocalData;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInvoicingBrandingFormView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = void 0;
|
|
3
|
+
exports.getInvoicingBrandingFormView = exports.getInvoicingQboSettingsFormView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = void 0;
|
|
4
4
|
exports.deriveInvoicingEnablePrerequisites = deriveInvoicingEnablePrerequisites;
|
|
5
5
|
const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
|
|
6
6
|
const addressViewSelector_1 = require("../../addressView/addressViewSelector");
|
|
7
7
|
const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
|
|
8
|
+
const invoicingQboViewSelector_1 = require("../invoicingQboView/invoicingQboViewSelector");
|
|
8
9
|
const invoicingBrandingFormConfig_1 = require("./invoicingBrandingFormConfig");
|
|
10
|
+
const invoicingQboSettingsFormConfig_1 = require("./invoicingQboSettingsFormConfig");
|
|
9
11
|
/**
|
|
10
12
|
* Shared primitive: the raw invoicing settings. Consumed internally by other
|
|
11
13
|
* CES selectors (create-invoice, customer-detail, overview) and by non-settings
|
|
@@ -100,6 +102,46 @@ const getInvoicingSettingsHubView = (state) => {
|
|
|
100
102
|
};
|
|
101
103
|
};
|
|
102
104
|
exports.getInvoicingSettingsHubView = getInvoicingSettingsHubView;
|
|
105
|
+
/**
|
|
106
|
+
* Bundled view for the QBO configuration page: the draft it edits, the accounts
|
|
107
|
+
* and option lists its dropdowns render, the connection and sync health it
|
|
108
|
+
* reports, and the fetch states that decide between skeleton, form and error.
|
|
109
|
+
*
|
|
110
|
+
* `localData` is the draft once the user has edited, and the settings response
|
|
111
|
+
* before that — so the page has one field to read and CES owns when it becomes
|
|
112
|
+
* available, rather than the page copying settings into local state.
|
|
113
|
+
*/
|
|
114
|
+
const getInvoicingQboSettingsFormView = (state) => {
|
|
115
|
+
const { error, fetchState, qboDraft, saveFetchState, settings } = state.invoicingSettingsViewState;
|
|
116
|
+
const { fetchState: configFetchState, qboAccountMappingKindOptions, qboCustomerMatchingOptions, qboSyncStatusOptions, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
|
|
117
|
+
const qboView = (0, invoicingQboViewSelector_1.getInvoicingQboView)(state);
|
|
118
|
+
return {
|
|
119
|
+
accountMappingKindOptions: qboAccountMappingKindOptions,
|
|
120
|
+
accounts: qboView.accounts,
|
|
121
|
+
backfillState: qboView.backfillState,
|
|
122
|
+
connection: qboView.connection,
|
|
123
|
+
configFetchState,
|
|
124
|
+
customerMatchingOptions: qboCustomerMatchingOptions,
|
|
125
|
+
// The dropdowns cannot be built before both the settings and the accounts
|
|
126
|
+
// land, so the page waits on either rather than rendering empty pickers.
|
|
127
|
+
isLoading: fetchState === 'Not-Started' ||
|
|
128
|
+
fetchState === 'In-Progress' ||
|
|
129
|
+
(0, invoicingQboViewSelector_1.isInvoicingAccountingPickerDataLoading)(state),
|
|
130
|
+
isSyncEnabledSaved: settings?.qbo?.enabled === true,
|
|
131
|
+
// Seeded in the reducer when the settings response lands, so this is a plain
|
|
132
|
+
// read rather than a second place that decides what the page starts from.
|
|
133
|
+
localData: qboDraft ?? invoicingQboSettingsFormConfig_1.initialInvoicingQboSettingsLocalData,
|
|
134
|
+
nestedAccountHierarchy: qboView.nestedAccountHierarchy,
|
|
135
|
+
retryFetchStateByTaskId: qboView.retryFetchStateByTaskId,
|
|
136
|
+
saveState: saveFetchState.fetchState === 'Not-Started' && error != null
|
|
137
|
+
? { fetchState, error }
|
|
138
|
+
: saveFetchState,
|
|
139
|
+
settingsFetchState: fetchState,
|
|
140
|
+
syncHealth: qboView.syncHealth,
|
|
141
|
+
syncStatusOptions: qboSyncStatusOptions,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
exports.getInvoicingQboSettingsFormView = getInvoicingQboSettingsFormView;
|
|
103
145
|
/**
|
|
104
146
|
* Bundled view for the branding settings form: the draft `localData` (seeded
|
|
105
147
|
* from the existing settings until the user edits), the business-address label
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { FetchStateAndError, FetchedState } from '../../../commonStateTypes/common';
|
|
2
2
|
import { InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
3
|
import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
|
|
4
|
+
import { InvoicingQboSettingsLocalData } from './invoicingQboSettingsFormConfig';
|
|
4
5
|
export interface InvoicingSettingsViewState extends FetchedState {
|
|
5
6
|
saveFetchState: FetchStateAndError;
|
|
6
7
|
stripeFetchState: FetchStateAndError;
|
|
7
8
|
brandingDraft?: InvoicingBrandingFormLocalData;
|
|
9
|
+
/**
|
|
10
|
+
* In-progress QBO settings edits. Held here rather than in the page so a
|
|
11
|
+
* selection cannot be lost between the change and the save, and so a
|
|
12
|
+
* half-finished edit survives navigating away. Undefined until first edited,
|
|
13
|
+
* which is what makes the server's settings the fallback.
|
|
14
|
+
*/
|
|
15
|
+
qboDraft?: InvoicingQboSettingsLocalData;
|
|
8
16
|
settings?: InvoicingSettingsPayload;
|
|
9
17
|
}
|
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.12",
|
|
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;
|