@thorprovider/storefront 0.6.2 → 0.7.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 (30) hide show
  1. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +649 -31
  2. package/assets/templates/app/lib/__STOREFRONT__/checkout-shipping.core.ts +37 -0
  3. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +117 -0
  4. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +7 -1
  5. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
  6. package/assets/templates/app/lib/__STOREFRONT__/views/sections/marketplace-product-card.client.tsx +19 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/views/sections/marketplace-product-card.tsx +16 -0
  8. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.marketplace-product-card.ts +67 -0
  9. package/assets/templates/features/checkout/handlers.ts +326 -31
  10. package/assets/templates/features/checkout/state.ts +79 -3
  11. package/assets/templates/views/checkout/content.ts +63 -2
  12. package/assets/templates/views/checkout/index.tsx +6 -0
  13. package/assets/templates/views/checkout/props.ts +61 -21
  14. package/assets/templates/views/checkout/registry.tsx +300 -33
  15. package/assets/templates/views/checkout/schema.ts +184 -8
  16. package/assets/templates/views/home/assembly/assembly.json +7 -0
  17. package/package.json +1 -1
  18. package/recipes/recipe.schema.json +1 -1
  19. package/recipes/recipes.json +2 -1
  20. package/recipes/sections.json +9 -0
  21. package/scripts/candidate.mjs +1 -1
  22. package/scripts/file-classes.mjs +1 -0
  23. package/skills/sf-view-gen/SKILL.md +6 -0
  24. package/skills/sf-view-gen/assets/recipes/recipes.json +2 -1
  25. package/skills/sf-view-gen/assets/recipes/sections.json +9 -0
  26. package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.client.tsx +19 -0
  27. package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.tsx +16 -0
  28. package/skills/sf-view-gen/assets/templates/views/sections/schema.marketplace-product-card.ts +67 -0
  29. package/skills/storefront-workflow/SKILL.md +5 -0
  30. package/skills/storefront-workflow/references/mobile-responsiveness.md +1 -1
@@ -9,36 +9,76 @@ import { checkoutContent, confirmationContent } from './content'
9
9
 
10
10
  export const checkoutViewProps = {
11
11
  ...checkoutContent,
12
- // Bounded structural presentation: the proven step-by-step flow. Change it
13
- // here to 'single-page' if this store wants every section visible at once.
12
+ // Bounded structural presentation. Options are 'single-page' (all sections
13
+ // visible), 'accordion' (one section open), and 'stepper' (one step at a time).
14
+ // The generated storefront keeps the proven step-by-step default.
14
15
  presentation: 'stepper' as const,
15
16
  showReviewStep: false,
17
+ // Phone requiredness is an explicit store policy; both fields are optional by default.
18
+ requireContactPhone: false,
19
+ requireShippingPhone: false,
16
20
  // Backend-authoritative summary: line totals and cart totals come from the
17
21
  // backend cart state, never computed here.
18
22
  orderSummary: {
19
23
  items: { $state: '/cart' },
20
24
  totals: { $state: '/cartTotals' },
21
25
  },
22
- countries: { $state: '/checkoutCountries' },
23
- shippingOptions: { $state: '/checkoutShippingOptions' },
24
- selectedShippingOptionId: { $state: '/checkoutSelectedShippingOptionId' },
25
- paymentMethods: { $state: '/checkoutPaymentMethods' },
26
- fieldErrors: { $state: '/checkoutFieldErrors' },
27
- values: {
28
- email: { $state: '/checkout/email' },
29
- firstName: { $state: '/checkout/firstName' },
30
- lastName: { $state: '/checkout/lastName' },
31
- phone: { $state: '/checkout/phone' },
32
- address: { $state: '/checkout/address' },
33
- city: { $state: '/checkout/city' },
34
- state: { $state: '/checkout/state' },
35
- zipCode: { $state: '/checkout/zipCode' },
36
- country: { $state: '/checkout/country' },
37
- paymentMethod: { $state: '/checkout/paymentMethod' },
38
- saveInfo: { $state: '/checkout/saveInfo' },
39
- newsletter: { $state: '/checkout/newsletter' },
40
- promoCode: { $state: '/checkout/promoCode' },
26
+ contact: {
27
+ email: { $state: '/checkoutContact/email' },
28
+ firstName: { $state: '/checkoutContact/firstName' },
29
+ lastName: { $state: '/checkoutContact/lastName' },
30
+ phone: { $state: '/checkoutContact/phone' },
31
+ },
32
+ shippingAddress: {
33
+ firstName: { $state: '/checkoutShippingAddress/firstName' },
34
+ lastName: { $state: '/checkoutShippingAddress/lastName' },
35
+ company: { $state: '/checkoutShippingAddress/company' },
36
+ address1: { $state: '/checkoutShippingAddress/address1' },
37
+ address2: { $state: '/checkoutShippingAddress/address2' },
38
+ city: { $state: '/checkoutShippingAddress/city' },
39
+ province: { $state: '/checkoutShippingAddress/province' },
40
+ postalCode: { $state: '/checkoutShippingAddress/postalCode' },
41
+ countryCode: { $state: '/checkoutShippingAddress/countryCode' },
42
+ phone: { $state: '/checkoutShippingAddress/phone' },
43
+ },
44
+ billingAddress: {
45
+ firstName: { $state: '/checkoutBillingAddress/firstName' },
46
+ lastName: { $state: '/checkoutBillingAddress/lastName' },
47
+ company: { $state: '/checkoutBillingAddress/company' },
48
+ address1: { $state: '/checkoutBillingAddress/address1' },
49
+ address2: { $state: '/checkoutBillingAddress/address2' },
50
+ city: { $state: '/checkoutBillingAddress/city' },
51
+ province: { $state: '/checkoutBillingAddress/province' },
52
+ postalCode: { $state: '/checkoutBillingAddress/postalCode' },
53
+ countryCode: { $state: '/checkoutBillingAddress/countryCode' },
54
+ phone: { $state: '/checkoutBillingAddress/phone' },
41
55
  },
56
+ sameAsShipping: { $state: '/checkoutSameAsShipping' },
57
+ paymentMethod: { $state: '/checkout/paymentMethod' },
58
+ customer: { $state: '/checkoutCustomer' },
59
+ savedAddresses: { $state: '/checkoutSavedAddresses' },
60
+ savedAddressState: { $state: '/checkoutSavedAddressState' },
61
+ shippingLocations: {
62
+ countries: { $state: '/checkoutShippingLocations/countries' },
63
+ provinces: { $state: '/checkoutShippingLocations/provinces' },
64
+ cities: { $state: '/checkoutShippingLocations/cities' },
65
+ provincesState: { $state: '/checkoutShippingLocations/provincesState' },
66
+ citiesState: { $state: '/checkoutShippingLocations/citiesState' },
67
+ },
68
+ billingLocations: {
69
+ countries: { $state: '/checkoutBillingLocations/countries' },
70
+ provinces: { $state: '/checkoutBillingLocations/provinces' },
71
+ cities: { $state: '/checkoutBillingLocations/cities' },
72
+ provincesState: { $state: '/checkoutBillingLocations/provincesState' },
73
+ citiesState: { $state: '/checkoutBillingLocations/citiesState' },
74
+ },
75
+ shippingGroups: { $state: '/checkoutShippingGroups' },
76
+ shippingState: { $state: '/checkoutShippingState' },
77
+ paymentState: { $state: '/checkoutPaymentState' },
78
+ adjustmentPayments: { $state: '/checkoutAdjustments' },
79
+ fieldErrors: { $state: '/checkoutFieldErrors' },
80
+ availability: { $state: '/checkoutAvailability' },
81
+ interruption: { $state: '/checkoutInterruption' },
42
82
  }
43
83
 
44
84
  export const checkoutConfirmationProps = {
@@ -11,24 +11,62 @@ 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
13
  import { useStateStore } from '@json-render/react'
14
- import { loadCheckoutAction, reconcileReceiptAction } from '../../actions'
14
+ import {
15
+ loadCheckoutAction,
16
+ loadCheckoutPrefillAction,
17
+ reconcileReceiptAction,
18
+ } from '../../actions'
19
+ import type {
20
+ CheckoutAddressValues,
21
+ CheckoutContactValues,
22
+ CheckoutShippingGroup,
23
+ } from '@thorprovider/blocks'
15
24
  import type { CartStatePatch, PlaceOrderResult } from '../../commerce'
16
25
  import type { ViewRegistry } from '../types'
17
- import { checkoutConfirmationPropsSchema, checkoutPropsSchema } from './schema'
26
+ import {
27
+ checkoutConfirmationPropsSchema,
28
+ checkoutPropsSchema,
29
+ validateCheckoutContactPhone,
30
+ validateCheckoutShippingAddress,
31
+ } from './schema'
18
32
 
19
- // Address fields whose change can complete the address; when the full address
20
- // is present the handler syncs it to the backend and loads eligible shipping.
21
- const ADDRESS_FIELDS = new Set([
22
- 'email',
23
- 'firstName',
24
- 'lastName',
25
- 'phone',
26
- 'address',
27
- 'city',
28
- 'state',
29
- 'zipCode',
30
- 'country',
31
- ])
33
+ function clearPhoneFieldError(
34
+ errors: Record<string, unknown>,
35
+ groupName: 'contact' | 'shippingAddress',
36
+ ): Record<string, unknown> {
37
+ const next = { ...errors }
38
+ const group = next[groupName]
39
+ if (group && typeof group === 'object' && !Array.isArray(group)) {
40
+ const fields = { ...(group as Record<string, unknown>) }
41
+ delete fields.phone
42
+ next[groupName] = fields
43
+ }
44
+ return next
45
+ }
46
+
47
+ function flatToContact(values: Record<string, unknown>): CheckoutContactValues {
48
+ const str = (key: string) => (typeof values[key] === 'string' ? (values[key] as string) : '')
49
+ return {
50
+ email: str('email'),
51
+ firstName: str('firstName'),
52
+ lastName: str('lastName'),
53
+ phone: str('phone'),
54
+ }
55
+ }
56
+
57
+ function flatToAddress(values: Record<string, unknown>): CheckoutAddressValues {
58
+ const str = (key: string) => (typeof values[key] === 'string' ? (values[key] as string) : '')
59
+ return {
60
+ firstName: str('firstName'),
61
+ lastName: str('lastName'),
62
+ address1: str('address'),
63
+ city: str('city'),
64
+ province: str('state'),
65
+ postalCode: str('zipCode'),
66
+ countryCode: str('country'),
67
+ phone: str('phone'),
68
+ }
69
+ }
32
70
 
33
71
  export const registry: ViewRegistry = {
34
72
  /**
@@ -59,6 +97,10 @@ export const registry: ViewRegistry = {
59
97
  set('/cartQuantity', 0)
60
98
  set('/cartCompleted', true)
61
99
  set('/checkoutSelectedShippingOptionId', null)
100
+ // The completed cart's delivery groups are gone with it.
101
+ set('/checkoutShippingGroups', [])
102
+ set('/checkoutShippingGroupProducts', {})
103
+ set('/checkoutShippingState', 'idle')
62
104
  return
63
105
  }
64
106
  set('/orderStatus', result.status === 'cart-error' ? 'error' : result.status)
@@ -90,7 +132,11 @@ export const registry: ViewRegistry = {
90
132
  }
91
133
  if (state.cartId) {
92
134
  set('/checkoutPending', true)
93
- void loadCheckoutAction()
135
+ void loadCheckoutAction({
136
+ // Reconcile the shopper's per-group selections by stable identity on
137
+ // a re-entry into the checkout.
138
+ previousShippingGroups: (state.checkoutShippingGroups ?? []) as CheckoutShippingGroup[],
139
+ })
94
140
  .then((result) => {
95
141
  set('/checkoutPending', false)
96
142
  if (!result.ok) {
@@ -107,8 +153,59 @@ export const registry: ViewRegistry = {
107
153
  set('/checkoutSelectedShippingOptionId', cart.cartSelectedShippingOptionId)
108
154
  if (result.countries) set('/checkoutCountries', result.countries)
109
155
  if (result.paymentMethods) set('/checkoutPaymentMethods', result.paymentMethods)
110
- if (result.shippingOptions) set('/checkoutShippingOptions', result.shippingOptions)
156
+ // The backend group quote is authoritative and mapped 1:1 — the
157
+ // host never wraps the flat option list into one group (D7).
158
+ set('/checkoutShippingGroups', result.shippingGroups ?? [])
159
+ set('/checkoutShippingGroupProducts', result.shippingGroupProducts ?? {})
160
+ if (result.shippingError) {
161
+ // Delivery failures stay in the delivery state only (R1): the
162
+ // block renders the error/unavailable copy and its own retry.
163
+ // `unavailable` means the provider cannot serve grouped delivery.
164
+ set('/checkoutShippingState', result.shippingState ?? 'error')
165
+ } else {
166
+ set('/checkoutShippingState', 'idle')
167
+ }
168
+
169
+ const flat = (state.checkout ?? {}) as Record<string, unknown>
170
+ const contact = flatToContact(flat)
171
+ const shippingAddress = flatToAddress(flat)
172
+ const countries = result.countries ?? []
173
+ set('/checkoutContact', contact)
174
+ set('/checkoutShippingAddress', shippingAddress)
175
+ set('/checkoutBillingAddress', shippingAddress)
176
+ set('/checkoutSameAsShipping', true)
177
+ set('/checkout/paymentMethod', typeof flat.paymentMethod === 'string' ? flat.paymentMethod : '')
178
+ set('/checkoutShippingLocations', { countries, provinces: [], cities: [] })
179
+ set('/checkoutBillingLocations', { countries, provinces: [], cities: [] })
180
+ set('/checkoutPaymentState', 'idle')
111
181
  set('/checkoutError', null)
182
+
183
+ void loadCheckoutPrefillAction({
184
+ contact,
185
+ shippingAddress,
186
+ sameAsShipping: true,
187
+ })
188
+ .then((prefill) => {
189
+ if (!prefill.ok) return
190
+ set('/checkoutContact', prefill.contact)
191
+ set('/checkoutShippingAddress', prefill.shippingAddress)
192
+ if (prefill.billingAddress) set('/checkoutBillingAddress', prefill.billingAddress)
193
+ set('/checkoutSameAsShipping', prefill.sameAsShipping)
194
+ set('/checkoutCustomer', prefill.customer)
195
+ set('/checkoutSavedAddresses', prefill.savedAddresses)
196
+ set('/checkoutShippingLocations', prefill.shippingLocations)
197
+ set('/checkoutBillingLocations', prefill.billingLocations)
198
+ if (prefill.customerUnavailable) {
199
+ set('/checkoutInterruption', {
200
+ kind: 'session-expired',
201
+ severity: 'info',
202
+ title: 'No pudimos cargar tu cuenta',
203
+ message: 'Puedes continuar y completar los datos manualmente.',
204
+ actions: ['retry'],
205
+ })
206
+ }
207
+ })
208
+ .catch(bootError('loadCheckoutPrefill'))
112
209
  })
113
210
  .catch(bootError('loadCheckout'))
114
211
  return
@@ -126,10 +223,71 @@ export const registry: ViewRegistry = {
126
223
  const unresolved = state.checkoutErrorKind === 'unresolved'
127
224
  const cartError = typeof state.cartError === 'string' ? state.cartError : undefined
128
225
  const checkoutError = typeof state.checkoutError === 'string' ? state.checkoutError : undefined
226
+ // A failed/unsupported grouped quote owns the delivery state, so the retry
227
+ // for its submit-time error must refresh the quote, not re-place the order.
228
+ const shippingFailed =
229
+ state.checkoutShippingState === 'error' || state.checkoutShippingState === 'unavailable'
230
+ const managementEnabled = Boolean(parsed.customer)
231
+
232
+ const setFlatAddress = (address: CheckoutAddressValues) => {
233
+ set('/checkout/address', address.address1)
234
+ set('/checkout/firstName', address.firstName)
235
+ set('/checkout/lastName', address.lastName)
236
+ set('/checkout/city', address.city)
237
+ set('/checkout/state', address.province ?? '')
238
+ set('/checkout/zipCode', address.postalCode ?? '')
239
+ set('/checkout/country', address.countryCode)
240
+ set('/checkout/phone', address.phone ?? '')
241
+ }
242
+
243
+ const flatField = (field: keyof CheckoutAddressValues) =>
244
+ field === 'address1'
245
+ ? 'address'
246
+ : field === 'province'
247
+ ? 'state'
248
+ : field === 'postalCode'
249
+ ? 'zipCode'
250
+ : field === 'countryCode'
251
+ ? 'country'
252
+ : field
253
+
254
+ const updateShipping = (field: keyof CheckoutAddressValues, value: string) => {
255
+ set(`/checkoutShippingAddress/${field}`, value)
256
+ set(`/checkout/${flatField(field)}`, value)
257
+ if (field === 'phone') {
258
+ set(
259
+ '/checkoutFieldErrors',
260
+ clearPhoneFieldError(state.checkoutFieldErrors, 'shippingAddress'),
261
+ )
262
+ }
263
+ if (field === 'countryCode') {
264
+ set('/checkoutShippingLocations', {
265
+ ...(parsed.shippingLocations ?? { countries: [], provinces: [], cities: [] }),
266
+ provinces: [],
267
+ cities: [],
268
+ provincesState: 'pending',
269
+ citiesState: 'idle',
270
+ })
271
+ set('/checkoutLocationRequest', { kind: 'shipping', level: 'provinces' })
272
+ emit('loadCheckoutLocations')
273
+ }
274
+ if (field === 'province') {
275
+ set('/checkoutShippingLocations', {
276
+ ...(parsed.shippingLocations ?? { countries: [], provinces: [], cities: [] }),
277
+ cities: [],
278
+ citiesState: 'pending',
279
+ })
280
+ set('/checkoutLocationRequest', { kind: 'shipping', level: 'cities' })
281
+ emit('loadCheckoutLocations')
282
+ }
283
+ }
284
+
129
285
  return (
130
286
  <CheckoutBlock
131
287
  presentation={parsed.presentation ?? 'stepper'}
132
288
  showReviewStep={parsed.showReviewStep}
289
+ requireContactPhone={parsed.requireContactPhone ?? false}
290
+ requireShippingPhone={parsed.requireShippingPhone ?? false}
133
291
  labels={{
134
292
  ...parsed.labels,
135
293
  ...(parsed.title ? { title: parsed.title } : {}),
@@ -137,30 +295,139 @@ export const registry: ViewRegistry = {
137
295
  ...(cartError ? { totalsErrorLabel: cartError } : {}),
138
296
  submitErrorActionLabel: unresolved ? 'Reconciliar' : 'Reintentar',
139
297
  }}
140
- orderSummary={parsed.orderSummary}
141
- totalsState={state.cartPending ? 'pending' : cartError ? 'error' : 'idle'}
142
- onRetryTotals={() => emit('syncCheckoutAddress')}
143
- countries={parsed.countries}
144
- shippingOptions={parsed.shippingOptions}
145
- selectedShippingOptionId={parsed.selectedShippingOptionId ?? undefined}
146
- onSelectShippingOption={(id) => {
147
- set('/checkoutSelectedShippingOptionId', id)
298
+ contact={parsed.contact}
299
+ onContactChange={(field, value) => {
300
+ set(`/checkoutContact/${field}`, value)
301
+ set(`/checkout/${field}`, value)
302
+ if (field === 'phone') {
303
+ set('/checkoutFieldErrors', clearPhoneFieldError(state.checkoutFieldErrors, 'contact'))
304
+ }
305
+ }}
306
+ shippingAddress={parsed.shippingAddress}
307
+ onShippingAddressChange={updateShipping}
308
+ billingAddress={parsed.billingAddress}
309
+ sameAsShipping={parsed.sameAsShipping}
310
+ onSameAsShippingChange={(same) => set('/checkoutSameAsShipping', same)}
311
+ validateStep={(step) => {
312
+ if (step === 'contact') {
313
+ const errors = validateCheckoutContactPhone(
314
+ parsed.contact,
315
+ parsed.requireContactPhone ?? false,
316
+ )
317
+ set('/checkoutFieldErrors', { contact: errors })
318
+ return Object.keys(errors).length === 0
319
+ }
320
+ if (step !== 'shipping') return true
321
+ const errors = validateCheckoutShippingAddress(
322
+ parsed.shippingAddress,
323
+ parsed.requireShippingPhone ?? false,
324
+ )
325
+ set('/checkoutFieldErrors', { shippingAddress: errors })
326
+ if (Object.keys(errors).length > 0) return false
327
+ // A failed grouped quote, or a provider that cannot serve grouped
328
+ // delivery at all, is reported explicitly and must not be bypassed by
329
+ // submitting as if the cart had no delivery (design D7).
330
+ const shippingState = state.checkoutShippingState
331
+ if (shippingState === 'error' || shippingState === 'unavailable') return false
332
+ // Every returned backend group needs a real option and one selected
333
+ // option. An EMPTY group list is not a shipping cart, so it stays
334
+ // allowed; the host never invents a group to fill the gap.
335
+ const groups = parsed.shippingGroups ?? []
336
+ return groups.every(
337
+ (group) => group.options.length > 0 && Boolean(group.selectedOptionId),
338
+ )
339
+ }}
340
+ onStepChange={(step) => {
341
+ if (step === 'payment') emit('syncCheckoutAddress')
342
+ }}
343
+ onBillingAddressChange={(field, value) =>
344
+ set(`/checkoutBillingAddress/${field}`, value)
345
+ }
346
+ customer={parsed.customer}
347
+ savedAddresses={parsed.savedAddresses}
348
+ onSelectSavedAddress={(id) => {
349
+ const saved = parsed.savedAddresses?.find((address) => address.id === id)
350
+ if (!saved) return
351
+ set('/checkoutShippingAddress', saved.address)
352
+ setFlatAddress(saved.address)
353
+ emit('syncCheckoutAddress')
354
+ }}
355
+ onCreateSavedAddress={
356
+ managementEnabled ? () => emit('createSavedAddress') : undefined
357
+ }
358
+ onUpdateSavedAddress={
359
+ managementEnabled
360
+ ? (id) => {
361
+ set('/checkoutSavedAddressTargetId', id)
362
+ emit('updateSavedAddress')
363
+ }
364
+ : undefined
365
+ }
366
+ onDeleteSavedAddress={
367
+ managementEnabled
368
+ ? (id) => {
369
+ set('/checkoutSavedAddressTargetId', id)
370
+ emit('deleteSavedAddress')
371
+ }
372
+ : undefined
373
+ }
374
+ onStartNewAddress={managementEnabled ? () => emit('startNewAddress') : undefined}
375
+ onCancelNewAddress={managementEnabled ? () => emit('cancelNewAddress') : undefined}
376
+ savedAddressState={parsed.savedAddressState}
377
+ shippingLocations={parsed.shippingLocations}
378
+ billingLocations={parsed.billingLocations}
379
+ onRetryLocations={(kind, level) => {
380
+ set('/checkoutLocationRequest', { kind, level })
381
+ emit('loadCheckoutLocations')
382
+ }}
383
+ shippingGroups={parsed.shippingGroups}
384
+ shippingState={parsed.shippingState}
385
+ onRetryShipping={() => emit('syncCheckoutAddress')}
386
+ onSelectShippingOption={(groupId, optionId) => {
387
+ const groups = parsed.shippingGroups ?? []
388
+ set(
389
+ '/checkoutShippingGroups',
390
+ groups.map((group) =>
391
+ group.id === groupId ? { ...group, selectedOptionId: optionId } : group,
392
+ ),
393
+ )
394
+ set('/checkoutSelectedShippingOptionId', optionId)
148
395
  emit('selectShippingMethod')
149
396
  }}
150
397
  paymentMethods={parsed.paymentMethods}
151
- values={parsed.values}
398
+ paymentState={parsed.paymentState}
399
+ paymentMethod={parsed.paymentMethod}
400
+ onSelectPaymentMethod={(id) => {
401
+ set('/checkout/paymentMethod', id)
402
+ set('/checkoutSelectedPaymentMethod', id)
403
+ }}
404
+ adjustmentPayments={parsed.adjustmentPayments}
405
+ orderSummary={parsed.orderSummary}
406
+ totalsState={state.cartPending ? 'pending' : cartError ? 'error' : 'idle'}
407
+ onRetryTotals={() => emit('syncCheckoutAddress')}
408
+ promoCode={(state.checkout as Record<string, unknown> | undefined)?.promoCode as string | undefined}
409
+ onPromoCodeChange={(value) => set('/checkout/promoCode', value)}
152
410
  fieldErrors={parsed.fieldErrors}
153
411
  fieldDescriptions={parsed.fieldDescriptions}
154
- onChange={(field, value) => {
155
- set(`/checkout/${field}`, value)
156
- if (ADDRESS_FIELDS.has(field)) emit('syncCheckoutAddress')
412
+ availability={parsed.availability}
413
+ interruption={parsed.interruption}
414
+ onInterruptionAction={() => set('/checkoutInterruption', null)}
415
+ onSubmit={(snapshot) => {
416
+ set('/checkoutSubmission', snapshot)
417
+ emit('placeOrder')
157
418
  }}
158
- onSubmit={() => emit('placeOrder')}
159
419
  submitting={Boolean(state.checkoutPending)}
160
420
  submitError={checkoutError}
161
- // An ambiguous completion offers RECONCILE only; a definite failure
162
- // (cart-with-error or pre-completion error) offers a controlled retry.
163
- onRetrySubmit={unresolved ? () => emit('reconcileOrder') : () => emit('placeOrder')}
421
+ // An ambiguous completion offers RECONCILE only; a delivery failure
422
+ // refreshes the quote; a definite order failure (cart-with-error or
423
+ // pre-completion error) offers a controlled retry.
424
+ onRetrySubmit={
425
+ unresolved
426
+ ? () => emit('reconcileOrder')
427
+ : shippingFailed
428
+ ? () => emit('syncCheckoutAddress')
429
+ : () => emit('placeOrder')
430
+ }
164
431
  />
165
432
  )
166
433
  },