@hszrdm/create-commerce 1.21.0 → 1.23.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 (33) hide show
  1. package/package.json +2 -2
  2. package/src/cli.mjs +7 -1
  3. package/templates/backend/package.json +1 -1
  4. package/templates/backend/scripts/commerce-ops.mjs +12 -5
  5. package/templates/backend/scripts/core-restore.mjs +20 -19
  6. package/templates/backend/scripts/lib/core-backup-common.mjs +83 -0
  7. package/templates/backend/scripts/production-assets/restore.sh +1 -1
  8. package/templates/storefront/README.md +16 -5
  9. package/templates/storefront/package-lock.json +1646 -0
  10. package/templates/storefront/package.json +6 -2
  11. package/templates/storefront/src/app/api/checkout/trusted-shop/route.ts +19 -0
  12. package/templates/storefront/src/app/checkout/success/actions.ts +17 -0
  13. package/templates/storefront/src/app/checkout/success/page.tsx +32 -22
  14. package/templates/storefront/src/app/globals.css +5 -0
  15. package/templates/storefront/src/components/account-dashboard.tsx +35 -15
  16. package/templates/storefront/src/components/account-verification-panel.tsx +29 -17
  17. package/templates/storefront/src/components/arukereso-trusted-shop.tsx +5 -5
  18. package/templates/storefront/src/components/checkout-flow.tsx +7 -1
  19. package/templates/storefront/src/components/cms-content.tsx +3 -1
  20. package/templates/storefront/src/components/consent-banner.tsx +10 -10
  21. package/templates/storefront/src/components/order-detail.tsx +79 -47
  22. package/templates/storefront/src/lib/core/abandoned-cart.ts +5 -1
  23. package/templates/storefront/src/lib/core/account.ts +2 -0
  24. package/templates/storefront/src/lib/core/after-sales.ts +50 -13
  25. package/templates/storefront/src/lib/core/checkout-confirmation-server.ts +16 -0
  26. package/templates/storefront/src/lib/core/checkout-proof.ts +16 -0
  27. package/templates/storefront/src/lib/core/checkout.ts +5 -10
  28. package/templates/storefront/src/lib/core/sanitize-cms-html.ts +30 -0
  29. package/templates/storefront/src/lib/storefront-copy.ts +8 -0
  30. package/templates/storefront/tests/account-verification.test.mjs +12 -0
  31. package/templates/storefront/tests/cms-html.test.mjs +49 -0
  32. package/templates/storefront/tests/consent.test.mjs +120 -0
  33. package/templates/storefront/tests/ga4-bootstrap.test.mjs +1 -1
@@ -14,23 +14,27 @@
14
14
  "test:stripe": "node --experimental-strip-types --test tests/stripe-checkout-phase.test.mjs",
15
15
  "test:company-tax": "node --experimental-strip-types --test tests/company-tax.test.mjs",
16
16
  "test:ga4": "node --experimental-strip-types --test tests/ga4-bootstrap.test.mjs",
17
+ "test:consent": "node --experimental-strip-types --test tests/consent.test.mjs",
17
18
  "test:seo": "node --experimental-strip-types --test tests/technical-seo.test.mjs",
18
19
  "test:account-verification": "node --test tests/account-verification.test.mjs",
19
20
  "test:product-images": "node --experimental-strip-types --test tests/product-image.test.mjs",
20
21
  "test:checkout-summary": "node --experimental-strip-types --test tests/checkout-summary.test.mjs",
22
+ "test:cms": "node --experimental-strip-types --test tests/cms-html.test.mjs",
21
23
  "test:checkout-payment-choices": "node --experimental-strip-types --test tests/checkout-payment-choices.test.mjs"
22
24
  },
23
25
  "dependencies": {
24
26
  "@stripe/react-stripe-js": "7.0.0",
25
27
  "@stripe/stripe-js": "10.2.0",
26
- "next": "16.4.3",
28
+ "next": "16.4.6",
27
29
  "react": "19.3.1",
28
- "react-dom": "19.3.1"
30
+ "react-dom": "19.3.1",
31
+ "sanitize-html": "2.18.2"
29
32
  },
30
33
  "devDependencies": {
31
34
  "@types/node": "26.6.5",
32
35
  "@types/react": "19.3.0",
33
36
  "@types/react-dom": "19.3.0",
37
+ "@types/sanitize-html": "2.16.2",
34
38
  "typescript": "7.0.2"
35
39
  }
36
40
  }
@@ -0,0 +1,19 @@
1
+ import { checkoutConfirmation } from "@/lib/core/checkout-confirmation-server"
2
+ import { medusaRawFetch } from "@/lib/core/client"
3
+
4
+ export async function POST(request: Request) {
5
+ const confirmation = await checkoutConfirmation()
6
+ const headers = { "Cache-Control": "private, no-store" }
7
+ const input = await request.json().catch(() => null)
8
+ if (!confirmation || confirmation.id !== input?.order_id) {
9
+ return new Response(null, { status: 404, headers })
10
+ }
11
+ const result = await medusaRawFetch(
12
+ `/store/arukereso/trusted-shop/${encodeURIComponent(confirmation.id)}`,
13
+ { method: "POST", body: "{}", headers: confirmation.headers, cache: "no-store" },
14
+ )
15
+ return new Response(result.body, {
16
+ status: result.status,
17
+ headers: { ...headers, "Content-Type": result.headers.get("Content-Type") || "application/json" },
18
+ })
19
+ }
@@ -0,0 +1,17 @@
1
+ "use server"
2
+
3
+ import { cookies } from "next/headers"
4
+ import { CONFIRMATION_COOKIE } from "@/lib/core/checkout-proof"
5
+ import { validConfirmationInput } from "@/lib/core/checkout-confirmation-server"
6
+
7
+ export async function saveCheckoutConfirmation(id: string, proof: string) {
8
+ if (!validConfirmationInput(id, proof)) throw new Error("Invalid checkout confirmation.")
9
+ // The Store API verifies the signature and current order ownership on every read.
10
+ ;(await cookies()).set(CONFIRMATION_COOKIE, `${id}.${proof}`, {
11
+ httpOnly: true,
12
+ sameSite: "lax",
13
+ secure: process.env.NODE_ENV === "production",
14
+ path: "/",
15
+ maxAge: 3600,
16
+ })
17
+ }
@@ -3,7 +3,7 @@ import { notFound } from "next/navigation"
3
3
  import { ArukeresoTrustedShop } from "@/components/arukereso-trusted-shop"
4
4
  import { GoogleAdsPurchase } from "@/components/google-ads-purchase"
5
5
  import { GoogleAnalyticsPurchase } from "@/components/google-analytics-purchase"
6
- import { checkoutApi } from "@/lib/core/checkout"
6
+ import { checkoutConfirmation } from "@/lib/core/checkout-confirmation-server"
7
7
  import { endpoint, getCoreConfig, medusaFetch } from "@/lib/core/client"
8
8
  import { asRecords, formatMoney, isRecord, stringValue, type JsonRecord } from "@/lib/core/commerce"
9
9
  import { storefrontCopy } from "@/lib/storefront-copy"
@@ -14,34 +14,47 @@ type SearchParams = Promise<{ order_id?: string }>
14
14
 
15
15
  export default async function CheckoutSuccessPage({ searchParams }: { searchParams: SearchParams }) {
16
16
  const query = await searchParams
17
- const orderId = query.order_id?.trim()
18
- if (!orderId) notFound()
17
+ const confirmation = await checkoutConfirmation()
18
+ if (!confirmation || (query.order_id && query.order_id !== confirmation.id)) notFound()
19
+ const orderId = confirmation.id
19
20
  const config = await getCoreConfig()
20
21
  const locale = await requestStorefrontLocale()
21
22
  const copy = storefrontCopy(locale)
22
23
  const routes = STOREFRONT_ROUTES[locale]
23
24
  const numberLocale = medusaLocale(locale)
24
25
  const orderEndpoint = endpoint(config.account.endpoints.order, { id: orderId })
25
- const { order } = await medusaFetch<{ order: JsonRecord }>(
26
- `${orderEndpoint}?fields=+items,+shipping_methods,+metadata`,
27
- { cache: "no-store" },
28
- ).catch(() => ({ order: null as unknown as JsonRecord }))
29
- if (!order) notFound()
26
+ const result = await medusaFetch<{ order: JsonRecord; checkout_payment?: JsonRecord }>(
27
+ `${orderEndpoint}?fields=+items,+shipping_methods,+customer_id`,
28
+ { headers: confirmation.headers, cache: "no-store" },
29
+ ).catch(() => null)
30
+ if (!result?.order) notFound()
31
+ const { order, checkout_payment: payment } = result
30
32
 
31
33
  const currency = stringValue(order.currency_code || config.store.default_currency).toUpperCase()
32
34
  const shippingMethods = asRecords(order.shipping_methods)
33
- const cod = shippingMethods.some((method) => isRecord(method.data) && (method.data.cod === true || method.data.cod === "true"))
34
- const metadata = isRecord(order.metadata) ? order.metadata : {}
35
- const transferSnapshot = isRecord(metadata.bank_transfer) ? metadata.bank_transfer : null
36
- const bankTransfer = config.payments.bank_transfer.enabled && !cod
37
- ? await checkoutApi(config).bankTransferDetails().catch(() => null)
35
+ const analyticsOrder = {
36
+ id: order.id, display_id: order.display_id, currency_code: order.currency_code,
37
+ total: order.total, shipping_total: order.shipping_total, tax_total: order.tax_total,
38
+ items: asRecords(order.items).map((item) => ({
39
+ id: item.id, variant_id: item.variant_id, product_id: item.product_id,
40
+ variant_sku: item.variant_sku, variant_title: item.variant_title, product_type: item.product_type,
41
+ product_title: item.product_title, title: item.title, quantity: item.quantity,
42
+ subtotal: item.subtotal, total: item.total, unit_price: item.unit_price, discount_total: item.discount_total,
43
+ })),
44
+ }
45
+ const cod = payment?.method === "cod" && payment.status === "pending"
46
+ const bank = isRecord(payment?.bank_transfer) ? payment.bank_transfer : null
47
+ const paymentMessage =
48
+ payment?.status === "paid" ? copy.confirmationPaymentPaid
49
+ : payment?.status === "canceled" ? copy.confirmationPaymentCanceled
50
+ : payment?.status === "failed" ? copy.confirmationPaymentFailed
51
+ : payment?.status === "pending" && !cod ? copy.confirmationPaymentPending
38
52
  : null
39
- const bank = bankTransfer && isRecord(bankTransfer.bank) ? bankTransfer.bank : null
40
53
 
41
54
  return (
42
55
  <div className="stack page-section narrow-page">
43
- <GoogleAnalyticsPurchase analytics={config.analytics} order={order} />
44
- <GoogleAdsPurchase googleAds={config.marketing.google_ads} order={order} />
56
+ <GoogleAnalyticsPurchase analytics={config.analytics} order={analyticsOrder} />
57
+ <GoogleAdsPurchase googleAds={config.marketing.google_ads} order={analyticsOrder} />
45
58
  <ArukeresoTrustedShop orderId={orderId} />
46
59
 
47
60
  <section className="success-hero panel stack">
@@ -50,6 +63,7 @@ export default async function CheckoutSuccessPage({ searchParams }: { searchPara
50
63
  <p className="eyebrow">{copy.orderRecorded}</p>
51
64
  <h1>{copy.thankYou}</h1>
52
65
  <p className="muted">{copy.orderNumber}: <strong>#{stringValue(order.display_id || order.id)}</strong></p>
66
+ {paymentMessage ? <p className="muted">{paymentMessage}</p> : null}
53
67
  </div>
54
68
  <div className="button-row">
55
69
  <Link className="button" href={routes.products}>{copy.continueShopping}</Link>
@@ -80,12 +94,8 @@ export default async function CheckoutSuccessPage({ searchParams }: { searchPara
80
94
  {bank.account_number ? <Info label={copy.bankAccount} value={stringValue(bank.account_number)} /> : null}
81
95
  {bank.iban ? <Info label="IBAN" value={stringValue(bank.iban)} /> : null}
82
96
  {bank.bic ? <Info label="BIC / SWIFT" value={stringValue(bank.bic)} /> : null}
83
- {transferSnapshot?.reference ? <Info label={copy.reference} value={stringValue(transferSnapshot.reference)} /> : null}
84
- {transferSnapshot?.dueDate
85
- ? <Info label={copy.paymentDeadline} value={stringValue(transferSnapshot.dueDate)} />
86
- : bankTransfer?.due_days
87
- ? <Info label={copy.paymentDeadline} value={`${stringValue(bankTransfer.due_days)} ${copy.days}`} />
88
- : null}
97
+ <Info label={copy.reference} value={stringValue(bank.reference)} />
98
+ {bank.due_date ? <Info label={copy.paymentDeadline} value={stringValue(bank.due_date)} /> : null}
89
99
  <p className="muted small">{copy.referenceHint}</p>
90
100
  </section>
91
101
  ) : null}
@@ -241,7 +241,12 @@ input[readonly] { background: var(--surface-soft); color: var(--muted); }
241
241
  .consent-toggle span { display: flex; flex-direction: column; gap: 2px; }
242
242
  .consent-toggle small { color: rgba(255,255,255,.65); }
243
243
  .consent-actions { display: flex; flex-direction: column; justify-content: end; gap: 8px; min-width: 220px; }
244
+ .consent-actions > .button:not(.consent-reject) { min-height: 48px; }
244
245
  .consent .button.secondary { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: white; }
246
+ /* Smaller tertiary choice, still full-width, high-contrast and 44px touch-accessible. */
247
+ .consent-actions > .consent-reject { min-height: 44px; font-size: .88rem; font-weight: 700; padding: 8px 12px; }
248
+ .consent-dismiss { position: absolute; top: 9px; right: 9px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 11px; background: transparent; color: white; cursor: pointer; font-size: 1.35rem; }
249
+ .consent-dismiss:hover, .consent-dismiss:focus-visible { background: rgba(255,255,255,.14); }
245
250
 
246
251
  @media (max-width: 1040px) {
247
252
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@@ -58,6 +58,27 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
58
58
  const [tab, setTab] = useState<AccountTab>("profile")
59
59
  const [email, setEmail] = useState("")
60
60
  const [password, setPassword] = useState("")
61
+ const [verificationLink, setVerificationLink] = useState("")
62
+ const [emailChangeLink, setEmailChangeLink] = useState("")
63
+
64
+ useEffect(() => {
65
+ const url = new URL(window.location.href)
66
+ const fragment = new URLSearchParams(url.hash.slice(1))
67
+ for (const [key, capture] of [
68
+ ["verify_email", setVerificationLink],
69
+ ["change_email_code", setEmailChangeLink],
70
+ ] as const) {
71
+ const code = fragment.get(key) || url.searchParams.get(key)
72
+ if (!code) continue
73
+ capture(code)
74
+ if (fragment.has(key)) {
75
+ fragment.delete(key)
76
+ url.hash = fragment.toString()
77
+ }
78
+ url.searchParams.delete(key)
79
+ window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash)
80
+ }
81
+ }, [])
61
82
  const [firstName, setFirstName] = useState("")
62
83
  const [lastName, setLastName] = useState("")
63
84
 
@@ -78,21 +99,15 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
78
99
  useEffect(() => {
79
100
  void refresh().catch(() => setCustomer(null)).finally(() => setLoading(false))
80
101
  }, [refresh])
81
- // The Email Center template is shared with registration verification.
82
- // Existing email-change links must keep working after adding link support.
83
102
  useEffect(() => {
84
- if (!customer || !isAccountEmailVerified(customer)) return
85
- const url = new URL(window.location.href)
86
- const code = url.searchParams.get("change_email_code")
87
- if (!code) return
88
- url.searchParams.delete("change_email_code")
89
- window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash)
90
- void api.confirmEmailChange(code).then(() => refresh()).then(() => {
103
+ if (!customer || !isAccountEmailVerified(customer) || !emailChangeLink) return
104
+ setEmailChangeLink("")
105
+ void api.confirmEmailChange(emailChangeLink).then(() => refresh()).then(() => {
91
106
  setAccountNotice({ tone: "success", text: localized(locale, "E-mail-cím módosítva.", "Email address updated.") })
92
- }).catch((error) => {
93
- setAccountNotice({ tone: "error", text: error instanceof Error ? error.message : localized(locale, "Az e-mail módosítása nem sikerült.", "Could not change email.") })
107
+ }).catch(() => {
108
+ setAccountNotice({ tone: "error", text: localized(locale, "Az e-mail módosítása nem sikerült.", "Could not change email.") })
94
109
  })
95
- }, [api, customer, refresh, locale])
110
+ }, [api, customer, emailChangeLink, refresh, locale])
96
111
 
97
112
 
98
113
  const authSubmit = async (event: FormEvent) => {
@@ -121,8 +136,8 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
121
136
  setMessage(
122
137
  localized(
123
138
  locale,
124
- "A fiók létrejött. Az e-mail megerősítéséhez kövesd a kapott kódot.",
125
- "Your account has been created. Use the code you received to verify your email.",
139
+ "A fiók létrejött. Erősítsd meg az e-mail-címed.",
140
+ "Your account has been created. Verify your email address to continue.",
126
141
  ),
127
142
  )
128
143
  return
@@ -166,6 +181,9 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
166
181
  <p className="eyebrow">{copy.customerAccount}</p>
167
182
  <h1>{mode === "register" ? copy.register : mode === "forgot" ? copy.forgotPassword : copy.login}</h1>
168
183
  </div>
184
+ {verificationLink || emailChangeLink ? (
185
+ <p role="status">{localized(locale, "A megerősítés folytatásához jelentkezz be.", "Sign in to continue verification.")}</p>
186
+ ) : null}
169
187
  <div className="segmented">
170
188
  <button type="button" className={mode === "login" ? "active" : ""} onClick={() => setMode("login")}>{copy.login}</button>
171
189
  <button type="button" className={mode === "register" ? "active" : ""} onClick={() => setMode("register")}>{copy.register}</button>
@@ -203,6 +221,8 @@ export function AccountDashboard({ config }: { config: CoreConfig }) {
203
221
  api={api}
204
222
  email={stringValue(customer.email)}
205
223
  locale={locale}
224
+ linkCode={verificationLink}
225
+ notice={message}
206
226
  onVerified={onVerificationComplete}
207
227
  onLogout={onVerificationLogout}
208
228
  />
@@ -447,7 +467,7 @@ function SecuritySection({
447
467
  <p className="muted">{localized(locale, "Jelenlegi cím", "Current address")}: {stringValue(customer.email)}</p>
448
468
  <Field label={copy.newEmail} type="email" value={newEmail} onChange={setNewEmail} />
449
469
  <Field label={copy.currentPassword} type="password" value={currentPassword} onChange={setCurrentPassword} />
450
- <button className="button secondary" type="button" onClick={() => void api.requestEmailChange(currentPassword, newEmail).then(() => setMessage(localized(locale, "Megerősítő kód elküldve az új címhez.", "A verification code was sent to the new address.")))}>{copy.requestEmailChange}</button>
470
+ <button className="button secondary" type="button" onClick={() => void api.requestEmailChange(currentPassword, newEmail).then(() => setMessage(localized(locale, "Megerősítő e-mail kérése rögzítve.", "Verification email requested.")))}>{copy.requestEmailChange}</button>
451
471
  <div className="inline-form">
452
472
  <input value={emailCode} onChange={(e) => setEmailCode(e.target.value)} placeholder={copy.verificationCode} />
453
473
  <button className="button" type="button" onClick={() => void api.confirmEmailChange(emailCode).then(refresh).then(() => setMessage(localized(locale, "E-mail cím módosítva.", "Email address changed.")))}>{copy.verify}</button>
@@ -14,12 +14,16 @@ export function AccountVerificationPanel({
14
14
  api,
15
15
  email,
16
16
  locale,
17
+ linkCode,
18
+ notice,
17
19
  onVerified,
18
20
  onLogout,
19
21
  }: {
20
22
  api: ReturnType<typeof accountApi>
21
23
  email: string
22
24
  locale: "hu" | "en"
25
+ linkCode: string
26
+ notice: string | null
23
27
  onVerified: () => Promise<unknown>
24
28
  onLogout: () => Promise<unknown>
25
29
  }) {
@@ -30,6 +34,7 @@ export function AccountVerificationPanel({
30
34
  const [loading, setLoading] = useState(true)
31
35
  const [busy, setBusy] = useState<"resend" | "verify" | "logout" | null>(null)
32
36
  const [message, setMessage] = useState("")
37
+ const inFlight = useRef(false)
33
38
  const usedLink = useRef("")
34
39
  const onVerifiedRef = useRef(onVerified)
35
40
  onVerifiedRef.current = onVerified
@@ -58,55 +63,61 @@ export function AccountVerificationPanel({
58
63
  }, [])
59
64
 
60
65
  const confirm = useCallback(async (value: string) => {
61
- if (!value.trim()) return
66
+ if (!value.trim() || inFlight.current) return
67
+ inFlight.current = true
62
68
  setBusy("verify")
63
69
  setMessage("")
64
70
  try {
65
71
  await api.confirmEmailVerification(value.trim())
66
72
  await onVerifiedRef.current()
67
73
  } catch (error) {
68
- setMessage(error instanceof Error ? error.message : (en ? "Verification failed." : "A megerősítés nem sikerült."))
74
+ setMessage(error instanceof CoreApiError && (error.status === 400 || error.status === 403)
75
+ ? (en ? "The verification code is invalid or expired." : "A kód érvénytelen vagy lejárt.")
76
+ : (en ? "Verification failed. Try again." : "A megerősítés sikertelen. Próbáld újra."))
69
77
  } finally {
78
+ inFlight.current = false
70
79
  setBusy(null)
71
80
  }
72
81
  }, [api, en])
73
82
 
74
- // Links are usable from the same session, or after the customer logs in.
75
- // Remove the sensitive code from browser history as soon as it is consumed.
76
83
  useEffect(() => {
77
- const url = new URL(window.location.href)
78
- const linkCode = url.searchParams.get("verify_email")
79
84
  if (!linkCode || usedLink.current === linkCode) return
80
85
  usedLink.current = linkCode
81
- url.searchParams.delete("verify_email")
82
- window.history.replaceState(window.history.state, "", url.pathname + url.search + url.hash)
83
86
  setCode(linkCode)
84
87
  void confirm(linkCode)
85
- }, [confirm])
88
+ }, [confirm, linkCode])
86
89
 
87
90
  const retrySeconds = retryAt && now ? Math.max(0, Math.ceil((retryAt - now) / 1000)) : 0
88
91
  const countdown = `${Math.floor(retrySeconds / 60).toString().padStart(2, "0")}:${(retrySeconds % 60).toString().padStart(2, "0")}`
89
92
 
90
93
  const resend = async () => {
91
- if (busy || loading || retrySeconds > 0) return
94
+ if (inFlight.current || loading || retrySeconds > 0) return
95
+ inFlight.current = true
92
96
  setBusy("resend")
93
97
  setMessage("")
94
98
  try {
95
99
  const result = await api.requestEmailVerification() as {
96
100
  resend_available_at?: string | null
97
- retry_after_seconds?: number
101
+ already_verified?: boolean
102
+ }
103
+ if (result.already_verified) {
104
+ await onVerifiedRef.current()
105
+ return
98
106
  }
99
107
  const millis = result.resend_available_at ? Date.parse(result.resend_available_at) : NaN
100
- setRetryAt(Number.isFinite(millis) ? millis : Date.now() + 600_000)
108
+ setRetryAt(Number.isFinite(millis) ? millis : null)
101
109
  setMessage(en ? "A new verification email has been requested." : "Új megerősítő e-mailt kértünk.")
102
110
  } catch (error) {
103
111
  if (error instanceof CoreApiError && error.status === 429) {
104
- const payload = error.payload as { retry_after_seconds?: number } | null
105
- setRetryAt(Date.now() + Math.max(1, Number(payload?.retry_after_seconds ?? 600)) * 1000)
112
+ const payload = error.payload as { resend_available_at?: string; retry_after_seconds?: number } | null
113
+ const availableAt = Date.parse(payload?.resend_available_at ?? "")
114
+ setRetryAt(Number.isFinite(availableAt) ? availableAt : Date.now() + (payload?.retry_after_seconds ?? 0) * 1000)
106
115
  } else {
107
- setMessage(error instanceof Error ? error.message : (en ? "Could not resend email." : "Az újraküldés nem sikerült."))
116
+ await refreshStatus().catch(() => undefined)
117
+ setMessage(en ? "Could not request a new email." : "Az újraküldési kérés nem sikerült.")
108
118
  }
109
119
  } finally {
120
+ inFlight.current = false
110
121
  setBusy(null)
111
122
  }
112
123
  }
@@ -115,9 +126,10 @@ export function AccountVerificationPanel({
115
126
  <section className="panel stack" aria-live="polite">
116
127
  <p className="eyebrow">{en ? "Account verification" : "Fiók megerősítése"}</p>
117
128
  <h1>{en ? "Your email is not verified yet" : "Az e-mail-címed még nincs megerősítve"}</h1>
129
+ {notice ? <p role="status">{notice}</p> : null}
118
130
  <p>{en
119
- ? `We sent a confirmation link and code to ${email}. Verify your email to use the store.`
120
- : `Megerősítő linket és kódot küldtünk a(z) ${email} címre. A webshop használatához erősítsd meg az e-mail-címed.`}</p>
131
+ ? `To use the store, verify ${email} with the link or code from your verification email.`
132
+ : `A webshop használatához erősítsd meg a(z) ${email} címet a levélben található linkkel vagy kóddal.`}</p>
121
133
  <button className="button secondary" type="button" onClick={() => void resend()} disabled={loading || busy !== null || retrySeconds > 0}>
122
134
  {busy === "resend"
123
135
  ? (en ? "Sending…" : "Küldés…")
@@ -1,7 +1,6 @@
1
1
  "use client"
2
2
 
3
3
  import { useEffect } from "react"
4
- import { medusaRawFetch } from "@/lib/core/client"
5
4
 
6
5
  const STORAGE_PREFIX = "hszrdm:arukereso-trusted-shop:v2:"
7
6
 
@@ -30,10 +29,11 @@ export function ArukeresoTrustedShop({ orderId }: { orderId: string }) {
30
29
 
31
30
  void (async () => {
32
31
  try {
33
- const response = await medusaRawFetch(
34
- `/store/arukereso/trusted-shop/${encodeURIComponent(orderId)}`,
35
- { method: "POST", body: JSON.stringify({}) },
36
- )
32
+ const response = await fetch("/api/checkout/trusted-shop", {
33
+ method: "POST",
34
+ headers: { "Content-Type": "application/json" },
35
+ body: JSON.stringify({ order_id: orderId }),
36
+ })
37
37
  if (cancelled || response.status === 204 || !response.ok) return
38
38
 
39
39
  const data = (await response.json()) as TrustedShopResponse
@@ -1,5 +1,8 @@
1
1
  "use client"
2
2
 
3
+ import { saveCheckoutConfirmation } from "@/app/checkout/success/actions"
4
+ import { forgetCartProof } from "@/lib/core/checkout-proof"
5
+
3
6
  import { useCallback, useEffect, useMemo, useRef, useState, useId } from "react"
4
7
  import { usePathname, useRouter, useSearchParams } from "next/navigation"
5
8
  import { useCart } from "./cart-provider"
@@ -400,8 +403,11 @@ export function CheckoutFlow({ config }: { config: CoreConfig }) {
400
403
  ),
401
404
  )
402
405
  }
406
+ const proof = stringValue(result.order_confirmation_proof)
407
+ await saveCheckoutConfirmation(orderId, proof)
408
+ forgetCartProof(cartId)
403
409
  clearCart()
404
- router.push(`${routes.checkoutSuccess}?order_id=${encodeURIComponent(orderId)}`)
410
+ router.push(routes.checkoutSuccess)
405
411
  return
406
412
  }
407
413
  const detail = isRecord(result.cart) ? stringValue(result.cart.error || result.cart.message) : ""
@@ -1,4 +1,6 @@
1
1
  import Link from "next/link"
2
+ import { sanitizeCmsHtml } from "@/lib/core/sanitize-cms-html"
3
+
2
4
  import type { CmsEntry } from "@/lib/core/cms"
3
5
 
4
6
  type Locale = "hu" | "en"
@@ -38,7 +40,7 @@ export function CmsEntryMeta({ entry, locale }: { entry: CmsEntry; locale: Local
38
40
 
39
41
  export function CmsEntryBody({ entry }: { entry: CmsEntry }) {
40
42
  if (entry.body_format === "html" && entry.body) {
41
- return <div className="cms-body" dangerouslySetInnerHTML={{ __html: entry.body }} />
43
+ return <div className="cms-body" dangerouslySetInnerHTML={{ __html: sanitizeCmsHtml(entry.body) }} />
42
44
  }
43
45
 
44
46
  if (entry.body_format === "blocks" && Array.isArray(entry.blocks)) {
@@ -66,6 +66,11 @@ export function ConsentBanner({ enabled }: { enabled: boolean }) {
66
66
 
67
67
  {open ? (
68
68
  <aside className="consent" aria-label="Cookie-beállítások" role="dialog" aria-modal="true">
69
+ {preferences ? (
70
+ <button type="button" className="consent-dismiss" aria-label="Cookie-beállítások bezárása" onClick={() => setOpen(false)}>
71
+ ×
72
+ </button>
73
+ ) : null}
69
74
  <div className="stack consent-copy">
70
75
  <div>
71
76
  <strong>Cookie-beállítások</strong>
@@ -109,20 +114,15 @@ export function ConsentBanner({ enabled }: { enabled: boolean }) {
109
114
  </div>
110
115
 
111
116
  <div className="consent-actions">
112
- <button className="button secondary" onClick={() => save({ analytics: false, marketing: false })}>
113
- Opcionálisak elutasítása
117
+ <button type="button" className="button" onClick={() => save({ analytics: true, marketing: true })}>
118
+ Mindet elfogadom
114
119
  </button>
115
- <button className="button secondary" onClick={() => save({ analytics, marketing })}>
120
+ <button type="button" className="button secondary" onClick={() => save({ analytics, marketing })}>
116
121
  Beállítások mentése
117
122
  </button>
118
- <button className="button" onClick={() => save({ analytics: true, marketing: true })}>
119
- Mindet elfogadom
123
+ <button type="button" className="button secondary consent-reject" onClick={() => save({ analytics: false, marketing: false })}>
124
+ Opcionálisak elutasítása
120
125
  </button>
121
- {preferences ? (
122
- <button className="button secondary" onClick={() => setOpen(false)}>
123
- Bezárás
124
- </button>
125
- ) : null}
126
126
  </div>
127
127
  </aside>
128
128
  ) : null}