create-brainerce-store 1.71.0 → 1.73.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.
Files changed (27) hide show
  1. package/README.md +31 -10
  2. package/dist/index.js +179 -107
  3. package/messages/en.json +14 -1
  4. package/messages/he.json +14 -1
  5. package/package.json +1 -1
  6. package/templates/nextjs/base/TRANSLATIONS.md +207 -200
  7. package/templates/nextjs/base/src/app/checkout/page.tsx +1074 -1018
  8. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +21 -2
  9. package/templates/nextjs/base/src/components/account/order-history.tsx +371 -385
  10. package/templates/nextjs/base/src/components/account/order-status-timeline.tsx +85 -66
  11. package/templates/nextjs/base/src/core/hooks/use-cart-page.ts +127 -58
  12. package/templates/nextjs/base/src/core/lib/auth.ts +32 -39
  13. package/templates/nextjs/base/src/core/lib/brainerce.ts.ejs +5 -16
  14. package/templates/nextjs/base/src/core/providers/store-provider.tsx.ejs +3 -6
  15. package/templates/nextjs/base/src/ui/cart/cart-item.tsx +164 -146
  16. package/templates/nextjs/base/src/ui/cart/cart-view.tsx +176 -140
  17. package/templates/nextjs/base/src/ui/cart/reservation-countdown.tsx +137 -95
  18. package/templates/nextjs/base/src/ui/product/review-form.tsx +33 -11
  19. package/templates/nextjs/designs/atelier/ui/cart/cart-drawer.tsx +177 -163
  20. package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +158 -140
  21. package/templates/nextjs/designs/atelier/ui/cart/cart-view.tsx +184 -147
  22. package/templates/nextjs/designs/atelier/ui/cart/reservation-countdown.tsx +131 -89
  23. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +30 -10
  24. package/templates/nextjs/ui-canvas/cart/cart-item.tsx +137 -123
  25. package/templates/nextjs/ui-canvas/cart/cart-view.tsx +140 -106
  26. package/templates/nextjs/ui-canvas/cart/reservation-countdown.tsx +124 -81
  27. package/templates/nextjs/ui-canvas/product/review-form.tsx +9 -1
@@ -32,10 +32,29 @@ function OrderConfirmationContent() {
32
32
  try {
33
33
  const client = getClient();
34
34
 
35
- // Clear cart state after successful payment
36
- client.handlePaymentSuccess(checkoutId!);
35
+ // Clear cart state after successful payment. handlePaymentSuccess is
36
+ // SYNCHRONOUS: it returns the outcome rather than a promise, so there
37
+ // is nothing to await. Read the result, then refresh the cart AFTER
38
+ // it, or the header badge can be repopulated from the pre-clear cart.
39
+ //
40
+ // mode 'full' - whole cart cleared
41
+ // mode 'partial' - only the purchased items were removed (partial
42
+ // checkout); whatever is left is still for sale
43
+ // mode 'none' - nothing to clear. Usually the SDK's idempotency
44
+ // guard: React Strict Mode runs this effect twice
45
+ // in development, and a refresh of this URL hits it
46
+ // too. On a good order this is expected, so it must
47
+ // never become a warning to the shopper.
48
+ const clearResult = client.handlePaymentSuccess(checkoutId!);
37
49
  await refreshCart();
38
50
 
51
+ if (!clearResult.cleared && clearResult.mode !== 'none') {
52
+ // A clear that neither succeeded nor was skipped leaves purchased
53
+ // items in the badge. Nothing the shopper can act on, but a silent
54
+ // gap here looks exactly like a working cart.
55
+ console.warn('Cart not cleared after payment:', clearResult);
56
+ }
57
+
39
58
  // For redirect-based payment providers, the customer returns with
40
59
  // provider params in the URL — CardCom: lowprofilecode; PayPal:
41
60
  // token + PayerID. Send these to the backend for server-side