@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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
2
|
import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
|
|
3
3
|
import { FetchStateAndError } from '../../../commonStateTypes/common';
|
|
4
|
-
import { AccountType } from '../../../entity/account/accountState';
|
|
4
|
+
import { AccountBase, AccountType } from '../../../entity/account/accountState';
|
|
5
|
+
import { ClassBase } from '../../../entity/class/classState';
|
|
5
6
|
import { RootState } from '../../../rootStateTypes';
|
|
6
7
|
import { InvoicingQboConnection, InvoicingQboSyncHealth } from './invoicingQboViewPayload';
|
|
7
8
|
export declare const INVOICING_ACCOUNT_LIST_KEY: "accountList";
|
|
@@ -20,6 +21,14 @@ export declare const getInvoicingQboConnectionFetchState: (state: RootState) =>
|
|
|
20
21
|
* "income accounts" rather than repeating the accounting service's vocabulary.
|
|
21
22
|
*/
|
|
22
23
|
export declare const INVOICING_INCOME_ACCOUNT_TYPES: readonly AccountType[];
|
|
24
|
+
/**
|
|
25
|
+
* The account behind a picker value. The pickers submit the QuickBooks id, so
|
|
26
|
+
* that is what callers hold; the payload builders need the whole entity to send
|
|
27
|
+
* `toAccountPayload`, which is why the lookup lives here next to the options.
|
|
28
|
+
*/
|
|
29
|
+
export declare const invoicingQboAccountByQboId: (state: RootState, qboId: string | undefined) => AccountBase | undefined;
|
|
30
|
+
/** The class behind a picker value, for the same reason as the account above. */
|
|
31
|
+
export declare const invoicingQboClassByQboId: (state: RootState, qboId: string | undefined) => ClassBase | undefined;
|
|
23
32
|
/** An account or class as the invoicing pickers render and submit it. */
|
|
24
33
|
export interface InvoicingAccountingOption {
|
|
25
34
|
id: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInvoicingQboView = exports.invoicingAccountHierarchyForTypes = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
3
|
+
exports.getInvoicingQboView = exports.invoicingAccountHierarchyForTypes = exports.invoicingAccountsForQboAccountTypes = exports.invoicingQboClassByQboId = exports.invoicingQboAccountByQboId = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
|
|
4
4
|
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
5
5
|
const classListSelector_1 = require("../../classList/classListSelector");
|
|
6
6
|
// The shared bucket, fetched with the same arguments as the other consumers so
|
|
@@ -43,6 +43,48 @@ exports.INVOICING_INCOME_ACCOUNT_TYPES = [
|
|
|
43
43
|
'income',
|
|
44
44
|
'other_income',
|
|
45
45
|
];
|
|
46
|
+
/**
|
|
47
|
+
* The account behind a picker value. The pickers submit the QuickBooks id, so
|
|
48
|
+
* that is what callers hold; the payload builders need the whole entity to send
|
|
49
|
+
* `toAccountPayload`, which is why the lookup lives here next to the options.
|
|
50
|
+
*/
|
|
51
|
+
const invoicingQboAccountByQboId = (state, qboId) => {
|
|
52
|
+
if (qboId == null || qboId === '') {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
// `getAccountList` throws when a listed id is missing from the entity slice.
|
|
56
|
+
// That is survivable when looking one account up — the caller falls back to
|
|
57
|
+
// the id it already had — but not when it happens inside an epic, where the
|
|
58
|
+
// throw would take the whole request with it.
|
|
59
|
+
try {
|
|
60
|
+
const { accounts } = (0, accountListSelector_1.getAccountList)(state.accountState, state.accountListState, exports.INVOICING_ACCOUNT_LIST_KEY);
|
|
61
|
+
// Matched on any id the account is known by. The pickers submit `qboId`,
|
|
62
|
+
// but a mapping that arrived from the service can name the account by its
|
|
63
|
+
// platform id instead, and an account we cannot resolve is a mapping that
|
|
64
|
+
// cannot be sent as a record.
|
|
65
|
+
return accounts.find((account) => account.qboId === qboId ||
|
|
66
|
+
account.accountId === qboId ||
|
|
67
|
+
account.coaId === qboId);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.invoicingQboAccountByQboId = invoicingQboAccountByQboId;
|
|
74
|
+
/** The class behind a picker value, for the same reason as the account above. */
|
|
75
|
+
const invoicingQboClassByQboId = (state, qboId) => {
|
|
76
|
+
if (qboId == null || qboId === '') {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const { classes } = (0, classListSelector_1.getClassList)(state.classState, state.classListState);
|
|
81
|
+
return classes.find((accountingClass) => accountingClass.qboId === qboId);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.invoicingQboClassByQboId = invoicingQboClassByQboId;
|
|
46
88
|
/**
|
|
47
89
|
* Accounts and classes as the invoicing pickers need them. Both come from the
|
|
48
90
|
* shared accounting-service lists, so whatever another screen already loaded
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const connectInvoicingStripeEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectInvoicingStripeEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
8
|
+
const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.connectInvoicingStripe.match), (0, operators_1.mergeMap)((action) => {
|
|
9
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
|
|
10
|
+
const { api_key, publishable_key, webhook_secret } = action.payload;
|
|
11
|
+
const body = {
|
|
12
|
+
api_key,
|
|
13
|
+
publishable_key,
|
|
14
|
+
...(webhook_secret != null && webhook_secret !== ''
|
|
15
|
+
? { webhook_secret }
|
|
16
|
+
: {}),
|
|
17
|
+
};
|
|
18
|
+
return zeniAPI
|
|
19
|
+
.postAndGetJSON(apiUrl, body)
|
|
20
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
21
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
22
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
|
|
23
|
+
stripe_connected: response.data.stripe_connected,
|
|
24
|
+
publishable_key: response.data.publishable_key,
|
|
25
|
+
}), (0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
26
|
+
}
|
|
27
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
|
|
28
|
+
}), (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 ' +
|
|
29
|
+
JSON.stringify(error))))));
|
|
30
|
+
}));
|
|
31
|
+
exports.connectInvoicingStripeEpic = connectInvoicingStripeEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const disconnectInvoicingStripeEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.disconnectInvoicingStripeEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
7
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
8
|
+
const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.disconnectInvoicingStripe.match), (0, operators_1.mergeMap)(() => {
|
|
9
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
|
|
10
|
+
return zeniAPI
|
|
11
|
+
.deleteAndGetJSON(apiUrl)
|
|
12
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
13
|
+
if ((0, responsePayload_1.isSuccessResponse)(response)) {
|
|
14
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
|
|
15
|
+
stripe_connected: false,
|
|
16
|
+
publishable_key: '',
|
|
17
|
+
}), (0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
18
|
+
}
|
|
19
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
|
|
20
|
+
}), (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 ' +
|
|
21
|
+
JSON.stringify(error))))));
|
|
22
|
+
}));
|
|
23
|
+
exports.disconnectInvoicingStripeEpic = disconnectInvoicingStripeEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const fetchInvoicingSettingsEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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 responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
9
|
+
const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.fetchInvoicingSettings.match), (0, operators_1.switchMap)(() => {
|
|
10
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
11
|
+
return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
|
|
12
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
13
|
+
const address = response.data.address;
|
|
14
|
+
return [
|
|
15
|
+
...(address != null ? [(0, addressReducer_1.updateAddresses)([address])] : []),
|
|
16
|
+
(0, settingsViewReducer_1.updateInvoicingSettings)(response.data),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)(response.status));
|
|
20
|
+
}), (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 ' +
|
|
21
|
+
JSON.stringify(error))))));
|
|
22
|
+
}));
|
|
23
|
+
exports.fetchInvoicingSettingsEpic = fetchInvoicingSettingsEpic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
5
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
6
|
+
export declare const saveInvoicingSettingsEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.saveInvoicingSettingsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const snackbarApiError_1 = require("../../../../entity/snackbar/snackbarApiError");
|
|
7
|
+
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
8
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
9
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
10
|
+
const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.saveInvoicingSettings.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
+
const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
|
|
12
|
+
const { settings, snackbarSection } = action.payload;
|
|
13
|
+
/** `status` surfaces the platform's error text; omit it to keep the generic copy. */
|
|
14
|
+
const snackbar = (messageText, status) => snackbarSection == null
|
|
15
|
+
? []
|
|
16
|
+
: [
|
|
17
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
18
|
+
messageSection: snackbarSection,
|
|
19
|
+
messageText,
|
|
20
|
+
type: messageText === 'success' ? 'success' : 'error',
|
|
21
|
+
variables: (0, snackbarApiError_1.apiErrorSnackbarVariables)(status),
|
|
22
|
+
}),
|
|
23
|
+
];
|
|
24
|
+
return zeniAPI
|
|
25
|
+
.putAndGetJSON(apiUrl, { ...settings })
|
|
26
|
+
.pipe((0, operators_1.switchMap)((response) => {
|
|
27
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
28
|
+
return (0, rxjs_1.from)([
|
|
29
|
+
(0, settingsViewReducer_1.saveInvoicingSettingsSuccess)(response.data),
|
|
30
|
+
...snackbar('success'),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
return (0, rxjs_1.from)([
|
|
34
|
+
(0, settingsViewReducer_1.saveInvoicingSettingsFailure)(response.status),
|
|
35
|
+
...snackbar('failed', response.status),
|
|
36
|
+
]);
|
|
37
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
38
|
+
(0, settingsViewReducer_1.saveInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save settings REST API call errored out ' +
|
|
39
|
+
JSON.stringify(error))),
|
|
40
|
+
...snackbar('failed'),
|
|
41
|
+
])));
|
|
42
|
+
}));
|
|
43
|
+
exports.saveInvoicingSettingsEpic = saveInvoicingSettingsEpic;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { updateAddresses } from '../../../../entity/address/addressReducer';
|
|
2
|
+
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
3
|
+
import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, submitInvoicingQboSettings, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection } from '../settingsViewReducer';
|
|
4
|
+
/** Every action the settings epics accept or emit. */
|
|
5
|
+
export type InvoicingSettingsViewActionType = ReturnType<typeof fetchInvoicingSettings> | ReturnType<typeof updateInvoicingSettings> | ReturnType<typeof updateInvoicingSettingsFailure> | ReturnType<typeof saveInvoicingSettings> | ReturnType<typeof saveInvoicingSettingsSuccess> | ReturnType<typeof submitInvoicingQboSettings> | ReturnType<typeof saveInvoicingSettingsFailure> | ReturnType<typeof connectInvoicingStripe> | ReturnType<typeof disconnectInvoicingStripe> | ReturnType<typeof updateInvoicingStripeConnection> | ReturnType<typeof invoicingStripeConnectionFailure> | ReturnType<typeof updateAddresses> | ReturnType<typeof openSnackbar>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../rootStateTypes';
|
|
4
|
+
import { InvoicingSettingsViewActionType } from './settingsViewActionType';
|
|
5
|
+
/**
|
|
6
|
+
* Saves the QBO local data. The screen fires this without a payload — the local
|
|
7
|
+
* data is already in the store, so sending it back through the action would make
|
|
8
|
+
* the page the carrier for state it does not own. Converting to the request body
|
|
9
|
+
* happens here too, keeping the wire shape out of the screen.
|
|
10
|
+
*/
|
|
11
|
+
export declare const submitInvoicingQboSettingsEpic: (actions$: ActionsObservable<InvoicingSettingsViewActionType>, state$: StateObservable<RootState>) => Observable<InvoicingSettingsViewActionType>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitInvoicingQboSettingsEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const invoicingQboViewSelector_1 = require("../../invoicingQboView/invoicingQboViewSelector");
|
|
7
|
+
const invoicingQboSettingsFormConfig_1 = require("../invoicingQboSettingsFormConfig");
|
|
8
|
+
const settingsViewReducer_1 = require("../settingsViewReducer");
|
|
9
|
+
/**
|
|
10
|
+
* Saves the QBO local data. The screen fires this without a payload — the local
|
|
11
|
+
* data is already in the store, so sending it back through the action would make
|
|
12
|
+
* the page the carrier for state it does not own. Converting to the request body
|
|
13
|
+
* happens here too, keeping the wire shape out of the screen.
|
|
14
|
+
*/
|
|
15
|
+
const submitInvoicingQboSettingsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.submitInvoicingQboSettings.match), (0, operators_1.withLatestFrom)(state$), (0, operators_1.mergeMap)(([, state]) => {
|
|
16
|
+
const { qboDraft } = state.invoicingSettingsViewState;
|
|
17
|
+
// No local data means the settings response has not landed, so there is
|
|
18
|
+
// nothing the user could have edited yet.
|
|
19
|
+
if (qboDraft == null) {
|
|
20
|
+
return rxjs_1.EMPTY;
|
|
21
|
+
}
|
|
22
|
+
return (0, rxjs_1.of)((0, settingsViewReducer_1.saveInvoicingSettings)({
|
|
23
|
+
settings: {
|
|
24
|
+
qbo: (0, invoicingQboSettingsFormConfig_1.invoicingQboSettingsLocalDataToPayload)(qboDraft, (accountId) => (0, invoicingQboViewSelector_1.invoicingQboAccountByQboId)(state, accountId)),
|
|
25
|
+
},
|
|
26
|
+
snackbarSection: 'invoicing_qbo_settings_save',
|
|
27
|
+
}));
|
|
28
|
+
}));
|
|
29
|
+
exports.submitInvoicingQboSettingsEpic = submitInvoicingQboSettingsEpic;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AccountBase } from '../../../entity/account/accountState';
|
|
2
|
+
import { InvoicingQboSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
|
+
/**
|
|
4
|
+
* The QBO configuration page's local data. A client shape, not the wire one: the
|
|
5
|
+
* page edits a flat `accountIdByMappingCode` map keyed by the config's mapping
|
|
6
|
+
* codes, where the payload carries one field pair per slot and two shapes for
|
|
7
|
+
* each. {@link entityToInvoicingQboSettingsLocalData} and
|
|
8
|
+
* {@link invoicingQboSettingsLocalDataToPayload} convert at the boundary.
|
|
9
|
+
*/
|
|
10
|
+
export interface InvoicingQboSettingsLocalData {
|
|
11
|
+
/**
|
|
12
|
+
* Mapping code to the QuickBooks account id the picker selected. Keyed by the
|
|
13
|
+
* config's own codes rather than a client-side list: the backend owns which
|
|
14
|
+
* slots exist, so anything narrower silently drops the ones it has not heard
|
|
15
|
+
* of.
|
|
16
|
+
*/
|
|
17
|
+
accountIdByMappingCode: Record<string, string>;
|
|
18
|
+
autoCreateItems: boolean;
|
|
19
|
+
closedPeriodVoidAsCreditMemo: boolean;
|
|
20
|
+
customerMatching: string;
|
|
21
|
+
isSyncEnabled: boolean;
|
|
22
|
+
/** ISO date, empty when unset — the picker clears to empty, not to null. */
|
|
23
|
+
syncStartDate: string;
|
|
24
|
+
trackingCategoriesEnabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare const initialInvoicingQboSettingsLocalData: InvoicingQboSettingsLocalData;
|
|
27
|
+
/** The settings response as the page edits it. */
|
|
28
|
+
export declare const entityToInvoicingQboSettingsLocalData: (qbo: InvoicingQboSettingsPayload | null | undefined) => InvoicingQboSettingsLocalData;
|
|
29
|
+
/**
|
|
30
|
+
* The local data as the request body. `accountForId` turns each picked id into
|
|
31
|
+
* the whole account the service stores; it comes from the epic, which is where
|
|
32
|
+
* the account list is in reach.
|
|
33
|
+
*/
|
|
34
|
+
export declare const invoicingQboSettingsLocalDataToPayload: (localData: InvoicingQboSettingsLocalData, accountForId: (accountId: string) => AccountBase | undefined) => InvoicingQboSettingsPayload;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invoicingQboSettingsLocalDataToPayload = exports.entityToInvoicingQboSettingsLocalData = exports.initialInvoicingQboSettingsLocalData = void 0;
|
|
4
|
+
const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
|
|
5
|
+
exports.initialInvoicingQboSettingsLocalData = {
|
|
6
|
+
accountIdByMappingCode: {},
|
|
7
|
+
autoCreateItems: false,
|
|
8
|
+
closedPeriodVoidAsCreditMemo: false,
|
|
9
|
+
customerMatching: '',
|
|
10
|
+
isSyncEnabled: false,
|
|
11
|
+
syncStartDate: '',
|
|
12
|
+
trackingCategoriesEnabled: false,
|
|
13
|
+
};
|
|
14
|
+
/** The settings response as the page edits it. */
|
|
15
|
+
const entityToInvoicingQboSettingsLocalData = (qbo) => {
|
|
16
|
+
const accountMappings = qbo?.account_mappings ?? {};
|
|
17
|
+
const accountIdByMappingCode = {};
|
|
18
|
+
// Keyed by the slot the payload used, which is the config code the page will
|
|
19
|
+
// ask for — the reader tolerates the older `_id` form on the way in.
|
|
20
|
+
Object.keys(accountMappings).forEach((key) => {
|
|
21
|
+
const accountId = (0, invoicingCommonPayload_1.getInvoicingQboAccountMappingId)(accountMappings, key);
|
|
22
|
+
if (accountId != null) {
|
|
23
|
+
accountIdByMappingCode[(0, invoicingCommonPayload_1.toInvoicingQboAccountMappingSlot)(key)] = accountId;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
accountIdByMappingCode,
|
|
28
|
+
autoCreateItems: qbo?.auto_create_items === true,
|
|
29
|
+
closedPeriodVoidAsCreditMemo: qbo?.closed_period_void_as_credit_memo === true,
|
|
30
|
+
customerMatching: qbo?.customer_matching ?? '',
|
|
31
|
+
isSyncEnabled: qbo?.enabled === true,
|
|
32
|
+
syncStartDate: qbo?.sync_start_date ?? '',
|
|
33
|
+
trackingCategoriesEnabled: qbo?.tracking_categories_enabled === true,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.entityToInvoicingQboSettingsLocalData = entityToInvoicingQboSettingsLocalData;
|
|
37
|
+
/**
|
|
38
|
+
* The local data as the request body. `accountForId` turns each picked id into
|
|
39
|
+
* the whole account the service stores; it comes from the epic, which is where
|
|
40
|
+
* the account list is in reach.
|
|
41
|
+
*/
|
|
42
|
+
const invoicingQboSettingsLocalDataToPayload = (localData, accountForId) => {
|
|
43
|
+
return {
|
|
44
|
+
account_mappings: (0, invoicingCommonPayload_1.toInvoicingQboAccountMappingsPayload)(localData.accountIdByMappingCode, accountForId),
|
|
45
|
+
auto_create_items: localData.autoCreateItems,
|
|
46
|
+
closed_period_void_as_credit_memo: localData.closedPeriodVoidAsCreditMemo,
|
|
47
|
+
customer_matching: localData.customerMatching,
|
|
48
|
+
enabled: localData.isSyncEnabled,
|
|
49
|
+
sync_start_date: localData.syncStartDate !== '' ? localData.syncStartDate : null,
|
|
50
|
+
tracking_categories_enabled: localData.trackingCategoriesEnabled,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.invoicingQboSettingsLocalDataToPayload = invoicingQboSettingsLocalDataToPayload;
|
|
@@ -2,6 +2,7 @@ import { InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCom
|
|
|
2
2
|
import { SnackbarMessageSections } from '../../../entity/snackbar/snackbarTypes';
|
|
3
3
|
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
4
4
|
import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
|
|
5
|
+
import { InvoicingQboSettingsLocalData } from './invoicingQboSettingsFormConfig';
|
|
5
6
|
import { StripeConnectCredentials } from './settingsViewPayload';
|
|
6
7
|
import { InvoicingSettingsViewState } from './settingsViewState';
|
|
7
8
|
export interface InvoicingStripeConnectionUpdate {
|
|
@@ -19,6 +20,8 @@ export interface SaveInvoicingSettingsPayload {
|
|
|
19
20
|
export declare const initialState: InvoicingSettingsViewState;
|
|
20
21
|
export declare const fetchInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/fetchInvoicingSettings">, updateInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingSettingsPayload, "invoicingSettingsView/updateInvoicingSettings">, updateInvoicingSettingsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingSettingsView/updateInvoicingSettingsFailure">, saveInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithPayload<SaveInvoicingSettingsPayload, "invoicingSettingsView/saveInvoicingSettings">, saveInvoicingSettingsSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingSettingsPayload, "invoicingSettingsView/saveInvoicingSettingsSuccess">, saveInvoicingSettingsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingSettingsView/saveInvoicingSettingsFailure">, resetSaveInvoicingSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetSaveInvoicingSettings">, updateInvoicingBrandingFormDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
21
22
|
localData: InvoicingBrandingFormLocalData;
|
|
22
|
-
}, "invoicingSettingsView/updateInvoicingBrandingFormDraft">, submitInvoicingBrandingForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/submitInvoicingBrandingForm">, resetInvoicingBrandingFormDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetInvoicingBrandingFormDraft">,
|
|
23
|
+
}, "invoicingSettingsView/updateInvoicingBrandingFormDraft">, submitInvoicingBrandingForm: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/submitInvoicingBrandingForm">, resetInvoicingBrandingFormDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetInvoicingBrandingFormDraft">, updateInvoicingQboSettingsDraft: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
24
|
+
localData: InvoicingQboSettingsLocalData;
|
|
25
|
+
}, "invoicingSettingsView/updateInvoicingQboSettingsDraft">, submitInvoicingQboSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/submitInvoicingQboSettings">, resetInvoicingQboSettingsDraft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/resetInvoicingQboSettingsDraft">, connectInvoicingStripe: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[credentials: StripeConnectCredentials], StripeConnectCredentials, "invoicingSettingsView/connectInvoicingStripe", never, never>, disconnectInvoicingStripe: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"invoicingSettingsView/disconnectInvoicingStripe">, updateInvoicingStripeConnection: import("@reduxjs/toolkit").ActionCreatorWithPayload<InvoicingStripeConnectionUpdate, "invoicingSettingsView/updateInvoicingStripeConnection">, invoicingStripeConnectionFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "invoicingSettingsView/invoicingStripeConnectionFailure">;
|
|
23
26
|
declare const _default: import("redux").Reducer<InvoicingSettingsViewState>;
|
|
24
27
|
export default _default;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.invoicingStripeConnectionFailure = exports.updateInvoicingStripeConnection = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.resetInvoicingBrandingFormDraft = exports.submitInvoicingBrandingForm = exports.updateInvoicingBrandingFormDraft = exports.resetSaveInvoicingSettings = exports.saveInvoicingSettingsFailure = exports.saveInvoicingSettingsSuccess = exports.saveInvoicingSettings = exports.updateInvoicingSettingsFailure = exports.updateInvoicingSettings = exports.fetchInvoicingSettings = exports.initialState = void 0;
|
|
4
|
+
exports.invoicingStripeConnectionFailure = exports.updateInvoicingStripeConnection = exports.disconnectInvoicingStripe = exports.connectInvoicingStripe = exports.resetInvoicingQboSettingsDraft = exports.submitInvoicingQboSettings = exports.updateInvoicingQboSettingsDraft = exports.resetInvoicingBrandingFormDraft = exports.submitInvoicingBrandingForm = exports.updateInvoicingBrandingFormDraft = exports.resetSaveInvoicingSettings = exports.saveInvoicingSettingsFailure = exports.saveInvoicingSettingsSuccess = exports.saveInvoicingSettings = exports.updateInvoicingSettingsFailure = exports.updateInvoicingSettings = exports.fetchInvoicingSettings = exports.initialState = void 0;
|
|
5
5
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
6
|
const rootActions_1 = require("../../../rootActions");
|
|
7
|
+
const invoicingQboSettingsFormConfig_1 = require("./invoicingQboSettingsFormConfig");
|
|
7
8
|
exports.initialState = {
|
|
8
9
|
fetchState: 'Not-Started',
|
|
9
10
|
error: undefined,
|
|
10
11
|
saveFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
11
12
|
stripeFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
12
13
|
settings: undefined,
|
|
14
|
+
// Listed so `clearAll` resets them: an in-progress draft left behind by a
|
|
15
|
+
// tenant switch would be shown and saved against the tenant switched to.
|
|
16
|
+
brandingDraft: undefined,
|
|
17
|
+
qboDraft: undefined,
|
|
13
18
|
hasValidState() {
|
|
14
19
|
return this.fetchState === 'Completed' && this.settings != null;
|
|
15
20
|
},
|
|
@@ -26,6 +31,11 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
26
31
|
draft.settings = action.payload;
|
|
27
32
|
draft.fetchState = 'Completed';
|
|
28
33
|
draft.error = undefined;
|
|
34
|
+
// Seed the QBO page's local data from the response. An edit already in
|
|
35
|
+
// progress wins: a refetch behind the user must not discard it.
|
|
36
|
+
if (draft.qboDraft == null) {
|
|
37
|
+
draft.qboDraft = (0, invoicingQboSettingsFormConfig_1.entityToInvoicingQboSettingsLocalData)(action.payload.qbo);
|
|
38
|
+
}
|
|
29
39
|
},
|
|
30
40
|
updateInvoicingSettingsFailure(draft, action) {
|
|
31
41
|
draft.fetchState = 'Error';
|
|
@@ -40,6 +50,9 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
40
50
|
saveInvoicingSettingsSuccess(draft, action) {
|
|
41
51
|
draft.settings = action.payload;
|
|
42
52
|
draft.saveFetchState = { fetchState: 'Completed', error: undefined };
|
|
53
|
+
// Re-seeded from what was just persisted, so the page keeps working off
|
|
54
|
+
// local data while showing the server's version of it.
|
|
55
|
+
draft.qboDraft = (0, invoicingQboSettingsFormConfig_1.entityToInvoicingQboSettingsLocalData)(action.payload.qbo);
|
|
43
56
|
},
|
|
44
57
|
saveInvoicingSettingsFailure(draft, action) {
|
|
45
58
|
draft.saveFetchState = { fetchState: 'Error', error: action.payload };
|
|
@@ -58,6 +71,17 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
58
71
|
resetInvoicingBrandingFormDraft(draft) {
|
|
59
72
|
draft.brandingDraft = undefined;
|
|
60
73
|
},
|
|
74
|
+
updateInvoicingQboSettingsDraft(draft, action) {
|
|
75
|
+
draft.qboDraft = action.payload.localData;
|
|
76
|
+
},
|
|
77
|
+
// Trigger only — handled by submitInvoicingQboSettingsEpic, which reads the
|
|
78
|
+
// local data and converts it to the request body.
|
|
79
|
+
submitInvoicingQboSettings(draft) {
|
|
80
|
+
draft.saveFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
81
|
+
},
|
|
82
|
+
resetInvoicingQboSettingsDraft(draft) {
|
|
83
|
+
draft.qboDraft = undefined;
|
|
84
|
+
},
|
|
61
85
|
connectInvoicingStripe: {
|
|
62
86
|
reducer(draft) {
|
|
63
87
|
draft.stripeFetchState = { fetchState: 'In-Progress', error: undefined };
|
|
@@ -89,5 +113,5 @@ const settingsView = (0, toolkit_1.createSlice)({
|
|
|
89
113
|
});
|
|
90
114
|
},
|
|
91
115
|
});
|
|
92
|
-
_a = settingsView.actions, exports.fetchInvoicingSettings = _a.fetchInvoicingSettings, exports.updateInvoicingSettings = _a.updateInvoicingSettings, exports.updateInvoicingSettingsFailure = _a.updateInvoicingSettingsFailure, exports.saveInvoicingSettings = _a.saveInvoicingSettings, exports.saveInvoicingSettingsSuccess = _a.saveInvoicingSettingsSuccess, exports.saveInvoicingSettingsFailure = _a.saveInvoicingSettingsFailure, exports.resetSaveInvoicingSettings = _a.resetSaveInvoicingSettings, exports.updateInvoicingBrandingFormDraft = _a.updateInvoicingBrandingFormDraft, exports.submitInvoicingBrandingForm = _a.submitInvoicingBrandingForm, exports.resetInvoicingBrandingFormDraft = _a.resetInvoicingBrandingFormDraft, exports.connectInvoicingStripe = _a.connectInvoicingStripe, exports.disconnectInvoicingStripe = _a.disconnectInvoicingStripe, exports.updateInvoicingStripeConnection = _a.updateInvoicingStripeConnection, exports.invoicingStripeConnectionFailure = _a.invoicingStripeConnectionFailure;
|
|
116
|
+
_a = settingsView.actions, exports.fetchInvoicingSettings = _a.fetchInvoicingSettings, exports.updateInvoicingSettings = _a.updateInvoicingSettings, exports.updateInvoicingSettingsFailure = _a.updateInvoicingSettingsFailure, exports.saveInvoicingSettings = _a.saveInvoicingSettings, exports.saveInvoicingSettingsSuccess = _a.saveInvoicingSettingsSuccess, exports.saveInvoicingSettingsFailure = _a.saveInvoicingSettingsFailure, exports.resetSaveInvoicingSettings = _a.resetSaveInvoicingSettings, exports.updateInvoicingBrandingFormDraft = _a.updateInvoicingBrandingFormDraft, exports.submitInvoicingBrandingForm = _a.submitInvoicingBrandingForm, exports.resetInvoicingBrandingFormDraft = _a.resetInvoicingBrandingFormDraft, exports.updateInvoicingQboSettingsDraft = _a.updateInvoicingQboSettingsDraft, exports.submitInvoicingQboSettings = _a.submitInvoicingQboSettings, exports.resetInvoicingQboSettingsDraft = _a.resetInvoicingQboSettingsDraft, exports.connectInvoicingStripe = _a.connectInvoicingStripe, exports.disconnectInvoicingStripe = _a.disconnectInvoicingStripe, exports.updateInvoicingStripeConnection = _a.updateInvoicingStripeConnection, exports.invoicingStripeConnectionFailure = _a.invoicingStripeConnectionFailure;
|
|
93
117
|
exports.default = settingsView.reducer;
|
|
@@ -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
|
}
|