@open-mercato/checkout 0.8.1-develop.7296.1.2111d779db → 0.8.1-develop.7441.1.b42958b98c

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 (24) hide show
  1. package/dist/modules/checkout/commands/links.js +9 -10
  2. package/dist/modules/checkout/commands/links.js.map +2 -2
  3. package/dist/modules/checkout/commands/shared.js +7 -0
  4. package/dist/modules/checkout/commands/shared.js.map +2 -2
  5. package/dist/modules/checkout/commands/templates.js +10 -11
  6. package/dist/modules/checkout/commands/templates.js.map +2 -2
  7. package/dist/modules/checkout/components/LinkTemplateForm.js +18 -0
  8. package/dist/modules/checkout/components/LinkTemplateForm.js.map +2 -2
  9. package/dist/modules/checkout/widgets/notifications/CheckoutTransactionCompletedRenderer.js +2 -2
  10. package/dist/modules/checkout/widgets/notifications/CheckoutTransactionCompletedRenderer.js.map +2 -2
  11. package/dist/modules/checkout/widgets/notifications/CheckoutTransactionFailedRenderer.js +2 -2
  12. package/dist/modules/checkout/widgets/notifications/CheckoutTransactionFailedRenderer.js.map +2 -2
  13. package/dist/modules/checkout/widgets/notifications/CheckoutUsageLimitReachedRenderer.js +2 -2
  14. package/dist/modules/checkout/widgets/notifications/CheckoutUsageLimitReachedRenderer.js.map +2 -2
  15. package/package.json +5 -5
  16. package/src/modules/checkout/commands/__tests__/undo-scope.test.ts +154 -0
  17. package/src/modules/checkout/commands/links.ts +9 -10
  18. package/src/modules/checkout/commands/shared.ts +7 -0
  19. package/src/modules/checkout/commands/templates.ts +10 -11
  20. package/src/modules/checkout/components/LinkTemplateForm.tsx +27 -0
  21. package/src/modules/checkout/components/__tests__/LinkTemplateForm.unparseableAmount.test.tsx +108 -0
  22. package/src/modules/checkout/widgets/notifications/CheckoutTransactionCompletedRenderer.tsx +2 -2
  23. package/src/modules/checkout/widgets/notifications/CheckoutTransactionFailedRenderer.tsx +2 -2
  24. package/src/modules/checkout/widgets/notifications/CheckoutUsageLimitReachedRenderer.tsx +2 -2
@@ -29,6 +29,7 @@ import { SwitchableMarkdownInput } from "@open-mercato/ui/backend/inputs";
29
29
  import { apiCall, apiCallOrThrow, readApiResultOrThrow, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
30
30
  import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
31
31
  import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
32
+ import { createCrudFormError } from "@open-mercato/ui/backend/utils/serverErrors";
32
33
  import { collectCustomFieldValues } from "@open-mercato/ui/backend/utils/customFieldValues";
33
34
  import { Button } from "@open-mercato/ui/primitives/button";
34
35
  import { ColorPicker } from "@open-mercato/ui/primitives/color-picker";
@@ -70,6 +71,14 @@ function toSubmittedAmount(value, locale) {
70
71
  if (!value.trim()) return null;
71
72
  return parseLocaleNumber(value, locale);
72
73
  }
74
+ function isUnparseableAmount(value, locale) {
75
+ return typeof value === "string" && value.trim().length > 0 && toSubmittedAmount(value, locale) === null;
76
+ }
77
+ function collectUnparseableAmountPaths(values, locale) {
78
+ const pricingMode = readString(values.pricingMode) || "fixed";
79
+ const candidates = pricingMode === "custom_amount" ? [["customAmountMin", values.customAmountMin], ["customAmountMax", values.customAmountMax]] : pricingMode === "price_list" ? normalizePriceListItems(values.priceListItems).map((item, index) => [`priceListItems.${index}.amount`, item.amount]) : [["fixedPriceAmount", values.fixedPriceAmount], ["fixedPriceOriginalAmount", values.fixedPriceOriginalAmount]];
80
+ return candidates.filter(([, value]) => isUnparseableAmount(value, locale)).map(([path]) => path);
81
+ }
73
82
  function readBoolean(value, fallback = false) {
74
83
  return typeof value === "boolean" ? value : fallback;
75
84
  }
@@ -1446,6 +1455,14 @@ function LinkTemplateForm({ mode, recordId }) {
1446
1455
  onSubmit: async (values, context) => {
1447
1456
  const submitIntent = context?.submitter?.value === "preview" ? "preview" : context?.submitter?.value === "publish" ? "publish" : "save";
1448
1457
  const shouldOpenPreview = submitIntent === "preview";
1458
+ const unparseableAmountPaths = collectUnparseableAmountPaths(values, locale);
1459
+ if (unparseableAmountPaths.length > 0) {
1460
+ const invalidNumberMessage = t("checkout.validation.common.invalidNumber");
1461
+ throw createCrudFormError(
1462
+ invalidNumberMessage,
1463
+ Object.fromEntries(unparseableAmountPaths.map((path) => [path, invalidNumberMessage]))
1464
+ );
1465
+ }
1449
1466
  const payload = {
1450
1467
  ...values,
1451
1468
  status: submitIntent === "publish" ? "active" : values.status,
@@ -1537,6 +1554,7 @@ export {
1537
1554
  LinkTemplateForm,
1538
1555
  PriceListEditor,
1539
1556
  PricingSection,
1557
+ collectUnparseableAmountPaths,
1540
1558
  LinkTemplateForm_default as default,
1541
1559
  toSubmittedAmount
1542
1560
  };