@thorprovider/storefront 0.4.0 → 0.6.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 +3 -1
- package/assets/templates/app/app/[[...slug]]/page.tsx +19 -1
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +20 -30
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +15 -13
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +34 -4
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +14 -15
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +26 -19
- package/assets/templates/features/checkout/state.ts +0 -5
- package/assets/templates/views/account/content.ts +14 -3
- package/assets/templates/views/account/index.tsx +1 -1
- package/assets/templates/views/account/registry.tsx +135 -104
- package/assets/templates/views/account/schema.ts +26 -6
- package/assets/templates/views/category/assembly/assembly.json +1 -1
- package/assets/templates/views/category/assembly/index.skeleton.tsx +11 -7
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +8 -8
- 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 +17 -13
- 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 +10 -6
- package/assets/templates/views/checkout/schema.ts +10 -16
- package/assets/templates/views/home/assembly/index.skeleton.tsx +0 -2
- package/assets/templates/views/home/index.tsx +0 -2
- package/assets/templates/views/product/registry.tsx +112 -14
- package/assets/templates/views/product/schema.ts +42 -7
- package/bin/storefront.js +21 -0
- package/examples/merchandising/category-led.json +1 -1
- package/examples/merchandising/collection-led.json +1 -1
- package/package.json +2 -1
- package/recipes/archetypes.json +27 -27
- package/recipes/catalog.json +43 -105
- package/recipes/features.json +2 -2
- package/recipes/recipes.json +10 -16
- package/recipes/sections.json +2 -2
- package/scripts/candidate.mjs +263 -6
- package/scripts/composers.mjs +2 -2
- package/scripts/logical-controls.mjs +4 -4
- package/scripts/operation-registry.mjs +1 -1
- package/scripts/view-assembly.mjs +2 -2
- package/skills/sf-view-gen/assets/recipes/archetypes.json +27 -27
- package/skills/sf-view-gen/assets/recipes/catalog.json +43 -105
- package/skills/sf-view-gen/assets/recipes/features.json +2 -2
- package/skills/sf-view-gen/assets/recipes/recipes.json +10 -16
- package/skills/sf-view-gen/assets/recipes/sections.json +2 -2
- package/skills/sf-view-gen/assets/templates/views/sections/schema.testimonials.ts +21 -11
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +2 -8
- package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/catalog.part +0 -5
package/README.md
CHANGED
|
@@ -453,6 +453,8 @@ surface and footer copy are configured without touching derived files. Configure
|
|
|
453
453
|
and the scaffold ships no submit callback, so a content-only newsletter renders no form
|
|
454
454
|
— never a fake form. `shippingNote` defaults to `''`: while it is empty (and there are
|
|
455
455
|
no utility links) the navbar renders no utility strip, so no placeholder note is shown.
|
|
456
|
+
The generated footer uses canonical `FooterSection` with `brand-columns` and
|
|
457
|
+
native link behavior; numbered footer adapters are no longer part of the Blocks API.
|
|
456
458
|
|
|
457
459
|
A view's derived `index.tsx` imports the user-owned `content.ts`/`props.ts`/
|
|
458
460
|
`data.ts`, so a customization changes real spec/loader output and survives `sync`.
|
|
@@ -497,4 +499,4 @@ of the contract with consumers: revisit them whenever the CLI surface changes
|
|
|
497
499
|
(flags, actions, validation) or the scaffold's preconditions change (target-directory
|
|
498
500
|
rules, linker, backend variables), and update the corresponding entry in
|
|
499
501
|
`packages/storefront/README.md`. The packaging test suite asserts these
|
|
500
|
-
sections and that every failure-mode entry carries a remedy.
|
|
502
|
+
sections and that every failure-mode entry carries a remedy.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { notFound } from 'next/navigation'
|
|
4
4
|
import { buildBreadcrumbListJsonLd, serializeJsonLd } from '@thorprovider/runtime/contracts'
|
|
5
|
+
import { getCatalog } from '@thorprovider/runtime/commerce'
|
|
5
6
|
import { __STOREFRONT_CAMEL__App } from '@/lib/__STOREFRONT__/runtime'
|
|
6
7
|
import { readCartStateForRender } from '@/lib/__STOREFRONT__/cart-state'
|
|
7
8
|
import { readAccountSession } from '@/lib/__STOREFRONT__/account-session'
|
|
@@ -23,6 +24,18 @@ export default async function Page({
|
|
|
23
24
|
const data = await __STOREFRONT_CAMEL__App.getPageData({ params, searchParams })
|
|
24
25
|
if (!data) return notFound()
|
|
25
26
|
|
|
27
|
+
// The shared shell is rendered for every route, so resolve its category links
|
|
28
|
+
// here rather than relying on a particular view loader. `getCatalog()` is
|
|
29
|
+
// request-cached by the commerce bridge and is shared with the view loader.
|
|
30
|
+
let navCategories: { label: string; href: string }[] = []
|
|
31
|
+
try {
|
|
32
|
+
navCategories = (await getCatalog()).categories.map(({ label, href }) => ({ label, href }))
|
|
33
|
+
} catch (error) {
|
|
34
|
+
// A failed catalog read must not invent links or take down otherwise usable
|
|
35
|
+
// page content; keep the shell empty and leave a diagnostic for operators.
|
|
36
|
+
console.error('[storefront] Failed to resolve shared navigation categories', error)
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
// Read the signed cookie and load the backend cart for the initial render.
|
|
27
40
|
// This never creates a cart; a guest identity is issued by a Server Action.
|
|
28
41
|
const cartState = await readCartStateForRender()
|
|
@@ -36,7 +49,12 @@ export default async function Page({
|
|
|
36
49
|
? toAccountInitialState(await readAccountSession())
|
|
37
50
|
: {}
|
|
38
51
|
|
|
39
|
-
const initialState = {
|
|
52
|
+
const initialState = {
|
|
53
|
+
...(data.initialState ?? {}),
|
|
54
|
+
navCategories,
|
|
55
|
+
...cartState,
|
|
56
|
+
...accountState,
|
|
57
|
+
}
|
|
40
58
|
|
|
41
59
|
// Entity structured data is server-rendered from the real loaded entity and
|
|
42
60
|
// sanitized so entity text cannot terminate the script element.
|
|
@@ -541,26 +541,9 @@ export async function loadCustomer(token: string | null): Promise<Customer | nul
|
|
|
541
541
|
// The host never talks to the backend SDK directly. `getCustomerOrders`
|
|
542
542
|
// delegates to `@thorprovider/runtime/commerce`, which builds a request-scoped
|
|
543
543
|
// provider carrying exactly the caller's token. The boundary maps the backend
|
|
544
|
-
// orders to a serializable
|
|
545
|
-
// own `currencyCode
|
|
546
|
-
// backend omits is omitted, never invented.
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* Format backend Money for display from its own currency, or undefined when the
|
|
550
|
-
* amount is absent/blank/non-finite. The decimal-string amount is already in
|
|
551
|
-
* major units, so it is never divided by 100.
|
|
552
|
-
*/
|
|
553
|
-
function formatMoney(money?: Money): string | undefined {
|
|
554
|
-
if (!money) return undefined
|
|
555
|
-
const amount = money.amount
|
|
556
|
-
if (typeof amount !== 'string' || amount.trim() === '') return undefined
|
|
557
|
-
const value = Number(amount)
|
|
558
|
-
if (!Number.isFinite(value)) return undefined
|
|
559
|
-
return new Intl.NumberFormat(undefined, {
|
|
560
|
-
style: 'currency',
|
|
561
|
-
currency: money.currencyCode,
|
|
562
|
-
}).format(value)
|
|
563
|
-
}
|
|
544
|
+
// orders to a serializable shape: amounts cross as canonical `Money` (the
|
|
545
|
+
// backend decimal plus its own `currencyCode`, never divided by 100) so the
|
|
546
|
+
// block formats them, and a field the backend omits is omitted, never invented.
|
|
564
547
|
|
|
565
548
|
/** Format an ISO timestamp as a locale date, or return the raw value unchanged. */
|
|
566
549
|
function formatOrderDate(value: string): string {
|
|
@@ -580,13 +563,18 @@ function formatAddress(address: Order['shippingAddress']): string | undefined {
|
|
|
580
563
|
return parts.join(', ')
|
|
581
564
|
}
|
|
582
565
|
|
|
583
|
-
/**
|
|
566
|
+
/**
|
|
567
|
+
* Map one backend order line to its account view, omitting absent optional
|
|
568
|
+
* fields. The backend `lineTotal` crosses the boundary as canonical `Money`: a
|
|
569
|
+
* preformatted string would drop the currency code the block needs to format
|
|
570
|
+
* the amount in the shopper's locale.
|
|
571
|
+
*/
|
|
584
572
|
export function toAccountOrderItemView(item: Order['items'][number]): AccountOrderItemView {
|
|
585
573
|
const view: AccountOrderItemView = {
|
|
586
574
|
id: item.id,
|
|
587
575
|
name: item.title,
|
|
588
576
|
quantity: item.quantity,
|
|
589
|
-
lineTotal:
|
|
577
|
+
lineTotal: item.total,
|
|
590
578
|
}
|
|
591
579
|
if (typeof item.variantTitle === 'string' && item.variantTitle.trim() !== '') {
|
|
592
580
|
view.variant = item.variantTitle
|
|
@@ -596,22 +584,24 @@ export function toAccountOrderItemView(item: Order['items'][number]): AccountOrd
|
|
|
596
584
|
return view
|
|
597
585
|
}
|
|
598
586
|
|
|
599
|
-
/**
|
|
587
|
+
/**
|
|
588
|
+
* Map a backend order to the account view row, omitting absent optional fields.
|
|
589
|
+
* Amounts pass through as canonical `Money` so the block — not this boundary —
|
|
590
|
+
* owns formatting and the unavailable state; an absent optional amount is
|
|
591
|
+
* omitted rather than serialized as `''`.
|
|
592
|
+
*/
|
|
600
593
|
export function toAccountOrderView(order: Order): AccountOrderView {
|
|
601
594
|
const view: AccountOrderView = {
|
|
602
595
|
id: order.id,
|
|
603
596
|
number: order.orderNumber,
|
|
604
597
|
date: formatOrderDate(order.createdAt),
|
|
605
598
|
status: order.status,
|
|
606
|
-
total:
|
|
599
|
+
total: order.total,
|
|
607
600
|
items: order.items.map(toAccountOrderItemView),
|
|
608
601
|
}
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
if (tax !== undefined) view.tax = tax
|
|
613
|
-
const shipping = formatMoney(order.shipping)
|
|
614
|
-
if (shipping !== undefined) view.shipping = shipping
|
|
602
|
+
if (order.subtotal !== undefined) view.subtotal = order.subtotal
|
|
603
|
+
if (order.tax !== undefined) view.tax = order.tax
|
|
604
|
+
if (order.shipping !== undefined) view.shipping = order.shipping
|
|
615
605
|
const address = formatAddress(order.shippingAddress)
|
|
616
606
|
if (address !== undefined) view.address = address
|
|
617
607
|
return view
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Installed manifest catalog features, in stable order, with their persisted
|
|
4
4
|
// config. This is the generation seam the catalog URL boundary consumes to
|
|
5
5
|
// reject parameters owned by a feature that is not installed, and the seam the
|
|
6
|
-
// single controlled
|
|
6
|
+
// single controlled CategoryListing reads to select its control
|
|
7
7
|
// visibility/config from the installed manifest only.
|
|
8
8
|
|
|
9
9
|
import type { CatalogFeatureName } from '@thorprovider/runtime/contracts'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Generated by Thor Commerce storefront (template: assets/templates/app/lib/__STOREFRONT__/registry.tsx)
|
|
4
4
|
// Base registry for the app shell plus every registered view's registry fragment.
|
|
5
5
|
//
|
|
6
|
-
// The shell renders the live backend cart: the
|
|
6
|
+
// The shell renders the live backend cart: the StorefrontNavbar mini-cart and the cart
|
|
7
7
|
// drawer read the authoritative cart state and dispatch cart mutations to the
|
|
8
8
|
// Server Actions. A listing card's add-to-cart adds the product's first
|
|
9
9
|
// purchasable variant (the card shortcut); opening a product from a listing
|
|
@@ -16,9 +16,7 @@ import { BackToTop as BackToTopBlock } from '@thorprovider/blocks/blocks/e-comme
|
|
|
16
16
|
import { MobileBottomNav as MobileBottomNavBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
17
17
|
import { SkipToContent as SkipToContentBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
|
|
18
18
|
import Banner1 from '@thorprovider/blocks/blocks/marketing/banners/banner-1'
|
|
19
|
-
import
|
|
20
|
-
import Navbar1 from '@thorprovider/blocks/blocks/marketing/navbars/navbar-1'
|
|
21
|
-
import Navbar4 from '@thorprovider/blocks/blocks/marketing/navbars/navbar-4'
|
|
19
|
+
import { FooterSection, Navbar, StorefrontNavbar } from '@thorprovider/blocks'
|
|
22
20
|
import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
|
|
23
21
|
import type { BackToTopProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
|
|
24
22
|
import type { MobileBottomNavProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
@@ -40,7 +38,7 @@ import {
|
|
|
40
38
|
} from './schema'
|
|
41
39
|
import { viewRegistries } from './views/registry'
|
|
42
40
|
|
|
43
|
-
//
|
|
41
|
+
// StorefrontNavbar accepts its own mini-cart line shape (`qty`), distinct from the block
|
|
44
42
|
// `CartItem` contract (`quantity`). Types are local so the asymmetry is explicit.
|
|
45
43
|
interface NavCartItem {
|
|
46
44
|
id: string
|
|
@@ -52,7 +50,7 @@ interface NavCartItem {
|
|
|
52
50
|
lineTotal?: Money
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
/** CartLineState ->
|
|
53
|
+
/** CartLineState -> StorefrontNavbar cart line. `price` is legacy; the authoritative
|
|
56
54
|
* subtotal and per-line total are passed separately, so neither is computed
|
|
57
55
|
* from the line. */
|
|
58
56
|
function toNavCartItems(cart: CartLineState[]): NavCartItem[] {
|
|
@@ -179,7 +177,7 @@ const baseComponents = {
|
|
|
179
177
|
isAvailableMoney(totals.subtotal) &&
|
|
180
178
|
isAvailableMoney(totals.total)
|
|
181
179
|
return (
|
|
182
|
-
<
|
|
180
|
+
<StorefrontNavbar
|
|
183
181
|
storeCategories={parsed.storeCategories}
|
|
184
182
|
shippingNote={parsed.shippingNote}
|
|
185
183
|
utilityLinks={parsed.utilityLinks}
|
|
@@ -259,18 +257,20 @@ const baseComponents = {
|
|
|
259
257
|
/>
|
|
260
258
|
)
|
|
261
259
|
},
|
|
262
|
-
Navbar: ({ props
|
|
260
|
+
Navbar: ({ props }: { props: Record<string, unknown>; emit: (event: string) => void }) => {
|
|
263
261
|
const parsed = navbarPropsSchema.parse(props)
|
|
264
262
|
return (
|
|
265
|
-
<
|
|
266
|
-
|
|
263
|
+
<Navbar
|
|
264
|
+
presentation={parsed.presentation}
|
|
267
265
|
logoText={parsed.logoText}
|
|
268
266
|
logoHref={parsed.logoHref}
|
|
269
267
|
currentPath={parsed.currentPath}
|
|
268
|
+
links={parsed.links}
|
|
269
|
+
featured={parsed.featured}
|
|
270
270
|
signIn={parsed.signIn}
|
|
271
271
|
cta={parsed.cta}
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
// Page-level navigation owns no commerce state: the cart affordance and
|
|
273
|
+
// its `openCart` intent belong to the StorefrontNavbar shell (D5).
|
|
274
274
|
/>
|
|
275
275
|
)
|
|
276
276
|
},
|
|
@@ -307,12 +307,14 @@ const baseComponents = {
|
|
|
307
307
|
Footer: ({ props }: { props: Record<string, unknown> }) => {
|
|
308
308
|
const parsed = footerPropsSchema.parse(props)
|
|
309
309
|
return (
|
|
310
|
-
<
|
|
310
|
+
<FooterSection
|
|
311
|
+
presentation="brand-columns"
|
|
311
312
|
brandName={parsed.brandName}
|
|
312
313
|
brandAccent={parsed.brandAccent}
|
|
313
314
|
brandDescription={parsed.brandDescription}
|
|
314
315
|
linkColumns={parsed.linkColumns}
|
|
315
316
|
className={parsed.className}
|
|
317
|
+
linkBehavior="native"
|
|
316
318
|
// The scaffold ships no newsletter submit callback. The seam's
|
|
317
319
|
// `newsletter` is content only, so the block swallows it and renders no
|
|
318
320
|
// form. Wiring a real host callback (which would enable the form) is an
|
|
@@ -11,9 +11,34 @@ export const ctaSchema = z.object({
|
|
|
11
11
|
href: z.string().optional(),
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const navbarItemSchema = z.object({
|
|
15
|
+
label: z.string(),
|
|
16
|
+
href: z.string(),
|
|
17
|
+
description: z.string().optional(),
|
|
18
|
+
/** Key resolved through the shell's host-bound icon map. */
|
|
19
|
+
icon: z.string().optional(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const navbarGroupSchema = z.object({
|
|
23
|
+
title: z.string().optional(),
|
|
24
|
+
items: z.array(navbarItemSchema),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const navbarLinkSchema = z.object({
|
|
15
28
|
label: z.string(),
|
|
16
29
|
href: z.string().optional(),
|
|
30
|
+
groups: z.array(navbarGroupSchema).optional(),
|
|
31
|
+
emphasis: z.boolean().optional(),
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export const navbarFeaturedSchema = z.object({
|
|
35
|
+
eyebrow: z.string(),
|
|
36
|
+
title: z.string(),
|
|
37
|
+
description: z.string().optional(),
|
|
38
|
+
href: z.string(),
|
|
39
|
+
linkLabel: z.string().optional(),
|
|
40
|
+
image: z.string().optional(),
|
|
41
|
+
imageAlt: z.string().optional(),
|
|
17
42
|
})
|
|
18
43
|
|
|
19
44
|
const footerLinkSchema = z.object({
|
|
@@ -45,14 +70,19 @@ export const productPresentationSchema = z.object({
|
|
|
45
70
|
badge: z.string().optional(),
|
|
46
71
|
})
|
|
47
72
|
|
|
73
|
+
// Mirrors the canonical page-level `Navbar` contract. Presentation is bounded to
|
|
74
|
+
// `bar`/`mega`/`floating`; the cart and account affordances belong to the
|
|
75
|
+
// `StorefrontNavbar` shell below, so no cart prop exists here.
|
|
48
76
|
export const navbarPropsSchema = z.object({
|
|
49
|
-
|
|
77
|
+
presentation: z.enum(['bar', 'mega', 'floating']).optional(),
|
|
50
78
|
logoText: z.string(),
|
|
51
79
|
logoHref: z.string().optional(),
|
|
52
80
|
currentPath: z.string().optional(),
|
|
81
|
+
links: z.array(navbarLinkSchema),
|
|
82
|
+
featured: navbarFeaturedSchema.optional(),
|
|
53
83
|
signIn: ctaSchema.optional(),
|
|
54
84
|
cta: ctaSchema.optional(),
|
|
55
|
-
|
|
85
|
+
className: z.string().optional(),
|
|
56
86
|
})
|
|
57
87
|
|
|
58
88
|
// Mirrors the StorefrontNavbar block contract in this scaffold. `storeCategories`
|
|
@@ -65,7 +95,7 @@ export const navCategorySchema = z.object({
|
|
|
65
95
|
emphasis: z.boolean().optional(),
|
|
66
96
|
})
|
|
67
97
|
|
|
68
|
-
// Optional brand seam mirroring the
|
|
98
|
+
// Optional brand seam mirroring the StorefrontNavbar / FooterSection accent props and
|
|
69
99
|
// the StorefrontHero editorial image. Declared locally (see
|
|
70
100
|
// productPresentationSchema) so the scaffold's zod version is the only one in
|
|
71
101
|
// play.
|
|
@@ -24,7 +24,7 @@ export const navbarShellProps = {
|
|
|
24
24
|
// Global navigation search is held until a verified backend search contract
|
|
25
25
|
// exists (E2 task 5.4), so the generated storefront presents NO search
|
|
26
26
|
// control. A merchant may set this to `true` to opt in once the contract is
|
|
27
|
-
// verified; the `
|
|
27
|
+
// verified; the `StorefrontNavbar` block still defaults to visible for legacy
|
|
28
28
|
// consumers that do not set this prop.
|
|
29
29
|
showSearch: false,
|
|
30
30
|
}
|
|
@@ -52,7 +52,7 @@ export interface CartTotalsState {
|
|
|
52
52
|
total: Money
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/** Mirrors the
|
|
55
|
+
/** Mirrors the canonical Checkout values contract (no card fields). */
|
|
56
56
|
export interface CheckoutFormData {
|
|
57
57
|
email: string
|
|
58
58
|
firstName: string
|
|
@@ -64,12 +64,7 @@ export interface CheckoutFormData {
|
|
|
64
64
|
zipCode: string
|
|
65
65
|
country: string
|
|
66
66
|
paymentMethod: string
|
|
67
|
-
cardNumber: string
|
|
68
|
-
expiryDate: string
|
|
69
|
-
cvv: string
|
|
70
|
-
cardName: string
|
|
71
67
|
saveInfo: boolean
|
|
72
|
-
sameAsBilling: boolean
|
|
73
68
|
newsletter: boolean
|
|
74
69
|
promoCode: string
|
|
75
70
|
}
|
|
@@ -110,19 +105,23 @@ export interface StorefrontOrderLineView {
|
|
|
110
105
|
image?: string
|
|
111
106
|
}
|
|
112
107
|
|
|
113
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* A single line of a customer order-history row. Amounts stay canonical
|
|
110
|
+
* `Money` (backend identity included) so the block formats them from their own
|
|
111
|
+
* currency; formatting at the boundary would lose the currency code.
|
|
112
|
+
*/
|
|
114
113
|
export interface AccountOrderItemView {
|
|
115
114
|
id: string
|
|
116
115
|
name: string
|
|
117
116
|
variant?: string
|
|
118
117
|
quantity: number
|
|
119
|
-
lineTotal:
|
|
118
|
+
lineTotal: Money
|
|
120
119
|
image?: string
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
/**
|
|
124
123
|
* A customer order-history row, mapped from the backend order for the account
|
|
125
|
-
* view.
|
|
124
|
+
* view. Amounts are carried as canonical `Money` (never preformatted strings);
|
|
126
125
|
* an optional field the backend omits is omitted, never invented.
|
|
127
126
|
*/
|
|
128
127
|
export interface AccountOrderView {
|
|
@@ -130,10 +129,10 @@ export interface AccountOrderView {
|
|
|
130
129
|
number: string
|
|
131
130
|
date: string
|
|
132
131
|
status: string
|
|
133
|
-
total:
|
|
134
|
-
subtotal?:
|
|
135
|
-
tax?:
|
|
136
|
-
shipping?:
|
|
132
|
+
total: Money
|
|
133
|
+
subtotal?: Money
|
|
134
|
+
tax?: Money
|
|
135
|
+
shipping?: Money
|
|
137
136
|
address?: string
|
|
138
137
|
items: AccountOrderItemView[]
|
|
139
138
|
}
|
|
@@ -167,7 +166,8 @@ export interface StorefrontCoreState {
|
|
|
167
166
|
heroProducts: FeaturedProduct[]
|
|
168
167
|
categories: ProductCategoryItem[]
|
|
169
168
|
categoryQuery: string
|
|
170
|
-
|
|
169
|
+
/** Seeded by the catch-all host so a missing navigation source cannot look empty. */
|
|
170
|
+
navCategories?: NavCategory[]
|
|
171
171
|
categoryProducts: CardProduct[]
|
|
172
172
|
/** Canonical product detail: real variants, options, availability, and Money. */
|
|
173
173
|
selectedProduct: ProductDetailProduct | null
|
|
@@ -231,7 +231,6 @@ export const storefrontCoreState: StorefrontCoreState = {
|
|
|
231
231
|
heroProducts: [],
|
|
232
232
|
categories: [],
|
|
233
233
|
categoryQuery: '',
|
|
234
|
-
navCategories: [],
|
|
235
234
|
categoryProducts: [],
|
|
236
235
|
selectedProduct: null,
|
|
237
236
|
selectedVariantId: null,
|
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
// Optional section fragment: testimonials (mirrors recipes/sections.json)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { TestimonialSection } from '@thorprovider/blocks'
|
|
4
4
|
import { z } from 'zod'
|
|
5
5
|
|
|
6
|
-
// Mirrors the Testimonial1Item/Testimonial1Props block contracts.
|
|
7
6
|
const testimonialItemSchema = z.object({
|
|
8
7
|
id: z.string(),
|
|
9
8
|
name: z.string(),
|
|
10
|
-
role: z.string(),
|
|
11
|
-
avatar: z.string(),
|
|
12
9
|
content: z.string(),
|
|
13
|
-
|
|
10
|
+
role: z.string().optional(),
|
|
11
|
+
avatar: z.string().optional(),
|
|
12
|
+
rating: z.number().optional(),
|
|
14
13
|
})
|
|
15
14
|
|
|
16
|
-
const testimonialsPropsSchema = z.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
const testimonialsPropsSchema = z.discriminatedUnion('presentation', [
|
|
16
|
+
z.object({
|
|
17
|
+
presentation: z.literal('carousel'),
|
|
18
|
+
carouselLabels: z.object({
|
|
19
|
+
previous: z.string(),
|
|
20
|
+
next: z.string(),
|
|
21
|
+
slide: z.string(),
|
|
22
|
+
}),
|
|
23
|
+
items: z.array(testimonialItemSchema),
|
|
24
|
+
title: z.string().optional(),
|
|
25
|
+
description: z.string().optional(),
|
|
26
|
+
className: z.string().optional(),
|
|
27
|
+
}),
|
|
28
|
+
z.object({
|
|
29
|
+
presentation: z.literal('bento'),
|
|
30
|
+
items: z.array(testimonialItemSchema),
|
|
31
|
+
title: z.string().optional(),
|
|
32
|
+
description: z.string().optional(),
|
|
33
|
+
className: z.string().optional(),
|
|
34
|
+
}),
|
|
35
|
+
])
|
|
23
36
|
|
|
24
37
|
export const testimonialsSection = {
|
|
25
38
|
elementType: 'Testimonials',
|
|
@@ -33,13 +46,7 @@ export const testimonialsSection = {
|
|
|
33
46
|
Testimonials: ({ props }: { props: Record<string, unknown> }) => {
|
|
34
47
|
const parsed = testimonialsPropsSchema.parse(props)
|
|
35
48
|
return (
|
|
36
|
-
<
|
|
37
|
-
title={parsed.title ?? 'Lo que dicen nuestros clientes'}
|
|
38
|
-
items={parsed.items}
|
|
39
|
-
prevLabel={parsed.prevLabel ?? 'Anterior'}
|
|
40
|
-
nextLabel={parsed.nextLabel ?? 'Siguiente'}
|
|
41
|
-
slideAriaLabel={parsed.slideAriaLabel ?? 'Testimonio'}
|
|
42
|
-
/>
|
|
49
|
+
<TestimonialSection {...parsed} />
|
|
43
50
|
)
|
|
44
51
|
},
|
|
45
52
|
},
|
|
@@ -22,12 +22,7 @@ const checkoutFormDefaults: CheckoutFormData = {
|
|
|
22
22
|
zipCode: '',
|
|
23
23
|
country: '',
|
|
24
24
|
paymentMethod: '',
|
|
25
|
-
cardNumber: '',
|
|
26
|
-
expiryDate: '',
|
|
27
|
-
cvv: '',
|
|
28
|
-
cardName: '',
|
|
29
25
|
saveInfo: false,
|
|
30
|
-
sameAsBilling: false,
|
|
31
26
|
newsletter: false,
|
|
32
27
|
promoCode: '',
|
|
33
28
|
}
|
|
@@ -26,9 +26,20 @@ export const accountContent = {
|
|
|
26
26
|
signInLabel: 'Inicia sesión',
|
|
27
27
|
},
|
|
28
28
|
orders: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Canonical `OrderHistory` labels: every string the block renders is owned
|
|
30
|
+
// here, and `{number}` / `{date}` / `{n}` interpolate backend data.
|
|
31
|
+
labels: {
|
|
32
|
+
title: 'Mis pedidos',
|
|
33
|
+
description: 'Consulta tus pedidos anteriores',
|
|
34
|
+
orderLabel: 'Pedido {number}',
|
|
35
|
+
placedOnLabel: 'Realizado el {date}',
|
|
36
|
+
quantityLabel: 'Cantidad: {n}',
|
|
37
|
+
totalLabel: 'Total del pedido',
|
|
38
|
+
viewOrderLabel: 'Ver pedido',
|
|
39
|
+
trackOrderLabel: 'Seguir pedido',
|
|
40
|
+
amountUnavailableLabel: '—',
|
|
41
|
+
emptyLabel: 'Aún no tienes pedidos.',
|
|
42
|
+
},
|
|
32
43
|
errorLabel: 'No se pudieron cargar tus pedidos.',
|
|
33
44
|
loadingLabel: 'Cargando pedidos…',
|
|
34
45
|
},
|
|
@@ -97,7 +97,7 @@ const catalog = {
|
|
|
97
97
|
AccountOrders: {
|
|
98
98
|
props: accountOrdersPropsSchema,
|
|
99
99
|
description:
|
|
100
|
-
"Signed-in customer's order history rendered by
|
|
100
|
+
"Signed-in customer's order history rendered by the canonical `OrderHistory` block (cards) with canonical Money amounts: the block owns the empty state, the host owns loading/error and an inline order detail.",
|
|
101
101
|
},
|
|
102
102
|
}
|
|
103
103
|
|