@thorprovider/storefront 0.7.0 → 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 (151) hide show
  1. package/README.md +22 -2
  2. package/assets/templates/AGENTS.md +14 -2
  3. package/assets/templates/app/app/[[...slug]]/page.tsx +9 -2
  4. package/assets/templates/app/lib/__STOREFRONT__/account-address.ts +129 -0
  5. package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +2 -2
  6. package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +143 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/account-profile.ts +220 -0
  8. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +621 -80
  9. package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
  10. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +346 -38
  11. package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +240 -0
  12. package/assets/templates/app/lib/__STOREFRONT__/customer-profile-port.ts +103 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +26 -0
  14. package/assets/templates/app/lib/__STOREFRONT__/orders-port.ts +30 -0
  15. package/assets/templates/app/lib/__STOREFRONT__/ports.ts +18 -0
  16. package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +4 -4
  17. package/assets/templates/app/lib/__STOREFRONT__/session.ts +24 -6
  18. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +21 -0
  19. package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx +29 -0
  20. package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx +19 -0
  21. package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.tsx +16 -0
  22. package/assets/templates/app/lib/__STOREFRONT__/views/sections/customer-profile.client.tsx +27 -0
  23. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +4 -1
  24. package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.client.tsx +19 -0
  25. package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.tsx +16 -0
  26. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.address-book-advanced.ts +437 -0
  27. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.checkout-commerce-v1.ts +398 -0
  28. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.customer-profile.ts +138 -0
  29. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.mega-menu-universal.ts +76 -0
  30. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +217 -0
  31. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +24 -0
  32. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.tsx +16 -0
  33. package/assets/templates/features/checkout/handlers.ts +24 -4
  34. package/assets/templates/features/customer-addresses/handlers.ts +11 -0
  35. package/assets/templates/features/customer-addresses/state.ts +33 -0
  36. package/assets/templates/features/customer-auth/state.ts +10 -0
  37. package/assets/templates/features/customer-profile/handlers.ts +11 -0
  38. package/assets/templates/features/customer-profile/state.ts +18 -0
  39. package/assets/templates/views/account/address-book-advanced.defaults.ts +534 -0
  40. package/assets/templates/views/account/assembly/assembly.json +41 -0
  41. package/assets/templates/views/account/assembly/index.skeleton.tsx +229 -0
  42. package/assets/templates/views/account/assembly/registry.skeleton.tsx +1116 -0
  43. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/binding.json +5 -0
  44. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/catalog.part +4 -0
  45. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/element.part +5 -0
  46. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/registry.part +1 -0
  47. package/assets/templates/views/account/assembly/slots/addresses/cards/catalog.part +5 -0
  48. package/assets/templates/views/account/assembly/slots/addresses/cards/element.part +10 -0
  49. package/assets/templates/views/account/assembly/slots/addresses/cards/registry.part +1 -0
  50. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +5 -0
  51. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +5 -0
  52. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +1 -0
  53. package/assets/templates/views/account/assembly/slots/login/card/catalog.part +4 -0
  54. package/assets/templates/views/account/assembly/slots/login/card/element.part +13 -0
  55. package/assets/templates/views/account/assembly/slots/login/card/registry.part +1 -0
  56. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/catalog.part +5 -0
  57. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/element.part +5 -0
  58. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/registry.part +2 -0
  59. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/binding.json +5 -0
  60. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/catalog.part +5 -0
  61. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/element.part +5 -0
  62. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/registry.part +1 -0
  63. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/binding.json +5 -0
  64. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/catalog.part +4 -0
  65. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/element.part +5 -0
  66. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/registry.part +1 -0
  67. package/assets/templates/views/account/assembly/slots/profile/form/catalog.part +5 -0
  68. package/assets/templates/views/account/assembly/slots/profile/form/element.part +10 -0
  69. package/assets/templates/views/account/assembly/slots/profile/form/registry.part +1 -0
  70. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/catalog.part +4 -0
  71. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/element.part +13 -0
  72. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/registry.part +1 -0
  73. package/assets/templates/views/account/assembly/slots/summary/stack/catalog.part +5 -0
  74. package/assets/templates/views/account/assembly/slots/summary/stack/element.part +5 -0
  75. package/assets/templates/views/account/assembly/slots/summary/stack/registry.part +1 -0
  76. package/assets/templates/views/account/assembly/slots/summary/tabs/catalog.part +5 -0
  77. package/assets/templates/views/account/assembly/slots/summary/tabs/element.part +5 -0
  78. package/assets/templates/views/account/assembly/slots/summary/tabs/registry.part +1 -0
  79. package/assets/templates/views/account/content.ts +326 -0
  80. package/assets/templates/views/account/customer-profile.defaults.ts +136 -0
  81. package/assets/templates/views/account/index.tsx +218 -35
  82. package/assets/templates/views/account/order-detail.client.tsx +35 -0
  83. package/assets/templates/views/account/order-detail.defaults.ts +457 -0
  84. package/assets/templates/views/account/orders-advanced.client.tsx +166 -0
  85. package/assets/templates/views/account/orders-advanced.defaults.ts +230 -0
  86. package/assets/templates/views/account/registry.tsx +944 -369
  87. package/assets/templates/views/account/schema.ts +50 -0
  88. package/assets/templates/views/account/sections-data.ts +2 -0
  89. package/assets/templates/views/cart/content.ts +1 -0
  90. package/assets/templates/views/category/assembly/index.skeleton.tsx +1 -0
  91. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
  92. package/assets/templates/views/category/content.ts +2 -0
  93. package/assets/templates/views/category/index.tsx +2 -0
  94. package/assets/templates/views/category/sections-data.ts +2 -0
  95. package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +1089 -0
  96. package/assets/templates/views/checkout/content.ts +51 -0
  97. package/assets/templates/views/checkout/index.tsx +1 -1
  98. package/assets/templates/views/checkout/props.ts +10 -2
  99. package/assets/templates/views/checkout/registry.tsx +104 -42
  100. package/assets/templates/views/checkout/schema.ts +76 -1
  101. package/assets/templates/views/home/assembly/assembly.json +22 -1
  102. package/assets/templates/views/home/assembly/index.skeleton.tsx +1 -0
  103. package/assets/templates/views/home/content.ts +2 -0
  104. package/assets/templates/views/home/index.tsx +1 -0
  105. package/assets/templates/views/home/sections-data.ts +2 -0
  106. package/assets/templates/views/product/content.ts +1 -0
  107. package/assets/templates/views/static/content.ts +1 -0
  108. package/bin/storefront.js +343 -13
  109. package/package.json +2 -1
  110. package/recipes/adapter-surface.json +158 -0
  111. package/recipes/archetypes.json +38 -3
  112. package/recipes/catalog.json +138 -1
  113. package/recipes/feature.schema.json +9 -0
  114. package/recipes/features.json +72 -1
  115. package/recipes/manifest.schema.json +5 -0
  116. package/recipes/recipe.schema.json +13 -1
  117. package/recipes/recipes.json +34 -5
  118. package/recipes/section.schema.json +112 -0
  119. package/recipes/sections.json +281 -4
  120. package/recipes/validate.mjs +83 -1
  121. package/scripts/adapter-surface.mjs +41 -0
  122. package/scripts/agent-blocks.mjs +700 -0
  123. package/scripts/block-validator.mjs +45 -0
  124. package/scripts/candidate.mjs +5 -4
  125. package/scripts/composers.mjs +7 -2
  126. package/scripts/default-sections.mjs +78 -0
  127. package/scripts/file-classes.mjs +14 -0
  128. package/scripts/generate-adapter-surface.mjs +148 -0
  129. package/scripts/operations.mjs +100 -0
  130. package/scripts/reconcile.mjs +67 -39
  131. package/scripts/section-configure.mjs +316 -0
  132. package/scripts/sync-assets.mjs +1 -0
  133. package/scripts/view-assembly.mjs +101 -14
  134. package/skills/sf-feature/SKILL.md +19 -0
  135. package/skills/sf-view-gen/SKILL.md +73 -7
  136. package/skills/sf-view-gen/assets/recipes/archetypes.json +38 -3
  137. package/skills/sf-view-gen/assets/recipes/catalog.json +138 -1
  138. package/skills/sf-view-gen/assets/recipes/features.json +72 -1
  139. package/skills/sf-view-gen/assets/recipes/recipes.json +34 -5
  140. package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
  141. package/skills/sf-view-gen/assets/recipes/sections.json +281 -4
  142. package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.client.tsx +19 -0
  143. package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.tsx +16 -0
  144. package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.client.tsx +19 -0
  145. package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.tsx +16 -0
  146. package/skills/sf-view-gen/assets/templates/views/sections/schema.checkout-commerce-v1.ts +398 -0
  147. package/skills/sf-view-gen/assets/templates/views/sections/schema.mega-menu-universal.ts +76 -0
  148. package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +217 -0
  149. package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.client.tsx +24 -0
  150. package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.tsx +16 -0
  151. package/skills/sf-view-gen/scripts/validate.mjs +83 -1
@@ -5,6 +5,7 @@
5
5
  // imports it and wires it into the element tree, so your edits here survive
6
6
  // `storefront sync` and unit removal. Plain data only: no React and no server
7
7
  // imports.
8
+ // A configured `sections/<id>.json` sidecar wins over this map for that instance.
8
9
 
9
10
  export const checkoutContent = {
10
11
  title: 'Finalizar compra',
@@ -40,6 +41,8 @@ export const checkoutContent = {
40
41
  countryPlaceholder: 'Selecciona un país',
41
42
  shippingMethodLegend: 'Método de envío',
42
43
  paymentMethodLegend: 'Método de pago',
44
+ paymentChooseLabel: 'Selecciona un método de pago',
45
+ paymentSelectActionLabel: 'Seleccionar',
43
46
  noPaymentMethodsLabel: 'No hay métodos de pago disponibles para esta región.',
44
47
  unavailableMethodLabel: 'No disponible',
45
48
  requiresSetupLabel: 'Requiere configuración adicional',
@@ -224,3 +227,51 @@ export const confirmationContent = {
224
227
  },
225
228
  },
226
229
  }
230
+
231
+ /**
232
+ * Copy for the designer confirmation. The layout and labels are the
233
+ * designer's; the email line reports the contact supplied by the order instead
234
+ * of promising an email the backend may not send.
235
+ */
236
+ export const designerConfirmationContent = {
237
+ labels: {
238
+ confirmationBadge: 'Confirmado',
239
+ confirmationTitle: 'Pedido creado',
240
+ confirmationBody: 'Gracias, {name}. Hemos recibido tu pedido y ya estamos preparándolo.',
241
+ confirmationEmailNote: 'Correo de contacto: {email}.',
242
+ confirmationReference: 'Número de pedido',
243
+ confirmationTotal: 'Total del pedido',
244
+ confirmationReferenceNote: 'Guarda este número para cualquier consulta.',
245
+ confirmationNextTitle: '¿Qué pasa ahora?',
246
+ confirmationNextOneTitle: 'Pedido recibido',
247
+ confirmationNextOneBody: 'Ya tenemos tu compra registrada.',
248
+ confirmationNextTwoTitle: 'Preparando tu pedido',
249
+ confirmationNextTwoBody: 'Cada entrega se prepara desde su almacén de origen.',
250
+ confirmationNextThreeTitle: 'Seguimiento',
251
+ confirmationNextThreeBody:
252
+ 'Cuando el seguimiento esté disponible, podrás consultar el estado desde aquí.',
253
+ confirmationOrderTitle: 'Tu pedido',
254
+ confirmationDetailsTitle: 'Entrega y pago',
255
+ confirmationQuantity: '{count} × {price}/ud.',
256
+ confirmationAssociateTag: 'Asociado',
257
+ confirmationCta: 'Seguir comprando',
258
+ summaryTitle: 'Resumen',
259
+ summaryItemOne: '1 artículo',
260
+ summaryItems: '{count} artículos',
261
+ deliveriesOne: '1 entrega',
262
+ deliveriesMany: '{count} entregas',
263
+ purchaseBreakdown: '{items} · {deliveries}',
264
+ subtotal: 'Subtotal',
265
+ tax: 'Impuestos ({rate}%)',
266
+ shippingCost: 'Envío',
267
+ pickupCost: 'Recogida',
268
+ extraCost: 'Extra',
269
+ total: 'Total',
270
+ groupFree: 'Gratis',
271
+ addressDelivery: 'Dirección de entrega',
272
+ paymentTitle: 'Pago',
273
+ billingTitle: 'Facturación',
274
+ checkSymbol: '✓',
275
+ lineDiscount: '{label} -{amount}',
276
+ },
277
+ }
@@ -88,7 +88,7 @@ const catalog = {
88
88
  },
89
89
  CheckoutConfirmation: {
90
90
  props: checkoutConfirmationPropsSchema,
91
- description: 'Order confirmation with fulfilment progress.',
91
+ description: 'Designer order confirmation with delivery, payment and totals.',
92
92
  },
93
93
  }
94
94
 
@@ -5,7 +5,11 @@
5
5
  // `storefront sync` and unit removal. Plain data only: no React and no server
6
6
  // imports.
7
7
 
8
- import { checkoutContent, confirmationContent } from './content'
8
+ import {
9
+ checkoutContent,
10
+ confirmationContent,
11
+ designerConfirmationContent,
12
+ } from './content'
9
13
 
10
14
  export const checkoutViewProps = {
11
15
  ...checkoutContent,
@@ -55,6 +59,7 @@ export const checkoutViewProps = {
55
59
  },
56
60
  sameAsShipping: { $state: '/checkoutSameAsShipping' },
57
61
  paymentMethod: { $state: '/checkout/paymentMethod' },
62
+ paymentMethods: { $state: '/checkoutPaymentMethods' },
58
63
  customer: { $state: '/checkoutCustomer' },
59
64
  savedAddresses: { $state: '/checkoutSavedAddresses' },
60
65
  savedAddressState: { $state: '/checkoutSavedAddressState' },
@@ -82,7 +87,10 @@ export const checkoutViewProps = {
82
87
  }
83
88
 
84
89
  export const checkoutConfirmationProps = {
85
- // One atomic state path carries the order and its backend lines together.
90
+ // One atomic state path carries the order, its backend lines and the
91
+ // host-confirmed confirmation model together.
86
92
  receipt: { $state: '/lastReceipt' },
93
+ labels: designerConfirmationContent.labels,
94
+ // Canonical labels remain for the legacy/rollback fallback only.
87
95
  ...confirmationContent,
88
96
  }
@@ -10,9 +10,13 @@ import { useEffect, useRef } from 'react'
10
10
  import { Button } from '@thorprovider/blocks/ui/button'
11
11
  import CheckoutBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout'
12
12
  import CheckoutConfirmationBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout-confirmation'
13
+ import { CheckoutConfirmationView } from '@thorprovider/blocks'
14
+ import { CheckoutCommerceHostedAdapter } from './checkout-commerce-hosted'
15
+ import { useNextApp } from '@json-render/next'
13
16
  import { useStateStore } from '@json-render/react'
14
17
  import {
15
18
  loadCheckoutAction,
19
+ loadCheckoutLocationsAction,
16
20
  loadCheckoutPrefillAction,
17
21
  reconcileReceiptAction,
18
22
  } from '../../actions'
@@ -30,11 +34,15 @@ import {
30
34
  validateCheckoutShippingAddress,
31
35
  } from './schema'
32
36
 
33
- function clearPhoneFieldError(
34
- errors: Record<string, unknown>,
37
+ /** Normalize malformed error state before clearing a single phone field. */
38
+ export function clearPhoneFieldError(
39
+ errors: unknown,
35
40
  groupName: 'contact' | 'shippingAddress',
36
41
  ): Record<string, unknown> {
37
- const next = { ...errors }
42
+ const next =
43
+ errors !== null && typeof errors === 'object' && !Array.isArray(errors)
44
+ ? { ...(errors as Record<string, unknown>) }
45
+ : {}
38
46
  const group = next[groupName]
39
47
  if (group && typeof group === 'object' && !Array.isArray(group)) {
40
48
  const fields = { ...(group as Record<string, unknown>) }
@@ -77,6 +85,7 @@ export const registry: ViewRegistry = {
77
85
  */
78
86
  CheckoutBoot: () => {
79
87
  const { state, set } = useStateStore()
88
+ const { navigate } = useNextApp()
80
89
  const booted = useRef(false)
81
90
  useEffect(() => {
82
91
  if (booted.current) return
@@ -85,9 +94,14 @@ export const registry: ViewRegistry = {
85
94
  const applyResult = (result: PlaceOrderResult) => {
86
95
  set('/checkoutPending', false)
87
96
  if (result.status === 'order') {
88
- // ONE atomic write carries the order and its backend lines, so an SSR
89
- // refresh cannot drop the lines.
90
- set('/lastReceipt', { order: result.order, lines: result.lines })
97
+ // ONE atomic write carries the order, its backend lines and the
98
+ // host-confirmed confirmation model, so an SSR refresh cannot drop
99
+ // the confirmation data.
100
+ set('/lastReceipt', {
101
+ order: result.order,
102
+ lines: result.lines,
103
+ confirmation: result.confirmation,
104
+ })
91
105
  set('/orderStatus', 'complete')
92
106
  set('/checkoutError', null)
93
107
  set('/checkoutErrorKind', null)
@@ -103,6 +117,10 @@ export const registry: ViewRegistry = {
103
117
  set('/checkoutShippingState', 'idle')
104
118
  return
105
119
  }
120
+ if (result.code === 'AUTH_REQUIRED') {
121
+ navigate('/account')
122
+ return
123
+ }
106
124
  set('/orderStatus', result.status === 'cart-error' ? 'error' : result.status)
107
125
  set('/checkoutErrorKind', result.status)
108
126
  set('/checkoutError', result.message)
@@ -140,6 +158,10 @@ export const registry: ViewRegistry = {
140
158
  .then((result) => {
141
159
  set('/checkoutPending', false)
142
160
  if (!result.ok) {
161
+ if (result.code === 'AUTH_REQUIRED') {
162
+ navigate('/account')
163
+ return
164
+ }
143
165
  set('/checkoutError', result.error)
144
166
  set('/checkoutErrorKind', 'error')
145
167
  return
@@ -186,7 +208,12 @@ export const registry: ViewRegistry = {
186
208
  sameAsShipping: true,
187
209
  })
188
210
  .then((prefill) => {
189
- if (!prefill.ok) return
211
+ if (!prefill.ok) {
212
+ if (prefill.code === 'AUTH_REQUIRED') {
213
+ navigate('/account')
214
+ }
215
+ return
216
+ }
190
217
  set('/checkoutContact', prefill.contact)
191
218
  set('/checkoutShippingAddress', prefill.shippingAddress)
192
219
  if (prefill.billingAddress) set('/checkoutBillingAddress', prefill.billingAddress)
@@ -217,7 +244,22 @@ export const registry: ViewRegistry = {
217
244
  }, [])
218
245
  return null
219
246
  },
220
- Checkout: ({ props, emit }) => {
247
+ // One-line rollback: Checkout: ({ props, emit }) => registry.CheckoutCanonical({ props, emit }),
248
+ // The shell `main` paints no padding, so this host supplies the page canvas
249
+ // the design block deliberately does not paint (block-viewport-ownership).
250
+ // Width and gutters stay consistent with the /account view container; the
251
+ // rollback target keeps its own frame, so it is not wrapped twice.
252
+ Checkout: ({ props, emit }) => (
253
+ <div className="mx-auto w-full max-w-7xl px-4 py-10 sm:px-6 lg:px-8">
254
+ <CheckoutCommerceHostedAdapter
255
+ props={props}
256
+ emit={emit}
257
+ loadLocations={loadCheckoutLocationsAction}
258
+ />
259
+ </div>
260
+ ),
261
+ // Retained in the element map as the one-line rollback target for the hosted route.
262
+ CheckoutCanonical: ({ props, emit }) => {
221
263
  const { state, set } = useStateStore()
222
264
  const parsed = checkoutPropsSchema.parse(props)
223
265
  const unresolved = state.checkoutErrorKind === 'unresolved'
@@ -444,43 +486,63 @@ export const registry: ViewRegistry = {
444
486
  ),
445
487
  CheckoutConfirmation: ({ props, emit }) => {
446
488
  const parsed = checkoutConfirmationPropsSchema.parse(props)
489
+ // The shell `main` paints no padding, so the confirmation gets the same
490
+ // host-provided page canvas as the checkout form and empty state.
491
+ const canvasClassName = 'mx-auto w-full max-w-7xl px-4 py-10 sm:px-6 lg:px-8'
492
+ // The designer confirmation is the production screen. The canonical block
493
+ // remains only for receipts created before the confirmation contract.
494
+ if (parsed.receipt.confirmation) {
495
+ return (
496
+ <div className={canvasClassName}>
497
+ <CheckoutConfirmationView
498
+ confirmation={parsed.receipt.confirmation}
499
+ labels={parsed.labels ?? {}}
500
+ locale={parsed.receipt.confirmation.locale}
501
+ currencyCode={parsed.receipt.confirmation.currencyCode}
502
+ onContinueShopping={() => emit('continueShopping')}
503
+ />
504
+ </div>
505
+ )
506
+ }
447
507
  // Forward every neutral label from user-owned content to the block, so the
448
508
  // curated flow never falls back to the block's non-neutral defaults.
449
509
  return (
450
- <CheckoutConfirmationBlock
451
- order={parsed.receipt.order}
452
- orderLines={parsed.receipt.lines}
453
- fulfilmentDetails={parsed.fulfilmentDetails}
454
- titleLabel={parsed.titleLabel}
455
- orderPlacedLabel={parsed.orderPlacedLabel}
456
- orderPlacedNoEmailLabel={parsed.orderPlacedNoEmailLabel}
457
- itemsLabel={parsed.itemsLabel}
458
- quantityLabel={parsed.quantityLabel}
459
- subtotalLabel={parsed.subtotalLabel}
460
- discountLabel={parsed.discountLabel}
461
- shippingLabel={parsed.shippingLabel}
462
- taxLabel={parsed.taxLabel}
463
- totalLabel={parsed.totalLabel}
464
- freeLabel={parsed.freeLabel}
465
- amountUnavailableLabel={parsed.amountUnavailableLabel}
466
- shippingAddressLabel={parsed.shippingAddressLabel}
467
- billingAddressLabel={parsed.billingAddressLabel}
468
- continueShoppingLabel={parsed.continueShoppingLabel}
469
- contactSupportLabel={parsed.contactSupportLabel}
470
- supportLabel={parsed.supportLabel}
471
- progressLabel={parsed.progressLabel}
472
- estimatedDeliveryLabel={parsed.estimatedDeliveryLabel}
473
- currentStageLabel={parsed.currentStageLabel}
474
- inProgressLabel={parsed.inProgressLabel}
475
- expectedByLabel={parsed.expectedByLabel}
476
- completedLabel={parsed.completedLabel}
477
- statusLabel={parsed.statusLabel}
478
- locationLabel={parsed.locationLabel}
479
- trackOrderLabel={parsed.trackOrderLabel}
480
- continueShoppingHref={parsed.continueShoppingHref ?? '#'}
481
- supportHref={parsed.supportHref}
482
- onContinueShopping={() => emit('continueShopping')}
483
- />
510
+ <div className={canvasClassName}>
511
+ <CheckoutConfirmationBlock
512
+ order={parsed.receipt.order}
513
+ orderLines={parsed.receipt.lines}
514
+ fulfilmentDetails={parsed.fulfilmentDetails}
515
+ titleLabel={parsed.titleLabel}
516
+ orderPlacedLabel={parsed.orderPlacedLabel}
517
+ orderPlacedNoEmailLabel={parsed.orderPlacedNoEmailLabel}
518
+ itemsLabel={parsed.itemsLabel}
519
+ quantityLabel={parsed.quantityLabel}
520
+ subtotalLabel={parsed.subtotalLabel}
521
+ discountLabel={parsed.discountLabel}
522
+ shippingLabel={parsed.shippingLabel}
523
+ taxLabel={parsed.taxLabel}
524
+ totalLabel={parsed.totalLabel}
525
+ freeLabel={parsed.freeLabel}
526
+ amountUnavailableLabel={parsed.amountUnavailableLabel}
527
+ shippingAddressLabel={parsed.shippingAddressLabel}
528
+ billingAddressLabel={parsed.billingAddressLabel}
529
+ continueShoppingLabel={parsed.continueShoppingLabel}
530
+ contactSupportLabel={parsed.contactSupportLabel}
531
+ supportLabel={parsed.supportLabel}
532
+ progressLabel={parsed.progressLabel}
533
+ estimatedDeliveryLabel={parsed.estimatedDeliveryLabel}
534
+ currentStageLabel={parsed.currentStageLabel}
535
+ inProgressLabel={parsed.inProgressLabel}
536
+ expectedByLabel={parsed.expectedByLabel}
537
+ completedLabel={parsed.completedLabel}
538
+ statusLabel={parsed.statusLabel}
539
+ locationLabel={parsed.locationLabel}
540
+ trackOrderLabel={parsed.trackOrderLabel}
541
+ continueShoppingHref={parsed.continueShoppingHref ?? '#'}
542
+ supportHref={parsed.supportHref}
543
+ onContinueShopping={() => emit('continueShopping')}
544
+ />
545
+ </div>
484
546
  )
485
547
  },
486
548
  }
@@ -349,10 +349,83 @@ export const fulfilmentStageDetailSchema = z.object({
349
349
  at: z.string().nullable(),
350
350
  })
351
351
 
352
- // The atomic receipt: the order and its backend lines arrive together.
352
+ // The designer confirmation view model. It is built from the host-confirmed
353
+ // order, never from browser-only checkout state, so a reload/reconcile renders
354
+ // the same screen. Optional sections are omitted by the view when absent.
355
+ export const confirmationAddressSchema = z.object({
356
+ id: z.string(),
357
+ isDefault: z.boolean(),
358
+ label: z.string(),
359
+ recipient: z.string(),
360
+ line1: z.string(),
361
+ line2: z.string().optional(),
362
+ company: z.string().optional(),
363
+ city: z.string(),
364
+ province: z.string().optional(),
365
+ countryCode: z.string().optional(),
366
+ postalCode: z.string().optional(),
367
+ phone: z.string().optional(),
368
+ })
369
+
370
+ export const confirmationLineSchema = z.object({
371
+ lineId: z.string(),
372
+ title: z.string(),
373
+ variant: z.string().optional(),
374
+ image: z.string().optional(),
375
+ unitCents: z.number().optional(),
376
+ quantity: z.number(),
377
+ netTotalCents: z.number().optional(),
378
+ })
379
+
380
+ export const confirmationGroupSchema = z.object({
381
+ id: z.string(),
382
+ title: z.string(),
383
+ modeLabel: z.string(),
384
+ methodLabel: z.string(),
385
+ detailLabel: z.string(),
386
+ feeCents: z.number(),
387
+ lines: z.array(confirmationLineSchema),
388
+ })
389
+
390
+ export const confirmationPromotionSchema = z.object({
391
+ id: z.string(),
392
+ label: z.string(),
393
+ kind: z.string(),
394
+ amountCents: z.number(),
395
+ code: z.string().optional(),
396
+ })
397
+
398
+ export const storefrontConfirmationSchema = z.object({
399
+ reference: z.string(),
400
+ totalCents: z.number(),
401
+ subtotalCents: z.number(),
402
+ unitCount: z.number().optional(),
403
+ promotions: z.array(confirmationPromotionSchema).optional(),
404
+ taxCents: z.number().optional(),
405
+ taxRateBps: z.number().optional(),
406
+ shippingCents: z.number().optional(),
407
+ pickupCents: z.number().optional(),
408
+ extraCents: z.number().optional(),
409
+ extraLabel: z.string().optional(),
410
+ groups: z.array(confirmationGroupSchema),
411
+ address: confirmationAddressSchema.nullable(),
412
+ paymentLabel: z.string(),
413
+ paymentDetail: z.string(),
414
+ billingLabel: z.string(),
415
+ billingDetail: z.string(),
416
+ customerName: z.string(),
417
+ customerEmail: z.string(),
418
+ locale: z.string(),
419
+ currencyCode: z.string(),
420
+ })
421
+
422
+ // The atomic receipt: the order, its backend lines and the host-confirmed
423
+ // confirmation model arrive together. `confirmation` is optional only for
424
+ // receipts created before this contract; those use the canonical fallback.
353
425
  export const receiptSchema = z.object({
354
426
  order: storefrontOrderSchema,
355
427
  lines: z.array(orderLineSchema),
428
+ confirmation: storefrontConfirmationSchema.optional(),
356
429
  })
357
430
 
358
431
  // Mirrors the CheckoutConfirmation props, including every neutral label the
@@ -360,6 +433,7 @@ export const receiptSchema = z.object({
360
433
  // the registry forwards them to the block instead of relying on its defaults.
361
434
  export const checkoutConfirmationPropsSchema = z.object({
362
435
  receipt: receiptSchema,
436
+ labels: z.record(z.string(), z.string()).optional(),
363
437
  fulfilmentDetails: z.record(z.string(), fulfilmentStageDetailSchema).optional(),
364
438
  titleLabel: z.string().optional(),
365
439
  orderPlacedLabel: z.string().optional(),
@@ -396,4 +470,5 @@ export type OrderSummary = z.infer<typeof orderSummarySchema>
396
470
  export type CheckoutProps = z.infer<typeof checkoutPropsSchema>
397
471
  export type StorefrontOrder = z.infer<typeof storefrontOrderSchema>
398
472
  export type OrderLine = z.infer<typeof orderLineSchema>
473
+ export type StorefrontConfirmation = z.infer<typeof storefrontConfirmationSchema>
399
474
  export type CheckoutConfirmationProps = z.infer<typeof checkoutConfirmationPropsSchema>