@thorprovider/storefront 0.6.3 → 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 (29) 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/file-classes.mjs +1 -0
  22. package/skills/sf-view-gen/SKILL.md +6 -0
  23. package/skills/sf-view-gen/assets/recipes/recipes.json +2 -1
  24. package/skills/sf-view-gen/assets/recipes/sections.json +9 -0
  25. package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.client.tsx +19 -0
  26. package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.tsx +16 -0
  27. package/skills/sf-view-gen/assets/templates/views/sections/schema.marketplace-product-card.ts +67 -0
  28. package/skills/storefront-workflow/SKILL.md +5 -0
  29. package/skills/storefront-workflow/references/mobile-responsiveness.md +1 -1
@@ -9,25 +9,50 @@ import { useEffect } from 'react'
9
9
  import { useActions, useStateStore } from '@json-render/react'
10
10
  import { useNextApp } from '@json-render/next'
11
11
  import {
12
+ applyCheckoutShippingGroupsAction,
13
+ createCheckoutAddressAction,
14
+ deleteCheckoutAddressAction,
15
+ loadCheckoutLocationsAction,
12
16
  placeOrderAction,
13
17
  reconcileReceiptAction,
14
- selectShippingMethodAction,
15
- syncCheckoutAddressAction,
18
+ syncCheckoutAddressStructuredAction,
19
+ updateCheckoutAddressAction,
16
20
  } from '../../actions'
21
+ import type {
22
+ CheckoutAddressValues,
23
+ CheckoutContactValues,
24
+ CheckoutLocationOptions,
25
+ CheckoutShippingGroup,
26
+ } from '@thorprovider/blocks'
17
27
  import type { CartStatePatch, PlaceOrderResult } from '../../commerce'
28
+ import { toShippingSelections } from '../../checkout-shipping.core'
18
29
  import { recordConfirmedTransition } from '../../section-observation'
19
30
 
20
- // The always-required core of an address. Optional fields (province, phone,
21
- // postal code) are left to the runtime validator so the host does not impose a
22
- // stricter contract than the backend; the validator returns structured errors.
23
- const REQUIRED_ADDRESS_FIELDS = ['email', 'firstName', 'lastName', 'city', 'country'] as const
24
-
25
- function addressComplete(values: Record<string, unknown>): boolean {
26
- return REQUIRED_ADDRESS_FIELDS.every(
27
- (field) => typeof values[field] === 'string' && (values[field] as string).trim() !== '',
28
- )
31
+ const emptyAddress: CheckoutAddressValues = {
32
+ firstName: '',
33
+ lastName: '',
34
+ address1: '',
35
+ address2: '',
36
+ company: '',
37
+ city: '',
38
+ province: '',
39
+ postalCode: '',
40
+ countryCode: '',
41
+ phone: '',
29
42
  }
30
43
 
44
+ /** The user-facing message when a delivery group is still incomplete. */
45
+ const incompleteShippingMessage =
46
+ 'Selecciona una opción de envío para cada grupo antes de pagar.'
47
+
48
+ /**
49
+ * The user-facing message when the order is submitted after the delivery quote
50
+ * failed (or was never loaded), so `placeOrder` must not treat the cart as a
51
+ * shipment-free cart.
52
+ */
53
+ const staleShippingMessage =
54
+ 'No pudimos cargar las opciones de envío. Reintenta el envío antes de pagar.'
55
+
31
56
  export function useCheckoutHandlers() {
32
57
  const { get, set } = useStateStore()
33
58
  const { navigate } = useNextApp()
@@ -66,6 +91,10 @@ export function useCheckoutHandlers() {
66
91
  set('/cartQuantity', 0)
67
92
  set('/cartCompleted', true)
68
93
  set('/checkoutSelectedShippingOptionId', null)
94
+ // The completed cart's delivery groups are gone with it.
95
+ set('/checkoutShippingGroups', [])
96
+ set('/checkoutShippingGroupProducts', {})
97
+ set('/checkoutShippingState', 'idle')
69
98
  return
70
99
  }
71
100
  // error | cart-error | unresolved. `orderStatus` only carries the UI
@@ -95,6 +124,52 @@ export function useCheckoutHandlers() {
95
124
  set('/checkoutErrorKind', 'error')
96
125
  }
97
126
 
127
+ // A grouped-delivery failure belongs to `/checkoutShippingState` only: the
128
+ // delivery block renders its own error/unavailable copy and retry, and the
129
+ // generic submit-error node must never offer `placeOrder` for it (R1).
130
+ const onShippingError = (scope: string) => (error: unknown) => {
131
+ console.error(
132
+ `[storefront/checkout] ${scope} failed`,
133
+ error instanceof Error ? error.message : error,
134
+ )
135
+ set('/checkoutPending', false)
136
+ set('/checkoutShippingState', 'error')
137
+ }
138
+
139
+ const setFlatAddress = (address: CheckoutAddressValues) => {
140
+ set('/checkout/address', address.address1)
141
+ set('/checkout/firstName', address.firstName)
142
+ set('/checkout/lastName', address.lastName)
143
+ set('/checkout/city', address.city)
144
+ set('/checkout/state', address.province ?? '')
145
+ set('/checkout/zipCode', address.postalCode ?? '')
146
+ set('/checkout/country', address.countryCode)
147
+ set('/checkout/phone', address.phone ?? '')
148
+ }
149
+
150
+ const addressMutationFailure =
151
+ (scope: string, id?: string) => (error: unknown) => {
152
+ console.error(
153
+ `[storefront/checkout] ${scope} failed`,
154
+ error instanceof Error ? error.message : error,
155
+ )
156
+ set(
157
+ '/checkoutSavedAddressState',
158
+ id
159
+ ? {
160
+ error: {
161
+ id,
162
+ message: 'No se pudo completar la operación. Inténtalo de nuevo.',
163
+ },
164
+ }
165
+ : {
166
+ error: {
167
+ message: 'No se pudo completar la operación. Inténtalo de nuevo.',
168
+ },
169
+ },
170
+ )
171
+ }
172
+
98
173
  const handlers: Record<string, () => void> = {
99
174
  goToCheckout: () => {
100
175
  // A confirmed checkout transition (the shopper started checkout).
@@ -104,10 +179,44 @@ export function useCheckoutHandlers() {
104
179
  },
105
180
  continueShopping: () => navigate('/'),
106
181
  placeOrder: () => {
182
+ // The block's `validateStep` is the primary guard; this is the safety
183
+ // net that keeps an incomplete grouped delivery from ever reaching
184
+ // payment (design D6). A cart with no returned group keeps the plain
185
+ // path so a non-shipping checkout still submits.
186
+ const groups = (get('/checkoutShippingGroups') ?? []) as CheckoutShippingGroup[]
187
+ const shippingState = get('/checkoutShippingState')
188
+ if (
189
+ groups.length === 0 &&
190
+ (shippingState === 'error' || shippingState === 'unavailable')
191
+ ) {
192
+ // The quote failed (or the provider cannot serve grouped delivery):
193
+ // with no groups to submit there is nothing honest to apply, so never
194
+ // fall through to `placeOrderAction` and never reuse a previously
195
+ // applied shipping method (R1).
196
+ set('/checkoutPending', false)
197
+ set('/checkoutError', staleShippingMessage)
198
+ set('/checkoutErrorKind', 'error')
199
+ return
200
+ }
201
+ const productsByGroup = (get('/checkoutShippingGroupProducts') ?? {}) as Record<
202
+ string,
203
+ string[]
204
+ >
205
+ const selections = toShippingSelections(groups, productsByGroup)
206
+ if (groups.length > 0 && !selections) {
207
+ set('/checkoutPending', false)
208
+ set('/checkoutError', incompleteShippingMessage)
209
+ set('/checkoutErrorKind', 'error')
210
+ return
211
+ }
107
212
  set('/checkoutPending', true)
108
213
  set('/checkoutError', null)
214
+ set('/checkoutErrorKind', null)
109
215
  set('/cartNotice', null)
110
- void placeOrderAction().then(applyResult).catch(onError('placeOrder'))
216
+ const request = selections
217
+ ? placeOrderAction({ shippingGroups: selections })
218
+ : placeOrderAction()
219
+ void request.then(applyResult).catch(onError('placeOrder'))
111
220
  },
112
221
  reconcileOrder: () => {
113
222
  set('/checkoutPending', true)
@@ -115,39 +224,225 @@ export function useCheckoutHandlers() {
115
224
  void reconcileReceiptAction().then(applyResult).catch(onError('reconcileOrder'))
116
225
  },
117
226
  syncCheckoutAddress: () => {
118
- const values = (get('/checkout') ?? {}) as Record<string, unknown>
119
- if (!addressComplete(values)) return
227
+ const contact = (get('/checkoutContact') ?? {}) as CheckoutContactValues
228
+ const shippingAddress = (get('/checkoutShippingAddress') ?? {}) as CheckoutAddressValues
229
+ const billingAddress = (get('/checkoutBillingAddress') ?? undefined) as
230
+ | CheckoutAddressValues
231
+ | undefined
232
+ const sameAsShipping = get('/checkoutSameAsShipping') !== false
233
+ if (!contact.email || !shippingAddress.countryCode) return
120
234
  set('/checkoutPending', true)
121
- void syncCheckoutAddressAction(values)
235
+ set('/checkoutShippingState', 'pending')
236
+ void syncCheckoutAddressStructuredAction({
237
+ contact,
238
+ shippingAddress,
239
+ billingAddress,
240
+ sameAsShipping,
241
+ // Reconcile the shopper's per-group choices by stable group identity.
242
+ previousShippingGroups: (get('/checkoutShippingGroups') ?? []) as CheckoutShippingGroup[],
243
+ })
122
244
  .then((result) => {
123
245
  set('/checkoutPending', false)
124
- if (result.ok) {
125
- applyCart(result.cart)
126
- if (result.shippingOptions) set('/checkoutShippingOptions', result.shippingOptions)
127
- set('/checkoutFieldErrors', result.fieldErrors ?? {})
128
- set('/checkoutError', null)
129
- } else {
246
+ if (!result.ok) {
247
+ // An address rejection is not a delivery failure: keep the field
248
+ // errors and leave the delivery state reachable again.
249
+ set('/checkoutShippingState', 'idle')
130
250
  set('/checkoutError', result.error)
251
+ set('/checkoutErrorKind', 'error')
252
+ set('/checkoutFieldErrors', result.fieldErrors ?? {})
253
+ return
254
+ }
255
+ applyCart(result.cart)
256
+ // The backend groups are authoritative: mapped 1:1, never wrapped.
257
+ set('/checkoutShippingGroups', result.shippingGroups ?? [])
258
+ set('/checkoutShippingGroupProducts', result.shippingGroupProducts ?? {})
259
+ set('/checkoutFieldErrors', result.fieldErrors ?? {})
260
+ if (result.shippingError) {
261
+ // The cart survives a quote failure; delivery is reported ONLY in
262
+ // the delivery state (design D7 / R1): the block renders the
263
+ // error/unavailable copy and its own retry, and the generic
264
+ // submit-error node must not offer `placeOrder` for it.
265
+ // `unavailable` marks a provider that cannot serve grouped
266
+ // delivery, so no retry is promised.
267
+ set('/checkoutShippingState', result.shippingState ?? 'error')
268
+ return
269
+ }
270
+ set('/checkoutShippingState', 'idle')
271
+ set('/checkoutError', null)
272
+ set('/checkoutErrorKind', null)
273
+ })
274
+ .catch(onShippingError('syncCheckoutAddress'))
275
+ },
276
+ createSavedAddress: () => {
277
+ const address = (get('/checkoutShippingAddress') ?? emptyAddress) as CheckoutAddressValues
278
+ set('/checkoutSavedAddressState', { pendingId: 'create' })
279
+ void createCheckoutAddressAction(address)
280
+ .then((result) => {
281
+ if (!result.ok) {
282
+ set('/checkoutSavedAddressState', {
283
+ error: { message: result.error },
284
+ })
285
+ set('/checkoutFieldErrors', result.fieldErrors ?? {})
286
+ return
287
+ }
288
+ set('/checkoutSavedAddresses', result.savedAddresses)
289
+ set('/checkoutSavedAddressState', {
290
+ lastSavedId: result.savedAddressId ?? 'create',
291
+ lastAction: 'saved',
292
+ })
293
+ set('/checkoutFieldErrors', {})
294
+ })
295
+ .catch(addressMutationFailure('createSavedAddress'))
296
+ },
297
+ updateSavedAddress: () => {
298
+ const id = get('/checkoutSavedAddressTargetId') as string | null
299
+ if (!id) return
300
+ const address = (get('/checkoutShippingAddress') ?? emptyAddress) as CheckoutAddressValues
301
+ set('/checkoutSavedAddressState', { pendingId: id })
302
+ void updateCheckoutAddressAction({ id, address })
303
+ .then((result) => {
304
+ if (!result.ok) {
305
+ set('/checkoutSavedAddressState', {
306
+ error: { id, message: result.error },
307
+ })
131
308
  set('/checkoutFieldErrors', result.fieldErrors ?? {})
309
+ return
132
310
  }
311
+ set('/checkoutSavedAddresses', result.savedAddresses)
312
+ set('/checkoutSavedAddressState', {
313
+ lastSavedId: result.savedAddressId ?? id,
314
+ lastAction: 'saved',
315
+ })
316
+ set('/checkoutFieldErrors', {})
133
317
  })
134
- .catch(onError('syncCheckoutAddress'))
318
+ .catch(addressMutationFailure('updateSavedAddress', id))
319
+ },
320
+ deleteSavedAddress: () => {
321
+ const id = get('/checkoutSavedAddressTargetId') as string | null
322
+ if (!id) return
323
+ set('/checkoutSavedAddressState', { pendingId: id })
324
+ void deleteCheckoutAddressAction({ id })
325
+ .then((result) => {
326
+ if (!result.ok) {
327
+ set('/checkoutSavedAddressState', {
328
+ error: { id, message: result.error },
329
+ })
330
+ return
331
+ }
332
+ set('/checkoutSavedAddresses', result.savedAddresses)
333
+ set('/checkoutSavedAddressState', {
334
+ lastSavedId: id,
335
+ lastAction: 'deleted',
336
+ })
337
+ set('/checkoutFieldErrors', {})
338
+ })
339
+ .catch(addressMutationFailure('deleteSavedAddress', id))
340
+ },
341
+ startNewAddress: () => {
342
+ const current = (get('/checkoutShippingAddress') ?? emptyAddress) as CheckoutAddressValues
343
+ set('/checkoutAddressBeforeNew', current)
344
+ set('/checkoutShippingAddress', emptyAddress)
345
+ setFlatAddress(emptyAddress)
346
+ set('/checkoutSavedAddressState', undefined)
347
+ set('/checkoutFieldErrors', {})
348
+ },
349
+ cancelNewAddress: () => {
350
+ const previous = get('/checkoutAddressBeforeNew') as CheckoutAddressValues | null
351
+ if (previous) {
352
+ set('/checkoutShippingAddress', previous)
353
+ setFlatAddress(previous)
354
+ }
355
+ set('/checkoutAddressBeforeNew', null)
356
+ set('/checkoutSavedAddressState', undefined)
357
+ set('/checkoutFieldErrors', {})
358
+ },
359
+ loadCheckoutLocations: () => {
360
+ const request = get('/checkoutLocationRequest') as {
361
+ kind: 'shipping' | 'billing'
362
+ level: 'provinces' | 'cities'
363
+ } | null
364
+ if (!request) return
365
+ const shippingAddress = (get('/checkoutShippingAddress') ?? {}) as CheckoutAddressValues
366
+ const path =
367
+ request.kind === 'shipping'
368
+ ? '/checkoutShippingLocations'
369
+ : '/checkoutBillingLocations'
370
+ const current = (get(path) ?? {
371
+ countries: [],
372
+ provinces: [],
373
+ cities: [],
374
+ }) as CheckoutLocationOptions
375
+ set(path, {
376
+ ...current,
377
+ ...(request.level === 'provinces'
378
+ ? { provincesState: 'pending', cities: [], citiesState: 'idle' }
379
+ : { citiesState: 'pending' }),
380
+ })
381
+ void loadCheckoutLocationsAction({
382
+ kind: request.kind,
383
+ level: request.level,
384
+ countryCode: shippingAddress.countryCode,
385
+ provinceCode: shippingAddress.province ?? '',
386
+ })
387
+ .then((result) => {
388
+ if (!result.ok) {
389
+ set(path, {
390
+ ...current,
391
+ ...(request.level === 'provinces'
392
+ ? { provincesState: 'error', provincesError: result.error }
393
+ : { citiesState: 'error', citiesError: result.error }),
394
+ })
395
+ return
396
+ }
397
+ set(path, {
398
+ ...current,
399
+ ...(request.level === 'provinces'
400
+ ? {
401
+ provinces: result.options,
402
+ provincesState: 'idle',
403
+ provincesError: undefined,
404
+ cities: [],
405
+ citiesState: 'idle',
406
+ }
407
+ : { cities: result.options, citiesState: 'idle', citiesError: undefined }),
408
+ })
409
+ })
410
+ .catch(onError('loadCheckoutLocations'))
135
411
  },
136
412
  selectShippingMethod: () => {
137
- const methodId = get('/checkoutSelectedShippingOptionId') as string | null
138
- if (!methodId) return
413
+ // One apply at a time: a second click while the groups are being applied
414
+ // (or the quote is reloading) is ignored instead of racing the backend.
415
+ if (get('/checkoutShippingState') === 'pending') return
416
+ // The view already wrote the chosen option into its group, so the group
417
+ // list is the single source of the per-group selection.
418
+ const groups = (get('/checkoutShippingGroups') ?? []) as CheckoutShippingGroup[]
419
+ const productsByGroup = (get('/checkoutShippingGroupProducts') ?? {}) as Record<
420
+ string,
421
+ string[]
422
+ >
423
+ const selections = toShippingSelections(groups, productsByGroup)
424
+ // Every group must be complete before anything is applied; a partial
425
+ // set is never sent to the backend.
426
+ if (!selections) return
139
427
  set('/checkoutPending', true)
140
- void selectShippingMethodAction({ methodId })
428
+ set('/checkoutShippingState', 'pending')
429
+ void applyCheckoutShippingGroupsAction({ shippingGroups: selections })
141
430
  .then((result) => {
142
431
  set('/checkoutPending', false)
143
- if (result.ok) {
144
- applyCart(result.cart)
145
- set('/checkoutError', null)
146
- } else {
147
- set('/checkoutError', result.error)
432
+ if (!result.ok) {
433
+ // Recoverable, and reported ONLY in the delivery state (R1): the
434
+ // delivery block owns the retry, which refreshes the quote and
435
+ // reconciles the selections by group identity (design D7). An
436
+ // unsupported provider reports `unavailable` instead of a retry.
437
+ set('/checkoutShippingState', result.shippingState ?? 'error')
438
+ return
148
439
  }
440
+ applyCart(result.cart)
441
+ set('/checkoutShippingState', 'idle')
442
+ set('/checkoutError', null)
443
+ set('/checkoutErrorKind', null)
149
444
  })
150
- .catch(onError('selectShippingMethod'))
445
+ .catch(onShippingError('selectShippingMethod'))
151
446
  },
152
447
  }
153
448
 
@@ -5,10 +5,22 @@
5
5
  import type {
6
6
  CheckoutFieldErrors,
7
7
  CheckoutFormData,
8
- CheckoutShippingOption,
9
8
  OrderStatus,
10
9
  StorefrontReceipt,
11
10
  } from '../../state.core'
11
+ import type {
12
+ CheckoutAddressValues,
13
+ CheckoutAdjustmentPayment,
14
+ CheckoutAvailability,
15
+ CheckoutContactValues,
16
+ CheckoutCustomerIdentity,
17
+ CheckoutInterruption,
18
+ CheckoutLocationOptions,
19
+ CheckoutReadState,
20
+ CheckoutSavedAddress,
21
+ CheckoutSavedAddressState,
22
+ CheckoutShippingGroup,
23
+ } from '@thorprovider/blocks'
12
24
  import type { PaymentMethod } from '@thorprovider/types'
13
25
 
14
26
  const checkoutFormDefaults: CheckoutFormData = {
@@ -27,13 +39,59 @@ const checkoutFormDefaults: CheckoutFormData = {
27
39
  promoCode: '',
28
40
  }
29
41
 
42
+ const emptyContact: CheckoutContactValues = {
43
+ email: '',
44
+ firstName: '',
45
+ lastName: '',
46
+ phone: '',
47
+ }
48
+
49
+ const emptyAddress: CheckoutAddressValues = {
50
+ firstName: '',
51
+ lastName: '',
52
+ address1: '',
53
+ city: '',
54
+ province: '',
55
+ postalCode: '',
56
+ countryCode: '',
57
+ phone: '',
58
+ }
59
+
60
+ const emptyLocations: CheckoutLocationOptions = {
61
+ countries: [],
62
+ provinces: [],
63
+ cities: [],
64
+ }
65
+
30
66
  export interface CheckoutState {
31
67
  checkout: CheckoutFormData
32
68
  checkoutCountries: { value: string; label: string }[]
33
69
  checkoutPaymentMethods: PaymentMethod[]
34
- checkoutShippingOptions: CheckoutShippingOption[]
35
70
  checkoutSelectedShippingOptionId: string | null
36
71
  checkoutFieldErrors: CheckoutFieldErrors
72
+ checkoutContact: CheckoutContactValues
73
+ checkoutShippingAddress: CheckoutAddressValues
74
+ checkoutBillingAddress: CheckoutAddressValues
75
+ checkoutSameAsShipping: boolean
76
+ checkoutCustomer: CheckoutCustomerIdentity | null
77
+ checkoutSavedAddresses: CheckoutSavedAddress[]
78
+ checkoutSavedAddressState: CheckoutSavedAddressState | undefined
79
+ checkoutSavedAddressTargetId: string | null
80
+ checkoutAddressBeforeNew: CheckoutAddressValues | null
81
+ checkoutShippingLocations: CheckoutLocationOptions
82
+ checkoutBillingLocations: CheckoutLocationOptions
83
+ checkoutShippingGroups: CheckoutShippingGroup[]
84
+ /** Presentation group id -> the backend `products` for that group's apply. */
85
+ checkoutShippingGroupProducts: Record<string, string[]>
86
+ checkoutShippingState: CheckoutReadState
87
+ checkoutPaymentState: CheckoutReadState
88
+ checkoutInterruption: CheckoutInterruption | undefined
89
+ checkoutAvailability: CheckoutAvailability | undefined
90
+ checkoutAdjustments: CheckoutAdjustmentPayment[]
91
+ checkoutLocationRequest: {
92
+ kind: 'shipping' | 'billing'
93
+ level: 'countries' | 'provinces' | 'cities'
94
+ } | null
37
95
  checkoutPending: boolean
38
96
  checkoutError: string | null
39
97
  checkoutErrorKind: 'error' | 'cart-error' | 'unresolved' | null
@@ -45,9 +103,27 @@ export const checkoutState: CheckoutState = {
45
103
  checkout: checkoutFormDefaults,
46
104
  checkoutCountries: [],
47
105
  checkoutPaymentMethods: [],
48
- checkoutShippingOptions: [],
49
106
  checkoutSelectedShippingOptionId: null,
50
107
  checkoutFieldErrors: {},
108
+ checkoutContact: emptyContact,
109
+ checkoutShippingAddress: emptyAddress,
110
+ checkoutBillingAddress: emptyAddress,
111
+ checkoutSameAsShipping: true,
112
+ checkoutCustomer: null,
113
+ checkoutSavedAddresses: [],
114
+ checkoutSavedAddressState: undefined,
115
+ checkoutSavedAddressTargetId: null,
116
+ checkoutAddressBeforeNew: null,
117
+ checkoutShippingLocations: emptyLocations,
118
+ checkoutBillingLocations: emptyLocations,
119
+ checkoutShippingGroups: [],
120
+ checkoutShippingGroupProducts: {},
121
+ checkoutShippingState: 'idle',
122
+ checkoutPaymentState: 'idle',
123
+ checkoutInterruption: undefined,
124
+ checkoutAvailability: undefined,
125
+ checkoutAdjustments: [],
126
+ checkoutLocationRequest: null,
51
127
  checkoutPending: false,
52
128
  checkoutError: null,
53
129
  checkoutErrorKind: null,
@@ -30,8 +30,9 @@ export const checkoutContent = {
30
30
  emailLabel: 'Email',
31
31
  firstNameLabel: 'Nombre',
32
32
  lastNameLabel: 'Apellidos',
33
- phoneLabel: 'Teléfono (opcional)',
34
- addressLabel: 'Dirección',
33
+ phoneLabel: 'Teléfono',
34
+ optionalIndicatorLabel: 'opcional',
35
+ addressLabel: 'Línea 1 de dirección',
35
36
  cityLabel: 'Ciudad',
36
37
  stateLabel: 'Estado / Provincia',
37
38
  zipCodeLabel: 'Código postal',
@@ -68,6 +69,66 @@ export const checkoutContent = {
68
69
  completeOrderLabel: 'Completar pedido',
69
70
  processingLabel: 'Procesando pedido…',
70
71
  submitErrorActionLabel: 'Reintentar',
72
+ billingHeading: 'Dirección de facturación',
73
+ billingDescription: 'Indica la dirección de la factura.',
74
+ billingSameAsShippingLabel: 'La facturación es la misma que el envío',
75
+ address2Label: 'Línea 2 de dirección (opcional)',
76
+ companyLabel: 'Empresa (opcional)',
77
+ provincePlaceholder: 'Selecciona una provincia o estado',
78
+ cityPlaceholder: 'Selecciona una ciudad',
79
+ signedInAsLabel: 'Sesión iniciada como',
80
+ signOutLabel: 'Cerrar sesión',
81
+ signInLabel: 'Iniciar sesión',
82
+ savedAddressesLabel: 'Direcciones guardadas',
83
+ defaultAddressLabel: 'Predeterminada',
84
+ recipientHeading: 'Destinatario',
85
+ recipientDescription: '¿Quién recibirá este pedido? Puede ser otra persona.',
86
+ addressHeading: 'Dirección',
87
+ addAddressLabel: 'Añadir dirección',
88
+ useAddressLabel: 'Usar',
89
+ deleteAddressLabel: 'Eliminar',
90
+ deleteAddressConfirmLabel: '¿Eliminar esta dirección guardada?',
91
+ deleteAddressHintLabel: 'El pedido se enviará igualmente a la dirección actual.',
92
+ cancelAddressLabel: 'Cancelar',
93
+ updateSavedAddressLabel: 'Actualizar dirección guardada',
94
+ saveAsNewAddressLabel: 'Guardar como dirección nueva',
95
+ saveAddressLabel: 'Guardar en mis direcciones',
96
+ newAddressLabel: 'Nueva dirección',
97
+ savingAddressLabel: 'Guardando dirección…',
98
+ deletingAddressLabel: 'Eliminando…',
99
+ addressSaveErrorLabel: 'No pudimos guardar esta dirección.',
100
+ addressDeleteErrorLabel: 'No pudimos eliminar esta dirección.',
101
+ addressSavedLabel: 'Dirección guardada.',
102
+ addressDeletedLabel: 'Dirección eliminada.',
103
+ locationLoadingLabel: 'Cargando opciones…',
104
+ locationErrorLabel: 'No pudimos cargar estas opciones.',
105
+ locationUnavailableLabel: 'No hay opciones disponibles.',
106
+ locationOptionalLabel: 'Opcional para esta dirección.',
107
+ noShippingOptionsLabel: 'No hay opciones de entrega para esta dirección.',
108
+ groupUnavailableLabel: 'No disponible para esta dirección.',
109
+ deliveryLoadingLabel: 'Cargando opciones de entrega…',
110
+ deliveryErrorLabel: 'No pudimos cargar las opciones de entrega.',
111
+ deliveryUnavailableLabel: 'La entrega no está disponible para esta dirección.',
112
+ paymentLoadingLabel: 'Cargando métodos de pago…',
113
+ paymentErrorLabel: 'No pudimos cargar los métodos de pago.',
114
+ paymentUnavailableLabel: 'El pago no está disponible para esta región.',
115
+ giftCardLabel: 'Tarjeta de regalo',
116
+ giftCardPlaceholder: 'Ingresa el código de la tarjeta',
117
+ applyLabel: 'Aplicar',
118
+ removeLabel: 'Quitar',
119
+ storeCreditLabel: 'Saldo a favor',
120
+ availableCreditLabel: 'Saldo disponible',
121
+ reviewBillingLabel: 'Facturación',
122
+ reviewAdjustmentsLabel: 'Ajustes',
123
+ reviewSameAsShippingLabel: 'Igual que el envío',
124
+ reviewLinesLabel: 'Productos',
125
+ interruptionAcknowledgeLabel: 'Entendido',
126
+ interruptionRefreshLabel: 'Actualizar',
127
+ interruptionReturnToCartLabel: 'Volver al carrito',
128
+ interruptionRetryLabel: 'Reintentar',
129
+ availabilityEmptyLabel: 'Tu carrito está vacío.',
130
+ availabilityUnavailableLabel: 'El checkout no está disponible.',
131
+ availabilityErrorLabel: 'No pudimos cargar el checkout.',
71
132
  },
72
133
  validation: {
73
134
  email: {
@@ -62,6 +62,12 @@ const elements: Record<string, StorefrontElement> = {
62
62
  placeOrder: { action: 'placeOrder' },
63
63
  reconcileOrder: { action: 'reconcileOrder' },
64
64
  syncCheckoutAddress: { action: 'syncCheckoutAddress' },
65
+ loadCheckoutLocations: { action: 'loadCheckoutLocations' },
66
+ createSavedAddress: { action: 'createSavedAddress' },
67
+ updateSavedAddress: { action: 'updateSavedAddress' },
68
+ deleteSavedAddress: { action: 'deleteSavedAddress' },
69
+ startNewAddress: { action: 'startNewAddress' },
70
+ cancelNewAddress: { action: 'cancelNewAddress' },
65
71
  selectShippingMethod: { action: 'selectShippingMethod' },
66
72
  },
67
73
  },