@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
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Pure confirmation mapping: canonical Order → designer confirmation model.
|
|
2
|
+
// Always present, independent of whether the checkout view is installed. The
|
|
3
|
+
// host-confirmed order is the only source; optional fields are omitted when the
|
|
4
|
+
// backend does not report them. No React, Next, or view imports.
|
|
5
|
+
|
|
6
|
+
import type { Address, Money, Order } from '@thorprovider/types'
|
|
7
|
+
import { APPROVED_MANUAL_TEST_PROVIDER_ID } from '@thorprovider/runtime/commerce'
|
|
8
|
+
|
|
9
|
+
export interface StorefrontConfirmationAddress {
|
|
10
|
+
id: string
|
|
11
|
+
isDefault: boolean
|
|
12
|
+
label: string
|
|
13
|
+
recipient: string
|
|
14
|
+
line1: string
|
|
15
|
+
line2?: string
|
|
16
|
+
company?: string
|
|
17
|
+
city: string
|
|
18
|
+
province?: string
|
|
19
|
+
countryCode?: string
|
|
20
|
+
postalCode?: string
|
|
21
|
+
phone?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface StorefrontConfirmationLine {
|
|
25
|
+
lineId: string
|
|
26
|
+
title: string
|
|
27
|
+
variant?: string
|
|
28
|
+
image?: string
|
|
29
|
+
unitCents?: number
|
|
30
|
+
quantity: number
|
|
31
|
+
netTotalCents?: number
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface StorefrontConfirmationGroup {
|
|
35
|
+
id: string
|
|
36
|
+
title: string
|
|
37
|
+
modeLabel: string
|
|
38
|
+
methodLabel: string
|
|
39
|
+
detailLabel: string
|
|
40
|
+
feeCents: number
|
|
41
|
+
lines: StorefrontConfirmationLine[]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface StorefrontConfirmationPromotion {
|
|
45
|
+
id: string
|
|
46
|
+
label: string
|
|
47
|
+
kind: string
|
|
48
|
+
amountCents: number
|
|
49
|
+
code?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface StorefrontConfirmation {
|
|
53
|
+
reference: string
|
|
54
|
+
totalCents: number
|
|
55
|
+
subtotalCents: number
|
|
56
|
+
unitCount?: number
|
|
57
|
+
promotions?: StorefrontConfirmationPromotion[]
|
|
58
|
+
taxCents?: number
|
|
59
|
+
taxRateBps?: number
|
|
60
|
+
shippingCents?: number
|
|
61
|
+
pickupCents?: number
|
|
62
|
+
extraCents?: number
|
|
63
|
+
extraLabel?: string
|
|
64
|
+
groups: StorefrontConfirmationGroup[]
|
|
65
|
+
address: StorefrontConfirmationAddress | null
|
|
66
|
+
paymentLabel: string
|
|
67
|
+
paymentDetail: string
|
|
68
|
+
billingLabel: string
|
|
69
|
+
billingDetail: string
|
|
70
|
+
customerName: string
|
|
71
|
+
customerEmail: string
|
|
72
|
+
locale: string
|
|
73
|
+
currencyCode: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Canonical decimal Money → integer display cents; no rounding beyond cents. */
|
|
77
|
+
export function moneyToCents(value: Money | null | undefined): number | undefined {
|
|
78
|
+
if (!value || !value.currencyCode.trim()) return undefined
|
|
79
|
+
const match = /^(-?)(\d+)(?:\.(\d+))?$/.exec(value.amount.trim())
|
|
80
|
+
if (!match) return undefined
|
|
81
|
+
const [, sign, whole, fraction = ''] = match
|
|
82
|
+
let cents = BigInt(whole) * BigInt(100) + BigInt((fraction + '00').slice(0, 2))
|
|
83
|
+
if (fraction.length > 2 && fraction[2]! >= '5') cents += BigInt(1)
|
|
84
|
+
if (sign === '-') cents = -cents
|
|
85
|
+
if (cents > BigInt(Number.MAX_SAFE_INTEGER) || cents < BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
86
|
+
return undefined
|
|
87
|
+
}
|
|
88
|
+
return Number(cents)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function addressDetail(address: Address): string {
|
|
92
|
+
return [
|
|
93
|
+
address.address1,
|
|
94
|
+
address.address2,
|
|
95
|
+
address.city,
|
|
96
|
+
address.province,
|
|
97
|
+
address.postalCode,
|
|
98
|
+
address.countryCode,
|
|
99
|
+
]
|
|
100
|
+
.filter((value): value is string => typeof value === 'string' && value.trim() !== '')
|
|
101
|
+
.join(', ')
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function normalizeImageUrl(url: string | null | undefined): string | undefined {
|
|
105
|
+
if (typeof url !== 'string') return undefined
|
|
106
|
+
const trimmed = url.trim()
|
|
107
|
+
return trimmed === '' ? undefined : trimmed
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Build the designer confirmation from the host-confirmed order. The order is
|
|
112
|
+
* the single source: addresses, delivery method, payment label and totals are
|
|
113
|
+
* only included when the backend reports them; the view omits what is absent.
|
|
114
|
+
*/
|
|
115
|
+
export function toStorefrontConfirmation(order: Order): StorefrontConfirmation {
|
|
116
|
+
const shippingAddress = order.shippingAddress
|
|
117
|
+
const recipient = shippingAddress
|
|
118
|
+
? `${shippingAddress.firstName} ${shippingAddress.lastName}`.trim()
|
|
119
|
+
: ''
|
|
120
|
+
const customerName =
|
|
121
|
+
recipient ||
|
|
122
|
+
[order.customer?.firstName, order.customer?.lastName]
|
|
123
|
+
.filter((part): part is string => Boolean(part))
|
|
124
|
+
.join(' ') ||
|
|
125
|
+
'Cliente'
|
|
126
|
+
const total = moneyToCents(order.total) ?? 0
|
|
127
|
+
const subtotal = moneyToCents(order.subtotal) ?? 0
|
|
128
|
+
const tax = moneyToCents(order.tax)
|
|
129
|
+
// The order's backend shipping/pickup total is authoritative; a single
|
|
130
|
+
// method's amount never substitutes for it.
|
|
131
|
+
const shippingTotal = moneyToCents(order.shipping) ?? moneyToCents(order.shippingMethod?.amount)
|
|
132
|
+
const discount = moneyToCents(order.discount)
|
|
133
|
+
const billing = order.billingAddress
|
|
134
|
+
const lines: StorefrontConfirmationLine[] = order.items.map((item) => {
|
|
135
|
+
const unitCents = moneyToCents(item.price)
|
|
136
|
+
const netTotalCents = moneyToCents(item.total)
|
|
137
|
+
return {
|
|
138
|
+
lineId: item.id,
|
|
139
|
+
title: item.title,
|
|
140
|
+
variant: item.variantTitle,
|
|
141
|
+
image: normalizeImageUrl(item.image?.url),
|
|
142
|
+
unitCents,
|
|
143
|
+
quantity: item.quantity,
|
|
144
|
+
netTotalCents,
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
const linesById = new Map(lines.map((line) => [line.lineId, line]))
|
|
148
|
+
const pickup =
|
|
149
|
+
order.deliveryGroups?.length
|
|
150
|
+
? order.deliveryGroups.every((group) => group.mode === 'pickup')
|
|
151
|
+
: order.shippingMethod?.mode === 'pickup'
|
|
152
|
+
const paymentLabel =
|
|
153
|
+
order.payment?.providerId === APPROVED_MANUAL_TEST_PROVIDER_ID
|
|
154
|
+
? 'Pago manual TEST'
|
|
155
|
+
: order.payment?.label ?? ''
|
|
156
|
+
|
|
157
|
+
// One confirmation entry per confirmed backend group, preserving each
|
|
158
|
+
// group's mode, method, detail, fee and line membership. Line membership is
|
|
159
|
+
// rendered only from the order's own data; membership the order does not
|
|
160
|
+
// expose is never invented, and a line claimed ambiguously by more than one
|
|
161
|
+
// group is omitted from every entry instead of assigned arbitrarily.
|
|
162
|
+
const membershipCounts = new Map<string, number>()
|
|
163
|
+
for (const group of order.deliveryGroups ?? []) {
|
|
164
|
+
for (const lineId of group.lineIds ?? []) {
|
|
165
|
+
membershipCounts.set(lineId, (membershipCounts.get(lineId) ?? 0) + 1)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const confirmedGroups = order.deliveryGroups?.length
|
|
169
|
+
? order.deliveryGroups.map((group) => {
|
|
170
|
+
const pickupGroup = group.mode === 'pickup'
|
|
171
|
+
return {
|
|
172
|
+
id: group.id,
|
|
173
|
+
title: pickupGroup ? 'Recogida' : 'Entrega',
|
|
174
|
+
modeLabel: pickupGroup ? 'Recogida' : 'Envío a domicilio',
|
|
175
|
+
methodLabel: group.methodLabel ?? (pickupGroup ? 'Recogida' : 'Envío'),
|
|
176
|
+
detailLabel: group.methodDetail ?? '',
|
|
177
|
+
feeCents: moneyToCents(group.fee) ?? 0,
|
|
178
|
+
lines: (group.lineIds ?? [])
|
|
179
|
+
.filter((lineId) => membershipCounts.get(lineId) === 1)
|
|
180
|
+
.map((lineId) => linesById.get(lineId))
|
|
181
|
+
.filter((line): line is StorefrontConfirmationLine => line !== undefined),
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
: undefined
|
|
185
|
+
|
|
186
|
+
// Declared fallbacks for providers without group support: a single reported
|
|
187
|
+
// method is one group covering the whole order; without any method the
|
|
188
|
+
// delivery entry carries only the backend total, with no method claims.
|
|
189
|
+
const groups: StorefrontConfirmationGroup[] = confirmedGroups ?? [
|
|
190
|
+
{
|
|
191
|
+
id: 'delivery-1',
|
|
192
|
+
title: pickup ? 'Recogida' : 'Entrega',
|
|
193
|
+
modeLabel: pickup ? 'Recogida' : 'Envío a domicilio',
|
|
194
|
+
methodLabel: order.shippingMethod?.label ?? (pickup ? 'Recogida' : 'Envío'),
|
|
195
|
+
detailLabel: order.shippingMethod?.detail ?? '',
|
|
196
|
+
feeCents: moneyToCents(order.shippingMethod?.amount) ?? shippingTotal ?? 0,
|
|
197
|
+
lines,
|
|
198
|
+
},
|
|
199
|
+
]
|
|
200
|
+
return {
|
|
201
|
+
reference: order.orderNumber,
|
|
202
|
+
totalCents: total,
|
|
203
|
+
subtotalCents: subtotal,
|
|
204
|
+
unitCount: order.items.reduce((sum, item) => sum + item.quantity, 0),
|
|
205
|
+
promotions:
|
|
206
|
+
discount && discount > 0
|
|
207
|
+
? [{ id: 'discount', label: 'Descuento', kind: 'discount', amountCents: discount }]
|
|
208
|
+
: undefined,
|
|
209
|
+
taxCents: tax,
|
|
210
|
+
taxRateBps: order.taxRateBps,
|
|
211
|
+
shippingCents: shippingTotal,
|
|
212
|
+
groups,
|
|
213
|
+
address: shippingAddress
|
|
214
|
+
? {
|
|
215
|
+
id: 'order-shipping-address',
|
|
216
|
+
isDefault: false,
|
|
217
|
+
label: shippingAddress.label || 'Dirección de entrega',
|
|
218
|
+
recipient,
|
|
219
|
+
line1: shippingAddress.address1 ?? '',
|
|
220
|
+
line2: shippingAddress.address2,
|
|
221
|
+
company: shippingAddress.company,
|
|
222
|
+
city: shippingAddress.city,
|
|
223
|
+
province: shippingAddress.province,
|
|
224
|
+
countryCode: shippingAddress.countryCode,
|
|
225
|
+
postalCode: shippingAddress.postalCode,
|
|
226
|
+
phone: shippingAddress.phone,
|
|
227
|
+
}
|
|
228
|
+
: null,
|
|
229
|
+
paymentLabel,
|
|
230
|
+
paymentDetail: order.payment?.detail ?? '',
|
|
231
|
+
billingLabel: billing ? billing.label || 'Dirección de facturación' : '',
|
|
232
|
+
billingDetail: billing ? addressDetail(billing) : '',
|
|
233
|
+
customerName,
|
|
234
|
+
customerEmail: order.email,
|
|
235
|
+
// The storefront's money presentation uses the design's en-US dollar
|
|
236
|
+
// format; copy stays in the store language.
|
|
237
|
+
locale: 'en-US',
|
|
238
|
+
currencyCode: order.total.currencyCode,
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { PortError } from '@thorprovider/blocks/ports'
|
|
2
|
+
import type {
|
|
3
|
+
CustomerProfilePort,
|
|
4
|
+
CustomerProfileSnapshot,
|
|
5
|
+
ProfileDraft,
|
|
6
|
+
VerificationChannel,
|
|
7
|
+
} from '@thorprovider/blocks/ports'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
customFieldsFromDraft,
|
|
11
|
+
formatPhoneNumber,
|
|
12
|
+
preferencesFromDraft,
|
|
13
|
+
personalMetadataFromDraft,
|
|
14
|
+
professionalFromDraft,
|
|
15
|
+
toCustomerProfileSnapshot,
|
|
16
|
+
} from './account-profile'
|
|
17
|
+
import {
|
|
18
|
+
loadAccountProfileAction,
|
|
19
|
+
updateAccountProfileAction,
|
|
20
|
+
updateAccountProfileMetadataAction,
|
|
21
|
+
} from './actions'
|
|
22
|
+
|
|
23
|
+
function text(draft: ProfileDraft, key: string): string {
|
|
24
|
+
const value = draft[key]
|
|
25
|
+
return typeof value === 'string' ? value.trim() : ''
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function failed(error: string, code: 'invalid' | 'unavailable' = 'unavailable'): never {
|
|
29
|
+
throw new PortError(code, error)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Host seam for the customer-profile surface. Identity fields go through the
|
|
34
|
+
* existing account action; preferences, professional data and store-defined
|
|
35
|
+
* fields persist in `customer.metadata.profile`. Every mutation re-reads the
|
|
36
|
+
* snapshot so the block never renders a locally invented success state.
|
|
37
|
+
*/
|
|
38
|
+
export function createCustomerProfilePort(): CustomerProfilePort {
|
|
39
|
+
async function loadSnapshot(): Promise<CustomerProfileSnapshot> {
|
|
40
|
+
const result = await loadAccountProfileAction()
|
|
41
|
+
if (!result.ok) failed(result.error)
|
|
42
|
+
return toCustomerProfileSnapshot(result.profile)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
load: loadSnapshot,
|
|
47
|
+
|
|
48
|
+
async updatePersonal(draft) {
|
|
49
|
+
const result = await updateAccountProfileAction({
|
|
50
|
+
firstName: text(draft, 'firstName'),
|
|
51
|
+
lastName: text(draft, 'lastName'),
|
|
52
|
+
profile: { person: personalMetadataFromDraft(draft) },
|
|
53
|
+
})
|
|
54
|
+
if (!result.ok) failed(result.error, 'invalid')
|
|
55
|
+
return loadSnapshot()
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
async updateContact(draft) {
|
|
59
|
+
const phone = formatPhoneNumber(
|
|
60
|
+
text(draft, 'phoneCountry'),
|
|
61
|
+
text(draft, 'phone'),
|
|
62
|
+
)
|
|
63
|
+
const result = await updateAccountProfileAction({
|
|
64
|
+
email: text(draft, 'email'),
|
|
65
|
+
phone: phone ?? '',
|
|
66
|
+
})
|
|
67
|
+
if (!result.ok) failed(result.error, 'invalid')
|
|
68
|
+
return loadSnapshot()
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
async updatePreferences(draft) {
|
|
72
|
+
const result = await updateAccountProfileMetadataAction({
|
|
73
|
+
preferences: preferencesFromDraft(draft),
|
|
74
|
+
})
|
|
75
|
+
if (!result.ok) failed(result.error)
|
|
76
|
+
return loadSnapshot()
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
async updateProfessional(draft) {
|
|
80
|
+
const result = await updateAccountProfileMetadataAction({
|
|
81
|
+
professional: professionalFromDraft(draft),
|
|
82
|
+
})
|
|
83
|
+
if (!result.ok) failed(result.error)
|
|
84
|
+
return loadSnapshot()
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
async updateCustomFields(draft) {
|
|
88
|
+
const current = await loadSnapshot()
|
|
89
|
+
const result = await updateAccountProfileMetadataAction({
|
|
90
|
+
customFields: customFieldsFromDraft(current.customFields, draft),
|
|
91
|
+
})
|
|
92
|
+
if (!result.ok) failed(result.error)
|
|
93
|
+
return loadSnapshot()
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
async requestVerification(channel: VerificationChannel) {
|
|
97
|
+
throw new PortError(
|
|
98
|
+
'unavailable',
|
|
99
|
+
`The backend does not expose ${channel} verification yet.`,
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PortError } from '@thorprovider/blocks/ports'
|
|
2
|
+
import type { OrderDetailPort } from '@thorprovider/blocks/ports'
|
|
3
|
+
|
|
4
|
+
export type OrderDetailRunner = OrderDetailPort['get']
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Host seam for the order-detail route. The backend contract lives in
|
|
8
|
+
* `STOREFRONT_BACKEND_WIRING/components/order-detail.md`; until the runtime
|
|
9
|
+
* query and the customer detail endpoint exist, the port fails closed with a
|
|
10
|
+
* typed `unavailable` error that the landed surface renders as its own error
|
|
11
|
+
* state. No order is ever synthesized from the list payload.
|
|
12
|
+
*
|
|
13
|
+
* The backend owner replaces the fallback through this factory; the block and
|
|
14
|
+
* the route binding do not change.
|
|
15
|
+
*/
|
|
16
|
+
export function createOrderDetailPort(run?: OrderDetailRunner): OrderDetailPort {
|
|
17
|
+
return {
|
|
18
|
+
async get(orderId, options) {
|
|
19
|
+
if (run) return run(orderId, options)
|
|
20
|
+
throw new PortError(
|
|
21
|
+
'unavailable',
|
|
22
|
+
`Order detail is not connected to the backend yet (requested ${orderId}).`,
|
|
23
|
+
)
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PortError } from '@thorprovider/blocks/ports'
|
|
2
|
+
import type { OrdersPort } from '@thorprovider/blocks/ports'
|
|
3
|
+
|
|
4
|
+
import { listOrdersQueryPageAction } from './actions'
|
|
5
|
+
|
|
6
|
+
export type OrdersQueryRunner = OrdersPort['list']
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Host seam for the advanced order-history query, which is the default
|
|
10
|
+
* `account.orders` surface.
|
|
11
|
+
*
|
|
12
|
+
* The default runner is the `listOrdersQueryPageAction` Server Action: the
|
|
13
|
+
* customer token never reaches the client, and the request-scoped runtime read
|
|
14
|
+
* serves both mock mode (`THOR_DATA_SOURCE=mock`, the seeded demo account) and a
|
|
15
|
+
* Medusa backend. The block owns the query UI; the action owns the data read.
|
|
16
|
+
*
|
|
17
|
+
* A Server Action cannot be cancelled, so `options.signal` only tells the block
|
|
18
|
+
* to discard a superseded result; the read itself completes. The `run` override
|
|
19
|
+
* stays for a host that wants to inject its own runner through the same factory.
|
|
20
|
+
*/
|
|
21
|
+
export function createOrdersPort(run?: OrdersQueryRunner): OrdersPort {
|
|
22
|
+
return {
|
|
23
|
+
async list(query, options) {
|
|
24
|
+
if (run) return run(query, options)
|
|
25
|
+
const result = await listOrdersQueryPageAction(query)
|
|
26
|
+
if (!result.ok) throw new PortError('unavailable', result.error)
|
|
27
|
+
return result.page
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createAddressesPort } from './addresses-port'
|
|
2
|
+
import { createCustomerProfilePort } from './customer-profile-port'
|
|
3
|
+
import { createOrderDetailPort } from './order-detail-port'
|
|
4
|
+
import { createOrdersPort } from './orders-port'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Host-injected asynchronous ports. `orders` is the seam for the advanced
|
|
8
|
+
* account order history (the default `account.orders` surface); its runner is
|
|
9
|
+
* the token-scoped customer order read, wired for mock mode and Medusa.
|
|
10
|
+
* `orderDetail` is the seam for the /account/orders/[id] route; it fails closed
|
|
11
|
+
* until the customer detail endpoint exists.
|
|
12
|
+
*/
|
|
13
|
+
export const ports = {
|
|
14
|
+
orders: createOrdersPort(),
|
|
15
|
+
orderDetail: createOrderDetailPort(),
|
|
16
|
+
customerProfile: createCustomerProfilePort(),
|
|
17
|
+
addresses: createAddressesPort(),
|
|
18
|
+
}
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
// retry/reconcile re-resolution, shell/4.2 claim) flows through `claimAccount`,
|
|
33
33
|
// the private reset happens AT the trigger even when the `/account` panel is
|
|
34
34
|
// unmounted and no effect can run. Same-identity claims are a no-op and the
|
|
35
|
-
// guest cart is never touched (`
|
|
35
|
+
// guest cart is never touched (`clearAccountPrivateState`).
|
|
36
36
|
|
|
37
37
|
import { createContext, useContext, useMemo, useRef, type ReactNode } from 'react'
|
|
38
38
|
import { useStateStore } from '@json-render/react'
|
|
39
39
|
import type { AccountIdentity, AccountResolution } from './account-session.core'
|
|
40
|
-
import { accountIdentityKey,
|
|
40
|
+
import { accountIdentityKey, clearAccountPrivateState } from './account-private.core'
|
|
41
41
|
import {
|
|
42
42
|
ACCOUNT_OWNED_KEYS,
|
|
43
43
|
createProjectionOwnership,
|
|
@@ -161,7 +161,7 @@ export function useAccountOwnership(): AccountOwnership {
|
|
|
161
161
|
// run. The prior key is read from the LIVE store (not a render closure),
|
|
162
162
|
// so it is correct regardless of which route is mounted. A same-identity
|
|
163
163
|
// claim (a re-resolution, or `beginMutation`'s snapshot claim) is a no-op,
|
|
164
|
-
// and `
|
|
164
|
+
// and `clearAccountPrivateState` never writes a guest cart key.
|
|
165
165
|
const priorKey = accountIdentityKey(
|
|
166
166
|
(getSnapshot().accountCustomer ?? null) as { id?: string | null } | null,
|
|
167
167
|
)
|
|
@@ -173,7 +173,7 @@ export function useAccountOwnership(): AccountOwnership {
|
|
|
173
173
|
})
|
|
174
174
|
// Clear BEFORE writing the new identity so no reader ever observes the
|
|
175
175
|
// new identity alongside the previous customer's private rows.
|
|
176
|
-
if (priorKey !== nextKey)
|
|
176
|
+
if (priorKey !== nextKey) clearAccountPrivateState(set)
|
|
177
177
|
set('/accountCustomer', accountCustomer)
|
|
178
178
|
set('/accountAuthenticated', accountAuthenticated)
|
|
179
179
|
set('/accountResolution', values.accountResolution)
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// printed; a missing or too-short secret throws before any cookie is written.
|
|
15
15
|
// No external SDK is called here; commerce data stays behind adapters/runtime.
|
|
16
16
|
|
|
17
|
-
import { cookies } from 'next/headers'
|
|
17
|
+
import { cookies, headers } from 'next/headers'
|
|
18
18
|
import type { StoreContext } from '@thorprovider/types'
|
|
19
19
|
import {
|
|
20
20
|
AUTH_TOKEN_TTL_SECONDS,
|
|
@@ -46,12 +46,30 @@ export function getSessionSecret(): string {
|
|
|
46
46
|
return secret
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Hardened cookie flags: httpOnly, SameSite=Lax, request-aware `secure`, TTL.
|
|
51
|
+
*
|
|
52
|
+
* `secure` follows the request's actual scheme (`x-forwarded-proto`), never
|
|
53
|
+
* NODE_ENV alone: a production `next start` served over plain HTTP (a local or
|
|
54
|
+
* LAN demo, no TLS proxy) would otherwise set a `Secure` cookie the browser
|
|
55
|
+
* silently drops — sign-in survives one response and every reload logs the
|
|
56
|
+
* shopper out. HTTPS requests through any standard proxy carry the header and
|
|
57
|
+
* keep the `Secure` flag; direct HTTPS without the header is not weakened
|
|
58
|
+
* because TLS is the only channel. Cookie writes happen in actions/routes, so
|
|
59
|
+
* `headers()` always resolves here.
|
|
60
|
+
*/
|
|
61
|
+
async function cookieOptions(): Promise<{
|
|
62
|
+
httpOnly: true
|
|
63
|
+
sameSite: 'lax'
|
|
64
|
+
secure: boolean
|
|
65
|
+
path: '/'
|
|
66
|
+
maxAge: number
|
|
67
|
+
}> {
|
|
68
|
+
const forwarded = (await headers()).get('x-forwarded-proto')?.split(',')[0]?.trim().toLowerCase()
|
|
51
69
|
return {
|
|
52
70
|
httpOnly: true,
|
|
53
71
|
sameSite: 'lax' as const,
|
|
54
|
-
secure:
|
|
72
|
+
secure: forwarded === 'https',
|
|
55
73
|
path: '/',
|
|
56
74
|
maxAge: SESSION_TTL_SECONDS,
|
|
57
75
|
}
|
|
@@ -126,7 +144,7 @@ async function writeHostSession(
|
|
|
126
144
|
store.set(
|
|
127
145
|
sessionCookieName(context.storeId),
|
|
128
146
|
encodeHostSession(payload, getSessionSecret()),
|
|
129
|
-
cookieOptions(),
|
|
147
|
+
await cookieOptions(),
|
|
130
148
|
)
|
|
131
149
|
}
|
|
132
150
|
|
|
@@ -158,7 +176,7 @@ export async function writeAuthToken(context: StoreContext, token: string): Prom
|
|
|
158
176
|
store.set(
|
|
159
177
|
authCookieName(context.storeId),
|
|
160
178
|
encodeHostAuth(createHostAuth(context.storeId, token), getSessionSecret()),
|
|
161
|
-
{ ...cookieOptions(), maxAge: AUTH_TOKEN_TTL_SECONDS },
|
|
179
|
+
{ ...(await cookieOptions()), maxAge: AUTH_TOKEN_TTL_SECONDS },
|
|
162
180
|
)
|
|
163
181
|
}
|
|
164
182
|
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
9
|
CardProduct,
|
|
10
|
+
CheckoutReadState,
|
|
11
|
+
CheckoutShippingGroup,
|
|
10
12
|
FeaturedProduct,
|
|
11
13
|
ProductCategoryItem,
|
|
12
14
|
ProductDetailProduct,
|
|
@@ -137,6 +139,27 @@ export interface AccountOrderView {
|
|
|
137
139
|
items: AccountOrderItemView[]
|
|
138
140
|
}
|
|
139
141
|
|
|
142
|
+
/**
|
|
143
|
+
* One saved address in the authenticated customer's address book, mapped from
|
|
144
|
+
* the backend `Address`. Optional fields are omitted rather than serialized as
|
|
145
|
+
* empty strings; the view registry formats the display lines.
|
|
146
|
+
*/
|
|
147
|
+
export interface AccountAddressView {
|
|
148
|
+
id: string
|
|
149
|
+
firstName: string
|
|
150
|
+
lastName: string
|
|
151
|
+
address1?: string
|
|
152
|
+
address2?: string
|
|
153
|
+
city: string
|
|
154
|
+
province?: string
|
|
155
|
+
postalCode?: string
|
|
156
|
+
countryCode: string
|
|
157
|
+
phone?: string
|
|
158
|
+
label?: string
|
|
159
|
+
isDefaultShipping?: boolean
|
|
160
|
+
isDefaultBilling?: boolean
|
|
161
|
+
}
|
|
162
|
+
|
|
140
163
|
/**
|
|
141
164
|
* The completed-order receipt as ONE atomic value.
|
|
142
165
|
*
|
|
@@ -211,9 +234,13 @@ export interface StorefrontState extends StorefrontCoreState {
|
|
|
211
234
|
checkout: CheckoutFormData
|
|
212
235
|
checkoutCountries: { value: string; label: string }[]
|
|
213
236
|
checkoutPaymentMethods: PaymentMethod[]
|
|
214
|
-
checkoutShippingOptions: CheckoutShippingOption[]
|
|
215
237
|
checkoutSelectedShippingOptionId: string | null
|
|
216
238
|
checkoutFieldErrors: CheckoutFieldErrors
|
|
239
|
+
/** The backend's own delivery groups, mapped 1:1 (never locally grouped). */
|
|
240
|
+
checkoutShippingGroups: CheckoutShippingGroup[]
|
|
241
|
+
/** Presentation group id -> the backend `products` for that group's apply. */
|
|
242
|
+
checkoutShippingGroupProducts: Record<string, string[]>
|
|
243
|
+
checkoutShippingState: CheckoutReadState
|
|
217
244
|
checkoutPending: boolean
|
|
218
245
|
checkoutError: string | null
|
|
219
246
|
/**
|
package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: address-book-advanced (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in address-book-advanced.tsx. @thorprovider/blocks ships a
|
|
5
|
+
// 'use client' boundary, but this fragment keeps the explicit client boundary so
|
|
6
|
+
// the section composes identically in any consumer graph.
|
|
7
|
+
|
|
8
|
+
import { AddressBookAdvanced } from '@thorprovider/blocks'
|
|
9
|
+
import { ports } from '../../ports'
|
|
10
|
+
import { addressBookAdvancedPropsSchema } from './schema.address-book-advanced'
|
|
11
|
+
import type { ViewRegistry } from '../types'
|
|
12
|
+
|
|
13
|
+
export const addressBookAdvancedRegistry: ViewRegistry = {
|
|
14
|
+
AddressBookAdvanced: ({ props }) => {
|
|
15
|
+
const parsed = addressBookAdvancedPropsSchema.parse(props)
|
|
16
|
+
return (
|
|
17
|
+
<AddressBookAdvanced
|
|
18
|
+
context={parsed.context as Parameters<typeof AddressBookAdvanced>[0]["context"]}
|
|
19
|
+
permissions={parsed.permissions as Parameters<typeof AddressBookAdvanced>[0]["permissions"]}
|
|
20
|
+
config={parsed.config as Parameters<typeof AddressBookAdvanced>[0]["config"]}
|
|
21
|
+
labels={parsed.labels as Parameters<typeof AddressBookAdvanced>[0]["labels"]}
|
|
22
|
+
countries={parsed.countries as Parameters<typeof AddressBookAdvanced>[0]["countries"]}
|
|
23
|
+
addressLabels={parsed.addressLabels as Parameters<typeof AddressBookAdvanced>[0]["addressLabels"]}
|
|
24
|
+
title={parsed.title as Parameters<typeof AddressBookAdvanced>[0]["title"]}
|
|
25
|
+
port={ports.addresses}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
},
|
|
29
|
+
}
|
package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: checkout-commerce-v1 (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in checkout-commerce-v1.tsx. @thorprovider/blocks ships a
|
|
5
|
+
// 'use client' boundary, but this fragment keeps the explicit client boundary so
|
|
6
|
+
// the section composes identically in any consumer graph.
|
|
7
|
+
|
|
8
|
+
import { CheckoutCommerceV1 } from '@thorprovider/blocks'
|
|
9
|
+
import { checkoutCommerceV1PropsSchema } from './schema.checkout-commerce-v1'
|
|
10
|
+
import type { ViewRegistry } from '../types'
|
|
11
|
+
|
|
12
|
+
export const checkoutCommerceV1Registry: ViewRegistry = {
|
|
13
|
+
CheckoutCommerceV1: ({ props }) => {
|
|
14
|
+
const parsed = checkoutCommerceV1PropsSchema.parse(props)
|
|
15
|
+
return (
|
|
16
|
+
<CheckoutCommerceV1 data={parsed.data} />
|
|
17
|
+
)
|
|
18
|
+
},
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Optional section fragment: checkout-commerce-v1 (mirrors recipes/sections.json)
|
|
2
|
+
// Server-side part: element type + zod catalog entry. The component mappings
|
|
3
|
+
// live in checkout-commerce-v1.client.tsx ('use client') and are composed via composeSections.
|
|
4
|
+
|
|
5
|
+
import { checkoutCommerceV1PropsSchema } from './schema.checkout-commerce-v1'
|
|
6
|
+
|
|
7
|
+
export const checkoutCommerceV1Section = {
|
|
8
|
+
elementType: 'CheckoutCommerceV1',
|
|
9
|
+
catalog: {
|
|
10
|
+
CheckoutCommerceV1: {
|
|
11
|
+
props: checkoutCommerceV1PropsSchema,
|
|
12
|
+
description: 'CheckoutCommerceV1 presentation section (delivery checkout-commerce-v1).',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
registryModule: './checkout-commerce-v1.client',
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: customer-profile (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in customer-profile.tsx. @thorprovider/blocks ships a
|
|
5
|
+
// 'use client' boundary, but this fragment keeps the explicit client boundary so
|
|
6
|
+
// the section composes identically in any consumer graph.
|
|
7
|
+
|
|
8
|
+
import { CustomerProfile } from '@thorprovider/blocks'
|
|
9
|
+
import { ports } from '../../ports'
|
|
10
|
+
import { customerProfilePropsSchema } from './schema.customer-profile'
|
|
11
|
+
import type { ViewRegistry } from '../types'
|
|
12
|
+
|
|
13
|
+
export const customerProfileRegistry: ViewRegistry = {
|
|
14
|
+
CustomerProfile: ({ props }) => {
|
|
15
|
+
const parsed = customerProfilePropsSchema.parse(props)
|
|
16
|
+
return (
|
|
17
|
+
<CustomerProfile
|
|
18
|
+
labels={parsed.labels as Parameters<typeof CustomerProfile>[0]["labels"]}
|
|
19
|
+
capabilities={parsed.capabilities as Parameters<typeof CustomerProfile>[0]["capabilities"]}
|
|
20
|
+
permissions={parsed.permissions as Parameters<typeof CustomerProfile>[0]["permissions"]}
|
|
21
|
+
defaultEditing={parsed.defaultEditing as Parameters<typeof CustomerProfile>[0]["defaultEditing"]}
|
|
22
|
+
lang={parsed.lang as Parameters<typeof CustomerProfile>[0]["lang"]}
|
|
23
|
+
port={ports.customerProfile}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
}
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
// catalog never pulls the React graph.
|
|
7
7
|
|
|
8
8
|
import type { ViewCatalogEntry } from '../types'
|
|
9
|
+
import { checkoutCommerceV1Section } from './checkout-commerce-v1'
|
|
9
10
|
import { ctaSection } from './cta'
|
|
10
11
|
import { faqSection } from './faq'
|
|
12
|
+
import { marketplaceProductCardSection } from './marketplace-product-card'
|
|
13
|
+
import { megaMenuUniversalSection } from './mega-menu-universal'
|
|
11
14
|
import { productsSection } from './products'
|
|
15
|
+
import { universalBannerSection } from './universal-banner'
|
|
12
16
|
|
|
13
|
-
export const sectionModules = [faqSection, ctaSection, productsSection] as const
|
|
17
|
+
export const sectionModules = [checkoutCommerceV1Section, faqSection, ctaSection, marketplaceProductCardSection, megaMenuUniversalSection, productsSection, universalBannerSection] as const
|
|
14
18
|
|
|
15
19
|
export const sectionCatalog: Record<string, ViewCatalogEntry> = Object.assign(
|
|
16
20
|
{},
|