@thorprovider/storefront 0.6.3 → 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 +1234 -75
- package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
- package/assets/templates/app/lib/__STOREFRONT__/checkout-shipping.core.ts +37 -0
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +460 -35
- 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 +28 -1
- 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 +5 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/marketplace-product-card.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/marketplace-product-card.tsx +16 -0
- 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.marketplace-product-card.ts +67 -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 +348 -33
- package/assets/templates/features/checkout/state.ts +79 -3
- 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 +114 -2
- package/assets/templates/views/checkout/index.tsx +7 -1
- package/assets/templates/views/checkout/props.ts +70 -22
- package/assets/templates/views/checkout/registry.tsx +400 -71
- package/assets/templates/views/checkout/schema.ts +260 -9
- package/assets/templates/views/home/assembly/assembly.json +28 -0
- 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 +14 -2
- package/recipes/recipes.json +35 -5
- package/recipes/section.schema.json +112 -0
- package/recipes/sections.json +289 -3
- 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 +15 -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 +79 -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 +35 -5
- package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
- package/skills/sf-view-gen/assets/recipes/sections.json +289 -3
- 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/marketplace-product-card.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/marketplace-product-card.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.marketplace-product-card.ts +67 -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
- package/skills/storefront-workflow/SKILL.md +5 -0
- 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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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()
|
|
@@ -53,8 +78,14 @@ export function useCheckoutHandlers() {
|
|
|
53
78
|
// A confirmed, persisted order — observed only on a genuine order result
|
|
54
79
|
// (not captured funds) and only when a section origin exists.
|
|
55
80
|
recordConfirmedTransition('order_confirmed')
|
|
56
|
-
// ONE atomic write carries the order
|
|
57
|
-
|
|
81
|
+
// ONE atomic write carries the order, its backend lines and the
|
|
82
|
+
// host-confirmed confirmation model, so the designer confirmation
|
|
83
|
+
// survives a reload without browser-only state.
|
|
84
|
+
set('/lastReceipt', {
|
|
85
|
+
order: result.order,
|
|
86
|
+
lines: result.lines,
|
|
87
|
+
confirmation: result.confirmation,
|
|
88
|
+
})
|
|
58
89
|
set('/orderStatus', 'complete')
|
|
59
90
|
set('/checkoutError', null)
|
|
60
91
|
set('/checkoutErrorKind', null)
|
|
@@ -66,6 +97,14 @@ export function useCheckoutHandlers() {
|
|
|
66
97
|
set('/cartQuantity', 0)
|
|
67
98
|
set('/cartCompleted', true)
|
|
68
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')
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
if (result.code === 'AUTH_REQUIRED') {
|
|
107
|
+
navigate('/account')
|
|
69
108
|
return
|
|
70
109
|
}
|
|
71
110
|
// error | cart-error | unresolved. `orderStatus` only carries the UI
|
|
@@ -95,6 +134,52 @@ export function useCheckoutHandlers() {
|
|
|
95
134
|
set('/checkoutErrorKind', 'error')
|
|
96
135
|
}
|
|
97
136
|
|
|
137
|
+
// A grouped-delivery failure belongs to `/checkoutShippingState` only: the
|
|
138
|
+
// delivery block renders its own error/unavailable copy and retry, and the
|
|
139
|
+
// generic submit-error node must never offer `placeOrder` for it (R1).
|
|
140
|
+
const onShippingError = (scope: string) => (error: unknown) => {
|
|
141
|
+
console.error(
|
|
142
|
+
`[storefront/checkout] ${scope} failed`,
|
|
143
|
+
error instanceof Error ? error.message : error,
|
|
144
|
+
)
|
|
145
|
+
set('/checkoutPending', false)
|
|
146
|
+
set('/checkoutShippingState', 'error')
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const setFlatAddress = (address: CheckoutAddressValues) => {
|
|
150
|
+
set('/checkout/address', address.address1)
|
|
151
|
+
set('/checkout/firstName', address.firstName)
|
|
152
|
+
set('/checkout/lastName', address.lastName)
|
|
153
|
+
set('/checkout/city', address.city)
|
|
154
|
+
set('/checkout/state', address.province ?? '')
|
|
155
|
+
set('/checkout/zipCode', address.postalCode ?? '')
|
|
156
|
+
set('/checkout/country', address.countryCode)
|
|
157
|
+
set('/checkout/phone', address.phone ?? '')
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const addressMutationFailure =
|
|
161
|
+
(scope: string, id?: string) => (error: unknown) => {
|
|
162
|
+
console.error(
|
|
163
|
+
`[storefront/checkout] ${scope} failed`,
|
|
164
|
+
error instanceof Error ? error.message : error,
|
|
165
|
+
)
|
|
166
|
+
set(
|
|
167
|
+
'/checkoutSavedAddressState',
|
|
168
|
+
id
|
|
169
|
+
? {
|
|
170
|
+
error: {
|
|
171
|
+
id,
|
|
172
|
+
message: 'No se pudo completar la operación. Inténtalo de nuevo.',
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
: {
|
|
176
|
+
error: {
|
|
177
|
+
message: 'No se pudo completar la operación. Inténtalo de nuevo.',
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
98
183
|
const handlers: Record<string, () => void> = {
|
|
99
184
|
goToCheckout: () => {
|
|
100
185
|
// A confirmed checkout transition (the shopper started checkout).
|
|
@@ -104,10 +189,54 @@ export function useCheckoutHandlers() {
|
|
|
104
189
|
},
|
|
105
190
|
continueShopping: () => navigate('/'),
|
|
106
191
|
placeOrder: () => {
|
|
192
|
+
// The block's `validateStep` is the primary guard; this is the safety
|
|
193
|
+
// net that keeps an incomplete grouped delivery from ever reaching
|
|
194
|
+
// payment (design D6). A cart with no returned group keeps the plain
|
|
195
|
+
// path so a non-shipping checkout still submits.
|
|
196
|
+
const groups = (get('/checkoutShippingGroups') ?? []) as CheckoutShippingGroup[]
|
|
197
|
+
const shippingState = get('/checkoutShippingState')
|
|
198
|
+
if (
|
|
199
|
+
groups.length === 0 &&
|
|
200
|
+
(shippingState === 'error' || shippingState === 'unavailable')
|
|
201
|
+
) {
|
|
202
|
+
// The quote failed (or the provider cannot serve grouped delivery):
|
|
203
|
+
// with no groups to submit there is nothing honest to apply, so never
|
|
204
|
+
// fall through to `placeOrderAction` and never reuse a previously
|
|
205
|
+
// applied shipping method (R1).
|
|
206
|
+
set('/checkoutPending', false)
|
|
207
|
+
set('/checkoutError', staleShippingMessage)
|
|
208
|
+
set('/checkoutErrorKind', 'error')
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
const productsByGroup = (get('/checkoutShippingGroupProducts') ?? {}) as Record<
|
|
212
|
+
string,
|
|
213
|
+
string[]
|
|
214
|
+
>
|
|
215
|
+
const selections = toShippingSelections(groups, productsByGroup)
|
|
216
|
+
if (groups.length > 0 && !selections) {
|
|
217
|
+
set('/checkoutPending', false)
|
|
218
|
+
set('/checkoutError', incompleteShippingMessage)
|
|
219
|
+
set('/checkoutErrorKind', 'error')
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
const paymentMethodId =
|
|
223
|
+
typeof get('/checkout/paymentMethod') === 'string'
|
|
224
|
+
? (get('/checkout/paymentMethod') as string)
|
|
225
|
+
: ''
|
|
226
|
+
if (!paymentMethodId) {
|
|
227
|
+
set('/checkoutPending', false)
|
|
228
|
+
set('/checkoutError', 'Selecciona un método de pago antes de confirmar.')
|
|
229
|
+
set('/checkoutErrorKind', 'error')
|
|
230
|
+
return
|
|
231
|
+
}
|
|
107
232
|
set('/checkoutPending', true)
|
|
108
233
|
set('/checkoutError', null)
|
|
234
|
+
set('/checkoutErrorKind', null)
|
|
109
235
|
set('/cartNotice', null)
|
|
110
|
-
|
|
236
|
+
const request = selections
|
|
237
|
+
? placeOrderAction({ shippingGroups: selections, paymentMethodId })
|
|
238
|
+
: placeOrderAction({ paymentMethodId })
|
|
239
|
+
void request.then(applyResult).catch(onError('placeOrder'))
|
|
111
240
|
},
|
|
112
241
|
reconcileOrder: () => {
|
|
113
242
|
set('/checkoutPending', true)
|
|
@@ -115,39 +244,225 @@ export function useCheckoutHandlers() {
|
|
|
115
244
|
void reconcileReceiptAction().then(applyResult).catch(onError('reconcileOrder'))
|
|
116
245
|
},
|
|
117
246
|
syncCheckoutAddress: () => {
|
|
118
|
-
const
|
|
119
|
-
|
|
247
|
+
const contact = (get('/checkoutContact') ?? {}) as CheckoutContactValues
|
|
248
|
+
const shippingAddress = (get('/checkoutShippingAddress') ?? {}) as CheckoutAddressValues
|
|
249
|
+
const billingAddress = (get('/checkoutBillingAddress') ?? undefined) as
|
|
250
|
+
| CheckoutAddressValues
|
|
251
|
+
| undefined
|
|
252
|
+
const sameAsShipping = get('/checkoutSameAsShipping') !== false
|
|
253
|
+
if (!contact.email || !shippingAddress.countryCode) return
|
|
120
254
|
set('/checkoutPending', true)
|
|
121
|
-
|
|
255
|
+
set('/checkoutShippingState', 'pending')
|
|
256
|
+
void syncCheckoutAddressStructuredAction({
|
|
257
|
+
contact,
|
|
258
|
+
shippingAddress,
|
|
259
|
+
billingAddress,
|
|
260
|
+
sameAsShipping,
|
|
261
|
+
// Reconcile the shopper's per-group choices by stable group identity.
|
|
262
|
+
previousShippingGroups: (get('/checkoutShippingGroups') ?? []) as CheckoutShippingGroup[],
|
|
263
|
+
})
|
|
122
264
|
.then((result) => {
|
|
123
265
|
set('/checkoutPending', false)
|
|
124
|
-
if (result.ok) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
set('/
|
|
128
|
-
set('/checkoutError', null)
|
|
129
|
-
} else {
|
|
266
|
+
if (!result.ok) {
|
|
267
|
+
// An address rejection is not a delivery failure: keep the field
|
|
268
|
+
// errors and leave the delivery state reachable again.
|
|
269
|
+
set('/checkoutShippingState', 'idle')
|
|
130
270
|
set('/checkoutError', result.error)
|
|
271
|
+
set('/checkoutErrorKind', 'error')
|
|
272
|
+
set('/checkoutFieldErrors', result.fieldErrors ?? {})
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
applyCart(result.cart)
|
|
276
|
+
// The backend groups are authoritative: mapped 1:1, never wrapped.
|
|
277
|
+
set('/checkoutShippingGroups', result.shippingGroups ?? [])
|
|
278
|
+
set('/checkoutShippingGroupProducts', result.shippingGroupProducts ?? {})
|
|
279
|
+
set('/checkoutFieldErrors', result.fieldErrors ?? {})
|
|
280
|
+
if (result.shippingError) {
|
|
281
|
+
// The cart survives a quote failure; delivery is reported ONLY in
|
|
282
|
+
// the delivery state (design D7 / R1): the block renders the
|
|
283
|
+
// error/unavailable copy and its own retry, and the generic
|
|
284
|
+
// submit-error node must not offer `placeOrder` for it.
|
|
285
|
+
// `unavailable` marks a provider that cannot serve grouped
|
|
286
|
+
// delivery, so no retry is promised.
|
|
287
|
+
set('/checkoutShippingState', result.shippingState ?? 'error')
|
|
288
|
+
return
|
|
289
|
+
}
|
|
290
|
+
set('/checkoutShippingState', 'idle')
|
|
291
|
+
set('/checkoutError', null)
|
|
292
|
+
set('/checkoutErrorKind', null)
|
|
293
|
+
})
|
|
294
|
+
.catch(onShippingError('syncCheckoutAddress'))
|
|
295
|
+
},
|
|
296
|
+
createSavedAddress: () => {
|
|
297
|
+
const address = (get('/checkoutShippingAddress') ?? emptyAddress) as CheckoutAddressValues
|
|
298
|
+
set('/checkoutSavedAddressState', { pendingId: 'create' })
|
|
299
|
+
void createCheckoutAddressAction(address)
|
|
300
|
+
.then((result) => {
|
|
301
|
+
if (!result.ok) {
|
|
302
|
+
set('/checkoutSavedAddressState', {
|
|
303
|
+
error: { message: result.error },
|
|
304
|
+
})
|
|
305
|
+
set('/checkoutFieldErrors', result.fieldErrors ?? {})
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
set('/checkoutSavedAddresses', result.savedAddresses)
|
|
309
|
+
set('/checkoutSavedAddressState', {
|
|
310
|
+
lastSavedId: result.savedAddressId ?? 'create',
|
|
311
|
+
lastAction: 'saved',
|
|
312
|
+
})
|
|
313
|
+
set('/checkoutFieldErrors', {})
|
|
314
|
+
})
|
|
315
|
+
.catch(addressMutationFailure('createSavedAddress'))
|
|
316
|
+
},
|
|
317
|
+
updateSavedAddress: () => {
|
|
318
|
+
const id = get('/checkoutSavedAddressTargetId') as string | null
|
|
319
|
+
if (!id) return
|
|
320
|
+
const address = (get('/checkoutShippingAddress') ?? emptyAddress) as CheckoutAddressValues
|
|
321
|
+
set('/checkoutSavedAddressState', { pendingId: id })
|
|
322
|
+
void updateCheckoutAddressAction({ id, address })
|
|
323
|
+
.then((result) => {
|
|
324
|
+
if (!result.ok) {
|
|
325
|
+
set('/checkoutSavedAddressState', {
|
|
326
|
+
error: { id, message: result.error },
|
|
327
|
+
})
|
|
131
328
|
set('/checkoutFieldErrors', result.fieldErrors ?? {})
|
|
329
|
+
return
|
|
330
|
+
}
|
|
331
|
+
set('/checkoutSavedAddresses', result.savedAddresses)
|
|
332
|
+
set('/checkoutSavedAddressState', {
|
|
333
|
+
lastSavedId: result.savedAddressId ?? id,
|
|
334
|
+
lastAction: 'saved',
|
|
335
|
+
})
|
|
336
|
+
set('/checkoutFieldErrors', {})
|
|
337
|
+
})
|
|
338
|
+
.catch(addressMutationFailure('updateSavedAddress', id))
|
|
339
|
+
},
|
|
340
|
+
deleteSavedAddress: () => {
|
|
341
|
+
const id = get('/checkoutSavedAddressTargetId') as string | null
|
|
342
|
+
if (!id) return
|
|
343
|
+
set('/checkoutSavedAddressState', { pendingId: id })
|
|
344
|
+
void deleteCheckoutAddressAction({ id })
|
|
345
|
+
.then((result) => {
|
|
346
|
+
if (!result.ok) {
|
|
347
|
+
set('/checkoutSavedAddressState', {
|
|
348
|
+
error: { id, message: result.error },
|
|
349
|
+
})
|
|
350
|
+
return
|
|
351
|
+
}
|
|
352
|
+
set('/checkoutSavedAddresses', result.savedAddresses)
|
|
353
|
+
set('/checkoutSavedAddressState', {
|
|
354
|
+
lastSavedId: id,
|
|
355
|
+
lastAction: 'deleted',
|
|
356
|
+
})
|
|
357
|
+
set('/checkoutFieldErrors', {})
|
|
358
|
+
})
|
|
359
|
+
.catch(addressMutationFailure('deleteSavedAddress', id))
|
|
360
|
+
},
|
|
361
|
+
startNewAddress: () => {
|
|
362
|
+
const current = (get('/checkoutShippingAddress') ?? emptyAddress) as CheckoutAddressValues
|
|
363
|
+
set('/checkoutAddressBeforeNew', current)
|
|
364
|
+
set('/checkoutShippingAddress', emptyAddress)
|
|
365
|
+
setFlatAddress(emptyAddress)
|
|
366
|
+
set('/checkoutSavedAddressState', undefined)
|
|
367
|
+
set('/checkoutFieldErrors', {})
|
|
368
|
+
},
|
|
369
|
+
cancelNewAddress: () => {
|
|
370
|
+
const previous = get('/checkoutAddressBeforeNew') as CheckoutAddressValues | null
|
|
371
|
+
if (previous) {
|
|
372
|
+
set('/checkoutShippingAddress', previous)
|
|
373
|
+
setFlatAddress(previous)
|
|
374
|
+
}
|
|
375
|
+
set('/checkoutAddressBeforeNew', null)
|
|
376
|
+
set('/checkoutSavedAddressState', undefined)
|
|
377
|
+
set('/checkoutFieldErrors', {})
|
|
378
|
+
},
|
|
379
|
+
loadCheckoutLocations: () => {
|
|
380
|
+
const request = get('/checkoutLocationRequest') as {
|
|
381
|
+
kind: 'shipping' | 'billing'
|
|
382
|
+
level: 'provinces' | 'cities'
|
|
383
|
+
} | null
|
|
384
|
+
if (!request) return
|
|
385
|
+
const shippingAddress = (get('/checkoutShippingAddress') ?? {}) as CheckoutAddressValues
|
|
386
|
+
const path =
|
|
387
|
+
request.kind === 'shipping'
|
|
388
|
+
? '/checkoutShippingLocations'
|
|
389
|
+
: '/checkoutBillingLocations'
|
|
390
|
+
const current = (get(path) ?? {
|
|
391
|
+
countries: [],
|
|
392
|
+
provinces: [],
|
|
393
|
+
cities: [],
|
|
394
|
+
}) as CheckoutLocationOptions
|
|
395
|
+
set(path, {
|
|
396
|
+
...current,
|
|
397
|
+
...(request.level === 'provinces'
|
|
398
|
+
? { provincesState: 'pending', cities: [], citiesState: 'idle' }
|
|
399
|
+
: { citiesState: 'pending' }),
|
|
400
|
+
})
|
|
401
|
+
void loadCheckoutLocationsAction({
|
|
402
|
+
kind: request.kind,
|
|
403
|
+
level: request.level,
|
|
404
|
+
countryCode: shippingAddress.countryCode,
|
|
405
|
+
provinceCode: shippingAddress.province ?? '',
|
|
406
|
+
})
|
|
407
|
+
.then((result) => {
|
|
408
|
+
if (!result.ok) {
|
|
409
|
+
set(path, {
|
|
410
|
+
...current,
|
|
411
|
+
...(request.level === 'provinces'
|
|
412
|
+
? { provincesState: 'error', provincesError: result.error }
|
|
413
|
+
: { citiesState: 'error', citiesError: result.error }),
|
|
414
|
+
})
|
|
415
|
+
return
|
|
132
416
|
}
|
|
417
|
+
set(path, {
|
|
418
|
+
...current,
|
|
419
|
+
...(request.level === 'provinces'
|
|
420
|
+
? {
|
|
421
|
+
provinces: result.options,
|
|
422
|
+
provincesState: 'idle',
|
|
423
|
+
provincesError: undefined,
|
|
424
|
+
cities: [],
|
|
425
|
+
citiesState: 'idle',
|
|
426
|
+
}
|
|
427
|
+
: { cities: result.options, citiesState: 'idle', citiesError: undefined }),
|
|
428
|
+
})
|
|
133
429
|
})
|
|
134
|
-
.catch(onError('
|
|
430
|
+
.catch(onError('loadCheckoutLocations'))
|
|
135
431
|
},
|
|
136
432
|
selectShippingMethod: () => {
|
|
137
|
-
|
|
138
|
-
|
|
433
|
+
// One apply at a time: a second click while the groups are being applied
|
|
434
|
+
// (or the quote is reloading) is ignored instead of racing the backend.
|
|
435
|
+
if (get('/checkoutShippingState') === 'pending') return
|
|
436
|
+
// The view already wrote the chosen option into its group, so the group
|
|
437
|
+
// list is the single source of the per-group selection.
|
|
438
|
+
const groups = (get('/checkoutShippingGroups') ?? []) as CheckoutShippingGroup[]
|
|
439
|
+
const productsByGroup = (get('/checkoutShippingGroupProducts') ?? {}) as Record<
|
|
440
|
+
string,
|
|
441
|
+
string[]
|
|
442
|
+
>
|
|
443
|
+
const selections = toShippingSelections(groups, productsByGroup)
|
|
444
|
+
// Every group must be complete before anything is applied; a partial
|
|
445
|
+
// set is never sent to the backend.
|
|
446
|
+
if (!selections) return
|
|
139
447
|
set('/checkoutPending', true)
|
|
140
|
-
|
|
448
|
+
set('/checkoutShippingState', 'pending')
|
|
449
|
+
void applyCheckoutShippingGroupsAction({ shippingGroups: selections })
|
|
141
450
|
.then((result) => {
|
|
142
451
|
set('/checkoutPending', false)
|
|
143
|
-
if (result.ok) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
452
|
+
if (!result.ok) {
|
|
453
|
+
// Recoverable, and reported ONLY in the delivery state (R1): the
|
|
454
|
+
// delivery block owns the retry, which refreshes the quote and
|
|
455
|
+
// reconciles the selections by group identity (design D7). An
|
|
456
|
+
// unsupported provider reports `unavailable` instead of a retry.
|
|
457
|
+
set('/checkoutShippingState', result.shippingState ?? 'error')
|
|
458
|
+
return
|
|
148
459
|
}
|
|
460
|
+
applyCart(result.cart)
|
|
461
|
+
set('/checkoutShippingState', 'idle')
|
|
462
|
+
set('/checkoutError', null)
|
|
463
|
+
set('/checkoutErrorKind', null)
|
|
149
464
|
})
|
|
150
|
-
.catch(
|
|
465
|
+
.catch(onShippingError('selectShippingMethod'))
|
|
151
466
|
},
|
|
152
467
|
}
|
|
153
468
|
|
|
@@ -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,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Generated by Thor Commerce storefront (feature: customer-addresses — handlers)
|
|
4
|
+
// The addresses module is driven by the account view registry (it calls the
|
|
5
|
+
// account Server Actions directly and keeps its pending/error state in the
|
|
6
|
+
// shared store). The handlers composer requires one hook per installed feature,
|
|
7
|
+
// so this module is intentionally a no-op: no global action needs registering.
|
|
8
|
+
|
|
9
|
+
export function useCustomerAddressesHandlers() {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Generated by Thor Commerce storefront (feature: customer-addresses — state slice)
|
|
2
|
+
// The customer-addresses capability's state. Installed only when the feature is in
|
|
3
|
+
// the manifest, so `accountAddressesAvailable` is the presence flag the account
|
|
4
|
+
// view reads: absent (undefined) means no address module, no navigation entry,
|
|
5
|
+
// and no address read.
|
|
6
|
+
|
|
7
|
+
import type { AccountAddressView } from '../../state.core'
|
|
8
|
+
|
|
9
|
+
export interface CustomerAddressesState {
|
|
10
|
+
/** Present only while the feature is installed. */
|
|
11
|
+
accountAddressesAvailable: boolean
|
|
12
|
+
accountAddresses: AccountAddressView[]
|
|
13
|
+
accountAddressesPending: boolean
|
|
14
|
+
accountAddressesError: string | null
|
|
15
|
+
/** The add/edit form is open when an id or the create flag is set. */
|
|
16
|
+
accountAddressFormOpen: boolean
|
|
17
|
+
accountAddressEditingId: string | null
|
|
18
|
+
accountAddressMutationPending: boolean
|
|
19
|
+
accountAddressMutationError: string | null
|
|
20
|
+
accountAddressFieldErrors: Record<string, string>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const customerAddressesState: CustomerAddressesState = {
|
|
24
|
+
accountAddressesAvailable: true,
|
|
25
|
+
accountAddresses: [],
|
|
26
|
+
accountAddressesPending: false,
|
|
27
|
+
accountAddressesError: null,
|
|
28
|
+
accountAddressFormOpen: false,
|
|
29
|
+
accountAddressEditingId: null,
|
|
30
|
+
accountAddressMutationPending: false,
|
|
31
|
+
accountAddressMutationError: null,
|
|
32
|
+
accountAddressFieldErrors: {},
|
|
33
|
+
}
|
|
@@ -18,6 +18,14 @@ export interface CustomerAuthState {
|
|
|
18
18
|
accountResolution: AccountResolution | 'unresolved'
|
|
19
19
|
/** Which auth surface is mounted: the sign-in page or the registration page. */
|
|
20
20
|
accountMode: 'login' | 'register'
|
|
21
|
+
/**
|
|
22
|
+
* The account area's current shape, seeded by the frame from its generation
|
|
23
|
+
* selection. `stack` renders every installed module in order; `tabs` shows one
|
|
24
|
+
* at a time. Client-owned so an RSC refresh never resets the active tab.
|
|
25
|
+
*/
|
|
26
|
+
accountShape: 'stack' | 'tabs'
|
|
27
|
+
/** The module shown in the tabbed shape; null in the stacked shape. */
|
|
28
|
+
accountTab: string | null
|
|
21
29
|
accountPending: boolean
|
|
22
30
|
/**
|
|
23
31
|
* True while a cross-tab invalidation or a foreground/resume recheck is in
|
|
@@ -48,6 +56,8 @@ export const customerAuthState: CustomerAuthState = {
|
|
|
48
56
|
accountAuthenticated: false,
|
|
49
57
|
accountResolution: 'unresolved',
|
|
50
58
|
accountMode: 'login',
|
|
59
|
+
accountShape: 'stack',
|
|
60
|
+
accountTab: null,
|
|
51
61
|
accountPending: false,
|
|
52
62
|
accountReconciling: false,
|
|
53
63
|
accountError: null,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Generated by Thor Commerce storefront (feature: customer-profile — handlers)
|
|
4
|
+
// The profile module is driven by the account view registry (it calls the
|
|
5
|
+
// account Server Actions directly and keeps its pending/error state in the
|
|
6
|
+
// shared store). The handlers composer requires one hook per installed feature,
|
|
7
|
+
// so this module is intentionally a no-op: no global action needs registering.
|
|
8
|
+
|
|
9
|
+
export function useCustomerProfileHandlers() {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by Thor Commerce storefront (feature: customer-profile — state slice)
|
|
2
|
+
// The customer-profile capability's state. Installed only when the feature is in
|
|
3
|
+
// the manifest, so `accountProfileAvailable` is the presence flag the account
|
|
4
|
+
// view reads: absent (undefined) means the module does not render and performs
|
|
5
|
+
// no profile read.
|
|
6
|
+
|
|
7
|
+
export interface CustomerProfileState {
|
|
8
|
+
/** Present only while the feature is installed. */
|
|
9
|
+
accountProfileAvailable: boolean
|
|
10
|
+
accountProfilePending: boolean
|
|
11
|
+
accountProfileError: string | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const customerProfileState: CustomerProfileState = {
|
|
15
|
+
accountProfileAvailable: true,
|
|
16
|
+
accountProfilePending: false,
|
|
17
|
+
accountProfileError: null,
|
|
18
|
+
}
|