@open-mercato/checkout 0.8.1-develop.7296.1.2111d779db → 0.9.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 (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 +6 -7
  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
@@ -22,7 +22,7 @@ function CheckoutTransactionCompletedRenderer({
22
22
  const currency = notification.bodyVariables?.currency ?? "";
23
23
  const viewAction = actions.find((action) => action.id === "view") ?? actions[0] ?? null;
24
24
  const handleView = async () => {
25
- if (!viewAction) {
25
+ if (!viewAction || notification.status === "actioned") {
26
26
  if (notification.linkHref) router.push(notification.linkHref);
27
27
  return;
28
28
  }
@@ -76,7 +76,7 @@ function CheckoutTransactionCompletedRenderer({
76
76
  e.stopPropagation();
77
77
  handleView();
78
78
  },
79
- disabled: executing || !viewAction && !notification.linkHref,
79
+ disabled: executing || !viewAction && !notification.linkHref || notification.status === "actioned" && !notification.linkHref,
80
80
  className: "gap-1",
81
81
  children: [
82
82
  /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" }),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/checkout/widgets/notifications/CheckoutTransactionCompletedRenderer.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { CheckCircle, ExternalLink, Calendar } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n\nexport function CheckoutTransactionCompletedRenderer({\n notification,\n onAction,\n onDismiss,\n actions = [],\n}: NotificationRendererProps) {\n const t = useT()\n const locale = useLocale()\n const router = useRouter()\n const [executing, setExecuting] = React.useState(false)\n const isUnread = notification.status === 'unread'\n\n const amount = notification.bodyVariables?.amount ?? ''\n const currency = notification.bodyVariables?.currency ?? ''\n const viewAction = actions.find((action) => action.id === 'view') ?? actions[0] ?? null\n\n const handleView = async () => {\n if (!viewAction) {\n if (notification.linkHref) router.push(notification.linkHref)\n return\n }\n setExecuting(true)\n try {\n await onAction(viewAction.id)\n } finally {\n setExecuting(false)\n }\n }\n\n return (\n <div\n className={cn(\n 'group relative px-4 py-3 hover:bg-muted/50 cursor-pointer transition-colors border-l-4 border-l-status-success-border',\n isUnread && 'bg-status-success-bg',\n )}\n onClick={handleView}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleView()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isUnread && (\n <div className=\"absolute left-1.5 top-1/2 -translate-y-1/2 h-2 w-2 rounded-full bg-primary\" />\n )}\n <div className=\"flex gap-3\">\n <div className=\"flex-shrink-0 mt-0.5\">\n <div className=\"h-10 w-10 rounded-lg bg-status-success-bg flex items-center justify-center\">\n <CheckCircle className=\"h-5 w-5 text-status-success-icon\" />\n </div>\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <h4 className={cn('text-sm font-medium', isUnread && 'font-semibold')}>\n {notification.title}\n </h4>\n <span className=\"flex-shrink-0 text-xs text-muted-foreground flex items-center gap-1\">\n <Calendar className=\"h-3 w-3\" />\n {formatRelativeTime(notification.createdAt, { locale, translate: t }) ?? ''}\n </span>\n </div>\n {amount ? (\n <div className=\"mt-1 text-xs text-muted-foreground\">\n <span className=\"font-medium text-foreground\">{amount} {currency}</span>\n </div>\n ) : null}\n <div className=\"mt-3 flex gap-2\">\n <Button\n variant=\"default\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); handleView() }}\n disabled={executing || (!viewAction && !notification.linkHref)}\n className=\"gap-1\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {t('checkout.notifications.renderer.viewTransaction', 'View Transaction')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); onDismiss() }}\n >\n {t('notifications.actions.dismiss', 'Dismiss')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default CheckoutTransactionCompletedRenderer\n"],
5
- "mappings": ";AAyDQ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AY,WAAU,oCAAmC,GAC5D,GACF;AAAA,UACA,qBAAC,SAAI,WAAU,kBACb;AAAA,iCAAC,SAAI,WAAU,0CACb;AAAA,kCAAC,QAAG,WAAW,GAAG,uBAAuB,YAAY,eAAe,GACjE,uBAAa,OAChB;AAAA,cACA,qBAAC,UAAK,WAAU,uEACd;AAAA,oCAAC,YAAS,WAAU,WAAU;AAAA,gBAC7B,mBAAmB,aAAa,WAAW,EAAE,QAAQ,WAAW,EAAE,CAAC,KAAK;AAAA,iBAC3E;AAAA,eACF;AAAA,YACC,SACC,oBAAC,SAAI,WAAU,sCACb,+BAAC,UAAK,WAAU,+BAA+B;AAAA;AAAA,cAAO;AAAA,cAAE;AAAA,eAAS,GACnE,IACE;AAAA,YACJ,qBAAC,SAAI,WAAU,mBACb;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,SAAS,CAAC,MAAM;AAAE,sBAAE,gBAAgB;AAAG,+BAAW;AAAA,kBAAE;AAAA,kBACpD,UAAU,aAAc,CAAC,cAAc,CAAC,aAAa;AAAA,kBACrD,WAAU;AAAA,kBAEV;AAAA,wCAAC,gBAAa,WAAU,WAAU;AAAA,oBACjC,EAAE,mDAAmD,kBAAkB;AAAA;AAAA;AAAA,cAC1E;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,SAAS,CAAC,MAAM;AAAE,sBAAE,gBAAgB;AAAG,8BAAU;AAAA,kBAAE;AAAA,kBAElD,YAAE,iCAAiC,SAAS;AAAA;AAAA,cAC/C;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,+CAAQ;",
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { CheckCircle, ExternalLink, Calendar } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n\nexport function CheckoutTransactionCompletedRenderer({\n notification,\n onAction,\n onDismiss,\n actions = [],\n}: NotificationRendererProps) {\n const t = useT()\n const locale = useLocale()\n const router = useRouter()\n const [executing, setExecuting] = React.useState(false)\n const isUnread = notification.status === 'unread'\n\n const amount = notification.bodyVariables?.amount ?? ''\n const currency = notification.bodyVariables?.currency ?? ''\n const viewAction = actions.find((action) => action.id === 'view') ?? actions[0] ?? null\n\n const handleView = async () => {\n if (!viewAction || notification.status === 'actioned') {\n if (notification.linkHref) router.push(notification.linkHref)\n return\n }\n setExecuting(true)\n try {\n await onAction(viewAction.id)\n } finally {\n setExecuting(false)\n }\n }\n\n return (\n <div\n className={cn(\n 'group relative px-4 py-3 hover:bg-muted/50 cursor-pointer transition-colors border-l-4 border-l-status-success-border',\n isUnread && 'bg-status-success-bg',\n )}\n onClick={handleView}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleView()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isUnread && (\n <div className=\"absolute left-1.5 top-1/2 -translate-y-1/2 h-2 w-2 rounded-full bg-primary\" />\n )}\n <div className=\"flex gap-3\">\n <div className=\"flex-shrink-0 mt-0.5\">\n <div className=\"h-10 w-10 rounded-lg bg-status-success-bg flex items-center justify-center\">\n <CheckCircle className=\"h-5 w-5 text-status-success-icon\" />\n </div>\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <h4 className={cn('text-sm font-medium', isUnread && 'font-semibold')}>\n {notification.title}\n </h4>\n <span className=\"flex-shrink-0 text-xs text-muted-foreground flex items-center gap-1\">\n <Calendar className=\"h-3 w-3\" />\n {formatRelativeTime(notification.createdAt, { locale, translate: t }) ?? ''}\n </span>\n </div>\n {amount ? (\n <div className=\"mt-1 text-xs text-muted-foreground\">\n <span className=\"font-medium text-foreground\">{amount} {currency}</span>\n </div>\n ) : null}\n <div className=\"mt-3 flex gap-2\">\n <Button\n variant=\"default\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); handleView() }}\n disabled={executing || (!viewAction && !notification.linkHref) || (notification.status === 'actioned' && !notification.linkHref)}\n className=\"gap-1\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {t('checkout.notifications.renderer.viewTransaction', 'View Transaction')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); onDismiss() }}\n >\n {t('notifications.actions.dismiss', 'Dismiss')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default CheckoutTransactionCompletedRenderer\n"],
5
+ "mappings": ";AAyDQ,cAaI,YAbJ;AAvDR,YAAY,WAAW;AACvB,SAAS,aAAa,cAAc,gBAAgB;AACpD,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,WAAW,YAAY;AAGzB,SAAS,qCAAqC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AACb,GAA8B;AAC5B,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,WAAW,aAAa,WAAW;AAEzC,QAAM,SAAS,aAAa,eAAe,UAAU;AACrD,QAAM,WAAW,aAAa,eAAe,YAAY;AACzD,QAAM,aAAa,QAAQ,KAAK,CAAC,WAAW,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,KAAK;AAEnF,QAAM,aAAa,YAAY;AAC7B,QAAI,CAAC,cAAc,aAAa,WAAW,YAAY;AACrD,UAAI,aAAa,SAAU,QAAO,KAAK,aAAa,QAAQ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AAC,aAAa,YAAc,aAAa,WAAW,cAAc,CAAC,aAAa;AAAA,kBACvH,WAAU;AAAA,kBAEV;AAAA,wCAAC,gBAAa,WAAU,WAAU;AAAA,oBACjC,EAAE,mDAAmD,kBAAkB;AAAA;AAAA;AAAA,cAC1E;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,SAAS,CAAC,MAAM;AAAE,sBAAE,gBAAgB;AAAG,8BAAU;AAAA,kBAAE;AAAA,kBAElD,YAAE,iCAAiC,SAAS;AAAA;AAAA,cAC/C;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,+CAAQ;",
6
6
  "names": []
7
7
  }
@@ -20,7 +20,7 @@ function CheckoutTransactionFailedRenderer({
20
20
  const isUnread = notification.status === "unread";
21
21
  const viewAction = actions.find((action) => action.id === "view") ?? actions[0] ?? null;
22
22
  const handleView = async () => {
23
- if (!viewAction) {
23
+ if (!viewAction || notification.status === "actioned") {
24
24
  if (notification.linkHref) router.push(notification.linkHref);
25
25
  return;
26
26
  }
@@ -69,7 +69,7 @@ function CheckoutTransactionFailedRenderer({
69
69
  e.stopPropagation();
70
70
  handleView();
71
71
  },
72
- disabled: executing || !viewAction && !notification.linkHref,
72
+ disabled: executing || !viewAction && !notification.linkHref || notification.status === "actioned" && !notification.linkHref,
73
73
  className: "gap-1",
74
74
  children: [
75
75
  /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" }),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/checkout/widgets/notifications/CheckoutTransactionFailedRenderer.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { AlertCircle, ExternalLink, Calendar } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n\nexport function CheckoutTransactionFailedRenderer({\n notification,\n onAction,\n onDismiss,\n actions = [],\n}: NotificationRendererProps) {\n const t = useT()\n const locale = useLocale()\n const router = useRouter()\n const [executing, setExecuting] = React.useState(false)\n const isUnread = notification.status === 'unread'\n\n const viewAction = actions.find((action) => action.id === 'view') ?? actions[0] ?? null\n\n const handleView = async () => {\n if (!viewAction) {\n if (notification.linkHref) router.push(notification.linkHref)\n return\n }\n setExecuting(true)\n try {\n await onAction(viewAction.id)\n } finally {\n setExecuting(false)\n }\n }\n\n return (\n <div\n className={cn(\n 'group relative px-4 py-3 hover:bg-muted/50 cursor-pointer transition-colors border-l-4 border-l-status-error-border',\n isUnread && 'bg-status-error-bg',\n )}\n onClick={handleView}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleView()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isUnread && (\n <div className=\"absolute left-1.5 top-1/2 -translate-y-1/2 h-2 w-2 rounded-full bg-primary\" />\n )}\n <div className=\"flex gap-3\">\n <div className=\"flex-shrink-0 mt-0.5\">\n <div className=\"h-10 w-10 rounded-lg bg-status-error-bg flex items-center justify-center\">\n <AlertCircle className=\"h-5 w-5 text-status-error-icon\" />\n </div>\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <h4 className={cn('text-sm font-medium', isUnread && 'font-semibold')}>\n {notification.title}\n </h4>\n <span className=\"flex-shrink-0 text-xs text-muted-foreground flex items-center gap-1\">\n <Calendar className=\"h-3 w-3\" />\n {formatRelativeTime(notification.createdAt, { locale, translate: t }) ?? ''}\n </span>\n </div>\n <div className=\"mt-3 flex gap-2\">\n <Button\n variant=\"default\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); handleView() }}\n disabled={executing || (!viewAction && !notification.linkHref)}\n className=\"gap-1\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {t('checkout.notifications.renderer.viewTransaction', 'View Transaction')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); onDismiss() }}\n >\n {t('notifications.actions.dismiss', 'Dismiss')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default CheckoutTransactionFailedRenderer\n"],
5
- "mappings": ";AAuDQ,cAaI,YAbJ;AArDR,YAAY,WAAW;AACvB,SAAS,aAAa,cAAc,gBAAgB;AACpD,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,WAAW,YAAY;AAGzB,SAAS,kCAAkC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AACb,GAA8B;AAC5B,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,WAAW,aAAa,WAAW;AAEzC,QAAM,aAAa,QAAQ,KAAK,CAAC,WAAW,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,KAAK;AAEnF,QAAM,aAAa,YAAY;AAC7B,QAAI,CAAC,YAAY;AACf,UAAI,aAAa,SAAU,QAAO,KAAK,aAAa,QAAQ;AAC5D;AAAA,IACF;AACA,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,SAAS,WAAW,EAAE;AAAA,IAC9B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,YAAY;AAAA,MACd;AAAA,MACA,SAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAA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client'\n\nimport * as React from 'react'\nimport { AlertCircle, ExternalLink, Calendar } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n\nexport function CheckoutTransactionFailedRenderer({\n notification,\n onAction,\n onDismiss,\n actions = [],\n}: NotificationRendererProps) {\n const t = useT()\n const locale = useLocale()\n const router = useRouter()\n const [executing, setExecuting] = React.useState(false)\n const isUnread = notification.status === 'unread'\n\n const viewAction = actions.find((action) => action.id === 'view') ?? actions[0] ?? null\n\n const handleView = async () => {\n if (!viewAction || notification.status === 'actioned') {\n if (notification.linkHref) router.push(notification.linkHref)\n return\n }\n setExecuting(true)\n try {\n await onAction(viewAction.id)\n } finally {\n setExecuting(false)\n }\n }\n\n return (\n <div\n className={cn(\n 'group relative px-4 py-3 hover:bg-muted/50 cursor-pointer transition-colors border-l-4 border-l-status-error-border',\n isUnread && 'bg-status-error-bg',\n )}\n onClick={handleView}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleView()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isUnread && (\n <div className=\"absolute left-1.5 top-1/2 -translate-y-1/2 h-2 w-2 rounded-full bg-primary\" />\n )}\n <div className=\"flex gap-3\">\n <div className=\"flex-shrink-0 mt-0.5\">\n <div className=\"h-10 w-10 rounded-lg bg-status-error-bg flex items-center justify-center\">\n <AlertCircle className=\"h-5 w-5 text-status-error-icon\" />\n </div>\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <h4 className={cn('text-sm font-medium', isUnread && 'font-semibold')}>\n {notification.title}\n </h4>\n <span className=\"flex-shrink-0 text-xs text-muted-foreground flex items-center gap-1\">\n <Calendar className=\"h-3 w-3\" />\n {formatRelativeTime(notification.createdAt, { locale, translate: t }) ?? ''}\n </span>\n </div>\n <div className=\"mt-3 flex gap-2\">\n <Button\n variant=\"default\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); handleView() }}\n disabled={executing || (!viewAction && !notification.linkHref) || (notification.status === 'actioned' && !notification.linkHref)}\n className=\"gap-1\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {t('checkout.notifications.renderer.viewTransaction', 'View Transaction')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); onDismiss() }}\n >\n {t('notifications.actions.dismiss', 'Dismiss')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default CheckoutTransactionFailedRenderer\n"],
5
+ "mappings": ";AAuDQ,cAaI,YAbJ;AArDR,YAAY,WAAW;AACvB,SAAS,aAAa,cAAc,gBAAgB;AACpD,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,WAAW,YAAY;AAGzB,SAAS,kCAAkC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AACb,GAA8B;AAC5B,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,WAAW,aAAa,WAAW;AAEzC,QAAM,aAAa,QAAQ,KAAK,CAAC,WAAW,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,KAAK;AAEnF,QAAM,aAAa,YAAY;AAC7B,QAAI,CAAC,cAAc,aAAa,WAAW,YAAY;AACrD,UAAI,aAAa,SAAU,QAAO,KAAK,aAAa,QAAQ;AAC5D;AAAA,IACF;AACA,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,SAAS,WAAW,EAAE;AAAA,IAC9B,UAAE;AACA,mB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kBACR,MAAK;AAAA,kBACL,SAAS,CAAC,MAAM;AAAE,sBAAE,gBAAgB;AAAG,8BAAU;AAAA,kBAAE;AAAA,kBAElD,YAAE,iCAAiC,SAAS;AAAA;AAAA,cAC/C;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,4CAAQ;",
6
6
  "names": []
7
7
  }
@@ -21,7 +21,7 @@ function CheckoutUsageLimitReachedRenderer({
21
21
  const linkName = notification.bodyVariables?.linkName ?? "";
22
22
  const viewAction = actions.find((action) => action.id === "view") ?? actions[0] ?? null;
23
23
  const handleView = async () => {
24
- if (!viewAction) {
24
+ if (!viewAction || notification.status === "actioned") {
25
25
  if (notification.linkHref) router.push(notification.linkHref);
26
26
  return;
27
27
  }
@@ -73,7 +73,7 @@ function CheckoutUsageLimitReachedRenderer({
73
73
  e.stopPropagation();
74
74
  handleView();
75
75
  },
76
- disabled: executing || !viewAction && !notification.linkHref,
76
+ disabled: executing || !viewAction && !notification.linkHref || notification.status === "actioned" && !notification.linkHref,
77
77
  className: "gap-1",
78
78
  children: [
79
79
  /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3" }),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/modules/checkout/widgets/notifications/CheckoutUsageLimitReachedRenderer.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { AlertTriangle, ExternalLink, Calendar } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n\nexport function CheckoutUsageLimitReachedRenderer({\n notification,\n onAction,\n onDismiss,\n actions = [],\n}: NotificationRendererProps) {\n const t = useT()\n const locale = useLocale()\n const router = useRouter()\n const [executing, setExecuting] = React.useState(false)\n const isUnread = notification.status === 'unread'\n\n const linkName = notification.bodyVariables?.linkName ?? ''\n const viewAction = actions.find((action) => action.id === 'view') ?? actions[0] ?? null\n\n const handleView = async () => {\n if (!viewAction) {\n if (notification.linkHref) router.push(notification.linkHref)\n return\n }\n setExecuting(true)\n try {\n await onAction(viewAction.id)\n } finally {\n setExecuting(false)\n }\n }\n\n return (\n <div\n className={cn(\n 'group relative px-4 py-3 hover:bg-muted/50 cursor-pointer transition-colors border-l-4 border-l-status-warning-border',\n isUnread && 'bg-status-warning-bg',\n )}\n onClick={handleView}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleView()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isUnread && (\n <div className=\"absolute left-1.5 top-1/2 -translate-y-1/2 h-2 w-2 rounded-full bg-primary\" />\n )}\n <div className=\"flex gap-3\">\n <div className=\"flex-shrink-0 mt-0.5\">\n <div className=\"h-10 w-10 rounded-lg bg-status-warning-bg flex items-center justify-center\">\n <AlertTriangle className=\"h-5 w-5 text-status-warning-icon\" />\n </div>\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <div>\n <h4 className={cn('text-sm font-medium', isUnread && 'font-semibold')}>\n {notification.title}\n </h4>\n {linkName ? (\n <span className=\"text-xs text-muted-foreground\">{linkName}</span>\n ) : null}\n </div>\n <span className=\"flex-shrink-0 text-xs text-muted-foreground flex items-center gap-1\">\n <Calendar className=\"h-3 w-3\" />\n {formatRelativeTime(notification.createdAt, { locale, translate: t }) ?? ''}\n </span>\n </div>\n <div className=\"mt-3 flex gap-2\">\n <Button\n variant=\"default\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); handleView() }}\n disabled={executing || (!viewAction && !notification.linkHref)}\n className=\"gap-1\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {t('checkout.notifications.renderer.viewLink', 'View Pay Link')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); onDismiss() }}\n >\n {t('notifications.actions.dismiss', 'Dismiss')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default CheckoutUsageLimitReachedRenderer\n"],
5
- "mappings": ";AAwDQ,cAUI,YAVJ;AAtDR,YAAY,WAAW;AACvB,SAAS,eAAe,cAAc,gBAAgB;AACtD,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,WAAW,YAAY;AAGzB,SAAS,kCAAkC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AACb,GAA8B;AAC5B,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,WAAW,aAAa,WAAW;AAEzC,QAAM,WAAW,aAAa,eAAe,YAAY;AACzD,QAAM,aAAa,QAAQ,KAAK,CAAC,WAAW,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,KAAK;AAEnF,QAAM,aAAa,YAAY;AAC7B,QAAI,CAAC,YAAY;AACf,UAAI,aAAa,SAAU,QAAO,KAAK,aAAa,QAAQ;AAC5D;AAAA,IACF;AACA,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,SAAS,WAAW,EAAE;AAAA,IAC9B,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,YAAY;AAAA,MACd;AAAA,MACA,SAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAChB,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,YAAE,eAAe;AACjB,qBAAW;AAAA,QACb;AAAA,MACF;AAAA,MAC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",
4
+ "sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { AlertTriangle, ExternalLink, Calendar } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { formatRelativeTime } from '@open-mercato/shared/lib/time'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { NotificationRendererProps } from '@open-mercato/shared/modules/notifications/types'\n\nexport function CheckoutUsageLimitReachedRenderer({\n notification,\n onAction,\n onDismiss,\n actions = [],\n}: NotificationRendererProps) {\n const t = useT()\n const locale = useLocale()\n const router = useRouter()\n const [executing, setExecuting] = React.useState(false)\n const isUnread = notification.status === 'unread'\n\n const linkName = notification.bodyVariables?.linkName ?? ''\n const viewAction = actions.find((action) => action.id === 'view') ?? actions[0] ?? null\n\n const handleView = async () => {\n if (!viewAction || notification.status === 'actioned') {\n if (notification.linkHref) router.push(notification.linkHref)\n return\n }\n setExecuting(true)\n try {\n await onAction(viewAction.id)\n } finally {\n setExecuting(false)\n }\n }\n\n return (\n <div\n className={cn(\n 'group relative px-4 py-3 hover:bg-muted/50 cursor-pointer transition-colors border-l-4 border-l-status-warning-border',\n isUnread && 'bg-status-warning-bg',\n )}\n onClick={handleView}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleView()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {isUnread && (\n <div className=\"absolute left-1.5 top-1/2 -translate-y-1/2 h-2 w-2 rounded-full bg-primary\" />\n )}\n <div className=\"flex gap-3\">\n <div className=\"flex-shrink-0 mt-0.5\">\n <div className=\"h-10 w-10 rounded-lg bg-status-warning-bg flex items-center justify-center\">\n <AlertTriangle className=\"h-5 w-5 text-status-warning-icon\" />\n </div>\n </div>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <div>\n <h4 className={cn('text-sm font-medium', isUnread && 'font-semibold')}>\n {notification.title}\n </h4>\n {linkName ? (\n <span className=\"text-xs text-muted-foreground\">{linkName}</span>\n ) : null}\n </div>\n <span className=\"flex-shrink-0 text-xs text-muted-foreground flex items-center gap-1\">\n <Calendar className=\"h-3 w-3\" />\n {formatRelativeTime(notification.createdAt, { locale, translate: t }) ?? ''}\n </span>\n </div>\n <div className=\"mt-3 flex gap-2\">\n <Button\n variant=\"default\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); handleView() }}\n disabled={executing || (!viewAction && !notification.linkHref) || (notification.status === 'actioned' && !notification.linkHref)}\n className=\"gap-1\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n {t('checkout.notifications.renderer.viewLink', 'View Pay Link')}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={(e) => { e.stopPropagation(); onDismiss() }}\n >\n {t('notifications.actions.dismiss', 'Dismiss')}\n </Button>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default CheckoutUsageLimitReachedRenderer\n"],
5
+ "mappings": ";AAwDQ,cAUI,YAVJ;AAtDR,YAAY,WAAW;AACvB,SAAS,eAAe,cAAc,gBAAgB;AACtD,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,WAAW,YAAY;AAGzB,SAAS,kCAAkC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AACb,GAA8B;AAC5B,QAAM,IAAI,KAAK;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,MAAM,SAAS,KAAK;AACtD,QAAM,WAAW,aAAa,WAAW;AAEzC,QAAM,WAAW,aAAa,eAAe,YAAY;AACzD,QAAM,aAAa,QAAQ,KAAK,CAAC,WAAW,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,KAAK;AAEnF,QAAM,aAAa,YAAY;AAC7B,QAAI,CAAC,cAAc,aA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pD,UAAU,aAAc,CAAC,cAAc,CAAC,aAAa,YAAc,aAAa,WAAW,cAAc,CAAC,aAAa;AAAA,kBACvH,WAAU;AAAA,kBAEV;AAAA,wCAAC,gBAAa,WAAU,WAAU;AAAA,oBACjC,EAAE,4CAA4C,eAAe;AAAA;AAAA;AAAA,cAChE;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,SAAS,CAAC,MAAM;AAAE,sBAAE,gBAAgB;AAAG,8BAAU;AAAA,kBAAE;AAAA,kBAElD,YAAE,iCAAiC,SAAS;AAAA;AAAA,cAC/C;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,4CAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/checkout",
3
- "version": "0.8.1-develop.7296.1.2111d779db",
3
+ "version": "0.9.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -62,18 +62,18 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "@open-mercato/core": "0.8.1-develop.7296.1.2111d779db",
66
- "@open-mercato/ui": "0.8.1-develop.7296.1.2111d779db",
65
+ "@open-mercato/core": "0.9.0",
66
+ "@open-mercato/ui": "0.9.0",
67
67
  "bcryptjs": "^3.0.3"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@mikro-orm/postgresql": "^7.0.14",
71
- "@open-mercato/shared": "0.8.1-develop.7296.1.2111d779db",
71
+ "@open-mercato/shared": "0.9.0",
72
72
  "react": "^19.0.0",
73
73
  "react-dom": "^19.0.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@open-mercato/shared": "0.8.1-develop.7296.1.2111d779db",
76
+ "@open-mercato/shared": "0.9.0",
77
77
  "@types/jest": "^30.0.0",
78
78
  "@types/react": "^19.2.18",
79
79
  "@types/react-dom": "^19.2.5",
@@ -92,6 +92,5 @@
92
92
  "type": "git",
93
93
  "url": "https://github.com/open-mercato/open-mercato",
94
94
  "directory": "packages/checkout"
95
- },
96
- "stableVersion": "0.8.0"
95
+ }
97
96
  }
@@ -0,0 +1,154 @@
1
+ /** @jest-environment node */
2
+
3
+ import { commandRegistry } from '@open-mercato/shared/lib/commands/registry'
4
+ import type { CommandRuntimeContext, CommandUndoLogEntry } from '@open-mercato/shared/lib/commands/types'
5
+ import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
6
+
7
+ const ORG_ID = '123e4567-e89b-12d3-a456-426614174000'
8
+ const TENANT_ID = '123e4567-e89b-12d3-a456-426614174001'
9
+ const FOREIGN_ORG_ID = '123e4567-e89b-12d3-a456-426614174100'
10
+ const FOREIGN_TENANT_ID = '123e4567-e89b-12d3-a456-426614174101'
11
+ const RECORD_ID = '123e4567-e89b-12d3-a456-426614174010'
12
+
13
+ const LOOKUP_SENTINEL = 'LOOKUP_REACHED'
14
+
15
+ const mockFindOneWithDecryption = jest.fn()
16
+ const mockSetCustomFieldsIfAny = jest.fn(async () => undefined)
17
+
18
+ jest.mock('@open-mercato/shared/lib/encryption/find', () => ({
19
+ findOneWithDecryption: jest.fn((...args: unknown[]) => mockFindOneWithDecryption(...args)),
20
+ findWithDecryption: jest.fn(async () => []),
21
+ }))
22
+
23
+ jest.mock('../../lib/gatewayProviderAvailability', () => ({
24
+ ensureGatewayProviderConfigured: jest.fn(async () => undefined),
25
+ getGatewayProviderConfigurationMessageKey: jest.fn(() => null),
26
+ }))
27
+
28
+ jest.mock('@open-mercato/shared/lib/commands/helpers', () => ({
29
+ setCustomFieldsIfAny: jest.fn((...args: unknown[]) => mockSetCustomFieldsIfAny(...(args as []))),
30
+ }))
31
+
32
+ jest.mock('@open-mercato/shared/lib/commands/customFieldSnapshots', () => ({
33
+ loadCustomFieldSnapshot: jest.fn(async () => ({})),
34
+ buildCustomFieldResetMap: jest.fn(() => ({ field: null })),
35
+ }))
36
+
37
+ jest.mock('@open-mercato/shared/lib/crud/custom-fields', () => ({
38
+ loadCustomFieldValues: jest.fn(async () => ({})),
39
+ }))
40
+
41
+ jest.mock('../../events', () => ({
42
+ emitCheckoutEvent: jest.fn(async () => undefined),
43
+ }))
44
+
45
+ import '../links'
46
+ import '../templates'
47
+
48
+ const mockEm = {
49
+ findOne: jest.fn(async () => {
50
+ throw new Error(LOOKUP_SENTINEL)
51
+ }),
52
+ flush: jest.fn(async () => undefined),
53
+ }
54
+
55
+ function makeContext(allowedIds: string[] | null = [ORG_ID]): CommandRuntimeContext {
56
+ return {
57
+ container: {
58
+ resolve: (token: string) => {
59
+ if (token === 'em') return mockEm
60
+ if (token === 'dataEngine') return {}
61
+ return null
62
+ },
63
+ } as unknown as CommandRuntimeContext['container'],
64
+ auth: { sub: 'user-1', orgId: ORG_ID, tenantId: TENANT_ID } as CommandRuntimeContext['auth'],
65
+ organizationScope: {
66
+ selectedId: ORG_ID,
67
+ filterIds: [ORG_ID],
68
+ allowedIds,
69
+ tenantId: TENANT_ID,
70
+ },
71
+ selectedOrganizationId: ORG_ID,
72
+ organizationIds: [ORG_ID],
73
+ }
74
+ }
75
+
76
+ function snapshot(organizationId: string, tenantId: string) {
77
+ return { id: RECORD_ID, organizationId, tenantId, slug: 'pay-link', custom: { field: 'value' } }
78
+ }
79
+
80
+ function logEntryFor(key: 'before' | 'after', organizationId: string, tenantId: string): CommandUndoLogEntry {
81
+ return { commandPayload: { undo: { [key]: snapshot(organizationId, tenantId) } } }
82
+ }
83
+
84
+ type Case = { commandId: string; mode: 'undo' | 'redo'; key: 'before' | 'after'; lookup: 'em' | 'decryption' }
85
+
86
+ const CASES: Case[] = [
87
+ { commandId: 'checkout.link.create', mode: 'undo', key: 'after', lookup: 'em' },
88
+ { commandId: 'checkout.link.create', mode: 'redo', key: 'after', lookup: 'decryption' },
89
+ { commandId: 'checkout.link.update', mode: 'undo', key: 'before', lookup: 'em' },
90
+ { commandId: 'checkout.link.delete', mode: 'undo', key: 'before', lookup: 'em' },
91
+ { commandId: 'checkout.template.create', mode: 'undo', key: 'after', lookup: 'em' },
92
+ { commandId: 'checkout.template.create', mode: 'redo', key: 'after', lookup: 'decryption' },
93
+ { commandId: 'checkout.template.update', mode: 'undo', key: 'before', lookup: 'em' },
94
+ { commandId: 'checkout.template.delete', mode: 'undo', key: 'before', lookup: 'em' },
95
+ ]
96
+
97
+ async function runHandler(testCase: Case, logEntry: CommandUndoLogEntry, ctx: CommandRuntimeContext = makeContext()) {
98
+ const handler = commandRegistry.get(testCase.commandId)
99
+ const run = testCase.mode === 'undo' ? handler?.undo : handler?.redo
100
+ if (!run) throw new Error(`[internal] ${testCase.commandId} has no ${testCase.mode} handler`)
101
+ return run({ input: {}, ctx, logEntry } as never)
102
+ }
103
+
104
+ function lookupMock(testCase: Case) {
105
+ return testCase.lookup === 'em' ? mockEm.findOne : mockFindOneWithDecryption
106
+ }
107
+
108
+ function lookupWhere(testCase: Case): Record<string, unknown> {
109
+ const calls = lookupMock(testCase).mock.calls as unknown[][]
110
+ return calls[0][testCase.lookup === 'em' ? 1 : 2] as Record<string, unknown>
111
+ }
112
+
113
+ describe('checkout undo/redo tenant scoping (#3831)', () => {
114
+ beforeEach(() => {
115
+ jest.clearAllMocks()
116
+ mockFindOneWithDecryption.mockImplementation(async () => {
117
+ throw new Error(LOOKUP_SENTINEL)
118
+ })
119
+ })
120
+
121
+ describe.each(CASES)('$commandId $mode', (testCase) => {
122
+ it('scopes the record lookup to the snapshot organization and tenant', async () => {
123
+ await expect(runHandler(testCase, logEntryFor(testCase.key, ORG_ID, TENANT_ID))).rejects.toThrow(LOOKUP_SENTINEL)
124
+
125
+ expect(lookupMock(testCase)).toHaveBeenCalledTimes(1)
126
+ expect(lookupWhere(testCase)).toMatchObject({ id: RECORD_ID, organizationId: ORG_ID, tenantId: TENANT_ID })
127
+ })
128
+
129
+ it('lets a caller with unrestricted organization visibility act on another organization of the same tenant', async () => {
130
+ await expect(
131
+ runHandler(testCase, logEntryFor(testCase.key, FOREIGN_ORG_ID, TENANT_ID), makeContext(null)),
132
+ ).rejects.toThrow(LOOKUP_SENTINEL)
133
+
134
+ expect(lookupWhere(testCase)).toMatchObject({ id: RECORD_ID, organizationId: FOREIGN_ORG_ID, tenantId: TENANT_ID })
135
+ })
136
+
137
+ it('rejects a snapshot from another tenant before touching any record', async () => {
138
+ const error = await runHandler(testCase, logEntryFor(testCase.key, ORG_ID, FOREIGN_TENANT_ID)).catch((err: unknown) => err)
139
+
140
+ expect(error).toBeInstanceOf(CrudHttpError)
141
+ expect(error).toMatchObject({ status: 403 })
142
+ expect(lookupMock(testCase)).not.toHaveBeenCalled()
143
+ expect(mockSetCustomFieldsIfAny).not.toHaveBeenCalled()
144
+ expect(mockEm.flush).not.toHaveBeenCalled()
145
+ })
146
+
147
+ it('rejects a snapshot from an organization outside the caller scope', async () => {
148
+ await expect(runHandler(testCase, logEntryFor(testCase.key, FOREIGN_ORG_ID, TENANT_ID))).rejects.toMatchObject({ status: 403 })
149
+ expect(lookupMock(testCase)).not.toHaveBeenCalled()
150
+ expect(mockSetCustomFieldsIfAny).not.toHaveBeenCalled()
151
+ expect(mockEm.flush).not.toHaveBeenCalled()
152
+ })
153
+ })
154
+ })
@@ -37,6 +37,7 @@ import {
37
37
  extractUndoPayload,
38
38
  readCommandId,
39
39
  resolveCommandScope,
40
+ resolveUndoScope,
40
41
  restoreLinkFromSnapshot,
41
42
  toCheckoutAuditSnapshot,
42
43
  type CheckoutLinkSnapshot,
@@ -182,6 +183,7 @@ const createLinkCommand: CommandHandler<Record<string, unknown>, { id: string; s
182
183
  undo: async ({ logEntry, ctx }) => {
183
184
  const after = extractUndoPayload<CheckoutLinkUndoPayload>(logEntry)?.after
184
185
  if (!after) return
186
+ const scope = resolveUndoScope(ctx, after)
185
187
  const em = ctx.container.resolve('em') as EntityManager
186
188
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
187
189
  const reset = buildCustomFieldResetMap(undefined, after.custom)
@@ -196,7 +198,7 @@ const createLinkCommand: CommandHandler<Record<string, unknown>, { id: string; s
196
198
  notify: false,
197
199
  })
198
200
  }
199
- const link = await em.findOne(CheckoutLink, { id: after.id })
201
+ const link = await em.findOne(CheckoutLink, { id: after.id, ...scope })
200
202
  if (!link) return
201
203
  link.deletedAt = new Date()
202
204
  await em.flush()
@@ -204,15 +206,10 @@ const createLinkCommand: CommandHandler<Record<string, unknown>, { id: string; s
204
206
  redo: async ({ logEntry, ctx }) => {
205
207
  const after = resolveRedoSnapshot<CheckoutLinkSnapshot>(logEntry)
206
208
  if (!after) throw new CrudHttpError(400, { error: '[internal] redo snapshot unavailable for checkout link create' })
209
+ const scope = resolveUndoScope(ctx, after)
207
210
  const em = ctx.container.resolve('em') as EntityManager
208
211
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
209
- let link = await findOneWithDecryption(
210
- em,
211
- CheckoutLink,
212
- { id: after.id },
213
- {},
214
- { tenantId: after.tenantId, organizationId: after.organizationId },
215
- )
212
+ let link = await findOneWithDecryption(em, CheckoutLink, { id: after.id, ...scope }, {}, scope)
216
213
  if (link) {
217
214
  restoreLinkFromSnapshot(link, after)
218
215
  link.deletedAt = null
@@ -387,9 +384,10 @@ const updateLinkCommand: CommandHandler<Record<string, unknown>, { ok: true; slu
387
384
  const before = undo?.before
388
385
  const after = undo?.after
389
386
  if (!before) return
387
+ const scope = resolveUndoScope(ctx, before)
390
388
  const em = ctx.container.resolve('em') as EntityManager
391
389
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
392
- const link = await em.findOne(CheckoutLink, { id: before.id, deletedAt: null })
390
+ const link = await em.findOne(CheckoutLink, { id: before.id, ...scope, deletedAt: null })
393
391
  if (!link) return
394
392
  restoreLinkFromSnapshot(link, before)
395
393
  link.slug = await resolveRestoredLinkSlug(em, before)
@@ -486,9 +484,10 @@ const deleteLinkCommand: CommandHandler<Record<string, unknown>, { ok: true }> =
486
484
  undo: async ({ logEntry, ctx }) => {
487
485
  const before = extractUndoPayload<CheckoutLinkUndoPayload>(logEntry)?.before
488
486
  if (!before) return
487
+ const scope = resolveUndoScope(ctx, before)
489
488
  const em = ctx.container.resolve('em') as EntityManager
490
489
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
491
- let link = await em.findOne(CheckoutLink, { id: before.id })
490
+ let link = await em.findOne(CheckoutLink, { id: before.id, ...scope })
492
491
  if (link) {
493
492
  restoreLinkFromSnapshot(link, before)
494
493
  link.slug = await resolveRestoredLinkSlug(em, before)
@@ -1,4 +1,5 @@
1
1
  import type { CommandRuntimeContext } from '@open-mercato/shared/lib/commands'
2
+ import { ensureOrganizationScope, ensureTenantScope } from '@open-mercato/shared/lib/commands/scope'
2
3
  import { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'
3
4
  import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
4
5
  import type { CustomFieldSnapshot } from '@open-mercato/shared/lib/commands/customFieldSnapshots'
@@ -14,6 +15,12 @@ export function resolveCommandScope(ctx: CommandRuntimeContext): CheckoutScope {
14
15
  return requireCheckoutScope({ auth: ctx.auth })
15
16
  }
16
17
 
18
+ export function resolveUndoScope(ctx: CommandRuntimeContext, snapshot: CheckoutScope): CheckoutScope {
19
+ ensureTenantScope(ctx, snapshot.tenantId)
20
+ ensureOrganizationScope(ctx, snapshot.organizationId)
21
+ return { organizationId: snapshot.organizationId, tenantId: snapshot.tenantId }
22
+ }
23
+
17
24
  export function readCommandId(input: unknown, message: string): string {
18
25
  if (typeof input === 'string' && input.trim()) return input
19
26
  if (isRecord(input)) {
@@ -34,6 +34,7 @@ import {
34
34
  captureLinkSnapshot,
35
35
  readCommandId,
36
36
  resolveCommandScope,
37
+ resolveUndoScope,
37
38
  restoreLinkFromSnapshot,
38
39
  restoreTemplateFromSnapshot,
39
40
  toCheckoutAuditSnapshot,
@@ -171,6 +172,7 @@ const createTemplateCommand: CommandHandler<Record<string, unknown>, { id: strin
171
172
  undo: async ({ logEntry, ctx }) => {
172
173
  const after = extractUndoPayload<CheckoutTemplateUndoPayload>(logEntry)?.after
173
174
  if (!after) return
175
+ const scope = resolveUndoScope(ctx, after)
174
176
  const em = ctx.container.resolve('em') as EntityManager
175
177
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
176
178
  const reset = buildCustomFieldResetMap(undefined, after.custom)
@@ -185,7 +187,7 @@ const createTemplateCommand: CommandHandler<Record<string, unknown>, { id: strin
185
187
  notify: false,
186
188
  })
187
189
  }
188
- const template = await em.findOne(CheckoutLinkTemplate, { id: after.id })
190
+ const template = await em.findOne(CheckoutLinkTemplate, { id: after.id, ...scope })
189
191
  if (!template) return
190
192
  template.deletedAt = new Date()
191
193
  await em.flush()
@@ -193,15 +195,10 @@ const createTemplateCommand: CommandHandler<Record<string, unknown>, { id: strin
193
195
  redo: async ({ logEntry, ctx }) => {
194
196
  const after = resolveRedoSnapshot<CheckoutTemplateSnapshot>(logEntry)
195
197
  if (!after) throw new CrudHttpError(400, { error: '[internal] redo snapshot unavailable for checkout template create' })
198
+ const scope = resolveUndoScope(ctx, after)
196
199
  const em = ctx.container.resolve('em') as EntityManager
197
200
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
198
- let template = await findOneWithDecryption(
199
- em,
200
- CheckoutLinkTemplate,
201
- { id: after.id },
202
- {},
203
- { tenantId: after.tenantId, organizationId: after.organizationId },
204
- )
201
+ let template = await findOneWithDecryption(em, CheckoutLinkTemplate, { id: after.id, ...scope }, {}, scope)
205
202
  if (template) {
206
203
  restoreTemplateFromSnapshot(template, after)
207
204
  template.deletedAt = null
@@ -370,9 +367,10 @@ const updateTemplateCommand: CommandHandler<Record<string, unknown>, { ok: true
370
367
  const before = undo?.before
371
368
  const after = undo?.after
372
369
  if (!before) return
370
+ const scope = resolveUndoScope(ctx, before)
373
371
  const em = ctx.container.resolve('em') as EntityManager
374
372
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
375
- const template = await em.findOne(CheckoutLinkTemplate, { id: before.id, deletedAt: null })
373
+ const template = await em.findOne(CheckoutLinkTemplate, { id: before.id, ...scope, deletedAt: null })
376
374
  if (!template) return
377
375
  restoreTemplateFromSnapshot(template, before)
378
376
  await em.flush()
@@ -392,7 +390,7 @@ const updateTemplateCommand: CommandHandler<Record<string, unknown>, { ok: true
392
390
  await syncLinkedLinksWithTemplateSnapshot({
393
391
  em,
394
392
  dataEngine,
395
- scope: { organizationId: before.organizationId, tenantId: before.tenantId },
393
+ scope,
396
394
  templateId: before.id,
397
395
  before: after,
398
396
  after: before,
@@ -477,9 +475,10 @@ const deleteTemplateCommand: CommandHandler<Record<string, unknown>, { ok: true
477
475
  undo: async ({ logEntry, ctx }) => {
478
476
  const before = extractUndoPayload<CheckoutTemplateUndoPayload>(logEntry)?.before
479
477
  if (!before) return
478
+ const scope = resolveUndoScope(ctx, before)
480
479
  const em = ctx.container.resolve('em') as EntityManager
481
480
  const dataEngine = ctx.container.resolve('dataEngine') as DataEngine
482
- let template = await em.findOne(CheckoutLinkTemplate, { id: before.id })
481
+ let template = await em.findOne(CheckoutLinkTemplate, { id: before.id, ...scope })
483
482
  if (template) {
484
483
  restoreTemplateFromSnapshot(template, before)
485
484
  } else {
@@ -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'
@@ -120,6 +121,24 @@ export function toSubmittedAmount(value: unknown, locale?: string): number | nul
120
121
  return parseLocaleNumber(value, locale)
121
122
  }
122
123
 
124
+ function isUnparseableAmount(value: unknown, locale?: string): boolean {
125
+ return typeof value === 'string' && value.trim().length > 0 && toSubmittedAmount(value, locale) === null
126
+ }
127
+
128
+ // `toSubmittedAmount` turns unparseable text into `null`, which the API then reads as "no
129
+ // amount" (or, for a price-list row, coerces to 0), so the typed value would be lost silently
130
+ // (issue #6311). Collects the money fields of the active pricing mode that hold text the
131
+ // locale-aware parser cannot read, keyed by form path, so submission can stop with a field error.
132
+ export function collectUnparseableAmountPaths(values: Record<string, unknown>, locale?: string): string[] {
133
+ const pricingMode = readString(values.pricingMode) || 'fixed'
134
+ const candidates: Array<[string, unknown]> = pricingMode === 'custom_amount'
135
+ ? [['customAmountMin', values.customAmountMin], ['customAmountMax', values.customAmountMax]]
136
+ : pricingMode === 'price_list'
137
+ ? normalizePriceListItems(values.priceListItems).map((item, index) => [`priceListItems.${index}.amount`, item.amount])
138
+ : [['fixedPriceAmount', values.fixedPriceAmount], ['fixedPriceOriginalAmount', values.fixedPriceOriginalAmount]]
139
+ return candidates.filter(([, value]) => isUnparseableAmount(value, locale)).map(([path]) => path)
140
+ }
141
+
123
142
  function readBoolean(value: unknown, fallback = false): boolean {
124
143
  return typeof value === 'boolean' ? value : fallback
125
144
  }
@@ -1686,6 +1705,14 @@ export function LinkTemplateForm({ mode, recordId }: Props) {
1686
1705
  ? 'publish'
1687
1706
  : 'save'
1688
1707
  const shouldOpenPreview = submitIntent === 'preview'
1708
+ const unparseableAmountPaths = collectUnparseableAmountPaths(values, locale)
1709
+ if (unparseableAmountPaths.length > 0) {
1710
+ const invalidNumberMessage = t('checkout.validation.common.invalidNumber')
1711
+ throw createCrudFormError(
1712
+ invalidNumberMessage,
1713
+ Object.fromEntries(unparseableAmountPaths.map((path) => [path, invalidNumberMessage])),
1714
+ )
1715
+ }
1689
1716
  const payload = {
1690
1717
  ...values,
1691
1718
  status: submitIntent === 'publish' ? 'active' : values.status,