@zeniai/client-epic-state 5.2.50 → 5.2.51

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.
Files changed (39) hide show
  1. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +45 -21
  2. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +4 -1
  3. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +16 -3
  4. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
  5. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +4 -1
  6. package/lib/esm/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
  7. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
  8. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
  9. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +43 -17
  10. package/lib/esm/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
  11. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
  12. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
  13. package/lib/esm/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +44 -18
  14. package/lib/esm/view/invoicing/invoicingFormDraft.js +13 -0
  15. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +22 -6
  16. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +47 -22
  17. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewReducer.js +3 -0
  18. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +14 -1
  19. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/seedInvoicingCatalogItemFormDraftEpic.js +6 -2
  20. package/lib/view/invoicing/editInvoicingCouponDetailView/editInvoicingCouponDetailViewReducer.js +3 -0
  21. package/lib/view/invoicing/editInvoicingCouponDetailView/seedInvoicingCouponFormDraftEpic.js +6 -2
  22. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.d.ts +3 -1
  23. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer.js +10 -2
  24. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.d.ts +7 -7
  25. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewSelector.js +33 -0
  26. package/lib/view/invoicing/editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewState.d.ts +6 -0
  27. package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.d.ts +15 -10
  28. package/lib/view/invoicing/editInvoicingCustomerDetailView/initializeInvoicingCustomerAddressEpic.js +42 -16
  29. package/lib/view/invoicing/editInvoicingCustomerDetailView/seedInvoicingCustomerFormDraftEpic.js +6 -2
  30. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.d.ts +3 -1
  31. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewReducer.js +10 -2
  32. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.d.ts +7 -0
  33. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewSelector.js +34 -0
  34. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/editInvoicingSubscriptionDetailViewState.d.ts +6 -0
  35. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.d.ts +15 -11
  36. package/lib/view/invoicing/editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddressEpic.js +42 -16
  37. package/lib/view/invoicing/invoicingFormDraft.d.ts +10 -1
  38. package/lib/view/invoicing/invoicingFormDraft.js +14 -0
  39. package/package.json +1 -1
@@ -7,10 +7,8 @@ import { InvoicingCatalogItemFormLocalData } from './editInvoicingCatalogItemDet
7
7
  export type SaveInvoicingCatalogItemResponse = ZeniAPIResponse<InvoicingPlanPayload>;
8
8
  /**
9
9
  * The price-point half of a save body. `InvoicingProductPayload` is the shape
10
- * the service returns; a save differs in two ways: a field is cleared by
11
- * sending an explicit `null` (an absent key reads as "leave it alone"), and a
12
- * price point the form has only just added carries a blank `id`, which the
13
- * update endpoint reads as "create this one".
10
+ * the service returns; a save differs in that a field is cleared by sending an
11
+ * explicit `null`, since an absent key reads as "leave it alone".
14
12
  */
15
13
  export type InvoicingCatalogSubFamilySavePayload = Omit<Partial<InvoicingProductPayload>, 'accounting_detail' | 'description' | 'invoice_notes'> & {
16
14
  accounting_detail?: InvoicingAccountingDetailPayload | null;
@@ -19,8 +17,13 @@ export type InvoicingCatalogSubFamilySavePayload = Omit<Partial<InvoicingProduct
19
17
  };
20
18
  /**
21
19
  * The catalog-item save body: the item the service returns, minus the fields it
22
- * assigns itself. Price points keep the `sub_families` name they are read back
23
- * under, and differ only in allowing the cleared and blank-id forms above.
20
+ * assigns itself.
21
+ *
22
+ * Price points travel under `sub_families`, the name they are read back under,
23
+ * and differ only in allowing the cleared forms above. An update addresses them
24
+ * by id, so a price point added on the form — which has none yet — is created
25
+ * by its own request instead; see
26
+ * `localDataToCreateInvoicingCatalogProductPayloads`.
24
27
  */
25
28
  export type InvoicingCatalogItemSavePayload = Omit<Partial<InvoicingPlanPayload>, 'sub_families'> & {
26
29
  sub_families?: InvoicingCatalogSubFamilySavePayload[];
@@ -51,6 +54,19 @@ export declare const buildAccountingDetail: (subFamily: InvoicingCatalogAccounti
51
54
  * edit cannot overwrite them with a value nobody chose.
52
55
  */
53
56
  export declare const localDataToSaveInvoicingCatalogItemPayload: (localData: InvoicingCatalogItemFormLocalData, isCreate: boolean, lookup: InvoicingCatalogAccountingLookup) => InvoicingCatalogItemSavePayload;
57
+ /**
58
+ * The bodies that create the price points added on an edit form, one per
59
+ * request to `/catalog/products`.
60
+ *
61
+ * An update cannot carry them: it addresses price points by id, and these have
62
+ * none until the service assigns one. They are bound to their item by
63
+ * `item_id`, so this needs the saved item's id and runs after the item itself
64
+ * is saved.
65
+ *
66
+ * Empty values are left off rather than sent as `null`: there is nothing on a
67
+ * price point that does not exist yet to clear.
68
+ */
69
+ export declare const localDataToCreateInvoicingCatalogProductPayloads: (localData: InvoicingCatalogItemFormLocalData, itemId: string, lookup: InvoicingCatalogAccountingLookup) => InvoicingCatalogSubFamilySavePayload[];
54
70
  export type RunInvoicingCatalogPlanActionResponse = ZeniAPIResponse<InvoicingPlanPayload>;
55
71
  export type RunInvoicingCatalogProductActionResponse = ZeniAPIResponse<InvoicingProductPayload>;
56
72
  export type InvoicingCatalogItemDetailResponse = ZeniAPIResponse<InvoicingPlanPayload>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localDataToSaveInvoicingCatalogItemPayload = exports.buildAccountingDetail = void 0;
3
+ exports.localDataToCreateInvoicingCatalogProductPayloads = exports.localDataToSaveInvoicingCatalogItemPayload = exports.buildAccountingDetail = void 0;
4
4
  const accountPayload_1 = require("../../../entity/account/accountPayload");
5
5
  const classPayload_1 = require("../../../entity/class/classPayload");
6
6
  const invoicingCatalogItemFormHelper_1 = require("./invoicingCatalogItemFormHelper");
@@ -134,27 +134,52 @@ const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate, lookup)
134
134
  const subFamilies = localData.subFamilies.length > 0
135
135
  ? localData.subFamilies
136
136
  : [(0, invoicingCatalogItemFormHelper_1.blankInvoicingCatalogSubFamily)()];
137
- itemPayload.sub_families = isCreate
138
- ? subFamilies.map((subFamily) => buildSubFamilyPayload(localData, subFamily, false, lookup))
139
- : subFamilies.map((subFamily) => {
140
- // Edits send the same body a create does. The narrower hand-built one
141
- // this replaces had to be kept in step by hand and was not: it dropped
142
- // `accounting_detail` once, and `billing_cycles`, `price`,
143
- // `pricing_model`, `period`, the trial fields, `proration_type`,
144
- // `free_quantity`, `is_taxable` and `tiers` were never added at all, so
145
- // editing any of them looked saved and changed nothing.
146
- const detail = buildSubFamilyPayload(localData, subFamily, true, lookup);
147
- // `null` rather than omitted when empty: an absent key on an update
148
- // reads as "leave it alone", which would make a cleared mapping
149
- // impossible to save — the same reason `description` and
150
- // `invoice_notes` are cleared rather than dropped above.
151
- detail.accounting_detail = detail.accounting_detail ?? null;
152
- // A price point added on this form has no id yet, and travels with a
153
- // blank one. The update endpoint reads that as "create this one", so it
154
- // lands in the same request as the edits around it rather than a second
155
- // call that could fail on its own.
156
- return { ...detail, id: subFamily.id.trim() };
157
- });
137
+ if (isCreate) {
138
+ itemPayload.sub_families = subFamilies.map((subFamily) => buildSubFamilyPayload(localData, subFamily, false, lookup));
139
+ return itemPayload;
140
+ }
141
+ // Only price points the service has already stored travel in an update: it
142
+ // addresses them by id, and a blank one has nothing to address. A price point
143
+ // added on the form is created by its own request once the item is saved,
144
+ // rather than riding along as a row the update cannot place.
145
+ itemPayload.sub_families = subFamilies
146
+ .filter((subFamily) => subFamily.id !== '')
147
+ .map((subFamily) => {
148
+ // Edits send the same body a create does. The narrower hand-built one
149
+ // this replaces had to be kept in step by hand and was not: it dropped
150
+ // `accounting_detail` once, and `billing_cycles`, `price`,
151
+ // `pricing_model`, `period`, the trial fields, `proration_type`,
152
+ // `free_quantity`, `is_taxable` and `tiers` were never added at all, so
153
+ // editing any of them looked saved and changed nothing.
154
+ const detail = buildSubFamilyPayload(localData, subFamily, true, lookup);
155
+ // `null` rather than omitted when empty: an absent key on an update
156
+ // reads as "leave it alone", which would make a cleared mapping
157
+ // impossible to save — the same reason `description` and
158
+ // `invoice_notes` are cleared rather than dropped above.
159
+ detail.accounting_detail = detail.accounting_detail ?? null;
160
+ // Never blank: the filter above leaves only price points the service has
161
+ // already stored, which is the only kind an update can address.
162
+ return { ...detail, id: subFamily.id };
163
+ });
158
164
  return itemPayload;
159
165
  };
160
166
  exports.localDataToSaveInvoicingCatalogItemPayload = localDataToSaveInvoicingCatalogItemPayload;
167
+ /**
168
+ * The bodies that create the price points added on an edit form, one per
169
+ * request to `/catalog/products`.
170
+ *
171
+ * An update cannot carry them: it addresses price points by id, and these have
172
+ * none until the service assigns one. They are bound to their item by
173
+ * `item_id`, so this needs the saved item's id and runs after the item itself
174
+ * is saved.
175
+ *
176
+ * Empty values are left off rather than sent as `null`: there is nothing on a
177
+ * price point that does not exist yet to clear.
178
+ */
179
+ const localDataToCreateInvoicingCatalogProductPayloads = (localData, itemId, lookup) => localData.subFamilies
180
+ .filter((subFamily) => subFamily.id === '')
181
+ .map((subFamily) => ({
182
+ ...buildSubFamilyPayload(localData, subFamily, false, lookup),
183
+ item_id: itemId,
184
+ }));
185
+ exports.localDataToCreateInvoicingCatalogProductPayloads = localDataToCreateInvoicingCatalogProductPayloads;
@@ -47,6 +47,9 @@ const editInvoicingCatalogItemDetailView = (0, toolkit_1.createSlice)({
47
47
  draft.error = undefined;
48
48
  draft.savedItemId = action.payload.itemId;
49
49
  draft.savedKind = action.payload.kind;
50
+ // An edit is refetched on success; keep the saved values on screen until
51
+ // that lands, and let it replace them.
52
+ (0, invoicingFormDraft_1.applyInvoicingFormDraftSaved)(draft.editDraftById, action.payload.itemId);
50
53
  },
51
54
  submitInvoicingCatalogItemFormFailure(draft, action) {
52
55
  draft.fetchState = 'Error';
@@ -84,7 +84,20 @@ const saveInvoicingCatalogItemEpic = (actions$, state$, zeniAPI) => actions$.pip
84
84
  }));
85
85
  return resultActions;
86
86
  };
87
- return completeSave([]);
87
+ // Price points added on an edit form cannot ride in the update:
88
+ // it addresses them by id and they have none yet. They are created
89
+ // against the item that was just saved, and their responses join
90
+ // the same success — one of them failing is the whole save
91
+ // failing, since the item on screen would otherwise claim price
92
+ // points the service never stored. A create needs none of this:
93
+ // its price points are nested in the item body.
94
+ const newProductPayloads = id != null
95
+ ? (0, editInvoicingCatalogItemDetailViewPayload_1.localDataToCreateInvoicingCatalogProductPayloads)(localData, savedItem.id, accountingLookup)
96
+ : [];
97
+ if (newProductPayloads.length === 0) {
98
+ return completeSave([]);
99
+ }
100
+ return (0, rxjs_1.forkJoin)(newProductPayloads.map((productPayload) => zeniAPI.postAndGetJSON(`${baseUrl}/catalog/products`, productPayload))).pipe((0, operators_1.mergeMap)((productResponses) => completeSave(productResponses)));
88
101
  }
89
102
  return (0, rxjs_1.from)([
90
103
  (0, editInvoicingCatalogItemDetailViewReducer_1.submitInvoicingCatalogItemFormFailure)(response.status),
@@ -26,9 +26,13 @@ const seedInvoicingCatalogItemFormDraftEpic = (actions$, state$) => actions$.pip
26
26
  // endpoints merge their own list-shaped rows into the same store. Only a
27
27
  // completed detail load does, which is also exactly when the page's
28
28
  // cache-guarded fetch issues no request and this is the sole seed.
29
+ // A forced refetch is the caller asking for fresh data: the response will
30
+ // seed, and seeding first from the entity as it stands would mark the
31
+ // draft loaded and lock that response out.
29
32
  if (editInvoicingCatalogItemDetailViewReducer_1.fetchInvoicingCatalogItemDetailPage.match(action) &&
30
- state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
31
- ?.fetchState !== 'Completed') {
33
+ (action.payload.cacheOverride === true ||
34
+ state.editInvoicingCatalogItemDetailViewState.recordStateById[id]
35
+ ?.fetchState !== 'Completed')) {
32
36
  return rxjs_1.EMPTY;
33
37
  }
34
38
  // Nothing to seed from on a cold open; the detail response triggers this
@@ -55,6 +55,9 @@ const editInvoicingCouponDetailView = (0, toolkit_1.createSlice)({
55
55
  draft.fetchState = 'Completed';
56
56
  draft.error = undefined;
57
57
  draft.savedCouponId = action.payload.couponId;
58
+ // An edit is refetched on success; keep the saved values on screen until
59
+ // that lands, and let it replace them.
60
+ (0, invoicingFormDraft_1.applyInvoicingFormDraftSaved)(draft.editDraftById, action.payload.couponId);
58
61
  },
59
62
  submitInvoicingCouponFormFailure(draft, action) {
60
63
  draft.fetchState = 'Error';
@@ -26,9 +26,13 @@ const seedInvoicingCouponFormDraftEpic = (actions$, state$) => actions$.pipe((0,
26
26
  // endpoints merge their own list-shaped rows into the same store. Only a
27
27
  // completed detail load does, which is also exactly when the page's
28
28
  // cache-guarded fetch issues no request and this is the sole seed.
29
+ // A forced refetch is the caller asking for fresh data: the response will
30
+ // seed, and seeding first from the entity as it stands would mark the
31
+ // draft loaded and lock that response out.
29
32
  if (editInvoicingCouponDetailViewReducer_1.fetchInvoicingCouponDetailPage.match(action) &&
30
- state.editInvoicingCouponDetailViewState.recordStateById[id]
31
- ?.fetchState !== 'Completed') {
33
+ (action.payload.cacheOverride === true ||
34
+ state.editInvoicingCouponDetailViewState.recordStateById[id]
35
+ ?.fetchState !== 'Completed')) {
32
36
  return rxjs_1.EMPTY;
33
37
  }
34
38
  // Nothing to seed from on a cold open; the detail response triggers this
@@ -56,6 +56,8 @@ export declare const fetchInvoicingPaymentLinkEmailPreview: import("@reduxjs/too
56
56
  customerId: ID;
57
57
  }, "editInvoicingCustomerDetailView/submitInvoicingCustomerFormSuccess">, submitInvoicingCustomerFormFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "editInvoicingCustomerDetailView/submitInvoicingCustomerFormFailure">, resetEditInvoicingCustomerDetailView: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{
58
58
  id?: ID;
59
- } | undefined, "editInvoicingCustomerDetailView/resetEditInvoicingCustomerDetailView">, initializeInvoicingCustomerAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingCustomerAddressPayload], InitializeInvoicingCustomerAddressPayload, "editInvoicingCustomerDetailView/initializeInvoicingCustomerAddress", never, never>;
59
+ } | undefined, "editInvoicingCustomerDetailView/resetEditInvoicingCustomerDetailView">, initializeInvoicingCustomerAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingCustomerAddressPayload], InitializeInvoicingCustomerAddressPayload, "editInvoicingCustomerDetailView/initializeInvoicingCustomerAddress", never, never>, claimInvoicingCustomerBillingAddress: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
60
+ id: ID;
61
+ }, "editInvoicingCustomerDetailView/claimInvoicingCustomerBillingAddress">;
60
62
  declare const _default: import("redux").Reducer<EditInvoicingCustomerDetailViewState>;
61
63
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.initializeInvoicingCustomerAddress = exports.resetEditInvoicingCustomerDetailView = exports.submitInvoicingCustomerFormFailure = exports.submitInvoicingCustomerFormSuccess = exports.submitInvoicingCustomerForm = exports.updateInvoicingCustomerFormDraft = exports.updateInvoicingCustomerDetailFailure = exports.submitAddPromotionalCredits = exports.resetPromotionalCreditAction = exports.updateInvoicingCustomerDetail = exports.seedInvoicingCustomerFormDraft = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.addPromotionalCreditsSuccess = exports.addPromotionalCreditsFailure = exports.updateInvoicingPaymentLinkEmailPreviewFailure = exports.updateInvoicingPaymentLinkEmailPreview = exports.fetchInvoicingPaymentLinkEmailPreviewPage = exports.fetchInvoicingPaymentLinkEmailPreview = exports.initialState = void 0;
4
+ exports.claimInvoicingCustomerBillingAddress = exports.initializeInvoicingCustomerAddress = exports.resetEditInvoicingCustomerDetailView = exports.submitInvoicingCustomerFormFailure = exports.submitInvoicingCustomerFormSuccess = exports.submitInvoicingCustomerForm = exports.updateInvoicingCustomerFormDraft = exports.updateInvoicingCustomerDetailFailure = exports.submitAddPromotionalCredits = exports.resetPromotionalCreditAction = exports.updateInvoicingCustomerDetail = exports.seedInvoicingCustomerFormDraft = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.addPromotionalCreditsSuccess = exports.addPromotionalCreditsFailure = exports.updateInvoicingPaymentLinkEmailPreviewFailure = exports.updateInvoicingPaymentLinkEmailPreview = exports.fetchInvoicingPaymentLinkEmailPreviewPage = exports.fetchInvoicingPaymentLinkEmailPreview = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const rootActions_1 = require("../../../rootActions");
7
7
  const invoicingFormDraft_1 = require("../invoicingFormDraft");
@@ -12,6 +12,7 @@ exports.initialState = {
12
12
  emailPreviewCustomerId: undefined,
13
13
  promotionalCreditSubmitState: { fetchState: 'Not-Started', error: undefined },
14
14
  recordStateById: {},
15
+ billingAddressOwnerId: undefined,
15
16
  fetchState: 'Not-Started',
16
17
  error: undefined,
17
18
  editDraftById: {},
@@ -158,6 +159,9 @@ const editInvoicingCustomerDetailView = (0, toolkit_1.createSlice)({
158
159
  draft.fetchState = 'Completed';
159
160
  draft.error = undefined;
160
161
  draft.savedCustomerId = action.payload.customerId;
162
+ // An edit is refetched on success; keep the saved values on screen until
163
+ // that lands, and let it replace them.
164
+ (0, invoicingFormDraft_1.applyInvoicingFormDraftSaved)(draft.editDraftById, action.payload.customerId);
161
165
  },
162
166
  submitInvoicingCustomerFormFailure(draft, action) {
163
167
  draft.fetchState = 'Error';
@@ -187,6 +191,10 @@ const editInvoicingCustomerDetailView = (0, toolkit_1.createSlice)({
187
191
  return { payload };
188
192
  },
189
193
  },
194
+ /** Record which customer the shared billing-address slot now belongs to. */
195
+ claimInvoicingCustomerBillingAddress(draft, action) {
196
+ draft.billingAddressOwnerId = action.payload.id;
197
+ },
190
198
  },
191
199
  extraReducers: (builder) => {
192
200
  builder.addCase(rootActions_1.clearAll, (draft) => {
@@ -194,5 +202,5 @@ const editInvoicingCustomerDetailView = (0, toolkit_1.createSlice)({
194
202
  });
195
203
  },
196
204
  });
197
- _a = editInvoicingCustomerDetailView.actions, exports.fetchInvoicingPaymentLinkEmailPreview = _a.fetchInvoicingPaymentLinkEmailPreview, exports.fetchInvoicingPaymentLinkEmailPreviewPage = _a.fetchInvoicingPaymentLinkEmailPreviewPage, exports.updateInvoicingPaymentLinkEmailPreview = _a.updateInvoicingPaymentLinkEmailPreview, exports.updateInvoicingPaymentLinkEmailPreviewFailure = _a.updateInvoicingPaymentLinkEmailPreviewFailure, exports.addPromotionalCreditsFailure = _a.addPromotionalCreditsFailure, exports.addPromotionalCreditsSuccess = _a.addPromotionalCreditsSuccess, exports.fetchInvoicingCustomerDetail = _a.fetchInvoicingCustomerDetail, exports.fetchInvoicingCustomerDetailPage = _a.fetchInvoicingCustomerDetailPage, exports.seedInvoicingCustomerFormDraft = _a.seedInvoicingCustomerFormDraft, exports.updateInvoicingCustomerDetail = _a.updateInvoicingCustomerDetail, exports.resetPromotionalCreditAction = _a.resetPromotionalCreditAction, exports.submitAddPromotionalCredits = _a.submitAddPromotionalCredits, exports.updateInvoicingCustomerDetailFailure = _a.updateInvoicingCustomerDetailFailure, exports.updateInvoicingCustomerFormDraft = _a.updateInvoicingCustomerFormDraft, exports.submitInvoicingCustomerForm = _a.submitInvoicingCustomerForm, exports.submitInvoicingCustomerFormSuccess = _a.submitInvoicingCustomerFormSuccess, exports.submitInvoicingCustomerFormFailure = _a.submitInvoicingCustomerFormFailure, exports.resetEditInvoicingCustomerDetailView = _a.resetEditInvoicingCustomerDetailView, exports.initializeInvoicingCustomerAddress = _a.initializeInvoicingCustomerAddress;
205
+ _a = editInvoicingCustomerDetailView.actions, exports.fetchInvoicingPaymentLinkEmailPreview = _a.fetchInvoicingPaymentLinkEmailPreview, exports.fetchInvoicingPaymentLinkEmailPreviewPage = _a.fetchInvoicingPaymentLinkEmailPreviewPage, exports.updateInvoicingPaymentLinkEmailPreview = _a.updateInvoicingPaymentLinkEmailPreview, exports.updateInvoicingPaymentLinkEmailPreviewFailure = _a.updateInvoicingPaymentLinkEmailPreviewFailure, exports.addPromotionalCreditsFailure = _a.addPromotionalCreditsFailure, exports.addPromotionalCreditsSuccess = _a.addPromotionalCreditsSuccess, exports.fetchInvoicingCustomerDetail = _a.fetchInvoicingCustomerDetail, exports.fetchInvoicingCustomerDetailPage = _a.fetchInvoicingCustomerDetailPage, exports.seedInvoicingCustomerFormDraft = _a.seedInvoicingCustomerFormDraft, exports.updateInvoicingCustomerDetail = _a.updateInvoicingCustomerDetail, exports.resetPromotionalCreditAction = _a.resetPromotionalCreditAction, exports.submitAddPromotionalCredits = _a.submitAddPromotionalCredits, exports.updateInvoicingCustomerDetailFailure = _a.updateInvoicingCustomerDetailFailure, exports.updateInvoicingCustomerFormDraft = _a.updateInvoicingCustomerFormDraft, exports.submitInvoicingCustomerForm = _a.submitInvoicingCustomerForm, exports.submitInvoicingCustomerFormSuccess = _a.submitInvoicingCustomerFormSuccess, exports.submitInvoicingCustomerFormFailure = _a.submitInvoicingCustomerFormFailure, exports.resetEditInvoicingCustomerDetailView = _a.resetEditInvoicingCustomerDetailView, exports.initializeInvoicingCustomerAddress = _a.initializeInvoicingCustomerAddress, exports.claimInvoicingCustomerBillingAddress = _a.claimInvoicingCustomerBillingAddress;
198
206
  exports.default = editInvoicingCustomerDetailView.reducer;
@@ -86,13 +86,13 @@ export interface InvoicingCustomerFormView extends SelectorView {
86
86
  billingAddressId?: ID;
87
87
  billingAddressLabel?: string;
88
88
  emailPreview?: InvoicingPaymentLinkEmailPreviewData;
89
+ /**
90
+ * A billing address entered on the Address screen that the customer has not
91
+ * saved yet. The inline-edit form cannot see it — the address lives in the
92
+ * shared address store, not in a field — so the detail page reads this to
93
+ * offer Save, or the address could never be linked.
94
+ */
95
+ hasUnsavedBillingAddress?: boolean;
89
96
  savedCustomerId?: ID;
90
97
  }
91
- /**
92
- * Bundled view for the customer create/edit form. Exposes the draft `localData`
93
- * (seeded from the existing customer entity in edit mode until the user edits),
94
- * the canonical option value sets (labels resolved in web-components), the save
95
- * fetch state/error, and the id of the customer last saved — so the form screen
96
- * depends on this single selector.
97
- */
98
98
  export declare const getInvoicingCustomerFormView: (state: RootState, invoicingCustomerID?: ID) => InvoicingCustomerFormView;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingCustomerFormView = exports.getInvoicingCustomerRecord = void 0;
4
4
  const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
5
+ const addressSelector_1 = require("../../../entity/address/addressSelector");
5
6
  const invoiceSelector_1 = require("../../../entity/invoicing/invoice/invoiceSelector");
6
7
  const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
7
8
  const invoicingCustomerSelector_2 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
@@ -54,6 +55,37 @@ exports.getInvoicingCustomerRecord = getInvoicingCustomerRecord;
54
55
  * fetch state/error, and the id of the customer last saved — so the form screen
55
56
  * depends on this single selector.
56
57
  */
58
+ /**
59
+ * Whether the billing address entered on the Address screen is a change the
60
+ * customer has not saved. Presence alone cannot say so: the detail page seeds
61
+ * the address store with the saved address on load so the Address screen opens
62
+ * prefilled. Only a pending address that differs from the saved one — or one
63
+ * where nothing is saved yet — is an unsaved change. Compared on what the user
64
+ * enters; a saved address's coordinates and timestamps are left out.
65
+ */
66
+ const isBillingAddressUnsaved = (state, id, savedBillingAddressId) => {
67
+ // The slot is keyed by address type alone; only a draft this customer owns counts.
68
+ if (id == null ||
69
+ state.editInvoicingCustomerDetailViewState.billingAddressOwnerId !== id) {
70
+ return false;
71
+ }
72
+ const pending = state.addressViewState.newAddressState?.[invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
73
+ if (pending == null) {
74
+ return false;
75
+ }
76
+ const saved = savedBillingAddressId != null
77
+ ? (0, addressSelector_1.getAddressByAddressId)(state.addressState, savedBillingAddressId)
78
+ : undefined;
79
+ if (saved == null) {
80
+ return true;
81
+ }
82
+ return !(pending.street.join('\u0000') === saved.street.join('\u0000') &&
83
+ pending.city === saved.city &&
84
+ pending.state === saved.state &&
85
+ pending.postalCode === saved.postalCode &&
86
+ pending.country === saved.country &&
87
+ (pending.countryCode ?? '') === (saved.countryCode ?? ''));
88
+ };
57
89
  const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
58
90
  const { editDraftById, error, fetchState, newCustomerDraft, savedCustomerId } = state.editInvoicingCustomerDetailViewState;
59
91
  const mode = invoicingCustomerID != null ? 'edit' : 'create';
@@ -105,6 +137,7 @@ const getInvoicingCustomerFormView = (state, invoicingCustomerID) => {
105
137
  taxabilityOptions,
106
138
  billingAddressId,
107
139
  billingAddressLabel,
140
+ hasUnsavedBillingAddress: isBillingAddressUnsaved(state, invoicingCustomerID, customer?.billingAddressId),
108
141
  savedCustomerId,
109
142
  fetchState,
110
143
  error,
@@ -53,6 +53,12 @@ export interface EditInvoicingCustomerDetailViewState extends FetchedState {
53
53
  promotionalCreditSubmitState: FetchStateAndError;
54
54
  /** Detail-load state per customer id. */
55
55
  recordStateById: Record<ID, FetchStateAndError>;
56
+ /**
57
+ * The customer whose billing address currently occupies the shared address
58
+ * store slot. That slot is keyed by address type alone, so without this a
59
+ * draft seeded or edited for one customer would pass for the next one's.
60
+ */
61
+ billingAddressOwnerId?: ID;
56
62
  emailPreview?: InvoicingPaymentLinkEmailPreviewData;
57
63
  emailPreviewCustomerId?: ID;
58
64
  savedCustomerId?: ID;
@@ -1,16 +1,21 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
3
  import { RootState } from '../../../rootStateTypes';
4
- import { newAddressInLocalStore } from '../../addressView/addressViewReducer';
5
- import { updateInvoicingCustomerDetail } from '../editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer';
6
- import { initializeInvoicingCustomerAddress } from './editInvoicingCustomerDetailViewReducer';
7
- export type ActionType = ReturnType<typeof initializeInvoicingCustomerAddress> | ReturnType<typeof updateInvoicingCustomerDetail> | ReturnType<typeof newAddressInLocalStore>;
4
+ import { newAddressInLocalStore, removeNewAddressDataInLocalStore } from '../../addressView/addressViewReducer';
5
+ import { claimInvoicingCustomerBillingAddress, fetchInvoicingCustomerDetail, fetchInvoicingCustomerDetailPage, initializeInvoicingCustomerAddress, updateInvoicingCustomerDetail } from './editInvoicingCustomerDetailViewReducer';
6
+ export type ActionType = ReturnType<typeof initializeInvoicingCustomerAddress> | ReturnType<typeof updateInvoicingCustomerDetail> | ReturnType<typeof fetchInvoicingCustomerDetailPage> | ReturnType<typeof fetchInvoicingCustomerDetail> | ReturnType<typeof claimInvoicingCustomerBillingAddress> | ReturnType<typeof newAddressInLocalStore> | ReturnType<typeof removeNewAddressDataInLocalStore>;
8
7
  /**
9
- * Seed the shared Address screen with an existing customer's saved billing
10
- * address (looked up in the address entity store by `billingAddressId`). Runs
11
- * both when the customer detail loads and on an explicit initialize trigger.
12
- * Skips when an in-progress draft already exists, so an address the user just
13
- * entered survives navigating between the form and the Address screen. Mirrors
14
- * `initializeVendorAddressEpic`.
8
+ * Seed the shared Address screen with the customer's saved billing address, and
9
+ * record that the slot is this customer's. Runs when a detail request is issued
10
+ * (every path that loads a record issues one — the detail page when not cached,
11
+ * the create/edit form always), when the page opens, when the detail load
12
+ * lands, and on an explicit initialize trigger.
13
+ *
14
+ * The address store slot is keyed by address type alone, so it can still hold
15
+ * another customer's draft. Only a draft this customer owns is left alone —
16
+ * that is what lets an address the user just entered survive a trip to the
17
+ * Address screen. Anything else is replaced by this customer's saved address,
18
+ * or cleared when it has none. Opening the page counts as a trigger because a
19
+ * record already loaded this session issues no detail request at all.
15
20
  */
16
21
  export declare const initializeInvoicingCustomerAddressEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -6,34 +6,60 @@ const operators_1 = require("rxjs/operators");
6
6
  const addressSelector_1 = require("../../../entity/address/addressSelector");
7
7
  const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
8
8
  const addressViewReducer_1 = require("../../addressView/addressViewReducer");
9
- const editInvoicingCustomerDetailViewReducer_1 = require("../editInvoicingCustomerDetailView/editInvoicingCustomerDetailViewReducer");
10
- const editInvoicingCustomerDetailViewReducer_2 = require("./editInvoicingCustomerDetailViewReducer");
9
+ const editInvoicingCustomerDetailViewReducer_1 = require("./editInvoicingCustomerDetailViewReducer");
11
10
  const invoicingCustomerFormConfig_1 = require("./invoicingCustomerFormConfig");
12
11
  /**
13
- * Seed the shared Address screen with an existing customer's saved billing
14
- * address (looked up in the address entity store by `billingAddressId`). Runs
15
- * both when the customer detail loads and on an explicit initialize trigger.
16
- * Skips when an in-progress draft already exists, so an address the user just
17
- * entered survives navigating between the form and the Address screen. Mirrors
18
- * `initializeVendorAddressEpic`.
12
+ * Seed the shared Address screen with the customer's saved billing address, and
13
+ * record that the slot is this customer's. Runs when a detail request is issued
14
+ * (every path that loads a record issues one — the detail page when not cached,
15
+ * the create/edit form always), when the page opens, when the detail load
16
+ * lands, and on an explicit initialize trigger.
17
+ *
18
+ * The address store slot is keyed by address type alone, so it can still hold
19
+ * another customer's draft. Only a draft this customer owns is left alone —
20
+ * that is what lets an address the user just entered survive a trip to the
21
+ * Address screen. Anything else is replaced by this customer's saved address,
22
+ * or cleared when it has none. Opening the page counts as a trigger because a
23
+ * record already loaded this session issues no detail request at all.
19
24
  */
20
- const initializeInvoicingCustomerAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingCustomerDetailViewReducer_2.initializeInvoicingCustomerAddress.match(action) ||
21
- editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerDetail.match(action)), (0, operators_1.mergeMap)((action) => {
25
+ const initializeInvoicingCustomerAddressEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => editInvoicingCustomerDetailViewReducer_1.initializeInvoicingCustomerAddress.match(action) ||
26
+ editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerDetail.match(action) ||
27
+ editInvoicingCustomerDetailViewReducer_1.fetchInvoicingCustomerDetailPage.match(action) ||
28
+ editInvoicingCustomerDetailViewReducer_1.fetchInvoicingCustomerDetail.match(action)), (0, operators_1.mergeMap)((action) => {
22
29
  const { id } = action.payload;
30
+ if (id == null) {
31
+ return rxjs_1.EMPTY;
32
+ }
23
33
  const rootState = state$.value;
24
- const existingDraft = rootState.addressViewState.newAddressState?.[invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
25
- if (existingDraft != null || id == null) {
34
+ const pending = rootState.addressViewState.newAddressState?.[invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE]?.addressToCreate;
35
+ const ownerId = rootState.editInvoicingCustomerDetailViewState.billingAddressOwnerId;
36
+ // A detail response speaks for the record it loaded, which may no longer
37
+ // be the one on screen: its request keeps running when the user moves on
38
+ // to a cached record, which issues no request of its own to cancel it.
39
+ // Only the page-open and explicit triggers define the current record.
40
+ if (editInvoicingCustomerDetailViewReducer_1.updateInvoicingCustomerDetail.match(action) &&
41
+ ownerId != null &&
42
+ ownerId !== id) {
43
+ return rxjs_1.EMPTY;
44
+ }
45
+ if (pending != null && ownerId === id) {
26
46
  return rxjs_1.EMPTY;
27
47
  }
28
48
  const customer = (0, invoicingCustomerSelector_1.getInvoicingCustomerById)(rootState.invoicingCustomerState, id);
29
49
  const address = customer?.billingAddressId != null
30
50
  ? (0, addressSelector_1.getAddressByAddressId)(rootState.addressState, customer.billingAddressId)
31
51
  : undefined;
32
- return address != null
33
- ? (0, rxjs_1.of)((0, addressViewReducer_1.newAddressInLocalStore)({
52
+ const actions = [];
53
+ if (address != null) {
54
+ actions.push((0, addressViewReducer_1.newAddressInLocalStore)({
34
55
  addressType: invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE,
35
56
  addressToCreate: address,
36
- }))
37
- : rxjs_1.EMPTY;
57
+ }));
58
+ }
59
+ else if (pending != null) {
60
+ actions.push((0, addressViewReducer_1.removeNewAddressDataInLocalStore)(invoicingCustomerFormConfig_1.INVOICING_CUSTOMER_BILLING_ADDRESS_TYPE));
61
+ }
62
+ actions.push((0, editInvoicingCustomerDetailViewReducer_1.claimInvoicingCustomerBillingAddress)({ id }));
63
+ return (0, rxjs_1.from)(actions);
38
64
  }));
39
65
  exports.initializeInvoicingCustomerAddressEpic = initializeInvoicingCustomerAddressEpic;
@@ -26,9 +26,13 @@ const seedInvoicingCustomerFormDraftEpic = (actions$, state$) => actions$.pipe((
26
26
  // endpoints merge their own list-shaped rows into the same store. Only a
27
27
  // completed detail load does, which is also exactly when the page's
28
28
  // cache-guarded fetch issues no request and this is the sole seed.
29
+ // A forced refetch is the caller asking for fresh data: the response will
30
+ // seed, and seeding first from the entity as it stands would mark the
31
+ // draft loaded and lock that response out.
29
32
  if (editInvoicingCustomerDetailViewReducer_1.fetchInvoicingCustomerDetailPage.match(action) &&
30
- state.editInvoicingCustomerDetailViewState.recordStateById[id]
31
- ?.fetchState !== 'Completed') {
33
+ (action.payload.cacheOverride === true ||
34
+ state.editInvoicingCustomerDetailViewState.recordStateById[id]
35
+ ?.fetchState !== 'Completed')) {
32
36
  return rxjs_1.EMPTY;
33
37
  }
34
38
  // Nothing to seed from on a cold open; the detail response triggers this
@@ -57,6 +57,8 @@ export declare const runInvoicingSubscriptionAction: import("@reduxjs/toolkit").
57
57
  subscriptionId: ID;
58
58
  }, "editInvoicingSubscriptionDetailView/submitInvoicingSubscriptionFormSuccess">, submitInvoicingSubscriptionFormFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "editInvoicingSubscriptionDetailView/submitInvoicingSubscriptionFormFailure">, resetEditInvoicingSubscriptionDetailView: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<{
59
59
  id?: ID;
60
- } | undefined, "editInvoicingSubscriptionDetailView/resetEditInvoicingSubscriptionDetailView">, initializeInvoicingSubscriptionAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingSubscriptionAddressPayload], InitializeInvoicingSubscriptionAddressPayload, "editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddress", never, never>, syncInvoicingSubscriptionCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SyncInvoicingSubscriptionCouponsPayload], SyncInvoicingSubscriptionCouponsPayload, "editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCoupons", never, never>;
60
+ } | undefined, "editInvoicingSubscriptionDetailView/resetEditInvoicingSubscriptionDetailView">, initializeInvoicingSubscriptionAddress: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: InitializeInvoicingSubscriptionAddressPayload], InitializeInvoicingSubscriptionAddressPayload, "editInvoicingSubscriptionDetailView/initializeInvoicingSubscriptionAddress", never, never>, claimInvoicingSubscriptionShippingAddress: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
61
+ id: ID;
62
+ }, "editInvoicingSubscriptionDetailView/claimInvoicingSubscriptionShippingAddress">, syncInvoicingSubscriptionCoupons: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[payload: SyncInvoicingSubscriptionCouponsPayload], SyncInvoicingSubscriptionCouponsPayload, "editInvoicingSubscriptionDetailView/syncInvoicingSubscriptionCoupons", never, never>;
61
63
  declare const _default: import("redux").Reducer<EditInvoicingSubscriptionDetailViewState>;
62
64
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.syncInvoicingSubscriptionCoupons = exports.initializeInvoicingSubscriptionAddress = exports.resetEditInvoicingSubscriptionDetailView = exports.submitInvoicingSubscriptionFormFailure = exports.submitInvoicingSubscriptionFormSuccess = exports.submitInvoicingSubscriptionForm = exports.updateInvoicingSubscriptionFormDraft = exports.updateInvoicingSubscriptionDetailFailure = exports.updateInvoicingSubscriptionDetail = exports.seedInvoicingSubscriptionFormDraft = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.runInvoicingSubscriptionActionSuccess = exports.runInvoicingSubscriptionActionFailure = exports.runInvoicingSubscriptionAction = exports.initialState = void 0;
4
+ exports.syncInvoicingSubscriptionCoupons = exports.claimInvoicingSubscriptionShippingAddress = exports.initializeInvoicingSubscriptionAddress = exports.resetEditInvoicingSubscriptionDetailView = exports.submitInvoicingSubscriptionFormFailure = exports.submitInvoicingSubscriptionFormSuccess = exports.submitInvoicingSubscriptionForm = exports.updateInvoicingSubscriptionFormDraft = exports.updateInvoicingSubscriptionDetailFailure = exports.updateInvoicingSubscriptionDetail = exports.seedInvoicingSubscriptionFormDraft = exports.fetchInvoicingSubscriptionFormPage = exports.fetchInvoicingSubscriptionDetailPage = exports.fetchInvoicingSubscriptionDetail = exports.runInvoicingSubscriptionActionSuccess = exports.runInvoicingSubscriptionActionFailure = exports.runInvoicingSubscriptionAction = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const rootActions_1 = require("../../../rootActions");
7
7
  const invoicingFormDraft_1 = require("../invoicingFormDraft");
@@ -12,6 +12,7 @@ exports.initialState = {
12
12
  editDraftById: {},
13
13
  actionStateById: {},
14
14
  recordStateById: {},
15
+ shippingAddressOwnerId: undefined,
15
16
  newSubscriptionDraft: { ...invoicingSubscriptionFormConfig_1.initialInvoicingSubscriptionFormLocalData },
16
17
  savedSubscriptionId: undefined,
17
18
  hasValidState() {
@@ -109,6 +110,9 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
109
110
  draft.fetchState = 'Completed';
110
111
  draft.error = undefined;
111
112
  draft.savedSubscriptionId = action.payload.subscriptionId;
113
+ // An edit is refetched on success; keep the saved values on screen until
114
+ // that lands, and let it replace them.
115
+ (0, invoicingFormDraft_1.applyInvoicingFormDraftSaved)(draft.editDraftById, action.payload.subscriptionId);
112
116
  },
113
117
  submitInvoicingSubscriptionFormFailure(draft, action) {
114
118
  draft.fetchState = 'Error';
@@ -140,6 +144,10 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
140
144
  return { payload };
141
145
  },
142
146
  },
147
+ /** Record which subscription the shared shipping-address slot now belongs to. */
148
+ claimInvoicingSubscriptionShippingAddress(draft, action) {
149
+ draft.shippingAddressOwnerId = action.payload.id;
150
+ },
143
151
  // Trigger only — handled by syncInvoicingSubscriptionCouponsEpic.
144
152
  syncInvoicingSubscriptionCoupons: {
145
153
  reducer() { },
@@ -154,5 +162,5 @@ const editInvoicingSubscriptionDetailView = (0, toolkit_1.createSlice)({
154
162
  });
155
163
  },
156
164
  });
157
- _a = editInvoicingSubscriptionDetailView.actions, exports.runInvoicingSubscriptionAction = _a.runInvoicingSubscriptionAction, exports.runInvoicingSubscriptionActionFailure = _a.runInvoicingSubscriptionActionFailure, exports.runInvoicingSubscriptionActionSuccess = _a.runInvoicingSubscriptionActionSuccess, exports.fetchInvoicingSubscriptionDetail = _a.fetchInvoicingSubscriptionDetail, exports.fetchInvoicingSubscriptionDetailPage = _a.fetchInvoicingSubscriptionDetailPage, exports.fetchInvoicingSubscriptionFormPage = _a.fetchInvoicingSubscriptionFormPage, exports.seedInvoicingSubscriptionFormDraft = _a.seedInvoicingSubscriptionFormDraft, exports.updateInvoicingSubscriptionDetail = _a.updateInvoicingSubscriptionDetail, exports.updateInvoicingSubscriptionDetailFailure = _a.updateInvoicingSubscriptionDetailFailure, exports.updateInvoicingSubscriptionFormDraft = _a.updateInvoicingSubscriptionFormDraft, exports.submitInvoicingSubscriptionForm = _a.submitInvoicingSubscriptionForm, exports.submitInvoicingSubscriptionFormSuccess = _a.submitInvoicingSubscriptionFormSuccess, exports.submitInvoicingSubscriptionFormFailure = _a.submitInvoicingSubscriptionFormFailure, exports.resetEditInvoicingSubscriptionDetailView = _a.resetEditInvoicingSubscriptionDetailView, exports.initializeInvoicingSubscriptionAddress = _a.initializeInvoicingSubscriptionAddress, exports.syncInvoicingSubscriptionCoupons = _a.syncInvoicingSubscriptionCoupons;
165
+ _a = editInvoicingSubscriptionDetailView.actions, exports.runInvoicingSubscriptionAction = _a.runInvoicingSubscriptionAction, exports.runInvoicingSubscriptionActionFailure = _a.runInvoicingSubscriptionActionFailure, exports.runInvoicingSubscriptionActionSuccess = _a.runInvoicingSubscriptionActionSuccess, exports.fetchInvoicingSubscriptionDetail = _a.fetchInvoicingSubscriptionDetail, exports.fetchInvoicingSubscriptionDetailPage = _a.fetchInvoicingSubscriptionDetailPage, exports.fetchInvoicingSubscriptionFormPage = _a.fetchInvoicingSubscriptionFormPage, exports.seedInvoicingSubscriptionFormDraft = _a.seedInvoicingSubscriptionFormDraft, exports.updateInvoicingSubscriptionDetail = _a.updateInvoicingSubscriptionDetail, exports.updateInvoicingSubscriptionDetailFailure = _a.updateInvoicingSubscriptionDetailFailure, exports.updateInvoicingSubscriptionFormDraft = _a.updateInvoicingSubscriptionFormDraft, exports.submitInvoicingSubscriptionForm = _a.submitInvoicingSubscriptionForm, exports.submitInvoicingSubscriptionFormSuccess = _a.submitInvoicingSubscriptionFormSuccess, exports.submitInvoicingSubscriptionFormFailure = _a.submitInvoicingSubscriptionFormFailure, exports.resetEditInvoicingSubscriptionDetailView = _a.resetEditInvoicingSubscriptionDetailView, exports.initializeInvoicingSubscriptionAddress = _a.initializeInvoicingSubscriptionAddress, exports.claimInvoicingSubscriptionShippingAddress = _a.claimInvoicingSubscriptionShippingAddress, exports.syncInvoicingSubscriptionCoupons = _a.syncInvoicingSubscriptionCoupons;
158
166
  exports.default = editInvoicingSubscriptionDetailView.reducer;
@@ -70,6 +70,13 @@ export interface InvoicingSubscriptionFormView extends SelectorView {
70
70
  subscriptionCommercialEditAllowedFromStatuses: string[];
71
71
  subscriptionLifecycleActionOptions: InvoicingSubscriptionLifecycleActionOption[];
72
72
  subscriptionMetadataEditAllowedFromStatuses: string[];
73
+ /**
74
+ * A shipping address entered on the Address screen that the subscription has
75
+ * not saved yet. The inline-edit form cannot see it — the address lives in the
76
+ * shared address store, not in a field — so the detail page reads this to
77
+ * offer Save, or the address could never be linked.
78
+ */
79
+ hasUnsavedShippingAddress?: boolean;
73
80
  savedSubscriptionId?: ID;
74
81
  shippingAddressLabel?: string;
75
82
  subscription?: InvoicingSubscription;