@thorprovider/storefront 0.4.0-mvp.2 → 0.5.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 +13 -13
- package/assets/templates/app/app/[[...slug]]/page.tsx +32 -1
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +43 -12
- package/assets/templates/app/lib/__STOREFRONT__/account-boundary.client.tsx +76 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +461 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-mutation.client.ts +46 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +103 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-reconcile.client.ts +465 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-session.core.ts +177 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-session.ts +44 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-user.core.ts +65 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +76 -27
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +4 -4
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +0 -10
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +3 -3
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +17 -18
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +209 -0
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.ts +247 -0
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +60 -29
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +83 -15
- package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +3 -5
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +25 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +7 -10
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.client.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.client.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +16 -16
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +26 -19
- package/assets/templates/features/checkout/state.ts +0 -5
- package/assets/templates/features/customer-auth/handlers.ts +19 -23
- package/assets/templates/features/customer-auth/state.ts +21 -0
- package/assets/templates/views/account/index.tsx +19 -7
- package/assets/templates/views/account/registry.tsx +263 -155
- package/assets/templates/views/account/schema.ts +1 -1
- package/assets/templates/views/cart/data.ts +7 -7
- package/assets/templates/views/cart/registry.tsx +4 -3
- package/assets/templates/views/category/assembly/assembly.json +2 -2
- package/assets/templates/views/category/assembly/index.skeleton.tsx +11 -7
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +9 -9
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +1 -1
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/catalog.part +5 -0
- package/assets/templates/views/category/assembly/slots/filter/{CategoryFilter2 → CategoryListing}/element.part +5 -3
- package/assets/templates/views/category/assembly/slots/filter/{CategoryFilter2 → CategoryListing}/registry.part +9 -5
- package/assets/templates/views/category/content.ts +2 -1
- package/assets/templates/views/category/index.tsx +19 -13
- package/assets/templates/views/category/props.ts +1 -1
- package/assets/templates/views/category/registry.tsx +19 -15
- package/assets/templates/views/category/schema.ts +48 -21
- package/assets/templates/views/checkout/content.ts +60 -0
- package/assets/templates/views/checkout/props.ts +4 -5
- package/assets/templates/views/checkout/registry.tsx +12 -10
- package/assets/templates/views/checkout/schema.ts +10 -16
- package/assets/templates/views/home/assembly/assembly.json +4 -4
- package/assets/templates/views/home/assembly/index.skeleton.tsx +2 -3
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +4 -1
- package/assets/templates/views/home/assembly/slots/benefits/cards/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/cards/registry.part +17 -0
- package/assets/templates/views/home/assembly/slots/benefits/split/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → split}/registry.part +6 -2
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/catalog.part +8 -0
- package/assets/templates/views/home/assembly/slots/categories/{ProductCategory2 → CategoryGrid}/element.part +1 -1
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/registry.part +31 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/registry.part +3 -1
- package/assets/templates/views/home/content.ts +22 -0
- package/assets/templates/views/home/index.tsx +11 -8
- package/assets/templates/views/home/props.ts +1 -0
- package/assets/templates/views/home/registry.tsx +39 -15
- package/assets/templates/views/home/schema.ts +141 -24
- package/assets/templates/views/product/data.ts +1 -1
- package/assets/templates/views/product/registry.tsx +10 -6
- package/assets/templates/views/product/schema.ts +36 -1
- package/examples/merchandising/category-led.json +1 -1
- package/examples/merchandising/collection-led.json +1 -1
- package/package.json +4 -5
- package/recipes/archetypes.json +39 -43
- package/recipes/catalog.json +212 -202
- package/recipes/catalog.mjs +10 -0
- package/recipes/catalog.schema.json +4 -0
- package/recipes/features.json +5 -5
- package/recipes/recipes.json +137 -43
- package/recipes/sections.json +4 -4
- package/recipes/validate.mjs +21 -4
- package/scripts/candidate.mjs +2 -2
- package/scripts/composers.mjs +2 -2
- package/scripts/file-classes.mjs +10 -0
- package/scripts/logical-controls.mjs +4 -4
- package/scripts/operation-registry.mjs +1 -1
- package/scripts/ownership-conflict.mjs +5 -2
- package/scripts/view-assembly.mjs +12 -4
- package/scripts/view-selection.mjs +1 -1
- package/skills/sf-view-gen/assets/recipes/archetypes.json +39 -43
- package/skills/sf-view-gen/assets/recipes/catalog.json +212 -202
- package/skills/sf-view-gen/assets/recipes/catalog.schema.json +4 -0
- package/skills/sf-view-gen/assets/recipes/features.json +5 -5
- package/skills/sf-view-gen/assets/recipes/recipes.json +137 -43
- package/skills/sf-view-gen/assets/recipes/sections.json +4 -4
- package/skills/sf-view-gen/assets/templates/views/sections/cta.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +16 -16
- package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/schema.testimonials.ts +21 -11
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +2 -8
- package/skills/sf-view-gen/scripts/catalog.mjs +10 -0
- package/skills/sf-view-gen/scripts/validate.mjs +21 -4
- package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/catalog.part +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/registry.part +0 -10
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/catalog.part +0 -4
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/registry.part +0 -16
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/catalog.part +0 -4
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/catalog.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/element.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/catalog.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/element.part +0 -0
- /package/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/element.part +0 -0
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
// spec (elements/catalog/route/loader) stays a pure Server Component module.
|
|
8
8
|
|
|
9
9
|
import { useEffect, useRef } from 'react'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CheckoutConfirmation as CheckoutConfirmationBlock,
|
|
14
|
-
} from '@thorprovider/blocks'
|
|
10
|
+
import { Button } from '@thorprovider/blocks/ui/button'
|
|
11
|
+
import CheckoutBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout'
|
|
12
|
+
import CheckoutConfirmationBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout-confirmation'
|
|
15
13
|
import { useStateStore } from '@json-render/react'
|
|
16
14
|
import { loadCheckoutAction, reconcileReceiptAction } from '../../actions'
|
|
17
15
|
import type { CartStatePatch, PlaceOrderResult } from '../../commerce'
|
|
@@ -130,11 +128,17 @@ export const registry: ViewRegistry = {
|
|
|
130
128
|
const checkoutError = typeof state.checkoutError === 'string' ? state.checkoutError : undefined
|
|
131
129
|
return (
|
|
132
130
|
<CheckoutBlock
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
presentation={parsed.presentation ?? 'stepper'}
|
|
132
|
+
showReviewStep={parsed.showReviewStep}
|
|
133
|
+
labels={{
|
|
134
|
+
...parsed.labels,
|
|
135
|
+
...(parsed.title ? { title: parsed.title } : {}),
|
|
136
|
+
...(parsed.description ? { description: parsed.description } : {}),
|
|
137
|
+
...(cartError ? { totalsErrorLabel: cartError } : {}),
|
|
138
|
+
submitErrorActionLabel: unresolved ? 'Reconciliar' : 'Reintentar',
|
|
139
|
+
}}
|
|
135
140
|
orderSummary={parsed.orderSummary}
|
|
136
141
|
totalsState={state.cartPending ? 'pending' : cartError ? 'error' : 'idle'}
|
|
137
|
-
totalsErrorLabel={cartError}
|
|
138
142
|
onRetryTotals={() => emit('syncCheckoutAddress')}
|
|
139
143
|
countries={parsed.countries}
|
|
140
144
|
shippingOptions={parsed.shippingOptions}
|
|
@@ -147,7 +151,6 @@ export const registry: ViewRegistry = {
|
|
|
147
151
|
values={parsed.values}
|
|
148
152
|
fieldErrors={parsed.fieldErrors}
|
|
149
153
|
fieldDescriptions={parsed.fieldDescriptions}
|
|
150
|
-
collectCardFields={false}
|
|
151
154
|
onChange={(field, value) => {
|
|
152
155
|
set(`/checkout/${field}`, value)
|
|
153
156
|
if (ADDRESS_FIELDS.has(field)) emit('syncCheckoutAddress')
|
|
@@ -158,7 +161,6 @@ export const registry: ViewRegistry = {
|
|
|
158
161
|
// An ambiguous completion offers RECONCILE only; a definite failure
|
|
159
162
|
// (cart-with-error or pre-completion error) offers a controlled retry.
|
|
160
163
|
onRetrySubmit={unresolved ? () => emit('reconcileOrder') : () => emit('placeOrder')}
|
|
161
|
-
submitErrorActionLabel={unresolved ? 'Reconciliar' : 'Reintentar'}
|
|
162
164
|
/>
|
|
163
165
|
)
|
|
164
166
|
},
|
|
@@ -15,8 +15,8 @@ const moneySchema = z.object({
|
|
|
15
15
|
currencyCode: z.string(),
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
-
// Mirrors the
|
|
19
|
-
//
|
|
18
|
+
// Mirrors the canonical Checkout values contract. There are no card fields:
|
|
19
|
+
// card collection belongs to the host payment-provider surface.
|
|
20
20
|
export const checkoutFormDataSchema = z.object({
|
|
21
21
|
email: z.string(),
|
|
22
22
|
firstName: z.string(),
|
|
@@ -28,29 +28,24 @@ export const checkoutFormDataSchema = z.object({
|
|
|
28
28
|
zipCode: z.string(),
|
|
29
29
|
country: z.string(),
|
|
30
30
|
paymentMethod: z.string(),
|
|
31
|
-
cardNumber: z.string(),
|
|
32
|
-
expiryDate: z.string(),
|
|
33
|
-
cvv: z.string(),
|
|
34
|
-
cardName: z.string(),
|
|
35
31
|
saveInfo: z.boolean(),
|
|
36
|
-
sameAsBilling: z.boolean(),
|
|
37
32
|
newsletter: z.boolean(),
|
|
38
33
|
promoCode: z.string(),
|
|
39
34
|
})
|
|
40
35
|
|
|
41
|
-
// Mirrors
|
|
42
|
-
//
|
|
36
|
+
// Mirrors the canonical Checkout order line: backend identity, optional canonical
|
|
37
|
+
// Money amounts, and an optional image omitted when absent.
|
|
43
38
|
export const orderSummaryItemSchema = z.object({
|
|
44
39
|
id: z.union([z.string(), z.number()]),
|
|
45
40
|
name: z.string(),
|
|
46
41
|
variant: z.string().optional(),
|
|
47
42
|
quantity: z.number(),
|
|
48
43
|
lineTotal: moneySchema.optional(),
|
|
49
|
-
|
|
44
|
+
unitPrice: moneySchema.optional(),
|
|
50
45
|
image: z.string().optional(),
|
|
51
46
|
})
|
|
52
47
|
|
|
53
|
-
// Mirrors
|
|
48
|
+
// Mirrors the canonical Checkout totals (backend-authoritative).
|
|
54
49
|
export const checkoutTotalsSchema = z.object({
|
|
55
50
|
subtotal: moneySchema,
|
|
56
51
|
discount: moneySchema.optional(),
|
|
@@ -62,10 +57,6 @@ export const checkoutTotalsSchema = z.object({
|
|
|
62
57
|
export const orderSummarySchema = z.object({
|
|
63
58
|
items: z.array(orderSummaryItemSchema),
|
|
64
59
|
totals: checkoutTotalsSchema.optional(),
|
|
65
|
-
shipping: z.number().optional(),
|
|
66
|
-
tax: z.number().optional(),
|
|
67
|
-
discount: z.number().optional(),
|
|
68
|
-
promoDiscount: z.number().optional(),
|
|
69
60
|
})
|
|
70
61
|
|
|
71
62
|
export const countryOptionSchema = z.object({
|
|
@@ -73,7 +64,7 @@ export const countryOptionSchema = z.object({
|
|
|
73
64
|
label: z.string(),
|
|
74
65
|
})
|
|
75
66
|
|
|
76
|
-
// Mirrors
|
|
67
|
+
// Mirrors the canonical Checkout shipping option (backend shipping method id).
|
|
77
68
|
export const shippingOptionSchema = z.object({
|
|
78
69
|
id: z.string(),
|
|
79
70
|
name: z.string(),
|
|
@@ -117,6 +108,9 @@ export const paymentMethodSchema = z.object({
|
|
|
117
108
|
export const checkoutPropsSchema = z.object({
|
|
118
109
|
title: z.string().optional(),
|
|
119
110
|
description: z.string().optional(),
|
|
111
|
+
presentation: z.enum(['single-page', 'stepper']).optional(),
|
|
112
|
+
showReviewStep: z.boolean().optional(),
|
|
113
|
+
labels: z.record(z.string(), z.string()).optional(),
|
|
120
114
|
orderSummary: orderSummarySchema.optional(),
|
|
121
115
|
countries: z.array(countryOptionSchema).optional(),
|
|
122
116
|
shippingOptions: z.array(shippingOptionSchema).optional(),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"view": "home",
|
|
3
3
|
"slots": [
|
|
4
|
-
{ "id": "home.hero", "slot": "hero", "default": "
|
|
5
|
-
{ "id": "home.benefits", "slot": "benefits", "default": "
|
|
6
|
-
{ "id": "home.categories", "slot": "categories", "default": "
|
|
4
|
+
{ "id": "home.hero", "slot": "hero", "default": "StorefrontHero" },
|
|
5
|
+
{ "id": "home.benefits", "slot": "benefits", "default": "cards" },
|
|
6
|
+
{ "id": "home.categories", "slot": "categories", "default": "CategoryGrid" }
|
|
7
7
|
],
|
|
8
8
|
"sections": {
|
|
9
9
|
"faq": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"propsModule": "./content",
|
|
28
28
|
"defaultProps": "{}",
|
|
29
29
|
"dataBound": true,
|
|
30
|
-
"defaultVariant": "
|
|
30
|
+
"defaultVariant": "ProductGrid"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -15,7 +15,8 @@ import * as homeData from './data'
|
|
|
15
15
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
16
16
|
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
17
17
|
import {
|
|
18
|
-
|
|
18
|
+
categoryCardPropsSchema,
|
|
19
|
+
categoryGridPropsSchema,
|
|
19
20
|
featurePropsSchema,
|
|
20
21
|
storefrontHeroPropsSchema,
|
|
21
22
|
} from './schema'@@SECTION_IMPORTS@@
|
|
@@ -67,7 +68,6 @@ export const home: ViewModule = {
|
|
|
67
68
|
return {
|
|
68
69
|
heroProducts: homeData.selectHeroProducts(products).map(toFeaturedProduct),
|
|
69
70
|
categories: categories.map(toCategoryCard),
|
|
70
|
-
navCategories: homeData.toNavCategories(categories),
|
|
71
71
|
dataSource: source,
|
|
72
72
|
dataError: null,
|
|
73
73
|
sections,
|
|
@@ -78,7 +78,6 @@ export const home: ViewModule = {
|
|
|
78
78
|
return {
|
|
79
79
|
heroProducts: [],
|
|
80
80
|
categories: [],
|
|
81
|
-
navCategories: [],
|
|
82
81
|
dataSource: getDataSource(),
|
|
83
82
|
dataError:
|
|
84
83
|
error instanceof Error ? error.message : 'No se pudo cargar el catálogo.',
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
// schema (./schema.ts) before binding, so a contract mismatch fails loudly at
|
|
11
11
|
// the boundary instead of rendering undefined fields or literal icon tags.
|
|
12
12
|
|
|
13
|
+
import { CategoryCard as CategoryCardBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/category-card'
|
|
13
14
|
@@BLOCK_IMPORTS@@@@SECTION_REGISTRY_IMPORTS@@
|
|
14
15
|
import { useStateStore } from '@json-render/react'
|
|
15
16
|
import { resolveIcon } from '../../icon-map'
|
|
16
17
|
import type { ViewRegistry } from '../types'
|
|
18
|
+
import * as featureSchemas from './schema'
|
|
17
19
|
import {
|
|
18
|
-
|
|
20
|
+
categoryCardPropsSchema,
|
|
21
|
+
categoryGridPropsSchema,
|
|
19
22
|
featurePropsSchema,
|
|
20
23
|
storefrontHeroPropsSchema,
|
|
21
24
|
} from './schema'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Feature: ({ props }) => {
|
|
2
|
+
const feature = featureSchemas.featureCardsSpecSchema.parse({
|
|
3
|
+
...props,
|
|
4
|
+
presentation: 'cards',
|
|
5
|
+
})
|
|
6
|
+
return (
|
|
7
|
+
<FeatureBlock
|
|
8
|
+
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
9
|
+
presentation='cards'
|
|
10
|
+
badge={feature.badge}
|
|
11
|
+
title={feature.title}
|
|
12
|
+
description={feature.description}
|
|
13
|
+
ctaLabel={feature.ctaLabel}
|
|
14
|
+
learnMoreLabel={feature.learnMoreLabel}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
},
|
package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → split}/registry.part
RENAMED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
Feature: ({ props }) => {
|
|
2
|
-
const feature =
|
|
2
|
+
const feature = featureSchemas.featureSplitSpecSchema.parse({
|
|
3
|
+
...props,
|
|
4
|
+
presentation: 'split',
|
|
5
|
+
})
|
|
3
6
|
return (
|
|
4
7
|
<FeatureBlock
|
|
5
8
|
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
6
|
-
|
|
9
|
+
presentation='split'
|
|
7
10
|
title={feature.title}
|
|
8
11
|
description={feature.description}
|
|
12
|
+
image={feature.image}
|
|
9
13
|
/>
|
|
10
14
|
)
|
|
11
15
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
CategoryCard: ({ props, emit }) => {
|
|
2
|
+
const { set } = useStateStore()
|
|
3
|
+
const card = categoryCardPropsSchema.parse(props)
|
|
4
|
+
return (
|
|
5
|
+
<CategoryCardBlock
|
|
6
|
+
{...card}
|
|
7
|
+
onBrowse={(category) => {
|
|
8
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
9
|
+
emit('openCategory')
|
|
10
|
+
}}
|
|
11
|
+
/>
|
|
12
|
+
)
|
|
13
|
+
},
|
|
14
|
+
CategoryGrid: ({ props, emit }) => {
|
|
15
|
+
const { set } = useStateStore()
|
|
16
|
+
const grid = categoryGridPropsSchema.parse(props)
|
|
17
|
+
return (
|
|
18
|
+
<CategoryGridBlock
|
|
19
|
+
{...grid}
|
|
20
|
+
onBrowse={(category) => {
|
|
21
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
22
|
+
emit('openCategory')
|
|
23
|
+
}}
|
|
24
|
+
onViewAll={() => {
|
|
25
|
+
set('/lastCategory', '/categories')
|
|
26
|
+
emit('openCategory')
|
|
27
|
+
}}
|
|
28
|
+
onQueryChange={(query) => set('/categoryQuery', query)}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
},
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
<StorefrontHeroBlock
|
|
6
6
|
title={hero.title}
|
|
7
7
|
description={hero.description}
|
|
8
|
+
presentation={hero.presentation}
|
|
9
|
+
currency={hero.currency}
|
|
8
10
|
products={hero.products}
|
|
9
11
|
titleAccent={hero.titleAccent}
|
|
10
12
|
badge={hero.badge}
|
|
11
13
|
primaryCta={hero.primaryCta}
|
|
12
14
|
secondaryCta={hero.secondaryCta}
|
|
13
15
|
heroImage={hero.heroImage}
|
|
16
|
+
rotationInterval={hero.rotationInterval}
|
|
14
17
|
onAddToCart={(product) => {
|
|
15
18
|
// Product-card shortcut: add the first purchasable variant.
|
|
16
19
|
set('/lastClicked', product)
|
|
@@ -20,7 +23,6 @@
|
|
|
20
23
|
set('/lastClicked', product)
|
|
21
24
|
emit('openProduct')
|
|
22
25
|
}}
|
|
23
|
-
onSelectColor={() => {}}
|
|
24
26
|
/>
|
|
25
27
|
)
|
|
26
28
|
},
|
|
@@ -27,11 +27,26 @@ export const heroContent = {
|
|
|
27
27
|
secondaryCta: { label: 'Ver categorías' },
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Neutral editorial seed for the detailed (split) presentation. Replace it with
|
|
32
|
+
* your own image; the block renders editorial imagery in grayscale. It lives in
|
|
33
|
+
* user-owned content, not in the block library.
|
|
34
|
+
*/
|
|
35
|
+
const editorialImage = {
|
|
36
|
+
src:
|
|
37
|
+
'data:image/svg+xml;charset=utf-8,' +
|
|
38
|
+
encodeURIComponent(
|
|
39
|
+
`<svg xmlns='http://www.w3.org/2000/svg' width='1200' height='900'><rect width='100%' height='100%' fill='#e2e8f0'/><circle cx='360' cy='300' r='170' fill='#cbd5e1'/><rect x='560' y='180' width='420' height='420' rx='24' fill='#94a3b8' opacity='.55'/><path d='M120 720h960' stroke='#94a3b8' stroke-width='14' stroke-linecap='round'/></svg>`,
|
|
40
|
+
),
|
|
41
|
+
alt: '',
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
export const benefitsContent = {
|
|
31
45
|
badge: '__SITE_NAME__',
|
|
32
46
|
title: 'Compra con confianza',
|
|
33
47
|
// Neutral: no delivery/shipping promise.
|
|
34
48
|
description: 'Ventajas pensadas para una compra clara y segura.',
|
|
49
|
+
image: editorialImage,
|
|
35
50
|
items: [
|
|
36
51
|
{
|
|
37
52
|
id: 'pago',
|
|
@@ -57,6 +72,13 @@ export const benefitsContent = {
|
|
|
57
72
|
export const categoriesContent = {
|
|
58
73
|
title: 'Compra por categoría',
|
|
59
74
|
description: 'Explora nuestro catálogo completo.',
|
|
75
|
+
browseLabel: 'Explorar',
|
|
76
|
+
itemsLabel: 'productos',
|
|
77
|
+
searchLabel: 'Buscar categorías',
|
|
78
|
+
searchPlaceholder: 'Buscar categorías',
|
|
79
|
+
emptyLabel: 'No hay categorías disponibles.',
|
|
80
|
+
noResultsLabel: 'No se encontraron categorías.',
|
|
81
|
+
viewAllLabel: 'Ver todas las categorías',
|
|
60
82
|
}
|
|
61
83
|
|
|
62
84
|
/**
|
|
@@ -15,7 +15,8 @@ import * as homeData from './data'
|
|
|
15
15
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
16
16
|
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
17
17
|
import {
|
|
18
|
-
|
|
18
|
+
categoryCardPropsSchema,
|
|
19
|
+
categoryGridPropsSchema,
|
|
19
20
|
featurePropsSchema,
|
|
20
21
|
storefrontHeroPropsSchema,
|
|
21
22
|
} from './schema'
|
|
@@ -33,7 +34,7 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
33
34
|
props: benefitsProps,
|
|
34
35
|
},
|
|
35
36
|
'home.categories': {
|
|
36
|
-
type: '
|
|
37
|
+
type: 'CategoryGrid',
|
|
37
38
|
props: categoriesProps,
|
|
38
39
|
on: { openCategory: { action: 'openCategory' } },
|
|
39
40
|
},
|
|
@@ -42,15 +43,19 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
42
43
|
const catalog = {
|
|
43
44
|
StorefrontHero: {
|
|
44
45
|
props: storefrontHeroPropsSchema,
|
|
45
|
-
description: 'Landing hero.',
|
|
46
|
+
description: 'Landing hero (presentations: compact, showcase, editorial, promotional).',
|
|
46
47
|
},
|
|
47
48
|
Feature: {
|
|
48
49
|
props: featurePropsSchema,
|
|
49
50
|
description: 'Benefit highlights.',
|
|
50
51
|
},
|
|
51
|
-
|
|
52
|
-
props:
|
|
53
|
-
description: 'Category
|
|
52
|
+
CategoryGrid: {
|
|
53
|
+
props: categoryGridPropsSchema,
|
|
54
|
+
description: 'Category listing that renders category cells.',
|
|
55
|
+
},
|
|
56
|
+
CategoryCard: {
|
|
57
|
+
props: categoryCardPropsSchema,
|
|
58
|
+
description: 'One category cell, without listing section chrome.',
|
|
54
59
|
},
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -91,7 +96,6 @@ export const home: ViewModule = {
|
|
|
91
96
|
return {
|
|
92
97
|
heroProducts: homeData.selectHeroProducts(products).map(toFeaturedProduct),
|
|
93
98
|
categories: categories.map(toCategoryCard),
|
|
94
|
-
navCategories: homeData.toNavCategories(categories),
|
|
95
99
|
dataSource: source,
|
|
96
100
|
dataError: null,
|
|
97
101
|
sections,
|
|
@@ -102,7 +106,6 @@ export const home: ViewModule = {
|
|
|
102
106
|
return {
|
|
103
107
|
heroProducts: [],
|
|
104
108
|
categories: [],
|
|
105
|
-
navCategories: [],
|
|
106
109
|
dataSource: getDataSource(),
|
|
107
110
|
dataError:
|
|
108
111
|
error instanceof Error ? error.message : 'No se pudo cargar el catálogo.',
|
|
@@ -10,16 +10,17 @@
|
|
|
10
10
|
// schema (./schema.ts) before binding, so a contract mismatch fails loudly at
|
|
11
11
|
// the boundary instead of rendering undefined fields or literal icon tags.
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '@thorprovider/blocks'
|
|
13
|
+
import { CategoryCard as CategoryCardBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/category-card'
|
|
14
|
+
import { CategoryGrid as CategoryGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/product-category-grid'
|
|
15
|
+
import { StorefrontHero as StorefrontHeroBlock } from '@thorprovider/blocks/blocks/e-commerce/storefront-hero/storefront-hero'
|
|
16
|
+
import { Feature as FeatureBlock } from '@thorprovider/blocks/blocks/marketing/features/feature'
|
|
18
17
|
import { useStateStore } from '@json-render/react'
|
|
19
18
|
import { resolveIcon } from '../../icon-map'
|
|
20
19
|
import type { ViewRegistry } from '../types'
|
|
20
|
+
import * as featureSchemas from './schema'
|
|
21
21
|
import {
|
|
22
|
-
|
|
22
|
+
categoryCardPropsSchema,
|
|
23
|
+
categoryGridPropsSchema,
|
|
23
24
|
featurePropsSchema,
|
|
24
25
|
storefrontHeroPropsSchema,
|
|
25
26
|
} from './schema'
|
|
@@ -32,12 +33,15 @@ export const registry: ViewRegistry = {
|
|
|
32
33
|
<StorefrontHeroBlock
|
|
33
34
|
title={hero.title}
|
|
34
35
|
description={hero.description}
|
|
36
|
+
presentation={hero.presentation}
|
|
37
|
+
currency={hero.currency}
|
|
35
38
|
products={hero.products}
|
|
36
39
|
titleAccent={hero.titleAccent}
|
|
37
40
|
badge={hero.badge}
|
|
38
41
|
primaryCta={hero.primaryCta}
|
|
39
42
|
secondaryCta={hero.secondaryCta}
|
|
40
43
|
heroImage={hero.heroImage}
|
|
44
|
+
rotationInterval={hero.rotationInterval}
|
|
41
45
|
onAddToCart={(product) => {
|
|
42
46
|
// Product-card shortcut: add the first purchasable variant.
|
|
43
47
|
set('/lastClicked', product)
|
|
@@ -47,34 +51,54 @@ export const registry: ViewRegistry = {
|
|
|
47
51
|
set('/lastClicked', product)
|
|
48
52
|
emit('openProduct')
|
|
49
53
|
}}
|
|
50
|
-
onSelectColor={() => {}}
|
|
51
54
|
/>
|
|
52
55
|
)
|
|
53
56
|
},
|
|
54
57
|
Feature: ({ props }) => {
|
|
55
|
-
const feature =
|
|
58
|
+
const feature = featureSchemas.featureCardsSpecSchema.parse({
|
|
59
|
+
...props,
|
|
60
|
+
presentation: 'cards',
|
|
61
|
+
})
|
|
56
62
|
return (
|
|
57
63
|
<FeatureBlock
|
|
58
64
|
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
65
|
+
presentation='cards'
|
|
59
66
|
badge={feature.badge}
|
|
60
67
|
title={feature.title}
|
|
61
68
|
description={feature.description}
|
|
69
|
+
ctaLabel={feature.ctaLabel}
|
|
70
|
+
learnMoreLabel={feature.learnMoreLabel}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
CategoryCard: ({ props, emit }) => {
|
|
75
|
+
const { set } = useStateStore()
|
|
76
|
+
const card = categoryCardPropsSchema.parse(props)
|
|
77
|
+
return (
|
|
78
|
+
<CategoryCardBlock
|
|
79
|
+
{...card}
|
|
80
|
+
onBrowse={(category) => {
|
|
81
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
82
|
+
emit('openCategory')
|
|
83
|
+
}}
|
|
62
84
|
/>
|
|
63
85
|
)
|
|
64
86
|
},
|
|
65
|
-
|
|
87
|
+
CategoryGrid: ({ props, emit }) => {
|
|
66
88
|
const { set } = useStateStore()
|
|
67
|
-
const
|
|
89
|
+
const grid = categoryGridPropsSchema.parse(props)
|
|
68
90
|
return (
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
description={cards.description}
|
|
72
|
-
categories={cards.categories}
|
|
73
|
-
cta={cards.cta}
|
|
91
|
+
<CategoryGridBlock
|
|
92
|
+
{...grid}
|
|
74
93
|
onBrowse={(category) => {
|
|
75
94
|
set('/lastCategory', category.handle ?? String(category.id))
|
|
76
95
|
emit('openCategory')
|
|
77
96
|
}}
|
|
97
|
+
onViewAll={() => {
|
|
98
|
+
set('/lastCategory', '/categories')
|
|
99
|
+
emit('openCategory')
|
|
100
|
+
}}
|
|
101
|
+
onQueryChange={(query) => set('/categoryQuery', query)}
|
|
78
102
|
/>
|
|
79
103
|
)
|
|
80
104
|
},
|