@zeniai/client-epic-state 5.2.49 → 5.2.50-betaAK0
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/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +22 -11
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +30 -7
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +22 -11
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +29 -6
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +22 -11
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +29 -6
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +24 -13
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
- package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +29 -8
- package/lib/esm/view/invoicing/invoicingFormDraft.js +78 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +22 -11
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.d.ts +10 -0
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewSelector.js +4 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +3 -2
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +29 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +22 -11
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.d.ts +13 -0
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewSelector.js +3 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/saveInvoicingCouponEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +28 -5
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +22 -11
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +4 -2
- package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/saveInvoicingCustomerEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +28 -5
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +24 -13
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +9 -0
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +3 -2
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +2 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/fetchInvoicingSubscriptionFormPageEpic.js +4 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js +1 -1
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.d.ts +10 -6
- package/lib/view/invoicing/editInvoicingSubscriptionDetailView/seedInvoicingSubscriptionFormDraftEpic.js +28 -7
- package/lib/view/invoicing/invoicingFormDraft.d.ts +63 -0
- package/lib/view/invoicing/invoicingFormDraft.js +86 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSaved, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingCatalogItemFormLocalData } from './invoicingCatalogItemFormHelper';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
fetchState: 'Not-Started',
|
|
@@ -21,7 +22,7 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
21
22
|
updateInvoicingCatalogItemFormDraft(draft, action) {
|
|
22
23
|
const { id, localData } = action.payload;
|
|
23
24
|
if (id != null) {
|
|
24
|
-
draft.editDraftById
|
|
25
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
28
|
draft.newItemDraft = localData;
|
|
@@ -42,6 +43,9 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
42
43
|
draft.error = undefined;
|
|
43
44
|
draft.savedItemId = action.payload.itemId;
|
|
44
45
|
draft.savedKind = action.payload.kind;
|
|
46
|
+
// An edit is refetched on success; keep the saved values on screen until
|
|
47
|
+
// that lands, and let it replace them.
|
|
48
|
+
applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.itemId);
|
|
45
49
|
},
|
|
46
50
|
submitInvoicingCatalogItemFormFailure(draft, action) {
|
|
47
51
|
draft.fetchState = 'Error';
|
|
@@ -64,6 +68,7 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
64
68
|
fetchState: 'Error',
|
|
65
69
|
error: action.payload.error,
|
|
66
70
|
};
|
|
71
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingCatalogItemFormLocalData);
|
|
67
72
|
},
|
|
68
73
|
fetchInvoicingCatalogItemDetailPage: {
|
|
69
74
|
reducer() {
|
|
@@ -79,14 +84,10 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
79
84
|
};
|
|
80
85
|
},
|
|
81
86
|
},
|
|
82
|
-
/**
|
|
83
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
84
|
-
* exists so a late-arriving refetch cannot overwrite in-progress edits.
|
|
85
|
-
*/
|
|
87
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
86
88
|
seedInvoicingCatalogItemFormDraft(draft, action) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
89
|
+
const { id, localData } = action.payload;
|
|
90
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
90
91
|
},
|
|
91
92
|
runInvoicingCatalogPlanAction(draft, action) {
|
|
92
93
|
draft.actionStateById[action.payload.id] = {
|
|
@@ -125,13 +126,23 @@ const editInvoicingCatalogItemDetailView = createSlice({
|
|
|
125
126
|
error: action.payload.error,
|
|
126
127
|
};
|
|
127
128
|
},
|
|
128
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Discard a form's draft — the catalog item's own when `id` is given,
|
|
131
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
132
|
+
* catalog item's half-finished edit is not this form's to throw away.
|
|
133
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
134
|
+
*/
|
|
135
|
+
resetEditInvoicingCatalogItemDetailView(draft, action) {
|
|
129
136
|
draft.fetchState = 'Not-Started';
|
|
130
137
|
draft.error = undefined;
|
|
131
138
|
draft.savedItemId = undefined;
|
|
132
139
|
draft.savedKind = undefined;
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
const id = action.payload?.id;
|
|
141
|
+
if (id == null) {
|
|
142
|
+
draft.newItemDraft = { ...initialInvoicingCatalogItemFormLocalData };
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
delete draft.editDraftById[id];
|
|
135
146
|
},
|
|
136
147
|
},
|
|
137
148
|
extraReducers: (builder) => {
|
|
@@ -2,6 +2,7 @@ import { createSelector } from '@reduxjs/toolkit';
|
|
|
2
2
|
import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState';
|
|
3
3
|
import { getInvoicingPlanById, getInvoicingPlansByIds, } from '../../../entity/invoicing/plan/planSelector';
|
|
4
4
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
5
|
+
import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
|
|
5
6
|
import { getInvoicingQboView, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
6
7
|
import { INVOICING_CATALOG_APPLICABILITY_VALUES, INVOICING_CATALOG_PRICING_MODEL_VALUES, INVOICING_CATALOG_PRORATION_VALUES, INVOICING_CATALOG_TIER_TYPE_VALUES, initialInvoicingCatalogItemFormLocalData, } from './invoicingCatalogItemFormHelper';
|
|
7
8
|
export const getEditInvoicingCatalogItemDetailViewState = (state) => ({
|
|
@@ -52,7 +53,7 @@ export const getInvoicingCatalogItemFormView = (state, id) => {
|
|
|
52
53
|
// lands. Until then the page is showing its skeleton, so the blank shape here
|
|
53
54
|
// is never rendered.
|
|
54
55
|
const localData = id != null
|
|
55
|
-
? (editDraftById
|
|
56
|
+
? getInvoicingFormDraftLocalData(editDraftById, id, initialInvoicingCatalogItemFormLocalData)
|
|
56
57
|
: newItemDraft;
|
|
57
58
|
const allApplicableItemOptions = getInvoicingApplicableCatalogItemOptions(state);
|
|
58
59
|
const applicableItemOptions = id != null
|
|
@@ -90,6 +91,8 @@ export const getInvoicingCatalogItemFormView = (state, id) => {
|
|
|
90
91
|
catalogProductLifecycleActionOptions,
|
|
91
92
|
recordState,
|
|
92
93
|
fieldHelp: invoicingFieldHelpForGroup(state, 'catalog'),
|
|
94
|
+
isFormLoading: isInvoicingAccountingPickerDataLoading(state) ||
|
|
95
|
+
isInvoicingFormDraftPending(editDraftById, id),
|
|
93
96
|
isQboPickerDataLoading: isInvoicingAccountingPickerDataLoading(state),
|
|
94
97
|
qboAccountHierarchy: qboView?.nestedAccountHierarchy ?? [],
|
|
95
98
|
qboClassHierarchy: qboView?.nestedClassHierarchy ?? [],
|
package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js
CHANGED
|
@@ -17,8 +17,9 @@ export const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actio
|
|
|
17
17
|
// class become the records the service stores. Price points ride along
|
|
18
18
|
// nested, so the detail page and the create/edit form share one request.
|
|
19
19
|
const viewState = state.editInvoicingCatalogItemDetailViewState;
|
|
20
|
-
const localData = (id != null
|
|
21
|
-
viewState.
|
|
20
|
+
const localData = (id != null
|
|
21
|
+
? viewState.editDraftById[id]?.localData
|
|
22
|
+
: viewState.newItemDraft) ?? viewState.newItemDraft;
|
|
22
23
|
const data = localDataToSaveInvoicingCatalogItemPayload(localData, id == null, accountingLookup);
|
|
23
24
|
const baseUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;
|
|
24
25
|
const path = id != null
|
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import { EMPTY, of } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { getInvoicingPlanById } from '../../../entity/invoicing/plan/planSelector';
|
|
4
|
-
import { seedInvoicingCatalogItemFormDraft, updateInvoicingCatalogItemDetail, } from './editInvoicingCatalogItemDetailViewReducer';
|
|
4
|
+
import { fetchInvoicingCatalogItemDetailPage, seedInvoicingCatalogItemFormDraft, updateInvoicingCatalogItemDetail, } from './editInvoicingCatalogItemDetailViewReducer';
|
|
5
5
|
import { entityToInvoicingCatalogItemFormLocalData } from './invoicingCatalogItemFormHelper';
|
|
6
6
|
/**
|
|
7
|
-
* Seeds the edit draft from the record the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Seeds the edit draft from the record, so the form has its values before it
|
|
8
|
+
* mounts. The reducer ignores a seed once the draft holds the record, which is
|
|
9
|
+
* what stops a background refetch from overwriting edits in progress.
|
|
10
|
+
*
|
|
11
|
+
* Opening the page counts as a trigger, not just the detail response: the page
|
|
12
|
+
* fetch is cache-guarded, so re-opening a form for a record already loaded this
|
|
13
|
+
* session issues no request at all — and a draft cleared in between (by a save
|
|
14
|
+
* or a cancel) would have nothing left to seed it.
|
|
11
15
|
*/
|
|
12
|
-
export const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actions$.pipe(filter(updateInvoicingCatalogItemDetail.match
|
|
13
|
-
|
|
16
|
+
export const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCatalogItemDetail.match(action) ||
|
|
17
|
+
fetchInvoicingCatalogItemDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
|
|
18
|
+
const id = action.payload.id;
|
|
19
|
+
if (id == null) {
|
|
20
|
+
return EMPTY;
|
|
21
|
+
}
|
|
22
|
+
// The entity alone does not say the whole record is loaded — the list
|
|
23
|
+
// endpoints merge their own list-shaped rows into the same store. Only a
|
|
24
|
+
// completed detail load does, which is also exactly when the page's
|
|
25
|
+
// cache-guarded fetch issues no request and this is the sole seed.
|
|
26
|
+
// A forced refetch is the caller asking for fresh data: the response will
|
|
27
|
+
// seed, and seeding first from the entity as it stands would mark the
|
|
28
|
+
// draft loaded and lock that response out.
|
|
29
|
+
if (fetchInvoicingCatalogItemDetailPage.match(action) &&
|
|
30
|
+
(action.payload.cacheOverride === true ||
|
|
31
|
+
state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
|
|
32
|
+
?.fetchState !== 'Completed')) {
|
|
33
|
+
return EMPTY;
|
|
34
|
+
}
|
|
35
|
+
// Nothing to seed from on a cold open; the detail response triggers this
|
|
36
|
+
// again once it lands.
|
|
14
37
|
const plan = getInvoicingPlanById(state.invoicingPlanState, id);
|
|
15
38
|
if (plan == null) {
|
|
16
39
|
return EMPTY;
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSaved, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingCouponFormLocalData, } from './editInvoicingCouponDetailViewState';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
fetchState: 'Not-Started',
|
|
@@ -20,7 +21,7 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
20
21
|
updateInvoicingCouponFormDraft(draft, action) {
|
|
21
22
|
const { id, localData } = action.payload;
|
|
22
23
|
if (id != null) {
|
|
23
|
-
draft.editDraftById
|
|
24
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
26
27
|
draft.newCouponDraft = localData;
|
|
@@ -50,6 +51,9 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
50
51
|
draft.fetchState = 'Completed';
|
|
51
52
|
draft.error = undefined;
|
|
52
53
|
draft.savedCouponId = action.payload.couponId;
|
|
54
|
+
// An edit is refetched on success; keep the saved values on screen until
|
|
55
|
+
// that lands, and let it replace them.
|
|
56
|
+
applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.couponId);
|
|
53
57
|
},
|
|
54
58
|
submitInvoicingCouponFormFailure(draft, action) {
|
|
55
59
|
draft.fetchState = 'Error';
|
|
@@ -85,15 +89,12 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
85
89
|
fetchState: 'Error',
|
|
86
90
|
error: action.payload.status,
|
|
87
91
|
};
|
|
92
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingCouponFormLocalData);
|
|
88
93
|
},
|
|
89
|
-
/**
|
|
90
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
91
|
-
* exists so a late refetch cannot overwrite in-progress edits.
|
|
92
|
-
*/
|
|
94
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
93
95
|
seedInvoicingCouponFormDraft(draft, action) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
96
|
+
const { id, localData } = action.payload;
|
|
97
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
97
98
|
},
|
|
98
99
|
runInvoicingDiscountAction(draft, action) {
|
|
99
100
|
draft.actionStateById[action.payload.id] = {
|
|
@@ -113,12 +114,22 @@ const editInvoicingCouponDetailView = createSlice({
|
|
|
113
114
|
error: action.payload.error,
|
|
114
115
|
};
|
|
115
116
|
},
|
|
116
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Discard a form's draft — the coupon's own when `id` is given,
|
|
119
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
120
|
+
* coupon's half-finished edit is not this form's to throw away.
|
|
121
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
122
|
+
*/
|
|
123
|
+
resetEditInvoicingCouponDetailView(draft, action) {
|
|
117
124
|
draft.fetchState = 'Not-Started';
|
|
118
125
|
draft.error = undefined;
|
|
119
126
|
draft.savedCouponId = undefined;
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
const id = action.payload?.id;
|
|
128
|
+
if (id == null) {
|
|
129
|
+
draft.newCouponDraft = { ...initialInvoicingCouponFormLocalData };
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
delete draft.editDraftById[id];
|
|
122
133
|
},
|
|
123
134
|
},
|
|
124
135
|
extraReducers: (builder) => {
|
|
@@ -2,6 +2,7 @@ import { reduceAllFetchState } from '../../../commonStateTypes/reduceFetchState'
|
|
|
2
2
|
import { getInvoicingCouponById } from '../../../entity/invoicing/coupon/couponSelector';
|
|
3
3
|
import { toInvoicingFormOption, toInvoicingQboAccountMappingSlot, } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
4
4
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
5
|
+
import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
|
|
5
6
|
import { getInvoicingQboView, invoicingAccountsForQboAccountTypes, invoicingQboAccountByQboId, isInvoicingAccountingPickerDataLoading, isInvoicingQboConnected, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
6
7
|
import { getInvoicingSettings, getInvoicingSettingsFetchState, } from '../settingsView/settingsViewSelector';
|
|
7
8
|
import { initialInvoicingCouponFormLocalData, invoicingCouponDiscountsAccountIdForCreate, } from './editInvoicingCouponDetailViewState';
|
|
@@ -41,6 +42,7 @@ export const getEditInvoicingCouponDetailViewState = (state, couponId) => {
|
|
|
41
42
|
{ error: undefined, fetchState: configFetchState },
|
|
42
43
|
]),
|
|
43
44
|
recordState,
|
|
45
|
+
isFormLoading: isInvoicingFormDraftPending(state.editInvoicingCouponDetailViewState.editDraftById, couponId),
|
|
44
46
|
coupon,
|
|
45
47
|
discountsAccountName: invoicingQboAccountByQboId(state, coupon?.discountsAccountId)?.accountName,
|
|
46
48
|
savedCouponId,
|
|
@@ -70,7 +72,7 @@ export const getInvoicingCouponFormView = (state, couponId) => {
|
|
|
70
72
|
// `seedInvoicingCouponFormDraftEpic` when the detail load lands. Until then
|
|
71
73
|
// the page is showing its skeleton.
|
|
72
74
|
const localData = couponId != null
|
|
73
|
-
? (editDraftById
|
|
75
|
+
? getInvoicingFormDraftLocalData(editDraftById, couponId, initialInvoicingCouponFormLocalData)
|
|
74
76
|
: newCouponDraft;
|
|
75
77
|
const { billingPeriodUnitOptions, discountApplyOnOptions, discountDurationTypeOptions, discountTypeOptions, qboAccountMappingKindOptions, } = getInvoicingConfigView(state);
|
|
76
78
|
const isQboConnected = isInvoicingQboConnected(state);
|
|
@@ -20,7 +20,7 @@ export const saveInvoicingCouponEpic = (actions$, state$, zeniAPI) => actions$.p
|
|
|
20
20
|
const state = state$.value;
|
|
21
21
|
const viewState = state.editInvoicingCouponDetailViewState;
|
|
22
22
|
const draft = (id != null
|
|
23
|
-
? viewState.editDraftById[id]
|
|
23
|
+
? viewState.editDraftById[id]?.localData
|
|
24
24
|
: viewState.newCouponDraft) ?? viewState.newCouponDraft;
|
|
25
25
|
// The create default is resolved here as well as in the form view,
|
|
26
26
|
// so a create that never touched the picker still persists the
|
package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import { EMPTY, of } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { getInvoicingCouponById } from '../../../entity/invoicing/coupon/couponSelector';
|
|
4
|
-
import { seedInvoicingCouponFormDraft, updateInvoicingCouponDetail, } from './editInvoicingCouponDetailViewReducer';
|
|
4
|
+
import { fetchInvoicingCouponDetailPage, seedInvoicingCouponFormDraft, updateInvoicingCouponDetail, } from './editInvoicingCouponDetailViewReducer';
|
|
5
5
|
import { entityToInvoicingCouponFormLocalData } from './editInvoicingCouponDetailViewState';
|
|
6
6
|
/**
|
|
7
|
-
* Seeds the edit draft from the record the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Seeds the edit draft from the record, so the form has its values before it
|
|
8
|
+
* mounts. The reducer ignores a seed once the draft holds the record, which is
|
|
9
|
+
* what stops a background refetch from overwriting edits in progress.
|
|
10
|
+
*
|
|
11
|
+
* Opening the page counts as a trigger, not just the detail response: the page
|
|
12
|
+
* fetch is cache-guarded, so re-opening a form for a record already loaded this
|
|
13
|
+
* session issues no request at all — and a draft cleared in between (by a save
|
|
14
|
+
* or a cancel) would have nothing left to seed it.
|
|
11
15
|
*/
|
|
12
|
-
export const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.pipe(filter(updateInvoicingCouponDetail.match
|
|
16
|
+
export const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCouponDetail.match(action) ||
|
|
17
|
+
fetchInvoicingCouponDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
|
|
13
18
|
const { id } = action.payload;
|
|
19
|
+
if (id == null) {
|
|
20
|
+
return EMPTY;
|
|
21
|
+
}
|
|
22
|
+
// The entity alone does not say the whole record is loaded — the list
|
|
23
|
+
// endpoints merge their own list-shaped rows into the same store. Only a
|
|
24
|
+
// completed detail load does, which is also exactly when the page's
|
|
25
|
+
// cache-guarded fetch issues no request and this is the sole seed.
|
|
26
|
+
// A forced refetch is the caller asking for fresh data: the response will
|
|
27
|
+
// seed, and seeding first from the entity as it stands would mark the
|
|
28
|
+
// draft loaded and lock that response out.
|
|
29
|
+
if (fetchInvoicingCouponDetailPage.match(action) &&
|
|
30
|
+
(action.payload.cacheOverride === true ||
|
|
31
|
+
state.editInvoicingCouponDetailViewState.recordStateById[id]
|
|
32
|
+
?.fetchState !== 'Completed')) {
|
|
33
|
+
return EMPTY;
|
|
34
|
+
}
|
|
35
|
+
// Nothing to seed from on a cold open; the detail response triggers this
|
|
36
|
+
// again once it lands.
|
|
14
37
|
const coupon = getInvoicingCouponById(state.invoicingCouponState, id);
|
|
15
38
|
if (coupon == null) {
|
|
16
39
|
return EMPTY;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSaved, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingCustomerFormLocalData } from './invoicingCustomerFormConfig';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
emailPreviewFetchState: { fetchState: 'Not-Started', error: undefined },
|
|
@@ -123,20 +124,17 @@ const editInvoicingCustomerDetailView = createSlice({
|
|
|
123
124
|
fetchState: 'Error',
|
|
124
125
|
error: action.payload.status,
|
|
125
126
|
};
|
|
127
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingCustomerFormLocalData);
|
|
126
128
|
},
|
|
127
|
-
/**
|
|
128
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
129
|
-
* exists so a late refetch cannot overwrite in-progress edits.
|
|
130
|
-
*/
|
|
129
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
131
130
|
seedInvoicingCustomerFormDraft(draft, action) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
131
|
+
const { id, localData } = action.payload;
|
|
132
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
135
133
|
},
|
|
136
134
|
updateInvoicingCustomerFormDraft(draft, action) {
|
|
137
135
|
const { id, localData } = action.payload;
|
|
138
136
|
if (id != null) {
|
|
139
|
-
draft.editDraftById
|
|
137
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
140
138
|
}
|
|
141
139
|
else {
|
|
142
140
|
draft.newCustomerDraft = localData;
|
|
@@ -156,17 +154,30 @@ const editInvoicingCustomerDetailView = createSlice({
|
|
|
156
154
|
draft.fetchState = 'Completed';
|
|
157
155
|
draft.error = undefined;
|
|
158
156
|
draft.savedCustomerId = action.payload.customerId;
|
|
157
|
+
// An edit is refetched on success; keep the saved values on screen until
|
|
158
|
+
// that lands, and let it replace them.
|
|
159
|
+
applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.customerId);
|
|
159
160
|
},
|
|
160
161
|
submitInvoicingCustomerFormFailure(draft, action) {
|
|
161
162
|
draft.fetchState = 'Error';
|
|
162
163
|
draft.error = action.payload;
|
|
163
164
|
},
|
|
164
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Discard a form's draft — the customer's own when `id` is given,
|
|
167
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
168
|
+
* customer's half-finished edit is not this form's to throw away.
|
|
169
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
170
|
+
*/
|
|
171
|
+
resetEditInvoicingCustomerDetailView(draft, action) {
|
|
165
172
|
draft.fetchState = 'Not-Started';
|
|
166
173
|
draft.error = undefined;
|
|
167
174
|
draft.savedCustomerId = undefined;
|
|
168
|
-
|
|
169
|
-
|
|
175
|
+
const id = action.payload?.id;
|
|
176
|
+
if (id == null) {
|
|
177
|
+
draft.newCustomerDraft = { ...initialInvoicingCustomerFormLocalData };
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
delete draft.editDraftById[id];
|
|
170
181
|
},
|
|
171
182
|
// Trigger only — handled by initializeInvoicingCustomerAddressEpic.
|
|
172
183
|
initializeInvoicingCustomerAddress: {
|
|
@@ -5,6 +5,7 @@ import { invoicingCustomerPaymentMethods } from '../../../entity/invoicing/invoi
|
|
|
5
5
|
import { getFormattedAddress } from '../../addressView/addressViewSelector';
|
|
6
6
|
import { getInvoicingPaymentLinkSendState, getInvoicingPaymentMethodSaveState, getInvoicingPlaidLinkToken, getInvoicingPlaidLinkTokenFetchState, getInvoicingSentPaymentLinkEmail, getInvoicingSentPaymentLinkMagicUrl, getInvoicingSetupIntent, getInvoicingSetupIntentFetchState, } from '../customerPaymentMethod/customerPaymentMethodSelector';
|
|
7
7
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
8
|
+
import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
|
|
8
9
|
import { isStripeConnectedFromSettings } from '../settingsView/invoicingSettingsHelpers';
|
|
9
10
|
import { getInvoicingSettings } from '../settingsView/settingsViewSelector';
|
|
10
11
|
import { INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE, initialInvoicingCustomerFormLocalData, } from './invoicingCustomerFormConfig';
|
|
@@ -59,8 +60,7 @@ export const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
|
|
|
59
60
|
// `seedInvoicingCustomerFormDraftEpic` when the detail load lands. Until then
|
|
60
61
|
// the page is showing its skeleton.
|
|
61
62
|
const localData = invoicingCustomerID != null
|
|
62
|
-
? (editDraftById
|
|
63
|
-
initialInvoicingCustomerFormLocalData)
|
|
63
|
+
? getInvoicingFormDraftLocalData(editDraftById, invoicingCustomerID, initialInvoicingCustomerFormLocalData)
|
|
64
64
|
: newCustomerDraft;
|
|
65
65
|
// Billing address is captured via the shared Address screen and seeded there
|
|
66
66
|
// (from the address entity) on detail load, so the formatted label comes from
|
|
@@ -78,6 +78,7 @@ export const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
|
|
|
78
78
|
? { error: undefined, fetchState: 'Completed' }
|
|
79
79
|
: (state.editInvoicingCustomerDetailViewState.recordStateById[invoicingCustomerID] ?? { error: undefined, fetchState: 'Not-Started' });
|
|
80
80
|
const { emailPreview, emailPreviewCustomerId, emailPreviewFetchState } = state.editInvoicingCustomerDetailViewState;
|
|
81
|
+
const isFormLoading = isInvoicingFormDraftPending(editDraftById, invoicingCustomerID);
|
|
81
82
|
return {
|
|
82
83
|
// A preview cached for another customer is not this screen's.
|
|
83
84
|
emailPreview: emailPreviewCustomerId === invoicingCustomerID ? emailPreview : undefined,
|
|
@@ -92,6 +93,7 @@ export const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
|
|
|
92
93
|
promotionalCreditSubmitState: state.editInvoicingCustomerDetailViewState.promotionalCreditSubmitState,
|
|
93
94
|
record: getInvoicingCustomerRecord(state, invoicingCustomerID),
|
|
94
95
|
fieldHelp: invoicingFieldHelpForGroup(state, 'customer'),
|
|
96
|
+
isFormLoading,
|
|
95
97
|
customerTypeOptions,
|
|
96
98
|
localData,
|
|
97
99
|
mode,
|
|
@@ -16,7 +16,7 @@ export const saveInvoicingCustomerEpic = (actions$, state$, zeniAPI) => actions$
|
|
|
16
16
|
const rootState = state$.value;
|
|
17
17
|
const viewState = rootState.editInvoicingCustomerDetailViewState;
|
|
18
18
|
const localData = (id != null
|
|
19
|
-
? viewState.editDraftById[id]
|
|
19
|
+
? viewState.editDraftById[id]?.localData
|
|
20
20
|
: viewState.newCustomerDraft) ?? viewState.newCustomerDraft;
|
|
21
21
|
// Billing address captured via the shared Address screen is sent as an
|
|
22
22
|
// object in the payload; the backend creates it and returns its id
|
package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
import { EMPTY, of } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap, withLatestFrom } from 'rxjs/operators';
|
|
3
3
|
import { getInvoicingCustomerById } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector';
|
|
4
|
-
import { seedInvoicingCustomerFormDraft, updateInvoicingCustomerDetail, } from './editInvoicingCustomerDetailViewReducer';
|
|
4
|
+
import { fetchInvoicingCustomerDetailPage, seedInvoicingCustomerFormDraft, updateInvoicingCustomerDetail, } from './editInvoicingCustomerDetailViewReducer';
|
|
5
5
|
import { entityToInvoicingCustomerFormLocalData } from './invoicingCustomerFormConfig';
|
|
6
6
|
/**
|
|
7
|
-
* Seeds the edit draft from the record the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Seeds the edit draft from the record, so the form has its values before it
|
|
8
|
+
* mounts. The reducer ignores a seed once the draft holds the record, which is
|
|
9
|
+
* what stops a background refetch from overwriting edits in progress.
|
|
10
|
+
*
|
|
11
|
+
* Opening the page counts as a trigger, not just the detail response: the page
|
|
12
|
+
* fetch is cache-guarded, so re-opening for a record already loaded this
|
|
13
|
+
* session issues no request at all — and a draft cleared in between (by a save
|
|
14
|
+
* or a cancel) would have nothing left to seed it.
|
|
11
15
|
*/
|
|
12
|
-
export const seedInvoicingCustomerFormDraftEpic = (actions$, state$) => actions$.pipe(filter(updateInvoicingCustomerDetail.match
|
|
16
|
+
export const seedInvoicingCustomerFormDraftEpic = (actions$, state$) => actions$.pipe(filter((action) => updateInvoicingCustomerDetail.match(action) ||
|
|
17
|
+
fetchInvoicingCustomerDetailPage.match(action)), withLatestFrom(state$), mergeMap(([action, state]) => {
|
|
13
18
|
const { id } = action.payload;
|
|
19
|
+
if (id == null) {
|
|
20
|
+
return EMPTY;
|
|
21
|
+
}
|
|
22
|
+
// The entity alone does not say the whole record is loaded — the list
|
|
23
|
+
// endpoints merge their own list-shaped rows into the same store. Only a
|
|
24
|
+
// completed detail load does, which is also exactly when the page's
|
|
25
|
+
// cache-guarded fetch issues no request and this is the sole seed.
|
|
26
|
+
// A forced refetch is the caller asking for fresh data: the response will
|
|
27
|
+
// seed, and seeding first from the entity as it stands would mark the
|
|
28
|
+
// draft loaded and lock that response out.
|
|
29
|
+
if (fetchInvoicingCustomerDetailPage.match(action) &&
|
|
30
|
+
(action.payload.cacheOverride === true ||
|
|
31
|
+
state.editInvoicingCustomerDetailViewState.recordStateById[id]
|
|
32
|
+
?.fetchState !== 'Completed')) {
|
|
33
|
+
return EMPTY;
|
|
34
|
+
}
|
|
35
|
+
// Nothing to seed from on a cold open; the detail response triggers this
|
|
36
|
+
// again once it lands.
|
|
14
37
|
const customer = getInvoicingCustomerById(state.invoicingCustomerState, id);
|
|
15
38
|
if (customer == null) {
|
|
16
39
|
return EMPTY;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
2
|
import { clearAll } from '../../../rootActions';
|
|
3
|
+
import { applyInvoicingFormDraftEdit, applyInvoicingFormDraftFailure, applyInvoicingFormDraftSaved, applyInvoicingFormDraftSeed, } from '../invoicingFormDraft';
|
|
3
4
|
import { initialInvoicingSubscriptionFormLocalData } from './invoicingSubscriptionFormConfig';
|
|
4
5
|
export const initialState = {
|
|
5
6
|
fetchState: 'Not-Started',
|
|
@@ -65,15 +66,12 @@ const editInvoicingSubscriptionDetailView = createSlice({
|
|
|
65
66
|
fetchState: 'Error',
|
|
66
67
|
error: action.payload.error,
|
|
67
68
|
};
|
|
69
|
+
applyInvoicingFormDraftFailure(draft.editDraftById, action.payload.id, initialInvoicingSubscriptionFormLocalData);
|
|
68
70
|
},
|
|
69
|
-
/**
|
|
70
|
-
* Seed the draft from the loaded record, once. Skipped when a draft already
|
|
71
|
-
* exists so a late refetch cannot overwrite in-progress edits.
|
|
72
|
-
*/
|
|
71
|
+
/** Fill the draft from the loaded record — see `applyInvoicingFormDraftSeed`. */
|
|
73
72
|
seedInvoicingSubscriptionFormDraft(draft, action) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
73
|
+
const { id, localData } = action.payload;
|
|
74
|
+
applyInvoicingFormDraftSeed(draft.editDraftById, id, localData);
|
|
77
75
|
},
|
|
78
76
|
fetchInvoicingSubscriptionFormPage: {
|
|
79
77
|
reducer() {
|
|
@@ -87,7 +85,7 @@ const editInvoicingSubscriptionDetailView = createSlice({
|
|
|
87
85
|
updateInvoicingSubscriptionFormDraft(draft, action) {
|
|
88
86
|
const { id, localData } = action.payload;
|
|
89
87
|
if (id != null) {
|
|
90
|
-
draft.editDraftById
|
|
88
|
+
applyInvoicingFormDraftEdit(draft.editDraftById, id, localData);
|
|
91
89
|
}
|
|
92
90
|
else {
|
|
93
91
|
draft.newSubscriptionDraft = localData;
|
|
@@ -107,19 +105,32 @@ const editInvoicingSubscriptionDetailView = createSlice({
|
|
|
107
105
|
draft.fetchState = 'Completed';
|
|
108
106
|
draft.error = undefined;
|
|
109
107
|
draft.savedSubscriptionId = action.payload.subscriptionId;
|
|
108
|
+
// An edit is refetched on success; keep the saved values on screen until
|
|
109
|
+
// that lands, and let it replace them.
|
|
110
|
+
applyInvoicingFormDraftSaved(draft.editDraftById, action.payload.subscriptionId);
|
|
110
111
|
},
|
|
111
112
|
submitInvoicingSubscriptionFormFailure(draft, action) {
|
|
112
113
|
draft.fetchState = 'Error';
|
|
113
114
|
draft.error = action.payload;
|
|
114
115
|
},
|
|
115
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Discard a form's draft — the subscription's own when `id` is given,
|
|
118
|
+
* the create draft otherwise. Scoped to the one form on purpose: another
|
|
119
|
+
* subscription's half-finished edit is not this form's to throw away.
|
|
120
|
+
* Clearing every draft at once is what `clearAll` is for.
|
|
121
|
+
*/
|
|
122
|
+
resetEditInvoicingSubscriptionDetailView(draft, action) {
|
|
116
123
|
draft.fetchState = 'Not-Started';
|
|
117
124
|
draft.error = undefined;
|
|
118
125
|
draft.savedSubscriptionId = undefined;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
const id = action.payload?.id;
|
|
127
|
+
if (id == null) {
|
|
128
|
+
draft.newSubscriptionDraft = {
|
|
129
|
+
...initialInvoicingSubscriptionFormLocalData,
|
|
130
|
+
};
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
delete draft.editDraftById[id];
|
|
123
134
|
},
|
|
124
135
|
// Trigger only — handled by initializeInvoicingSubscriptionAddressEpic.
|
|
125
136
|
initializeInvoicingSubscriptionAddress: {
|
|
@@ -5,6 +5,7 @@ import { getInvoicingCouponListItems } from '../couponView/couponViewSelector';
|
|
|
5
5
|
import { getInvoicingCatalogListView, getInvoicingCatalogPrices, } from '../invoicingCatalogListView/invoicingCatalogListViewSelector';
|
|
6
6
|
import { getInvoicingConfigView, invoicingFieldHelpForGroup, } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
7
7
|
import { getInvoicingCustomerListView } from '../invoicingCustomerListView/invoicingCustomerListViewSelector';
|
|
8
|
+
import { getInvoicingFormDraftLocalData, isInvoicingFormDraftPending, } from '../invoicingFormDraft';
|
|
8
9
|
import { initialInvoicingSubscriptionFormLocalData } from './invoicingSubscriptionFormConfig';
|
|
9
10
|
import { INVOICING_SUBSCRIPTION_SHIPPING_ADDRESS_TYPE } from './invoicingSubscriptionFormConfig';
|
|
10
11
|
export const getEditInvoicingSubscriptionDetailViewState = (state, invoicingSubscriptionID) => {
|
|
@@ -33,8 +34,7 @@ export const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID)
|
|
|
33
34
|
// `seedInvoicingSubscriptionFormDraftEpic` when the detail load lands. Until
|
|
34
35
|
// then the page is showing its skeleton.
|
|
35
36
|
const localData = invoicingSubscriptionID != null
|
|
36
|
-
? (editDraftById
|
|
37
|
-
initialInvoicingSubscriptionFormLocalData)
|
|
37
|
+
? getInvoicingFormDraftLocalData(editDraftById, invoicingSubscriptionID, initialInvoicingSubscriptionFormLocalData)
|
|
38
38
|
: newSubscriptionDraft;
|
|
39
39
|
// Shipping address is captured via the shared Address screen and seeded there
|
|
40
40
|
// (looked up in the shared address store by `shippingAddressId`) on detail
|
|
@@ -65,6 +65,7 @@ export const getInvoicingSubscriptionFormView = (state, invoicingSubscriptionID)
|
|
|
65
65
|
subscriptionLifecycleActionOptions: configState.subscriptionLifecycleActionOptions,
|
|
66
66
|
subscriptionMetadataEditAllowedFromStatuses: configState.subscriptionMetadataEditAllowedFromStatuses,
|
|
67
67
|
recordState,
|
|
68
|
+
isFormLoading: isInvoicingFormDraftPending(editDraftById, invoicingSubscriptionID),
|
|
68
69
|
fieldHelp: invoicingFieldHelpForGroup(state, 'subscription'),
|
|
69
70
|
coupons: getInvoicingCouponListItems(state),
|
|
70
71
|
customers: getInvoicingCustomerListView(state).customers,
|
|
@@ -16,8 +16,11 @@ export const fetchInvoicingSubscriptionFormPageEpic = (actions$) => actions$.pip
|
|
|
16
16
|
const { subscriptionId } = action.payload;
|
|
17
17
|
const pageActions = [
|
|
18
18
|
fetchInvoicingCustomerList({ filters: {}, keepExistingListItems: false }),
|
|
19
|
+
// Plans only: the form's plan picker is the one consumer, and an
|
|
20
|
+
// unfiltered list would replace the store's plans with every catalog
|
|
21
|
+
// item.
|
|
19
22
|
fetchInvoicingCatalogPlanList({
|
|
20
|
-
filters: {},
|
|
23
|
+
filters: { type: 'plan' },
|
|
21
24
|
keepExistingListItems: false,
|
|
22
25
|
}),
|
|
23
26
|
fetchInvoicingCouponList({ filters: {}, keepExistingListItems: false }),
|
package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/saveInvoicingSubscriptionEpic.js
CHANGED
|
@@ -17,7 +17,7 @@ export const saveInvoicingSubscriptionEpic = (actions$, state$, zeniAPI) => acti
|
|
|
17
17
|
const rootState = state$.value;
|
|
18
18
|
const viewState = rootState.editInvoicingSubscriptionDetailViewState;
|
|
19
19
|
const localData = (id != null
|
|
20
|
-
? viewState.editDraftById[id]
|
|
20
|
+
? viewState.editDraftById[id]?.localData
|
|
21
21
|
: viewState.newSubscriptionDraft) ?? viewState.newSubscriptionDraft;
|
|
22
22
|
// Shipping address captured via the shared Address screen is sent as an
|
|
23
23
|
// object in the payload (same pattern as the customer save flow).
|