@zeniai/client-epic-state 5.2.44-betaAK0 → 5.2.45
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/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +44 -9
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +6 -3
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/fetchInvoicingCouponDetailPageEpic.js +22 -4
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +41 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js +6 -3
- package/lib/view/invoicing/editInvoicingCouponDetailView/fetchInvoicingCouponDetailPageEpic.d.ts +9 -5
- package/lib/view/invoicing/editInvoicingCouponDetailView/fetchInvoicingCouponDetailPageEpic.js +22 -4
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState';
|
|
2
2
|
import { getInvoicingCouponById } from '../../../entity/invoicing/coupon/couponSelector';
|
|
3
|
-
import { toInvoicingFormOption, } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
3
|
+
import { toInvoicingFormOption, toInvoicingQboAccountMappingSlot, } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
4
4
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
5
|
-
import { getInvoicingQboView, invoicingAccountsForQboAccountTypes, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
6
|
-
import { getInvoicingSettings } from '../settingsView/settingsViewSelector';
|
|
5
|
+
import { getInvoicingQboView, invoicingAccountsForQboAccountTypes, invoicingQboAccountByQboId, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
6
|
+
import { getInvoicingSettings, getInvoicingSettingsFetchState, } from '../settingsView/settingsViewSelector';
|
|
7
7
|
import { initialInvoicingCouponFormLocalData, invoicingCouponDiscountsAccountIdForCreate, } from './editInvoicingCouponDetailViewState';
|
|
8
8
|
/**
|
|
9
9
|
* Bundled view for the discount create/edit form: the save fetch state/error,
|
|
@@ -25,6 +25,9 @@ export const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
25
25
|
fetchState: 'Not-Started',
|
|
26
26
|
})
|
|
27
27
|
: { error: undefined, fetchState: 'Completed' };
|
|
28
|
+
const coupon = couponId != null
|
|
29
|
+
? getInvoicingCouponById(state.invoicingCouponState, couponId)
|
|
30
|
+
: undefined;
|
|
28
31
|
return {
|
|
29
32
|
actionState: couponId != null
|
|
30
33
|
? (state.editInvoicingCouponDetailViewState.actionStateById[couponId] ??
|
|
@@ -38,9 +41,8 @@ export const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
38
41
|
{ error: undefined, fetchState: configFetchState },
|
|
39
42
|
]),
|
|
40
43
|
recordState,
|
|
41
|
-
coupon
|
|
42
|
-
|
|
43
|
-
: undefined,
|
|
44
|
+
coupon,
|
|
45
|
+
discountsAccountName: invoicingQboAccountByQboId(state, coupon?.discountsAccountId)?.accountName,
|
|
44
46
|
savedCouponId,
|
|
45
47
|
fetchState,
|
|
46
48
|
error,
|
|
@@ -53,6 +55,8 @@ export const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
53
55
|
* account; offering every account instead would let a save be rejected.
|
|
54
56
|
*/
|
|
55
57
|
const DEFAULT_DISCOUNTS_ACCOUNT_TYPES = 'Income';
|
|
58
|
+
/** The account-mapping slot a coupon's discounts account shares with settings. */
|
|
59
|
+
const DISCOUNTS_ACCOUNT_MAPPING_SLOT = 'discounts_account';
|
|
56
60
|
/**
|
|
57
61
|
* Bundled view for the discount form screen: the edit view (save state + the
|
|
58
62
|
* coupon to prefill in edit mode), the draft `localData` (seeded from the
|
|
@@ -71,17 +75,48 @@ export const getInvoicingCouponFormView = (state, couponId) => {
|
|
|
71
75
|
const { billingPeriodUnitOptions, discountApplyOnOptions, discountDurationTypeOptions, discountTypeOptions, qboAccountMappingKindOptions, } = getInvoicingConfigView(state);
|
|
72
76
|
const isQboConnected = isInvoicingQboConnected(state);
|
|
73
77
|
const qboView = isQboConnected ? getInvoicingQboView(state) : undefined;
|
|
78
|
+
const isQboPickerDataLoading = isInvoicingAccountingPickerDataLoading(state);
|
|
79
|
+
const settingsFetchState = getInvoicingSettingsFetchState(state).fetchState;
|
|
80
|
+
// Only a create reads the settings, and only until they arrive: an `Error`
|
|
81
|
+
// is a create that starts on no account, not a page that never renders.
|
|
82
|
+
const isCreateSeedPending = couponId == null &&
|
|
83
|
+
(settingsFetchState === 'Not-Started' ||
|
|
84
|
+
settingsFetchState === 'In-Progress');
|
|
74
85
|
// The account types the discounts slot accepts come from the same config the
|
|
75
86
|
// QBO settings page reads, so the two pickers offer the same accounts and
|
|
76
|
-
// widening the slot stays a config change.
|
|
77
|
-
|
|
87
|
+
// widening the slot stays a config change. Matched on the slot rather than
|
|
88
|
+
// the code as written: a config that names the kind `discounts_account_id`
|
|
89
|
+
// is the same slot, and missing it here would quietly fall back to the
|
|
90
|
+
// default and offer a different set than the settings page does.
|
|
91
|
+
const discountsAccountTypes = qboAccountMappingKindOptions.find((kindOption) => toInvoicingQboAccountMappingSlot(kindOption.code) ===
|
|
92
|
+
DISCOUNTS_ACCOUNT_MAPPING_SLOT)?.accountTypes ?? DEFAULT_DISCOUNTS_ACCOUNT_TYPES;
|
|
78
93
|
return {
|
|
79
94
|
...base,
|
|
80
95
|
applyOnOptions: discountApplyOnOptions.map(toInvoicingFormOption),
|
|
81
96
|
discountTypeOptions: discountTypeOptions.map(toInvoicingFormOption),
|
|
82
97
|
durationTypeOptions: discountDurationTypeOptions.map(toInvoicingFormOption),
|
|
83
98
|
isQboConnected,
|
|
84
|
-
isQboPickerDataLoading
|
|
99
|
+
isQboPickerDataLoading,
|
|
100
|
+
// Widened past the record and config the detail page waits on: the form
|
|
101
|
+
// also renders from the account list, and seeds a create from the settings
|
|
102
|
+
// discounts account. A form that mounted before those landed would offer an
|
|
103
|
+
// empty picker and save a coupon with no account of its own — not wrong,
|
|
104
|
+
// since blank means "use the settings account", but not what the user was
|
|
105
|
+
// shown either. Widened here rather than on the base view, so the detail
|
|
106
|
+
// page does not start waiting on lists it never renders.
|
|
107
|
+
//
|
|
108
|
+
// Only while they are still coming, though, and the settings only on a
|
|
109
|
+
// create: a coupon saves fine without a discounts account, so neither is
|
|
110
|
+
// allowed to hold the form behind a skeleton once it has failed.
|
|
111
|
+
pageFetchState: reduceAllFetchState([
|
|
112
|
+
base.pageFetchState,
|
|
113
|
+
{
|
|
114
|
+
error: undefined,
|
|
115
|
+
fetchState: isQboPickerDataLoading || isCreateSeedPending
|
|
116
|
+
? 'In-Progress'
|
|
117
|
+
: 'Completed',
|
|
118
|
+
},
|
|
119
|
+
]),
|
|
85
120
|
localData: couponId != null
|
|
86
121
|
? localData
|
|
87
122
|
: {
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js
CHANGED
|
@@ -57,6 +57,9 @@ export const entityToInvoicingCouponFormLocalData = (coupon) => {
|
|
|
57
57
|
* Create only. An edit shows the coupon's stored account, so a coupon saved
|
|
58
58
|
* without one keeps showing none.
|
|
59
59
|
*/
|
|
60
|
-
export const invoicingCouponDiscountsAccountIdForCreate = (discountsAccountId, accountMappings) =>
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
export const invoicingCouponDiscountsAccountIdForCreate = (discountsAccountId, accountMappings) => {
|
|
61
|
+
const pickedAccountId = discountsAccountId.trim();
|
|
62
|
+
return pickedAccountId !== ''
|
|
63
|
+
? pickedAccountId
|
|
64
|
+
: (getInvoicingQboAccountMappingId(accountMappings ?? undefined, 'discounts_account') ?? '');
|
|
65
|
+
};
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/fetchInvoicingCouponDetailPageEpic.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EMPTY, from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { fetchInvoicingConfig } from '../invoicingConfigView/invoicingConfigViewReducer';
|
|
4
|
+
import { fetchInvoicingAccountingPickers, fetchInvoicingQboConnection, } from '../invoicingQboView/invoicingQboViewReducer';
|
|
5
|
+
import { fetchInvoicingSettings } from '../settingsView/settingsViewReducer';
|
|
4
6
|
import { fetchInvoicingCouponDetail, fetchInvoicingCouponDetailPage, } from './editInvoicingCouponDetailViewReducer';
|
|
5
7
|
/**
|
|
6
8
|
* Fetch unless the endpoint is already loaded or in flight — or always when the
|
|
@@ -10,10 +12,12 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
|
|
|
10
12
|
(fetchStateAndError.fetchState !== 'Completed' &&
|
|
11
13
|
fetchStateAndError.fetchState !== 'In-Progress');
|
|
12
14
|
/**
|
|
13
|
-
* Orchestrates the discount
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Orchestrates the discount pages: one action fans out to the coupon record,
|
|
16
|
+
* the invoicing config behind its dropdowns and field help, and the QuickBooks
|
|
17
|
+
* connection, account list and settings the form's Discounts account picker
|
|
18
|
+
* renders and seeds from — each skipped when already cached. The page reads a
|
|
19
|
+
* single reduced fetch state off the view, so the form mounts once with real
|
|
20
|
+
* values.
|
|
17
21
|
*/
|
|
18
22
|
export const fetchInvoicingCouponDetailPageEpic = (actions$, state$) => actions$.pipe(filter(fetchInvoicingCouponDetailPage.match), withLatestFrom(state$), mergeMap(([action, state]) => {
|
|
19
23
|
const { cacheOverride = false, id } = action.payload;
|
|
@@ -32,5 +36,19 @@ export const fetchInvoicingCouponDetailPageEpic = (actions$, state$) => actions$
|
|
|
32
36
|
if (shouldFetch({ error: configState.error, fetchState: configState.fetchState }, cacheOverride)) {
|
|
33
37
|
pageActions.push(fetchInvoicingConfig());
|
|
34
38
|
}
|
|
39
|
+
const qboState = state.invoicingQboViewState;
|
|
40
|
+
if (shouldFetch(qboState.connectionFetchState, cacheOverride)) {
|
|
41
|
+
pageActions.push(fetchInvoicingQboConnection());
|
|
42
|
+
}
|
|
43
|
+
// The picker epic tops up the shared account list and skips what the
|
|
44
|
+
// store already holds, so this is safe to ask for on every open.
|
|
45
|
+
pageActions.push(fetchInvoicingAccountingPickers());
|
|
46
|
+
const settingsState = state.invoicingSettingsViewState;
|
|
47
|
+
if (shouldFetch({ error: settingsState.error, fetchState: settingsState.fetchState }, cacheOverride)) {
|
|
48
|
+
// A create seeds its Discounts account from the settings mapping, so
|
|
49
|
+
// the settings are page data here rather than a settings-screen
|
|
50
|
+
// concern.
|
|
51
|
+
pageActions.push(fetchInvoicingSettings());
|
|
52
|
+
}
|
|
35
53
|
return pageActions.length > 0 ? from(pageActions) : EMPTY;
|
|
36
54
|
}));
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts
CHANGED
|
@@ -31,6 +31,15 @@ export interface EditInvoicingCouponDetailView extends SelectorView {
|
|
|
31
31
|
*/
|
|
32
32
|
recordState: FetchStateAndError;
|
|
33
33
|
coupon?: InvoicingCoupon;
|
|
34
|
+
/**
|
|
35
|
+
* The name of the account the coupon's discount line posts to, resolved from
|
|
36
|
+
* the id the coupon stores against the shared QuickBooks account list.
|
|
37
|
+
* Resolved here rather than carried on the entity: the account is a record
|
|
38
|
+
* the accounting lists already own, and the coupon only ever stored a
|
|
39
|
+
* reference to it. Absent while the list is still loading, or when the id
|
|
40
|
+
* names an account this tenant can no longer see.
|
|
41
|
+
*/
|
|
42
|
+
discountsAccountName?: string;
|
|
34
43
|
savedCouponId?: ID;
|
|
35
44
|
}
|
|
36
45
|
export declare const getEditInvoicingCouponDetailViewState: (state: RootState, couponId?: ID) => EditInvoicingCouponDetailView;
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js
CHANGED
|
@@ -28,6 +28,9 @@ const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
28
28
|
fetchState: 'Not-Started',
|
|
29
29
|
})
|
|
30
30
|
: { error: undefined, fetchState: 'Completed' };
|
|
31
|
+
const coupon = couponId != null
|
|
32
|
+
? (0, couponSelector_1.getInvoicingCouponById)(state.invoicingCouponState, couponId)
|
|
33
|
+
: undefined;
|
|
31
34
|
return {
|
|
32
35
|
actionState: couponId != null
|
|
33
36
|
? (state.editInvoicingCouponDetailViewState.actionStateById[couponId] ??
|
|
@@ -41,9 +44,8 @@ const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
41
44
|
{ error: undefined, fetchState: configFetchState },
|
|
42
45
|
]),
|
|
43
46
|
recordState,
|
|
44
|
-
coupon
|
|
45
|
-
|
|
46
|
-
: undefined,
|
|
47
|
+
coupon,
|
|
48
|
+
discountsAccountName: (0, invoicingQboViewSelector_1.invoicingQboAccountByQboId)(state, coupon?.discountsAccountId)?.accountName,
|
|
47
49
|
savedCouponId,
|
|
48
50
|
fetchState,
|
|
49
51
|
error,
|
|
@@ -57,6 +59,8 @@ exports.getEditInvoicingCouponDetailViewState = getEditInvoicingCouponDetailView
|
|
|
57
59
|
* account; offering every account instead would let a save be rejected.
|
|
58
60
|
*/
|
|
59
61
|
const DEFAULT_DISCOUNTS_ACCOUNT_TYPES = 'Income';
|
|
62
|
+
/** The account-mapping slot a coupon's discounts account shares with settings. */
|
|
63
|
+
const DISCOUNTS_ACCOUNT_MAPPING_SLOT = 'discounts_account';
|
|
60
64
|
/**
|
|
61
65
|
* Bundled view for the discount form screen: the edit view (save state + the
|
|
62
66
|
* coupon to prefill in edit mode), the draft `localData` (seeded from the
|
|
@@ -75,17 +79,48 @@ const getInvoicingCouponFormView = (state, couponId) => {
|
|
|
75
79
|
const { billingPeriodUnitOptions, discountApplyOnOptions, discountDurationTypeOptions, discountTypeOptions, qboAccountMappingKindOptions, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
|
|
76
80
|
const isQboConnected = (0, invoicingQboViewSelector_1.isInvoicingQboConnected)(state);
|
|
77
81
|
const qboView = isQboConnected ? (0, invoicingQboViewSelector_1.getInvoicingQboView)(state) : undefined;
|
|
82
|
+
const isQboPickerDataLoading = (0, invoicingQboViewSelector_1.isInvoicingAccountingPickerDataLoading)(state);
|
|
83
|
+
const settingsFetchState = (0, settingsViewSelector_1.getInvoicingSettingsFetchState)(state).fetchState;
|
|
84
|
+
// Only a create reads the settings, and only until they arrive: an `Error`
|
|
85
|
+
// is a create that starts on no account, not a page that never renders.
|
|
86
|
+
const isCreateSeedPending = couponId == null &&
|
|
87
|
+
(settingsFetchState === 'Not-Started' ||
|
|
88
|
+
settingsFetchState === 'In-Progress');
|
|
78
89
|
// The account types the discounts slot accepts come from the same config the
|
|
79
90
|
// QBO settings page reads, so the two pickers offer the same accounts and
|
|
80
|
-
// widening the slot stays a config change.
|
|
81
|
-
|
|
91
|
+
// widening the slot stays a config change. Matched on the slot rather than
|
|
92
|
+
// the code as written: a config that names the kind `discounts_account_id`
|
|
93
|
+
// is the same slot, and missing it here would quietly fall back to the
|
|
94
|
+
// default and offer a different set than the settings page does.
|
|
95
|
+
const discountsAccountTypes = qboAccountMappingKindOptions.find((kindOption) => (0, invoicingCommonPayload_1.toInvoicingQboAccountMappingSlot)(kindOption.code) ===
|
|
96
|
+
DISCOUNTS_ACCOUNT_MAPPING_SLOT)?.accountTypes ?? DEFAULT_DISCOUNTS_ACCOUNT_TYPES;
|
|
82
97
|
return {
|
|
83
98
|
...base,
|
|
84
99
|
applyOnOptions: discountApplyOnOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
|
|
85
100
|
discountTypeOptions: discountTypeOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
|
|
86
101
|
durationTypeOptions: discountDurationTypeOptions.map(invoicingCommonPayload_1.toInvoicingFormOption),
|
|
87
102
|
isQboConnected,
|
|
88
|
-
isQboPickerDataLoading
|
|
103
|
+
isQboPickerDataLoading,
|
|
104
|
+
// Widened past the record and config the detail page waits on: the form
|
|
105
|
+
// also renders from the account list, and seeds a create from the settings
|
|
106
|
+
// discounts account. A form that mounted before those landed would offer an
|
|
107
|
+
// empty picker and save a coupon with no account of its own — not wrong,
|
|
108
|
+
// since blank means "use the settings account", but not what the user was
|
|
109
|
+
// shown either. Widened here rather than on the base view, so the detail
|
|
110
|
+
// page does not start waiting on lists it never renders.
|
|
111
|
+
//
|
|
112
|
+
// Only while they are still coming, though, and the settings only on a
|
|
113
|
+
// create: a coupon saves fine without a discounts account, so neither is
|
|
114
|
+
// allowed to hold the form behind a skeleton once it has failed.
|
|
115
|
+
pageFetchState: (0, reduceFetchState_1.reduceAllFetchState)([
|
|
116
|
+
base.pageFetchState,
|
|
117
|
+
{
|
|
118
|
+
error: undefined,
|
|
119
|
+
fetchState: isQboPickerDataLoading || isCreateSeedPending
|
|
120
|
+
? 'In-Progress'
|
|
121
|
+
: 'Completed',
|
|
122
|
+
},
|
|
123
|
+
]),
|
|
89
124
|
localData: couponId != null
|
|
90
125
|
? localData
|
|
91
126
|
: {
|
package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.js
CHANGED
|
@@ -61,7 +61,10 @@ exports.entityToInvoicingCouponFormLocalData = entityToInvoicingCouponFormLocalD
|
|
|
61
61
|
* Create only. An edit shows the coupon's stored account, so a coupon saved
|
|
62
62
|
* without one keeps showing none.
|
|
63
63
|
*/
|
|
64
|
-
const invoicingCouponDiscountsAccountIdForCreate = (discountsAccountId, accountMappings) =>
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const invoicingCouponDiscountsAccountIdForCreate = (discountsAccountId, accountMappings) => {
|
|
65
|
+
const pickedAccountId = discountsAccountId.trim();
|
|
66
|
+
return pickedAccountId !== ''
|
|
67
|
+
? pickedAccountId
|
|
68
|
+
: ((0, invoicingCommonPayload_1.getInvoicingQboAccountMappingId)(accountMappings ?? undefined, 'discounts_account') ?? '');
|
|
69
|
+
};
|
|
67
70
|
exports.invoicingCouponDiscountsAccountIdForCreate = invoicingCouponDiscountsAccountIdForCreate;
|
package/lib/view/invoicing/editInvoicingCouponDetailView/fetchInvoicingCouponDetailPageEpic.d.ts
CHANGED
|
@@ -2,12 +2,16 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RootState } from '../../../rootStateTypes';
|
|
4
4
|
import { fetchInvoicingConfig } from '../invoicingConfigView/invoicingConfigViewReducer';
|
|
5
|
+
import { fetchInvoicingAccountingPickers, fetchInvoicingQboConnection } from '../invoicingQboView/invoicingQboViewReducer';
|
|
6
|
+
import { fetchInvoicingSettings } from '../settingsView/settingsViewReducer';
|
|
5
7
|
import { fetchInvoicingCouponDetail, fetchInvoicingCouponDetailPage } from './editInvoicingCouponDetailViewReducer';
|
|
6
|
-
export type ActionType = ReturnType<typeof fetchInvoicingCouponDetailPage> | ReturnType<typeof fetchInvoicingCouponDetail> | ReturnType<typeof fetchInvoicingConfig>;
|
|
8
|
+
export type ActionType = ReturnType<typeof fetchInvoicingCouponDetailPage> | ReturnType<typeof fetchInvoicingCouponDetail> | ReturnType<typeof fetchInvoicingConfig> | ReturnType<typeof fetchInvoicingQboConnection> | ReturnType<typeof fetchInvoicingAccountingPickers> | ReturnType<typeof fetchInvoicingSettings>;
|
|
7
9
|
/**
|
|
8
|
-
* Orchestrates the discount
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Orchestrates the discount pages: one action fans out to the coupon record,
|
|
11
|
+
* the invoicing config behind its dropdowns and field help, and the QuickBooks
|
|
12
|
+
* connection, account list and settings the form's Discounts account picker
|
|
13
|
+
* renders and seeds from — each skipped when already cached. The page reads a
|
|
14
|
+
* single reduced fetch state off the view, so the form mounts once with real
|
|
15
|
+
* values.
|
|
12
16
|
*/
|
|
13
17
|
export declare const fetchInvoicingCouponDetailPageEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
package/lib/view/invoicing/editInvoicingCouponDetailView/fetchInvoicingCouponDetailPageEpic.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.fetchInvoicingCouponDetailPageEpic = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const invoicingConfigViewReducer_1 = require("../invoicingConfigView/invoicingConfigViewReducer");
|
|
7
|
+
const invoicingQboViewReducer_1 = require("../invoicingQboView/invoicingQboViewReducer");
|
|
8
|
+
const settingsViewReducer_1 = require("../settingsView/settingsViewReducer");
|
|
7
9
|
const editInvoicingCouponDetailViewReducer_1 = require("./editInvoicingCouponDetailViewReducer");
|
|
8
10
|
/**
|
|
9
11
|
* Fetch unless the endpoint is already loaded or in flight — or always when the
|
|
@@ -13,10 +15,12 @@ const shouldFetch = (fetchStateAndError, cacheOverride) => cacheOverride ||
|
|
|
13
15
|
(fetchStateAndError.fetchState !== 'Completed' &&
|
|
14
16
|
fetchStateAndError.fetchState !== 'In-Progress');
|
|
15
17
|
/**
|
|
16
|
-
* Orchestrates the discount
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* Orchestrates the discount pages: one action fans out to the coupon record,
|
|
19
|
+
* the invoicing config behind its dropdowns and field help, and the QuickBooks
|
|
20
|
+
* connection, account list and settings the form's Discounts account picker
|
|
21
|
+
* renders and seeds from — each skipped when already cached. The page reads a
|
|
22
|
+
* single reduced fetch state off the view, so the form mounts once with real
|
|
23
|
+
* values.
|
|
20
24
|
*/
|
|
21
25
|
const fetchInvoicingCouponDetailPageEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(editInvoicingCouponDetailViewReducer_1.fetchInvoicingCouponDetailPage.match), (0, operators_1.withLatestFrom)(state$), (0, operators_1.mergeMap)(([action, state]) => {
|
|
22
26
|
const { cacheOverride = false, id } = action.payload;
|
|
@@ -35,6 +39,20 @@ const fetchInvoicingCouponDetailPageEpic = (actions$, state$) => actions$.pipe((
|
|
|
35
39
|
if (shouldFetch({ error: configState.error, fetchState: configState.fetchState }, cacheOverride)) {
|
|
36
40
|
pageActions.push((0, invoicingConfigViewReducer_1.fetchInvoicingConfig)());
|
|
37
41
|
}
|
|
42
|
+
const qboState = state.invoicingQboViewState;
|
|
43
|
+
if (shouldFetch(qboState.connectionFetchState, cacheOverride)) {
|
|
44
|
+
pageActions.push((0, invoicingQboViewReducer_1.fetchInvoicingQboConnection)());
|
|
45
|
+
}
|
|
46
|
+
// The picker epic tops up the shared account list and skips what the
|
|
47
|
+
// store already holds, so this is safe to ask for on every open.
|
|
48
|
+
pageActions.push((0, invoicingQboViewReducer_1.fetchInvoicingAccountingPickers)());
|
|
49
|
+
const settingsState = state.invoicingSettingsViewState;
|
|
50
|
+
if (shouldFetch({ error: settingsState.error, fetchState: settingsState.fetchState }, cacheOverride)) {
|
|
51
|
+
// A create seeds its Discounts account from the settings mapping, so
|
|
52
|
+
// the settings are page data here rather than a settings-screen
|
|
53
|
+
// concern.
|
|
54
|
+
pageActions.push((0, settingsViewReducer_1.fetchInvoicingSettings)());
|
|
55
|
+
}
|
|
38
56
|
return pageActions.length > 0 ? (0, rxjs_1.from)(pageActions) : rxjs_1.EMPTY;
|
|
39
57
|
}));
|
|
40
58
|
exports.fetchInvoicingCouponDetailPageEpic = fetchInvoicingCouponDetailPageEpic;
|
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.45",
|
|
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",
|