@propeller-commerce/propeller-v2-react-ui 0.4.13 → 0.4.15
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 +25 -0
- package/dist/index.cjs +9 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -673,14 +673,32 @@ interface UseCheckoutOptions {
|
|
|
673
673
|
interface PlaceOrderOptions {
|
|
674
674
|
/** Id of the cart to convert. */
|
|
675
675
|
cartId: string;
|
|
676
|
-
/**
|
|
677
|
-
|
|
676
|
+
/**
|
|
677
|
+
* Order status to set. `'NEW'` for a completed order, `'REQUEST'` for a quote
|
|
678
|
+
* request, `'UNFINISHED'` for an order awaiting an external payment (PSP) — the
|
|
679
|
+
* payment webhook promotes it to its final status later. Any other backend
|
|
680
|
+
* status string is also accepted.
|
|
681
|
+
*/
|
|
682
|
+
orderStatus: 'NEW' | 'REQUEST' | 'UNFINISHED' | (string & {});
|
|
678
683
|
/** Customer reference printed on the order. */
|
|
679
684
|
reference?: string;
|
|
680
685
|
/** Free-text order notes. */
|
|
681
686
|
notes?: string;
|
|
682
687
|
/** When `true`, treats this as a quote: suppresses confirmation email/PDF and triggers a quote-send request. */
|
|
683
688
|
isQuoteMode?: boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Whether this placement *finalizes* the order — i.e. sends the order
|
|
691
|
+
* confirmation email, fires the confirm event, attaches the order PDF, and
|
|
692
|
+
* clears the cart. Defaults to `true` for a normal order and `false` for a
|
|
693
|
+
* quote.
|
|
694
|
+
*
|
|
695
|
+
* Set this to `false` for an order that still awaits an external payment
|
|
696
|
+
* (e.g. `'UNFINISHED'` orders handed off to a PSP). The confirmation/cart
|
|
697
|
+
* deletion should then happen when the payment is confirmed (the PSP webhook),
|
|
698
|
+
* not at placement — otherwise the shopper is emailed and the cart cleared
|
|
699
|
+
* before they've paid.
|
|
700
|
+
*/
|
|
701
|
+
finalizeOrder?: boolean;
|
|
684
702
|
}
|
|
685
703
|
/** State and checkout actions returned by {@link useCheckout}. */
|
|
686
704
|
interface UseCheckoutReturn {
|
package/dist/index.d.ts
CHANGED
|
@@ -673,14 +673,32 @@ interface UseCheckoutOptions {
|
|
|
673
673
|
interface PlaceOrderOptions {
|
|
674
674
|
/** Id of the cart to convert. */
|
|
675
675
|
cartId: string;
|
|
676
|
-
/**
|
|
677
|
-
|
|
676
|
+
/**
|
|
677
|
+
* Order status to set. `'NEW'` for a completed order, `'REQUEST'` for a quote
|
|
678
|
+
* request, `'UNFINISHED'` for an order awaiting an external payment (PSP) — the
|
|
679
|
+
* payment webhook promotes it to its final status later. Any other backend
|
|
680
|
+
* status string is also accepted.
|
|
681
|
+
*/
|
|
682
|
+
orderStatus: 'NEW' | 'REQUEST' | 'UNFINISHED' | (string & {});
|
|
678
683
|
/** Customer reference printed on the order. */
|
|
679
684
|
reference?: string;
|
|
680
685
|
/** Free-text order notes. */
|
|
681
686
|
notes?: string;
|
|
682
687
|
/** When `true`, treats this as a quote: suppresses confirmation email/PDF and triggers a quote-send request. */
|
|
683
688
|
isQuoteMode?: boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Whether this placement *finalizes* the order — i.e. sends the order
|
|
691
|
+
* confirmation email, fires the confirm event, attaches the order PDF, and
|
|
692
|
+
* clears the cart. Defaults to `true` for a normal order and `false` for a
|
|
693
|
+
* quote.
|
|
694
|
+
*
|
|
695
|
+
* Set this to `false` for an order that still awaits an external payment
|
|
696
|
+
* (e.g. `'UNFINISHED'` orders handed off to a PSP). The confirmation/cart
|
|
697
|
+
* deletion should then happen when the payment is confirmed (the PSP webhook),
|
|
698
|
+
* not at placement — otherwise the shopper is emailed and the cart cleared
|
|
699
|
+
* before they've paid.
|
|
700
|
+
*/
|
|
701
|
+
finalizeOrder?: boolean;
|
|
684
702
|
}
|
|
685
703
|
/** State and checkout actions returned by {@link useCheckout}. */
|
|
686
704
|
interface UseCheckoutReturn {
|
package/dist/index.js
CHANGED
|
@@ -995,6 +995,8 @@ function useCheckout(options) {
|
|
|
995
995
|
const cartService = createServices(graphqlClient).cart;
|
|
996
996
|
const orderService = createServices(graphqlClient).order;
|
|
997
997
|
const { cartId, orderStatus, reference, notes, isQuoteMode } = opts;
|
|
998
|
+
const finalizeOrder = opts.finalizeOrder ?? true;
|
|
999
|
+
const sendConfirmation = finalizeOrder && !isQuoteMode;
|
|
998
1000
|
if (reference || notes) {
|
|
999
1001
|
await cartService.updateCart({
|
|
1000
1002
|
id: cartId,
|
|
@@ -1016,10 +1018,13 @@ function useCheckout(options) {
|
|
|
1016
1018
|
orderId,
|
|
1017
1019
|
status: orderStatus,
|
|
1018
1020
|
payStatus: PaymentStatuses.OPEN,
|
|
1019
|
-
sendOrderConfirmationEmail:
|
|
1020
|
-
addPDFAttachment:
|
|
1021
|
-
triggerOrderSendConfirmEvent:
|
|
1022
|
-
|
|
1021
|
+
sendOrderConfirmationEmail: sendConfirmation,
|
|
1022
|
+
addPDFAttachment: sendConfirmation,
|
|
1023
|
+
triggerOrderSendConfirmEvent: sendConfirmation,
|
|
1024
|
+
// Keep the cart only for an unfinalized (PSP-pending) order so the
|
|
1025
|
+
// shopper can retry payment; clear it once the order is finalized
|
|
1026
|
+
// (a normal order or a quote).
|
|
1027
|
+
deleteCart: finalizeOrder
|
|
1023
1028
|
});
|
|
1024
1029
|
if (isQuoteMode) {
|
|
1025
1030
|
await orderService.triggerQuoteSendRequest({ orderId, language });
|