@open-mercato/core 0.11.1-develop.8541.1.955f210e1d → 0.11.1-develop.8549.1.bd34c91190

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 (121) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/modules/customer_accounts/api/admin/users/[id]/verify-email.js +10 -30
  3. package/dist/modules/customer_accounts/api/admin/users/[id]/verify-email.js.map +2 -2
  4. package/dist/modules/customer_accounts/api/admin/users/[id].js +10 -9
  5. package/dist/modules/customer_accounts/api/admin/users/[id].js.map +2 -2
  6. package/dist/modules/customer_accounts/api/email/verify.js +11 -10
  7. package/dist/modules/customer_accounts/api/email/verify.js.map +2 -2
  8. package/dist/modules/customer_accounts/api/magic-link/verify.js +9 -8
  9. package/dist/modules/customer_accounts/api/magic-link/verify.js.map +2 -2
  10. package/dist/modules/customer_accounts/api/password/reset-confirm.js +13 -16
  11. package/dist/modules/customer_accounts/api/password/reset-confirm.js.map +2 -2
  12. package/dist/modules/customer_accounts/api/portal/notifications/[id]/dismiss.js +3 -2
  13. package/dist/modules/customer_accounts/api/portal/notifications/[id]/dismiss.js.map +2 -2
  14. package/dist/modules/customer_accounts/api/portal/notifications/[id]/read.js +3 -2
  15. package/dist/modules/customer_accounts/api/portal/notifications/[id]/read.js.map +2 -2
  16. package/dist/modules/customer_accounts/api/portal/notifications/mark-all-read.js +4 -0
  17. package/dist/modules/customer_accounts/api/portal/notifications/mark-all-read.js.map +2 -2
  18. package/dist/modules/customer_accounts/api/portal/notifications/unread-count.js +4 -0
  19. package/dist/modules/customer_accounts/api/portal/notifications/unread-count.js.map +2 -2
  20. package/dist/modules/customer_accounts/api/portal/notifications.js +4 -0
  21. package/dist/modules/customer_accounts/api/portal/notifications.js.map +2 -2
  22. package/dist/modules/customer_accounts/api/signup.js +33 -19
  23. package/dist/modules/customer_accounts/api/signup.js.map +3 -3
  24. package/dist/modules/customer_accounts/data/validators.js +3 -2
  25. package/dist/modules/customer_accounts/data/validators.js.map +2 -2
  26. package/dist/modules/customer_accounts/lib/customerAuth.js +11 -10
  27. package/dist/modules/customer_accounts/lib/customerAuth.js.map +2 -2
  28. package/dist/modules/customer_accounts/lib/customerAuthServer.js +7 -7
  29. package/dist/modules/customer_accounts/lib/customerAuthServer.js.map +2 -2
  30. package/dist/modules/customer_accounts/lib/customerEntityOwnership.js +12 -1
  31. package/dist/modules/customer_accounts/lib/customerEntityOwnership.js.map +2 -2
  32. package/dist/modules/customer_accounts/lib/moduleEntityRegistration.js +8 -0
  33. package/dist/modules/customer_accounts/lib/moduleEntityRegistration.js.map +7 -0
  34. package/dist/modules/customer_accounts/lib/pendingSignup.js +16 -0
  35. package/dist/modules/customer_accounts/lib/pendingSignup.js.map +7 -0
  36. package/dist/modules/customer_accounts/lib/portalNotificationsAvailability.js +9 -0
  37. package/dist/modules/customer_accounts/lib/portalNotificationsAvailability.js.map +7 -0
  38. package/dist/modules/customer_accounts/lib/verifyCustomerEmail.js +50 -0
  39. package/dist/modules/customer_accounts/lib/verifyCustomerEmail.js.map +7 -0
  40. package/dist/modules/customer_accounts/services/customerInvitationService.js +15 -1
  41. package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
  42. package/dist/modules/customer_accounts/services/customerTokenService.js +13 -13
  43. package/dist/modules/customer_accounts/services/customerTokenService.js.map +2 -2
  44. package/dist/modules/customer_accounts/services/customerUserService.js +1 -1
  45. package/dist/modules/customer_accounts/services/customerUserService.js.map +2 -2
  46. package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js +44 -51
  47. package/dist/modules/customer_accounts/subscribers/autoLinkCrm.js.map +2 -2
  48. package/dist/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.js +12 -0
  49. package/dist/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.js.map +7 -0
  50. package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js +3 -1
  51. package/dist/modules/customer_accounts/subscribers/autoLinkCrmReverse.js.map +2 -2
  52. package/dist/modules/customer_accounts/workers/cleanupExpiredTokens.js +6 -0
  53. package/dist/modules/customer_accounts/workers/cleanupExpiredTokens.js.map +2 -2
  54. package/dist/modules/portal/frontend/[orgSlug]/portal/PasswordForm.js +127 -0
  55. package/dist/modules/portal/frontend/[orgSlug]/portal/PasswordForm.js.map +7 -0
  56. package/dist/modules/portal/frontend/[orgSlug]/portal/reset-password/page.js +10 -122
  57. package/dist/modules/portal/frontend/[orgSlug]/portal/reset-password/page.js.map +2 -2
  58. package/dist/modules/portal/frontend/[orgSlug]/portal/signup/page.js +2 -11
  59. package/dist/modules/portal/frontend/[orgSlug]/portal/signup/page.js.map +2 -2
  60. package/dist/modules/portal/frontend/[orgSlug]/portal/verify/page.js +3 -61
  61. package/dist/modules/portal/frontend/[orgSlug]/portal/verify/page.js.map +2 -2
  62. package/dist/modules/wms/index.js +1 -1
  63. package/dist/modules/wms/index.js.map +2 -2
  64. package/dist/modules/wms/setup.js +4 -1
  65. package/dist/modules/wms/setup.js.map +2 -2
  66. package/dist/modules/workflows/api/events/route.js +1 -1
  67. package/dist/modules/workflows/api/events/route.js.map +2 -2
  68. package/dist/modules/workflows/api/instances/[id]/events/route.js +1 -1
  69. package/dist/modules/workflows/api/instances/[id]/events/route.js.map +2 -2
  70. package/dist/modules/workflows/api/instances/[id]/steps/route.js +1 -1
  71. package/dist/modules/workflows/api/instances/[id]/steps/route.js.map +2 -2
  72. package/dist/modules/workflows/api/instances/failure-queue/route.js +1 -1
  73. package/dist/modules/workflows/api/instances/failure-queue/route.js.map +2 -2
  74. package/dist/modules/workflows/lib/event-logger.js +1 -1
  75. package/dist/modules/workflows/lib/event-logger.js.map +2 -2
  76. package/dist/modules/workflows/lib/work-inbox/user-task-source.js +1 -1
  77. package/dist/modules/workflows/lib/work-inbox/user-task-source.js.map +2 -2
  78. package/package.json +7 -7
  79. package/src/modules/customer_accounts/api/admin/users/[id]/verify-email.ts +11 -33
  80. package/src/modules/customer_accounts/api/admin/users/[id].ts +10 -9
  81. package/src/modules/customer_accounts/api/email/verify.ts +15 -11
  82. package/src/modules/customer_accounts/api/magic-link/verify.ts +9 -9
  83. package/src/modules/customer_accounts/api/password/reset-confirm.ts +13 -18
  84. package/src/modules/customer_accounts/api/portal/notifications/[id]/dismiss.ts +8 -5
  85. package/src/modules/customer_accounts/api/portal/notifications/[id]/read.ts +8 -5
  86. package/src/modules/customer_accounts/api/portal/notifications/mark-all-read.ts +4 -0
  87. package/src/modules/customer_accounts/api/portal/notifications/unread-count.ts +4 -0
  88. package/src/modules/customer_accounts/api/portal/notifications.ts +4 -0
  89. package/src/modules/customer_accounts/api/signup.ts +36 -24
  90. package/src/modules/customer_accounts/data/validators.ts +2 -1
  91. package/src/modules/customer_accounts/lib/customerAuth.ts +12 -10
  92. package/src/modules/customer_accounts/lib/customerAuthServer.ts +7 -7
  93. package/src/modules/customer_accounts/lib/customerEntityOwnership.ts +13 -1
  94. package/src/modules/customer_accounts/lib/moduleEntityRegistration.ts +12 -0
  95. package/src/modules/customer_accounts/lib/pendingSignup.ts +12 -0
  96. package/src/modules/customer_accounts/lib/portalNotificationsAvailability.ts +7 -0
  97. package/src/modules/customer_accounts/lib/verifyCustomerEmail.ts +57 -0
  98. package/src/modules/customer_accounts/services/customerInvitationService.ts +16 -1
  99. package/src/modules/customer_accounts/services/customerTokenService.ts +13 -13
  100. package/src/modules/customer_accounts/services/customerUserService.ts +2 -2
  101. package/src/modules/customer_accounts/subscribers/autoLinkCrm.ts +46 -78
  102. package/src/modules/customer_accounts/subscribers/autoLinkCrmOnVerification.ts +9 -0
  103. package/src/modules/customer_accounts/subscribers/autoLinkCrmReverse.ts +3 -1
  104. package/src/modules/customer_accounts/workers/cleanupExpiredTokens.ts +7 -0
  105. package/src/modules/portal/frontend/[orgSlug]/portal/PasswordForm.tsx +182 -0
  106. package/src/modules/portal/frontend/[orgSlug]/portal/reset-password/page.tsx +9 -165
  107. package/src/modules/portal/frontend/[orgSlug]/portal/signup/page.tsx +2 -12
  108. package/src/modules/portal/frontend/[orgSlug]/portal/verify/page.tsx +3 -89
  109. package/src/modules/portal/i18n/de.json +2 -1
  110. package/src/modules/portal/i18n/en.json +2 -1
  111. package/src/modules/portal/i18n/es.json +2 -1
  112. package/src/modules/portal/i18n/ko.json +2 -1
  113. package/src/modules/portal/i18n/pl.json +2 -1
  114. package/src/modules/wms/index.ts +1 -1
  115. package/src/modules/wms/setup.ts +4 -1
  116. package/src/modules/workflows/api/events/route.ts +1 -1
  117. package/src/modules/workflows/api/instances/[id]/events/route.ts +1 -1
  118. package/src/modules/workflows/api/instances/[id]/steps/route.ts +3 -2
  119. package/src/modules/workflows/api/instances/failure-queue/route.ts +1 -1
  120. package/src/modules/workflows/lib/event-logger.ts +1 -1
  121. package/src/modules/workflows/lib/work-inbox/user-task-source.ts +3 -2
@@ -1,173 +1,17 @@
1
1
  "use client"
2
- import { useCallback, useMemo, useState, useEffect } from 'react'
2
+ import { useMemo } from 'react'
3
3
  import { extensionPoints } from '@open-mercato/core/modules/portal/extension-points'
4
- import { useSearchParams } from 'next/navigation'
5
- import Link from 'next/link'
6
- import { useT } from '@open-mercato/shared/lib/i18n/context'
7
- import { PasswordInput } from '@open-mercato/ui/primitives/password-input'
8
- import { Label } from '@open-mercato/ui/primitives/label'
9
- import { Button } from '@open-mercato/ui/primitives/button'
10
- import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
11
- import { EmptyState } from '@open-mercato/ui/primitives/empty-state'
12
- import { SearchX } from 'lucide-react'
13
- import { Spinner } from '@open-mercato/ui/primitives/spinner'
14
- import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
15
- import { usePortalContext } from '@open-mercato/ui/portal/PortalContext'
16
4
  import { InjectionSpot } from '@open-mercato/ui/backend/injection/InjectionSpot'
5
+ import { PortalPasswordForm } from '../PasswordForm'
17
6
 
18
- type Props = { params: { orgSlug: string } }
19
-
20
- export default function PortalResetPasswordPage({ params }: Props) {
21
- const t = useT()
7
+ export default function PortalResetPasswordPage({ params }: { params: { orgSlug: string } }) {
22
8
  const orgSlug = params.orgSlug
23
- const { tenant } = usePortalContext()
24
- const searchParams = useSearchParams()
25
-
26
- const [password, setPassword] = useState('')
27
- const [confirmPassword, setConfirmPassword] = useState('')
28
- const [error, setError] = useState<string | null>(null)
29
- const [success, setSuccess] = useState(false)
30
- const [submitting, setSubmitting] = useState(false)
31
- const [token, setToken] = useState<string | null>(null)
32
-
33
- useEffect(() => {
34
- const tokenParam = searchParams.get('token')
35
- if (!tokenParam) {
36
- setError(t('portal.resetPassword.error.noToken', 'Invalid or missing reset token.'))
37
- } else {
38
- setToken(tokenParam)
39
- }
40
- }, [searchParams, t])
41
-
42
- const handleSubmit = useCallback(
43
- async (event: React.FormEvent) => {
44
- event.preventDefault()
45
- setError(null)
46
-
47
- if (!token) {
48
- setError(t('portal.resetPassword.error.noToken', 'Invalid or missing reset token.'))
49
- return
50
- }
51
-
52
- if (password !== confirmPassword) {
53
- setError(t('portal.resetPassword.error.passwordMismatch', 'Passwords do not match.'))
54
- return
55
- }
56
-
57
- if (password.length < 8) {
58
- setError(t('portal.resetPassword.error.passwordTooShort', 'Password must be at least 8 characters long.'))
59
- return
60
- }
61
-
62
- setSubmitting(true)
63
- try {
64
- const result = await apiCall<{ ok: boolean; error?: string }>('/api/customer_accounts/password/reset-confirm', {
65
- method: 'POST',
66
- headers: { 'Content-Type': 'application/json' },
67
- body: JSON.stringify({ token, password }),
68
- })
69
-
70
- if (result.ok && result.result?.ok) {
71
- setSuccess(true)
72
- return
73
- }
74
-
75
- if (result.status === 400) {
76
- setError(t('portal.resetPassword.error.invalidToken', 'Invalid or expired reset token.'))
77
- } else {
78
- setError(result.result?.error || t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))
79
- }
80
- } catch {
81
- setError(t('portal.resetPassword.error.generic', 'Password reset failed. Please try again.'))
82
- } finally {
83
- setSubmitting(false)
84
- }
85
- },
86
- [token, password, confirmPassword, t],
87
- )
88
-
89
- const injectionContext = useMemo(
90
- () => ({ orgSlug }),
91
- [orgSlug],
92
- )
93
-
94
- if (tenant.loading) {
95
- return <div className="flex items-center justify-center py-20"><Spinner /></div>
96
- }
97
-
98
- if (tenant.error) {
99
- return (
100
- <div className="mx-auto w-full max-w-md py-12">
101
- <EmptyState
102
- variant="subtle"
103
- size="lg"
104
- icon={<SearchX className="h-6 w-6" aria-hidden />}
105
- title={t('portal.org.invalid', 'Organization not found.')}
106
- />
107
- </div>
108
- )
109
- }
110
-
111
- if (success) {
112
- return (
113
- <div className="mx-auto w-full max-w-sm">
114
- <div className="mb-8 text-center">
115
- <h1 className="text-2xl font-bold tracking-tight">{t('portal.resetPassword.success.title', 'Password Reset Complete')}</h1>
116
- <p className="mt-1.5 text-sm text-muted-foreground">{t('portal.resetPassword.success.description', 'Your password has been successfully reset.')}</p>
117
- </div>
118
-
119
- <Alert>
120
- <AlertDescription>{t('portal.resetPassword.success.message', 'You can now sign in with your new password.')}</AlertDescription>
121
- </Alert>
122
-
123
- <div className="mt-6 text-center">
124
- <Link href={`/${orgSlug}/portal/login`} className="font-medium text-foreground underline underline-offset-4 hover:opacity-80">
125
- {t('portal.resetPassword.success.loginLink', 'Go to Sign In')}
126
- </Link>
127
- </div>
128
- </div>
129
- )
130
- }
131
-
9
+ const injectionContext = useMemo(() => ({ orgSlug }), [orgSlug])
132
10
  return (
133
- <div className="mx-auto w-full max-w-sm">
134
- <div className="mb-8 text-center">
135
- <h1 className="text-2xl font-bold tracking-tight">{t('portal.resetPassword.title', 'Reset Password')}</h1>
136
- <p className="mt-1.5 text-sm text-muted-foreground">{t('portal.resetPassword.description', 'Enter your new password below.')}</p>
137
- </div>
138
-
139
- <InjectionSpot spotId={extensionPoints.hosts.resetPasswordBefore.spotId} context={injectionContext} />
140
-
141
- <form onSubmit={handleSubmit} className="flex flex-col gap-4">
142
- {error ? (
143
- <Alert status="error">
144
- <AlertDescription>{error}</AlertDescription>
145
- </Alert>
146
- ) : null}
147
-
148
- <div className="flex flex-col gap-1.5">
149
- <Label htmlFor="reset-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.resetPassword.password', 'New Password')}</Label>
150
- <PasswordInput id="reset-password" autoComplete="new-password" required placeholder={t('portal.resetPassword.password.placeholder', '••••••••')} value={password} onChange={(e) => setPassword(e.target.value)} disabled={submitting || !token} className="rounded-lg" />
151
- </div>
152
-
153
- <div className="flex flex-col gap-1.5">
154
- <Label htmlFor="confirm-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.resetPassword.confirmPassword', 'Confirm New Password')}</Label>
155
- <PasswordInput id="confirm-password" autoComplete="new-password" required placeholder={t('portal.resetPassword.confirmPassword.placeholder', '••••••••')} value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} disabled={submitting || !token} className="rounded-lg" />
156
- </div>
157
-
158
- <Button type="submit" disabled={submitting || !token} className="mt-1 w-full rounded-lg">
159
- {submitting ? t('portal.resetPassword.submitting', 'Resetting password...') : t('portal.resetPassword.submit', 'Reset Password')}
160
- </Button>
161
-
162
- <p className="text-center text-sm text-muted-foreground">
163
- {t('portal.resetPassword.backToLogin', 'Remember your password?')}{' '}
164
- <Link href={`/${orgSlug}/portal/login`} className="font-medium text-foreground underline underline-offset-4 hover:opacity-80">
165
- {t('portal.resetPassword.loginLink', 'Sign in')}
166
- </Link>
167
- </p>
168
- </form>
169
-
170
- <InjectionSpot spotId={extensionPoints.hosts.resetPasswordAfter.spotId} context={injectionContext} />
171
- </div>
11
+ <PortalPasswordForm
12
+ params={params}
13
+ beforeForm={<InjectionSpot spotId={extensionPoints.hosts.resetPasswordBefore.spotId} context={injectionContext} />}
14
+ afterForm={<InjectionSpot spotId={extensionPoints.hosts.resetPasswordAfter.spotId} context={injectionContext} />}
15
+ />
172
16
  )
173
17
  }
@@ -5,7 +5,6 @@ import Link from 'next/link'
5
5
  import { useT } from '@open-mercato/shared/lib/i18n/context'
6
6
  import { Input } from '@open-mercato/ui/primitives/input'
7
7
  import { EmailInput } from '@open-mercato/ui/primitives/email-input'
8
- import { PasswordInput } from '@open-mercato/ui/primitives/password-input'
9
8
  import { Label } from '@open-mercato/ui/primitives/label'
10
9
  import { Button } from '@open-mercato/ui/primitives/button'
11
10
  import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
@@ -26,7 +25,6 @@ export default function PortalSignupPage({ params }: Props) {
26
25
 
27
26
  const [displayName, setDisplayName] = useState('')
28
27
  const [email, setEmail] = useState('')
29
- const [password, setPassword] = useState('')
30
28
  const [error, setError] = useState<string | null>(null)
31
29
  const [fieldErrors, setFieldErrors] = useState<Record<string, string>>({})
32
30
  const [success, setSuccess] = useState(false)
@@ -48,7 +46,7 @@ export default function PortalSignupPage({ params }: Props) {
48
46
  const result = await apiCall<SignupResponse>('/api/customer_accounts/signup', {
49
47
  method: 'POST',
50
48
  headers: { 'Content-Type': 'application/json' },
51
- body: JSON.stringify({ email, password, displayName, organizationId: tenant.organizationId }),
49
+ body: JSON.stringify({ email, displayName, organizationId: tenant.organizationId }),
52
50
  })
53
51
 
54
52
  if (result.status === 202 && result.result?.ok) {
@@ -66,8 +64,6 @@ export default function PortalSignupPage({ params }: Props) {
66
64
  mapped.displayName = t('portal.signup.error.displayName.required', 'Full name is required.')
67
65
  } else if (fieldKey === 'email') {
68
66
  mapped.email = t('portal.signup.error.email.invalid', 'Please enter a valid email address.')
69
- } else if (fieldKey === 'password') {
70
- mapped.password = t('portal.signup.error.password.minLength', 'Password must be at least 8 characters.')
71
67
  }
72
68
  }
73
69
  const hasUnmappedField = detailEntries.some(([fieldKey]) => !(fieldKey in mapped))
@@ -84,7 +80,7 @@ export default function PortalSignupPage({ params }: Props) {
84
80
  setSubmitting(false)
85
81
  }
86
82
  },
87
- [displayName, email, password, tenant.organizationId, t],
83
+ [displayName, email, tenant.organizationId, t],
88
84
  )
89
85
 
90
86
  const injectionContext = useMemo(
@@ -155,12 +151,6 @@ export default function PortalSignupPage({ params }: Props) {
155
151
  {fieldErrors.email && <p id="signup-email-error" role="alert" className="text-sm text-destructive">{fieldErrors.email}</p>}
156
152
  </div>
157
153
 
158
- <div className="flex flex-col gap-1.5">
159
- <Label htmlFor="signup-password" className="text-overline font-semibold uppercase tracking-wider text-muted-foreground/70">{t('portal.signup.password', 'Password')}</Label>
160
- <PasswordInput id="signup-password" autoComplete="new-password" required placeholder={t('portal.signup.password.placeholder', '\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022')} value={password} onChange={(e) => setPassword(e.target.value)} disabled={submitting} aria-invalid={fieldErrors.password ? true : undefined} aria-describedby={fieldErrors.password ? 'signup-password-error' : undefined} className="rounded-lg" />
161
- {fieldErrors.password && <p id="signup-password-error" role="alert" className="text-sm text-destructive">{fieldErrors.password}</p>}
162
- </div>
163
-
164
154
  <Button type="submit" disabled={submitting} className="mt-1 w-full rounded-lg">
165
155
  {submitting ? t('portal.signup.submitting', 'Creating account...') : t('portal.signup.submit', 'Create Account')}
166
156
  </Button>
@@ -1,92 +1,6 @@
1
1
  "use client"
2
- import { useEffect, useState } from 'react'
3
- import Link from 'next/link'
4
- import { useSearchParams } from 'next/navigation'
5
- import { useT } from '@open-mercato/shared/lib/i18n/context'
6
- import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
7
- import { Button } from '@open-mercato/ui/primitives/button'
8
- import { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'
9
- import { Spinner } from '@open-mercato/ui/primitives/spinner'
2
+ import { PortalPasswordForm } from '../PasswordForm'
10
3
 
11
- type Props = { params: { orgSlug: string } }
12
-
13
- type VerifyState = 'verifying' | 'success' | 'error'
14
-
15
- export default function PortalVerifyPage({ params }: Props) {
16
- const t = useT()
17
- const searchParams = useSearchParams()
18
- const token = searchParams.get('token') ?? ''
19
- const [state, setState] = useState<VerifyState>(token ? 'verifying' : 'error')
20
- const [error, setError] = useState<string | null>(token ? null : t('portal.verify.error.invalidToken', 'Verification token is missing.'))
21
-
22
- useEffect(() => {
23
- if (!token) return
24
-
25
- let active = true
26
-
27
- void apiCall<{ ok: boolean; error?: string }>('/api/customer_accounts/email/verify', {
28
- method: 'POST',
29
- headers: { 'Content-Type': 'application/json' },
30
- body: JSON.stringify({ token }),
31
- }).then((result) => {
32
- if (!active) return
33
- if (result.ok && result.result?.ok) {
34
- setState('success')
35
- return
36
- }
37
-
38
- setState('error')
39
- setError(result.result?.error || t('portal.verify.error.generic', 'Email verification failed. Please try again.'))
40
- }).catch(() => {
41
- if (!active) return
42
- setState('error')
43
- setError(t('portal.verify.error.generic', 'Email verification failed. Please try again.'))
44
- })
45
-
46
- return () => {
47
- active = false
48
- }
49
- }, [token, t])
50
-
51
- if (state === 'verifying') {
52
- return (
53
- <div className="mx-auto flex max-w-sm flex-col items-center gap-4 py-12 text-center">
54
- <Spinner />
55
- <div>
56
- <h1 className="text-2xl font-bold tracking-tight">{t('portal.verify.title', 'Verifying email')}</h1>
57
- <p className="mt-1.5 text-sm text-muted-foreground">{t('portal.verify.description', 'Please wait while we verify your email address.')}</p>
58
- </div>
59
- </div>
60
- )
61
- }
62
-
63
- if (state === 'success') {
64
- return (
65
- <div className="mx-auto flex max-w-sm flex-col items-center gap-4 py-12 text-center">
66
- <div className="mx-auto flex size-12 items-center justify-center rounded-full bg-foreground text-background">
67
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="size-6">
68
- <polyline points="20 6 9 17 4 12" />
69
- </svg>
70
- </div>
71
- <div>
72
- <h1 className="text-2xl font-bold tracking-tight">{t('portal.verify.success.title', 'Email verified')}</h1>
73
- <p className="mt-1.5 text-sm text-muted-foreground">{t('portal.verify.success.description', 'Your email has been verified. You can now sign in to the portal.')}</p>
74
- </div>
75
- <Button asChild className="w-full rounded-lg">
76
- <Link href={`/${params.orgSlug}/portal/login`}>{t('portal.verify.success.loginLink', 'Sign In')}</Link>
77
- </Button>
78
- </div>
79
- )
80
- }
81
-
82
- return (
83
- <div className="mx-auto flex max-w-sm flex-col gap-4 py-12">
84
- <Alert status="error">
85
- <AlertDescription>{error || t('portal.verify.error.generic', 'Email verification failed. Please try again.')}</AlertDescription>
86
- </Alert>
87
- <Button asChild variant="outline" className="rounded-lg">
88
- <Link href={`/${params.orgSlug}/portal/login`}>{t('portal.verify.error.backToLogin', 'Back to sign in')}</Link>
89
- </Button>
90
- </div>
91
- )
4
+ export default function PortalVerifyPage({ params }: { params: { orgSlug: string } }) {
5
+ return <PortalPasswordForm params={params} verify />
92
6
  }
@@ -144,8 +144,9 @@
144
144
  "portal.verify.error.backToLogin": "Zurück zur Anmeldung",
145
145
  "portal.verify.error.generic": "Die E-Mail-Bestätigung ist fehlgeschlagen. Bitte versuchen Sie es erneut.",
146
146
  "portal.verify.error.invalidToken": "Das Bestätigungs-Token fehlt.",
147
+ "portal.verify.submit": "E-Mail-Adresse bestätigen und Passwort festlegen",
147
148
  "portal.verify.success.description": "Ihre E-Mail-Adresse wurde bestätigt. Sie können sich jetzt im Portal anmelden.",
148
149
  "portal.verify.success.loginLink": "Anmelden",
149
150
  "portal.verify.success.title": "E-Mail bestätigt",
150
- "portal.verify.title": "E-Mail wird bestätigt"
151
+ "portal.verify.title": "E-Mail-Adresse bestätigen"
151
152
  }
@@ -144,8 +144,9 @@
144
144
  "portal.verify.error.backToLogin": "Back to sign in",
145
145
  "portal.verify.error.generic": "Email verification failed. Please try again.",
146
146
  "portal.verify.error.invalidToken": "Verification token is missing.",
147
+ "portal.verify.submit": "Verify email and set password",
147
148
  "portal.verify.success.description": "Your email has been verified. You can now sign in to the portal.",
148
149
  "portal.verify.success.loginLink": "Sign In",
149
150
  "portal.verify.success.title": "Email verified",
150
- "portal.verify.title": "Verifying email"
151
+ "portal.verify.title": "Verify email"
151
152
  }
@@ -144,8 +144,9 @@
144
144
  "portal.verify.error.backToLogin": "Volver a iniciar sesión",
145
145
  "portal.verify.error.generic": "La verificación del correo electrónico falló. Inténtalo de nuevo.",
146
146
  "portal.verify.error.invalidToken": "Falta el token de verificación.",
147
+ "portal.verify.submit": "Verificar correo electrónico y establecer contraseña",
147
148
  "portal.verify.success.description": "Su correo electrónico ha sido verificado. Ahora puede iniciar sesión en el portal.",
148
149
  "portal.verify.success.loginLink": "Iniciar sesión",
149
150
  "portal.verify.success.title": "Correo verificado",
150
- "portal.verify.title": "Verificando correo electrónico"
151
+ "portal.verify.title": "Verificar correo electrónico"
151
152
  }
@@ -144,8 +144,9 @@
144
144
  "portal.verify.error.backToLogin": "로그인으로 돌아가기",
145
145
  "portal.verify.error.generic": "이메일 인증에 실패했습니다. 다시 시도해 주세요.",
146
146
  "portal.verify.error.invalidToken": "인증 토큰이 없습니다.",
147
+ "portal.verify.submit": "이메일 인증 및 비밀번호 설정",
147
148
  "portal.verify.success.description": "이메일 인증이 완료되었습니다. 이제 포털에 로그인할 수 있습니다.",
148
149
  "portal.verify.success.loginLink": "로그인",
149
150
  "portal.verify.success.title": "이메일 인증 완료",
150
- "portal.verify.title": "이메일 인증 중"
151
+ "portal.verify.title": "이메일 인증"
151
152
  }
@@ -144,8 +144,9 @@
144
144
  "portal.verify.error.backToLogin": "Wróć do logowania",
145
145
  "portal.verify.error.generic": "Weryfikacja adresu e-mail nie powiodła się. Spróbuj ponownie.",
146
146
  "portal.verify.error.invalidToken": "Brakuje tokenu weryfikacyjnego.",
147
+ "portal.verify.submit": "Zweryfikuj adres e-mail i ustaw hasło",
147
148
  "portal.verify.success.description": "Twój adres e-mail został zweryfikowany. Możesz teraz zalogować się do portalu.",
148
149
  "portal.verify.success.loginLink": "Zaloguj się",
149
150
  "portal.verify.success.title": "Adres e-mail zweryfikowany",
150
- "portal.verify.title": "Weryfikowanie adresu e-mail"
151
+ "portal.verify.title": "Zweryfikuj adres e-mail"
151
152
  }
@@ -9,7 +9,7 @@ export const metadata: ModuleInfo = {
9
9
  author: 'Open Mercato Team',
10
10
  license: 'MIT',
11
11
  ejectable: true,
12
- requires: ['catalog', 'customers', 'sales', 'feature_toggles'],
12
+ requires: ['catalog', 'sales'],
13
13
  }
14
14
 
15
15
  export { features } from './acl'
@@ -1,5 +1,6 @@
1
1
  import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
2
2
  import { ensureRoles } from '@open-mercato/core/modules/auth/lib/setup-app'
3
+ import { FeatureToggle } from '@open-mercato/core/modules/feature_toggles/data/entities'
3
4
  import {
4
5
  WMS_CUSTOM_ROLE_NAMES,
5
6
  WMS_OPERATOR_FEATURES,
@@ -15,7 +16,9 @@ async function seedWmsRoles(em: Parameters<typeof ensureRoles>[0], tenantId: str
15
16
 
16
17
  export const setup: ModuleSetupConfig = {
17
18
  seedDefaults: async (ctx) => {
18
- await seedWmsIntegrationToggles(ctx.em)
19
+ if (ctx.em.getMetadata().find(FeatureToggle)) {
20
+ await seedWmsIntegrationToggles(ctx.em)
21
+ }
19
22
  await seedWmsRoles(ctx.em, ctx.tenantId)
20
23
  },
21
24
  defaultRoleFeatures: {
@@ -123,7 +123,7 @@ export async function GET(request: NextRequest) {
123
123
  WorkflowEvent,
124
124
  where,
125
125
  {
126
- orderBy: { [sortField]: sortDir },
126
+ orderBy: { [sortField]: sortDir, id: sortDir },
127
127
  limit: pageSize,
128
128
  offset,
129
129
  }
@@ -100,7 +100,7 @@ export async function GET(
100
100
  WorkflowEvent,
101
101
  where,
102
102
  {
103
- orderBy: { occurredAt: 'DESC' },
103
+ orderBy: { occurredAt: 'DESC', id: 'DESC' },
104
104
  limit,
105
105
  offset,
106
106
  }
@@ -90,7 +90,8 @@ export async function GET(request: NextRequest, context: RouteContext) {
90
90
 
91
91
  // Ordered by when the step was entered so the Gantt and the overlay read the
92
92
  // run in execution order. `createdAt` is the tiebreaker because a step
93
- // instance is persisted before `enteredAt` is stamped on some paths.
93
+ // instance is persisted before `enteredAt` is stamped on some paths, and
94
+ // `id` comes last so steps sharing both timestamps page deterministically.
94
95
  const [steps, total] = await em.findAndCount(
95
96
  StepInstance,
96
97
  {
@@ -99,7 +100,7 @@ export async function GET(request: NextRequest, context: RouteContext) {
99
100
  ...orgFilter.where,
100
101
  },
101
102
  {
102
- orderBy: [{ enteredAt: 'ASC' }, { createdAt: 'ASC' }],
103
+ orderBy: [{ enteredAt: 'ASC' }, { createdAt: 'ASC' }, { id: 'ASC' }],
103
104
  limit,
104
105
  offset,
105
106
  }
@@ -113,7 +113,7 @@ export async function GET(request: NextRequest) {
113
113
  // Grouping first, over a bounded scan, so the group counts describe the
114
114
  // same set the caller is paging through.
115
115
  const scanned = (await em.find(WorkflowInstance, where, {
116
- orderBy: { createdAt: 'DESC' },
116
+ orderBy: { createdAt: 'DESC', id: 'DESC' },
117
117
  limit: FAILURE_GROUP_SCAN_LIMIT,
118
118
  })) as WorkflowInstance[]
119
119
  const scannedInputs = scanned.map(toTriageInput)
@@ -246,7 +246,7 @@ export async function getWorkflowEvents(
246
246
  WorkflowEvent,
247
247
  where,
248
248
  {
249
- orderBy: { occurredAt: 'ASC' },
249
+ orderBy: { occurredAt: 'ASC', id: 'ASC' },
250
250
  limit: options?.limit,
251
251
  offset: options?.offset,
252
252
  }
@@ -196,7 +196,8 @@ export function toUserTaskWorkInboxRow(task: UserTask, now: Date): WorkInboxRow
196
196
 
197
197
  /**
198
198
  * SQL orders by due date (Postgres puts NULLs last on ASC, which is what the
199
- * inbox wants) and then by recency; the canonical priority → due → created
199
+ * inbox wants), then by recency, then by `id` so the window is a total order
200
+ * and tied rows cannot shift between requests; the canonical priority → due → created
200
201
  * ordering is applied by the merge service over the returned window, because
201
202
  * `priority` is an authored label with no ordinal column to sort on. Phase 1 is
202
203
  * a projection — a persisted sort key belongs with the `Task` entity, which
@@ -213,7 +214,7 @@ async function listUserTaskWorkItems(
213
214
  const where = buildUserTaskWorkInboxWhere(query, context.scope, options)
214
215
 
215
216
  const [tasks, total] = await em.findAndCount(UserTask, where, {
216
- orderBy: [{ dueDate: 'ASC' }, { createdAt: 'DESC' }],
217
+ orderBy: [{ dueDate: 'ASC' }, { createdAt: 'DESC' }, { id: 'ASC' }],
217
218
  limit: query.offset + query.limit,
218
219
  offset: 0,
219
220
  })