@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.
- package/README.md +22 -2
- package/assets/templates/AGENTS.md +14 -2
- package/assets/templates/app/app/[[...slug]]/page.tsx +9 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-address.ts +129 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +2 -2
- package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +143 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-profile.ts +220 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +621 -80
- package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +346 -38
- package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +240 -0
- package/assets/templates/app/lib/__STOREFRONT__/customer-profile-port.ts +103 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/orders-port.ts +30 -0
- package/assets/templates/app/lib/__STOREFRONT__/ports.ts +18 -0
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +4 -4
- package/assets/templates/app/lib/__STOREFRONT__/session.ts +24 -6
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +21 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx +29 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/customer-profile.client.tsx +27 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +4 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.tsx +16 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.address-book-advanced.ts +437 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.checkout-commerce-v1.ts +398 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.customer-profile.ts +138 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.mega-menu-universal.ts +76 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +217 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +24 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.tsx +16 -0
- package/assets/templates/features/checkout/handlers.ts +24 -4
- package/assets/templates/features/customer-addresses/handlers.ts +11 -0
- package/assets/templates/features/customer-addresses/state.ts +33 -0
- package/assets/templates/features/customer-auth/state.ts +10 -0
- package/assets/templates/features/customer-profile/handlers.ts +11 -0
- package/assets/templates/features/customer-profile/state.ts +18 -0
- package/assets/templates/views/account/address-book-advanced.defaults.ts +534 -0
- package/assets/templates/views/account/assembly/assembly.json +41 -0
- package/assets/templates/views/account/assembly/index.skeleton.tsx +229 -0
- package/assets/templates/views/account/assembly/registry.skeleton.tsx +1116 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/element.part +10 -0
- package/assets/templates/views/account/assembly/slots/addresses/cards/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/login/card/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/login/card/element.part +13 -0
- package/assets/templates/views/account/assembly/slots/login/card/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistory/registry.part +2 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/binding.json +5 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/profile/form/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/profile/form/element.part +10 -0
- package/assets/templates/views/account/assembly/slots/profile/form/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/catalog.part +4 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/element.part +13 -0
- package/assets/templates/views/account/assembly/slots/register/SignUpPage1/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/stack/registry.part +1 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/catalog.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/element.part +5 -0
- package/assets/templates/views/account/assembly/slots/summary/tabs/registry.part +1 -0
- package/assets/templates/views/account/content.ts +326 -0
- package/assets/templates/views/account/customer-profile.defaults.ts +136 -0
- package/assets/templates/views/account/index.tsx +218 -35
- package/assets/templates/views/account/order-detail.client.tsx +35 -0
- package/assets/templates/views/account/order-detail.defaults.ts +457 -0
- package/assets/templates/views/account/orders-advanced.client.tsx +166 -0
- package/assets/templates/views/account/orders-advanced.defaults.ts +230 -0
- package/assets/templates/views/account/registry.tsx +944 -369
- package/assets/templates/views/account/schema.ts +50 -0
- package/assets/templates/views/account/sections-data.ts +2 -0
- package/assets/templates/views/cart/content.ts +1 -0
- package/assets/templates/views/category/assembly/index.skeleton.tsx +1 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
- package/assets/templates/views/category/content.ts +2 -0
- package/assets/templates/views/category/index.tsx +2 -0
- package/assets/templates/views/category/sections-data.ts +2 -0
- package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +1089 -0
- package/assets/templates/views/checkout/content.ts +51 -0
- package/assets/templates/views/checkout/index.tsx +1 -1
- package/assets/templates/views/checkout/props.ts +10 -2
- package/assets/templates/views/checkout/registry.tsx +104 -42
- package/assets/templates/views/checkout/schema.ts +76 -1
- package/assets/templates/views/home/assembly/assembly.json +22 -1
- package/assets/templates/views/home/assembly/index.skeleton.tsx +1 -0
- package/assets/templates/views/home/content.ts +2 -0
- package/assets/templates/views/home/index.tsx +1 -0
- package/assets/templates/views/home/sections-data.ts +2 -0
- package/assets/templates/views/product/content.ts +1 -0
- package/assets/templates/views/static/content.ts +1 -0
- package/bin/storefront.js +343 -13
- package/package.json +2 -1
- package/recipes/adapter-surface.json +158 -0
- package/recipes/archetypes.json +38 -3
- package/recipes/catalog.json +138 -1
- package/recipes/feature.schema.json +9 -0
- package/recipes/features.json +72 -1
- package/recipes/manifest.schema.json +5 -0
- package/recipes/recipe.schema.json +13 -1
- package/recipes/recipes.json +34 -5
- package/recipes/section.schema.json +112 -0
- package/recipes/sections.json +281 -4
- package/recipes/validate.mjs +83 -1
- package/scripts/adapter-surface.mjs +41 -0
- package/scripts/agent-blocks.mjs +700 -0
- package/scripts/block-validator.mjs +45 -0
- package/scripts/candidate.mjs +5 -4
- package/scripts/composers.mjs +7 -2
- package/scripts/default-sections.mjs +78 -0
- package/scripts/file-classes.mjs +14 -0
- package/scripts/generate-adapter-surface.mjs +148 -0
- package/scripts/operations.mjs +100 -0
- package/scripts/reconcile.mjs +67 -39
- package/scripts/section-configure.mjs +316 -0
- package/scripts/sync-assets.mjs +1 -0
- package/scripts/view-assembly.mjs +101 -14
- package/skills/sf-feature/SKILL.md +19 -0
- package/skills/sf-view-gen/SKILL.md +73 -7
- package/skills/sf-view-gen/assets/recipes/archetypes.json +38 -3
- package/skills/sf-view-gen/assets/recipes/catalog.json +138 -1
- package/skills/sf-view-gen/assets/recipes/features.json +72 -1
- package/skills/sf-view-gen/assets/recipes/recipes.json +34 -5
- package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
- package/skills/sf-view-gen/assets/recipes/sections.json +281 -4
- package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.tsx +16 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.checkout-commerce-v1.ts +398 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.mega-menu-universal.ts +76 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +217 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.client.tsx +24 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.tsx +16 -0
- 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
|
+
}
|
|
@@ -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 {
|
|
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
|
|
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
|
-
|
|
34
|
-
|
|
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 =
|
|
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
|
|
89
|
-
// refresh cannot drop
|
|
90
|
-
|
|
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)
|
|
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
|
-
<
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
|
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>
|