@zeniai/client-epic-state 5.1.91-betaAK0 → 5.1.92

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.
@@ -80,12 +80,12 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
80
80
  }
81
81
  return payload;
82
82
  };
83
+ /** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices sub-families. */
84
+ const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
83
85
  /**
84
86
  * Build the parent catalog-item request body from the form draft. Creates omit
85
87
  * both parent and sub-family IDs; edits retain returned sub-family IDs.
86
88
  */
87
- /** Sent for every catalog item now that the form does not collect a unit. */
88
- const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
89
89
  export const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate) => {
90
90
  const description = trimOrUndefined(localData.description);
91
91
  const productCode = trimOrUndefined(localData.productCode) ?? toProductCode(localData.name);
@@ -103,8 +103,7 @@ export const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate)
103
103
  if (description != null) {
104
104
  itemPayload.description = description;
105
105
  }
106
- // The form no longer collects a unit, so a new item is created with the fixed
107
- // default; an item that already carries one keeps it when saved from the form.
106
+ // The form no longer collects a unit; an item that already has one keeps it.
108
107
  itemPayload.unit =
109
108
  trimOrUndefined(localData.unit) ?? DEFAULT_CATALOG_ITEM_UNIT;
110
109
  if (localData.itemApplicability === 'restricted' &&
@@ -5,7 +5,7 @@ import { extractInvoicingInvoiceAddresses } from '../../../entity/invoicing/invo
5
5
  import { updateInvoices } from '../../../entity/invoicing/invoice/invoiceReducer';
6
6
  import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
7
7
  import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
8
- import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
8
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
9
9
  import { runInvoicingInvoiceAction, runInvoicingInvoiceActionFailure, runInvoicingInvoiceActionSuccess, updateInvoicingInvoice, } from './invoiceActionReducer';
10
10
  /** Snackbar copy per action kind; unlisted kinds run without one. */
11
11
  const SNACKBAR_SECTION_BY_KIND = {
@@ -17,13 +17,15 @@ export const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => act
17
17
  action.payload.action !== 'issue-credit-note'), mergeMap((action) => {
18
18
  const { action: kind, body, invoiceId } = action.payload;
19
19
  const snackbarSection = SNACKBAR_SECTION_BY_KIND[kind];
20
- const snackbar = (messageText) => snackbarSection == null
20
+ /** `status` surfaces the platform's error text; omit it to keep the generic copy. */
21
+ const snackbar = (messageText, status) => snackbarSection == null
21
22
  ? []
22
23
  : [
23
24
  openSnackbar({
24
25
  messageSection: snackbarSection,
25
26
  messageText,
26
27
  type: messageText === 'success' ? 'success' : 'error',
28
+ variables: apiErrorSnackbarVariables(status),
27
29
  }),
28
30
  ];
29
31
  const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(invoiceId)}/${kind}`;
@@ -43,7 +45,7 @@ export const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => act
43
45
  error: response.status,
44
46
  invoiceId,
45
47
  }),
46
- ...snackbar('failed'),
48
+ ...snackbar('failed', response.status),
47
49
  ]);
48
50
  }), catchError((error) => from([
49
51
  runInvoicingInvoiceActionFailure({
@@ -2,4 +2,8 @@ import { InvoicingPlanPayload } from '../../../entity/invoicing/plan/planPayload
2
2
  import { ZeniAPIResponse } from '../../../responsePayload';
3
3
  import { InvoicingCatalogItemFormLocalData } from './editInvoicingCatalogItemDetailViewState';
4
4
  export type SaveInvoicingCatalogItemResponse = ZeniAPIResponse<InvoicingPlanPayload>;
5
+ /**
6
+ * Build the parent catalog-item request body from the form draft. Creates omit
7
+ * both parent and sub-family IDs; edits retain returned sub-family IDs.
8
+ */
5
9
  export declare const localDataToSaveInvoicingCatalogItemPayload: (localData: InvoicingCatalogItemFormLocalData, isCreate: boolean) => Record<string, unknown>;
@@ -83,12 +83,12 @@ const buildSubFamilyPayload = (localData, subFamily, clearEmptyValues) => {
83
83
  }
84
84
  return payload;
85
85
  };
86
+ /** `unit` is the item's unit of measure, not a currency; `CURRENCY_CODE` above prices sub-families. */
87
+ const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
86
88
  /**
87
89
  * Build the parent catalog-item request body from the form draft. Creates omit
88
90
  * both parent and sub-family IDs; edits retain returned sub-family IDs.
89
91
  */
90
- /** Sent for every catalog item now that the form does not collect a unit. */
91
- const DEFAULT_CATALOG_ITEM_UNIT = 'USD';
92
92
  const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate) => {
93
93
  const description = trimOrUndefined(localData.description);
94
94
  const productCode = trimOrUndefined(localData.productCode) ?? toProductCode(localData.name);
@@ -106,8 +106,7 @@ const localDataToSaveInvoicingCatalogItemPayload = (localData, isCreate) => {
106
106
  if (description != null) {
107
107
  itemPayload.description = description;
108
108
  }
109
- // The form no longer collects a unit, so a new item is created with the fixed
110
- // default; an item that already carries one keeps it when saved from the form.
109
+ // The form no longer collects a unit; an item that already has one keeps it.
111
110
  itemPayload.unit =
112
111
  trimOrUndefined(localData.unit) ?? DEFAULT_CATALOG_ITEM_UNIT;
113
112
  if (localData.itemApplicability === 'restricted' &&
@@ -20,13 +20,15 @@ const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => actions$.p
20
20
  action.payload.action !== 'issue-credit-note'), (0, operators_1.mergeMap)((action) => {
21
21
  const { action: kind, body, invoiceId } = action.payload;
22
22
  const snackbarSection = SNACKBAR_SECTION_BY_KIND[kind];
23
- const snackbar = (messageText) => snackbarSection == null
23
+ /** `status` surfaces the platform's error text; omit it to keep the generic copy. */
24
+ const snackbar = (messageText, status) => snackbarSection == null
24
25
  ? []
25
26
  : [
26
27
  (0, snackbarReducer_1.openSnackbar)({
27
28
  messageSection: snackbarSection,
28
29
  messageText,
29
30
  type: messageText === 'success' ? 'success' : 'error',
31
+ variables: (0, snackbarApiError_1.apiErrorSnackbarVariables)(status),
30
32
  }),
31
33
  ];
32
34
  const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(invoiceId)}/${kind}`;
@@ -46,7 +48,7 @@ const runInvoicingInvoiceActionEpic = (actions$, _state$, zeniAPI) => actions$.p
46
48
  error: response.status,
47
49
  invoiceId,
48
50
  }),
49
- ...snackbar('failed'),
51
+ ...snackbar('failed', response.status),
50
52
  ]);
51
53
  }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
52
54
  (0, invoiceActionReducer_1.runInvoicingInvoiceActionFailure)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.91-betaAK0",
3
+ "version": "5.1.92",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",