@wearejh/m2-pwa-checkout 0.18.0 → 0.20.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.20.0](https://github.com/WeareJH/mage-mono/compare/v0.19.0...v0.20.0) (2023-03-27)
7
+
8
+ **Note:** Version bump only for package @wearejh/m2-pwa-checkout
9
+
10
+
11
+
12
+
13
+
14
+ # [0.19.0](https://github.com/WeareJH/mage-mono/compare/v0.18.0...v0.19.0) (2023-03-24)
15
+
16
+ **Note:** Version bump only for package @wearejh/m2-pwa-checkout
17
+
18
+
19
+
20
+
21
+
6
22
  # [0.18.0](https://github.com/WeareJH/mage-mono/compare/v0.17.0...v0.18.0) (2023-03-14)
7
23
 
8
24
  **Note:** Version bump only for package @wearejh/m2-pwa-checkout
@@ -7,6 +7,7 @@ import { catchError, mergeMap, withLatestFrom } from 'rxjs/operators';
7
7
 
8
8
  import { CheckoutActions, CheckoutMsg, TypeMap } from '../checkout.actions';
9
9
  import { execute as getJHOrderIDQuery } from '../rest/JhOrderApiOrderListServiceV1GetOrderGet';
10
+ import { execute as getGuestJHOrderIDQuery } from '../rest/WoodiesSalesOrderIdMapperServiceV1GetIncrementIdByEntityIdGet';
10
11
  import { signedIn } from '../utils/stateObservables';
11
12
 
12
13
  /**
@@ -41,7 +42,7 @@ export function getOrderIncrementId(action$: Observable<any>, state$: any, deps:
41
42
  const orderId = parseInt(payload.orderId);
42
43
 
43
44
  /**
44
- * The Order increment ID can only be retrived by
45
+ * The Order increment ID for
45
46
  * signed in users.
46
47
  */
47
48
  if (isSignedInUser) {
@@ -81,16 +82,36 @@ export function getOrderIncrementId(action$: Observable<any>, state$: any, deps:
81
82
  }
82
83
 
83
84
  /**
84
- * If the user is a guest, the order increment
85
- * ID cannot be retrived.
86
- *
87
- * The temporary solution is to continue with
88
- * the original order id (which doesn't match
89
- * the order id in the confirmation email).
85
+ * The Order increment ID for
86
+ * Guest users.
90
87
  */
91
- return of(
92
- CheckoutMsg('Checkout.Complete', {
93
- orderId: payload.orderId,
88
+ return getGuestJHOrderIDQuery({ entityId: orderId }, deps).pipe(
89
+ /**
90
+ * Handle the success response from the
91
+ * API query.
92
+ */
93
+ mergeMap((response: any) => {
94
+ const orderId = response ?? null;
95
+
96
+ /**
97
+ * Return the increment id
98
+ * but if failed then it returns the entity id
99
+ */
100
+ return of(
101
+ CheckoutMsg('Checkout.Complete', {
102
+ orderId: orderId ?? payload.orderId,
103
+ }),
104
+ );
105
+ }),
106
+
107
+ /**
108
+ * Handle the error response from the
109
+ * API query.
110
+ */
111
+ catchError((errorResponse) => {
112
+ const { error } = extractErrorAndCode(errorResponse);
113
+
114
+ return of(CheckoutMsg('Checkout.PaymentSubmitError', error), scrollTop());
94
115
  }),
95
116
  );
96
117
  }),
@@ -0,0 +1,18 @@
1
+ import { Effects } from '@wearejh/swagger-rxjs';
2
+ import * as Definitions from '@wearejh/swagger-rxjs/lib/Definitions';
3
+ import { Observable } from 'rxjs';
4
+
5
+ export const description = '';
6
+ export const method = 'GET';
7
+ export const operationId = 'woodiesSalesOrderIdMapperServiceV1GetIncrementIdByEntityIdGet';
8
+ export const path = '/V1/get-increment-id/{entityId}';
9
+ export interface PathParams {
10
+ entityId: number;
11
+ }
12
+ export type Response = Response200 | ResponseDefault;
13
+ export type Response200 = string;
14
+ export type ResponseDefault = Definitions.ErrorResponse;
15
+ type MinimalEffects = Pick<Effects, 'apiUrl' | 'restHeaders' | 'getJSON'>;
16
+ export function execute(pathParams: PathParams, effects: MinimalEffects): Observable<Response200> {
17
+ return effects.getJSON(effects.apiUrl(operationId)(path, pathParams), effects.restHeaders({})) as any;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wearejh/m2-pwa-checkout",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "> TODO: description",
5
5
  "author": "Shane Osbourne <shane.osbourne8@gmail.com>",
6
6
  "homepage": "",
@@ -18,15 +18,15 @@
18
18
  ],
19
19
  "scripts": {},
20
20
  "dependencies": {
21
- "@wearejh/m2-pwa-addresses": "^0.18.0",
22
- "@wearejh/m2-pwa-cart": "^0.18.0",
23
- "@wearejh/m2-pwa-engine": "^0.18.0",
24
- "@wearejh/m2-pwa-user": "^0.18.0",
25
- "@wearejh/rx-form": "^0.18.0",
26
- "@wearejh/swagger-rxjs": "^0.18.0"
21
+ "@wearejh/m2-pwa-addresses": "^0.20.0",
22
+ "@wearejh/m2-pwa-cart": "^0.20.0",
23
+ "@wearejh/m2-pwa-engine": "^0.20.0",
24
+ "@wearejh/m2-pwa-user": "^0.20.0",
25
+ "@wearejh/rx-form": "^0.20.0",
26
+ "@wearejh/swagger-rxjs": "^0.20.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@reach/dialog": "0.8.2"
30
30
  },
31
- "gitHead": "b8ae72d72b9b73e1cfc1e42347bd012de3f2095c"
31
+ "gitHead": "187f06965f8f6c3f9e6d5393c6526f3c76144b0a"
32
32
  }