@zeniai/client-epic-state 5.1.50-betaAK2 → 5.1.50-betaAK3

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.
@@ -1,10 +1,18 @@
1
1
  import recordGet from 'lodash/get';
2
+ import { getAddressByAddressId } from '../../../entity/address/addressSelector';
2
3
  import { getInvoiceById } from '../../../entity/invoicing/invoice/invoiceSelector';
3
4
  import { getInvoicingInvoiceActionState } from '../invoiceAction/invoiceActionSelector';
4
5
  export const getInvoiceDetail = (state, invoiceId) => {
5
6
  const detail = recordGet(state.invoicingInvoiceDetailState.detailById, invoiceId, undefined);
7
+ const invoice = getInvoiceById(state, invoiceId);
6
8
  return {
7
- invoice: getInvoiceById(state, invoiceId),
9
+ invoice,
10
+ billingAddress: invoice?.billingAddressId != null
11
+ ? getAddressByAddressId(state.addressState, invoice.billingAddressId)
12
+ : undefined,
13
+ shippingAddress: invoice?.shippingAddressId != null
14
+ ? getAddressByAddressId(state.addressState, invoice.shippingAddressId)
15
+ : undefined,
8
16
  actionState: getInvoicingInvoiceActionState(invoiceId)(state),
9
17
  fetchState: detail?.fetchState ?? 'Not-Started',
10
18
  error: detail?.error,
@@ -1,13 +1,18 @@
1
1
  import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
2
2
  import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
3
+ import { Address } from '../../../entity/address/addressState';
3
4
  import { InvoicingInvoice } from '../../../entity/invoicing/invoice/invoiceState';
4
5
  import { RootState } from '../../../reducer';
5
6
  /**
6
7
  * Read-only view for the invoice detail page: the invoice entity + its per-id
7
- * fetch state, with the per-invoice lifecycle-action run-state folded in.
8
+ * fetch state, with the per-invoice lifecycle-action run-state folded in. The
9
+ * billing/shipping addresses are resolved here from the shared address store so
10
+ * the view layer renders them without touching the store itself.
8
11
  */
9
12
  export interface InvoiceDetailView extends SelectorView {
10
13
  actionState: FetchStateAndError;
14
+ billingAddress?: Address;
11
15
  invoice?: InvoicingInvoice;
16
+ shippingAddress?: Address;
12
17
  }
13
18
  export declare const getInvoiceDetail: (state: RootState, invoiceId: ID) => InvoiceDetailView;
@@ -5,12 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getInvoiceDetail = void 0;
7
7
  const get_1 = __importDefault(require("lodash/get"));
8
+ const addressSelector_1 = require("../../../entity/address/addressSelector");
8
9
  const invoiceSelector_1 = require("../../../entity/invoicing/invoice/invoiceSelector");
9
10
  const invoiceActionSelector_1 = require("../invoiceAction/invoiceActionSelector");
10
11
  const getInvoiceDetail = (state, invoiceId) => {
11
12
  const detail = (0, get_1.default)(state.invoicingInvoiceDetailState.detailById, invoiceId, undefined);
13
+ const invoice = (0, invoiceSelector_1.getInvoiceById)(state, invoiceId);
12
14
  return {
13
- invoice: (0, invoiceSelector_1.getInvoiceById)(state, invoiceId),
15
+ invoice,
16
+ billingAddress: invoice?.billingAddressId != null
17
+ ? (0, addressSelector_1.getAddressByAddressId)(state.addressState, invoice.billingAddressId)
18
+ : undefined,
19
+ shippingAddress: invoice?.shippingAddressId != null
20
+ ? (0, addressSelector_1.getAddressByAddressId)(state.addressState, invoice.shippingAddressId)
21
+ : undefined,
14
22
  actionState: (0, invoiceActionSelector_1.getInvoicingInvoiceActionState)(invoiceId)(state),
15
23
  fetchState: detail?.fetchState ?? 'Not-Started',
16
24
  error: detail?.error,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.50-betaAK2",
3
+ "version": "5.1.50-betaAK3",
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",