@thorprovider/storefront 0.7.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +22 -2
  2. package/assets/templates/AGENTS.md +14 -2
  3. package/assets/templates/app/app/[[...slug]]/page.tsx +9 -2
  4. package/assets/templates/app/lib/__STOREFRONT__/account-address.ts +129 -0
  5. package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +2 -2
  6. package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +143 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/account-profile.ts +220 -0
  8. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +677 -80
  9. package/assets/templates/app/lib/__STOREFRONT__/addresses-port.ts +107 -0
  10. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +477 -38
  11. package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +240 -0
  12. package/assets/templates/app/lib/__STOREFRONT__/customer-profile-port.ts +103 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/fulfillment-evidence-port.ts +31 -0
  14. package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +21 -4
  15. package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +6 -2
  16. package/assets/templates/app/lib/__STOREFRONT__/order-detail-mapper.ts +642 -0
  17. package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +25 -0
  18. package/assets/templates/app/lib/__STOREFRONT__/orders-port.ts +30 -0
  19. package/assets/templates/app/lib/__STOREFRONT__/ports.ts +28 -0
  20. package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +4 -4
  21. package/assets/templates/app/lib/__STOREFRONT__/session.ts +24 -6
  22. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +21 -0
  23. package/assets/templates/app/lib/__STOREFRONT__/views/sections/address-book-advanced.client.tsx +29 -0
  24. package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.client.tsx +19 -0
  25. package/assets/templates/app/lib/__STOREFRONT__/views/sections/checkout-commerce-v1.tsx +16 -0
  26. package/assets/templates/app/lib/__STOREFRONT__/views/sections/customer-profile.client.tsx +27 -0
  27. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +4 -1
  28. package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.client.tsx +19 -0
  29. package/assets/templates/app/lib/__STOREFRONT__/views/sections/mega-menu-universal.tsx +16 -0
  30. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.address-book-advanced.ts +437 -0
  31. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.checkout-commerce-v1.ts +398 -0
  32. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.customer-profile.ts +138 -0
  33. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.mega-menu-universal.ts +76 -0
  34. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +217 -0
  35. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +24 -0
  36. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.tsx +16 -0
  37. package/assets/templates/features/checkout/handlers.ts +24 -4
  38. package/assets/templates/features/customer-addresses/handlers.ts +11 -0
  39. package/assets/templates/features/customer-addresses/state.ts +33 -0
  40. package/assets/templates/features/customer-auth/state.ts +10 -0
  41. package/assets/templates/features/customer-profile/handlers.ts +11 -0
  42. package/assets/templates/features/customer-profile/state.ts +18 -0
  43. package/assets/templates/views/account/address-book-advanced.defaults.ts +534 -0
  44. package/assets/templates/views/account/assembly/assembly.json +36 -0
  45. package/assets/templates/views/account/assembly/index.skeleton.tsx +277 -0
  46. package/assets/templates/views/account/assembly/registry.skeleton.tsx +1057 -0
  47. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/binding.json +5 -0
  48. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/catalog.part +4 -0
  49. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/element.part +5 -0
  50. package/assets/templates/views/account/assembly/slots/addresses/AddressBookAdvanced/registry.part +1 -0
  51. package/assets/templates/views/account/assembly/slots/addresses/cards/catalog.part +5 -0
  52. package/assets/templates/views/account/assembly/slots/addresses/cards/element.part +10 -0
  53. package/assets/templates/views/account/assembly/slots/addresses/cards/registry.part +1 -0
  54. package/assets/templates/views/account/assembly/slots/login/card/catalog.part +4 -0
  55. package/assets/templates/views/account/assembly/slots/login/card/element.part +13 -0
  56. package/assets/templates/views/account/assembly/slots/login/card/registry.part +1 -0
  57. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/catalog.part +5 -0
  58. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/element.part +5 -0
  59. package/assets/templates/views/account/assembly/slots/orders/OrderHistory/registry.part +2 -0
  60. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/binding.json +5 -0
  61. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/catalog.part +5 -0
  62. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/element.part +5 -0
  63. package/assets/templates/views/account/assembly/slots/orders/OrderHistoryAdvanced/registry.part +1 -0
  64. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/binding.json +5 -0
  65. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/catalog.part +4 -0
  66. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/element.part +5 -0
  67. package/assets/templates/views/account/assembly/slots/profile/CustomerProfileAdvanced/registry.part +1 -0
  68. package/assets/templates/views/account/assembly/slots/profile/form/catalog.part +5 -0
  69. package/assets/templates/views/account/assembly/slots/profile/form/element.part +10 -0
  70. package/assets/templates/views/account/assembly/slots/profile/form/registry.part +1 -0
  71. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/catalog.part +4 -0
  72. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/element.part +13 -0
  73. package/assets/templates/views/account/assembly/slots/register/SignUpPage1/registry.part +1 -0
  74. package/assets/templates/views/account/assembly/slots/summary/stack/catalog.part +5 -0
  75. package/assets/templates/views/account/assembly/slots/summary/stack/element.part +5 -0
  76. package/assets/templates/views/account/assembly/slots/summary/stack/registry.part +1 -0
  77. package/assets/templates/views/account/assembly/slots/summary/tabs/catalog.part +5 -0
  78. package/assets/templates/views/account/assembly/slots/summary/tabs/element.part +5 -0
  79. package/assets/templates/views/account/assembly/slots/summary/tabs/registry.part +1 -0
  80. package/assets/templates/views/account/content.ts +326 -0
  81. package/assets/templates/views/account/customer-profile.defaults.ts +136 -0
  82. package/assets/templates/views/account/fulfillment-evidence.client.tsx +34 -0
  83. package/assets/templates/views/account/fulfillment-evidence.defaults.ts +145 -0
  84. package/assets/templates/views/account/fulfillment-evidence.schema.ts +15 -0
  85. package/assets/templates/views/account/index.tsx +259 -38
  86. package/assets/templates/views/account/order-detail.client.tsx +35 -0
  87. package/assets/templates/views/account/order-detail.defaults.ts +457 -0
  88. package/assets/templates/views/account/orders-advanced.client.tsx +77 -0
  89. package/assets/templates/views/account/orders-advanced.defaults.ts +230 -0
  90. package/assets/templates/views/account/registry.tsx +935 -420
  91. package/assets/templates/views/account/schema.ts +50 -0
  92. package/assets/templates/views/account/sections-data.ts +2 -0
  93. package/assets/templates/views/cart/content.ts +1 -0
  94. package/assets/templates/views/category/assembly/index.skeleton.tsx +1 -0
  95. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
  96. package/assets/templates/views/category/content.ts +2 -0
  97. package/assets/templates/views/category/index.tsx +2 -0
  98. package/assets/templates/views/category/sections-data.ts +2 -0
  99. package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +1089 -0
  100. package/assets/templates/views/checkout/content.ts +51 -0
  101. package/assets/templates/views/checkout/index.tsx +1 -1
  102. package/assets/templates/views/checkout/props.ts +10 -2
  103. package/assets/templates/views/checkout/registry.tsx +104 -42
  104. package/assets/templates/views/checkout/schema.ts +76 -1
  105. package/assets/templates/views/home/assembly/assembly.json +23 -2
  106. package/assets/templates/views/home/assembly/index.skeleton.tsx +4 -1
  107. package/assets/templates/views/home/assembly/registry.skeleton.tsx +1 -0
  108. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/binding.json +5 -0
  109. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/catalog.part +4 -0
  110. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/element.part +4 -0
  111. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +10 -0
  112. package/assets/templates/views/home/content.ts +247 -1
  113. package/assets/templates/views/home/data.ts +10 -1
  114. package/assets/templates/views/home/index.tsx +8 -6
  115. package/assets/templates/views/home/props.ts +7 -1
  116. package/assets/templates/views/home/registry.tsx +11 -28
  117. package/assets/templates/views/home/schema.ts +163 -0
  118. package/assets/templates/views/home/sections-data.ts +2 -0
  119. package/assets/templates/views/product/content.ts +1 -0
  120. package/assets/templates/views/static/content.ts +1 -0
  121. package/bin/storefront.js +356 -27
  122. package/package.json +2 -1
  123. package/recipes/adapter-surface.json +159 -0
  124. package/recipes/archetypes.json +43 -4
  125. package/recipes/catalog.json +147 -2
  126. package/recipes/feature.schema.json +9 -0
  127. package/recipes/features.json +72 -1
  128. package/recipes/manifest.schema.json +5 -0
  129. package/recipes/recipe.schema.json +13 -1
  130. package/recipes/recipes.json +37 -7
  131. package/recipes/section.schema.json +112 -0
  132. package/recipes/sections.json +281 -4
  133. package/recipes/validate.mjs +83 -1
  134. package/scripts/adapter-surface.mjs +41 -0
  135. package/scripts/agent-blocks.mjs +700 -0
  136. package/scripts/block-validator.mjs +45 -0
  137. package/scripts/candidate.mjs +56 -14
  138. package/scripts/composers.mjs +7 -2
  139. package/scripts/default-sections.mjs +78 -0
  140. package/scripts/file-classes.mjs +18 -0
  141. package/scripts/generate-adapter-surface.mjs +148 -0
  142. package/scripts/operations.mjs +100 -0
  143. package/scripts/reconcile.mjs +67 -39
  144. package/scripts/section-configure.mjs +316 -0
  145. package/scripts/sync-assets.mjs +1 -0
  146. package/scripts/view-assembly.mjs +101 -14
  147. package/skills/sf-feature/SKILL.md +19 -0
  148. package/skills/sf-view-gen/SKILL.md +73 -7
  149. package/skills/sf-view-gen/assets/recipes/archetypes.json +43 -4
  150. package/skills/sf-view-gen/assets/recipes/catalog.json +147 -2
  151. package/skills/sf-view-gen/assets/recipes/features.json +72 -1
  152. package/skills/sf-view-gen/assets/recipes/recipes.json +37 -7
  153. package/skills/sf-view-gen/assets/recipes/section.schema.json +112 -0
  154. package/skills/sf-view-gen/assets/recipes/sections.json +281 -4
  155. package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.client.tsx +19 -0
  156. package/skills/sf-view-gen/assets/templates/views/sections/checkout-commerce-v1.tsx +16 -0
  157. package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.client.tsx +19 -0
  158. package/skills/sf-view-gen/assets/templates/views/sections/mega-menu-universal.tsx +16 -0
  159. package/skills/sf-view-gen/assets/templates/views/sections/schema.checkout-commerce-v1.ts +398 -0
  160. package/skills/sf-view-gen/assets/templates/views/sections/schema.mega-menu-universal.ts +76 -0
  161. package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +217 -0
  162. package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.client.tsx +24 -0
  163. package/skills/sf-view-gen/assets/templates/views/sections/universal-banner.tsx +16 -0
  164. package/skills/sf-view-gen/scripts/validate.mjs +83 -1
@@ -6,35 +6,78 @@
6
6
  //
7
7
  // The initial render does NOT read the auth cookie here (this module is part of
8
8
  // the client catalog graph). The catch-all page seeds the account identity for
9
- // every route (tasks 2.1/2.2) and the globally mounted shared account lifecycle
10
- // (feature customer-auth handlers) owns identity; the headless `AccountBoot`
11
- // boundary is passive and only surfaces the retryable unavailable status, so no
12
- // route-level identity fetch happens here.
9
+ // every route and the globally mounted shared account lifecycle owns identity;
10
+ // the headless `AccountBoot` boundary is passive and only surfaces the retryable
11
+ // unavailable status, so no route-level identity fetch happens here.
12
+ //
13
+ // The element tree is assembled from the registered slots (boot, login,
14
+ // register, summary, orders, profile, addresses). Module slots render only when
15
+ // their feature is installed and the shopper is authenticated; the account frame
16
+ // owns the shape (stack/tabs) and the module navigation.
13
17
 
18
+ import { notFound } from 'next/navigation'
14
19
  import { getDataSource } from '../../store-context'
15
20
  import { pageRoot } from '../../spec/page-root'
16
21
  import type { StorefrontElement } from '../../spec/types'
17
22
  import type { ViewModule } from '../types'
18
23
  import { registry } from './registry'
24
+ import { sectionData } from './sections-data'
19
25
  import { accountContent } from './content'
26
+ import { orderDetailDefaults } from './order-detail.defaults'
27
+ import { fulfillmentEvidenceDefaults } from './fulfillment-evidence.defaults'
28
+ import { accountOrdersAdvancedDefaults } from './orders-advanced.defaults'
20
29
  import {
30
+ accountAddressPropsSchema,
21
31
  accountEmptyPropsSchema,
32
+ accountFramePropsSchema,
22
33
  accountLoginPropsSchema,
34
+ accountOrderDetailPropsSchema,
35
+ accountOrdersAdvancedPropsSchema,
23
36
  accountOrdersPropsSchema,
37
+ accountProfilePropsSchema,
24
38
  accountRegisterPropsSchema,
25
39
  } from './schema'
40
+ import { accountFulfillmentEvidencePropsSchema } from './fulfillment-evidence.schema'
41
+ import { customerProfileDefaults } from './customer-profile.defaults'
42
+ import { customerProfilePropsSchema } from '../sections/schema.customer-profile'
43
+ import { addressBookAdvancedDefaults } from './address-book-advanced.defaults'
44
+ import { addressBookAdvancedPropsSchema } from '../sections/schema.address-book-advanced'
45
+
46
+ // Existing stores keep a user-owned content.ts that may predate the advanced
47
+ // orders variant; the derived defaults keep the element type-safe and renderable
48
+ // until the store opts into its own copy.
49
+ const ordersAdvancedContent =
50
+ (accountContent as { ordersAdvanced?: typeof accountOrdersAdvancedDefaults }).ordersAdvanced ??
51
+ accountOrdersAdvancedDefaults
26
52
 
27
- // Surfaces: a passive boundary (headless unavailable/retry), sign-in,
28
- // registration, and the signed-in panel. Sign-in and registration are toggled
29
- // by `/accountMode` and hidden while the session is `unavailable`, so an outage
30
- // shows the retryable boundary rather than a false signed-out form; the panel
31
- // shows only when `/accountAuthenticated` is true.
32
53
  const elements: Record<string, StorefrontElement> = {
54
+ // Route-only detail element: it belongs to /account/orders/[id], never to the
55
+ // account page root. The loader supplies the id and the port is injected by
56
+ // the client binding.
57
+ 'account.orderDetail': {
58
+ type: 'AccountOrderDetail',
59
+ props: {
60
+ orderId: { $state: '/orderDetailId' },
61
+ ...orderDetailDefaults,
62
+ },
63
+ },
64
+ // Headless account boundary. It is fixed infrastructure, not a selectable
65
+ // slot, so a generated store's normalized composition cannot drop it and
66
+ // leave every account route referencing a missing element.
33
67
  'account.boot': {
34
68
  type: 'AccountBoot',
35
69
  props: {},
36
70
  on: { retry: { action: 'retryAccountSession' } },
37
71
  },
72
+ // Route-only evidence element: it belongs to the nested fulfillment route,
73
+ // never to the account page root or the order-detail page root.
74
+ 'account.fulfillmentEvidence': {
75
+ type: 'AccountFulfillmentEvidence',
76
+ props: {
77
+ fulfillmentId: { $state: '/fulfillmentEvidenceId' },
78
+ ...fulfillmentEvidenceDefaults,
79
+ },
80
+ },
38
81
  'account.login': {
39
82
  type: 'AccountLogin',
40
83
  visible: {
@@ -42,8 +85,6 @@ const elements: Record<string, StorefrontElement> = {
42
85
  { $state: '/accountAuthenticated', not: true },
43
86
  { $state: '/accountResolution', neq: 'unavailable' },
44
87
  { $state: '/accountMode', eq: 'login' },
45
- // While a reconciliation is in flight the sign-in form must not appear
46
- // (that would fake a signed-out state before the server confirms it).
47
88
  { $state: '/accountReconciling', not: true },
48
89
  ],
49
90
  },
@@ -63,24 +104,81 @@ const elements: Record<string, StorefrontElement> = {
63
104
  props: accountContent.register,
64
105
  on: { showLogin: { action: 'showLogin' } },
65
106
  },
66
- 'account.panel': {
67
- type: 'AccountPanel',
107
+ 'account.summary': {
108
+ type: 'AccountFrame',
68
109
  visible: { $state: '/accountAuthenticated' },
69
- props: {},
70
- on: { logout: { action: 'logout' } },
110
+ props: { ...accountContent.frame, presentation: 'stack' },
71
111
  },
72
112
  'account.orders': {
73
- type: 'AccountOrders',
113
+ type: 'AccountOrdersAdvanced',
114
+ visible: { $state: '/accountAuthenticated' },
115
+ props: ordersAdvancedContent,
116
+ },
117
+ 'account.profile': {
118
+ type: 'CustomerProfile',
119
+ visible: {"$and":[{"$state":"/accountAuthenticated"},{"$state":"/accountProfileAvailable","eq":true}]},
120
+ props: customerProfileDefaults,
121
+ },
122
+ 'account.addresses': {
123
+ type: 'AddressBookAdvanced',
124
+ visible: {"$and":[{"$state":"/accountAuthenticated"},{"$state":"/accountAddressesAvailable","eq":true}]},
125
+ props: addressBookAdvancedDefaults,
126
+ },
127
+ // Route-specific shell roots. The same shell component receives the active
128
+ // module as children; the route, not a client tab, decides which module is
129
+ // current.
130
+ 'account.shell.overview': {
131
+ type: 'AccountShell',
132
+ visible: { $state: '/accountAuthenticated' },
133
+ props: {},
134
+ children: ['account.overview'],
135
+ },
136
+ 'account.shell.orders': {
137
+ type: 'AccountShell',
74
138
  visible: { $state: '/accountAuthenticated' },
75
- props: accountContent.orders,
139
+ props: {},
140
+ children: ['account.orders'],
141
+ },
142
+ 'account.shell.profile': {
143
+ type: 'AccountShell',
144
+ visible: { $state: '/accountAuthenticated' },
145
+ props: {},
146
+ children: ['account.profile'],
147
+ },
148
+ 'account.shell.addresses': {
149
+ type: 'AccountShell',
150
+ visible: { $state: '/accountAuthenticated' },
151
+ props: {},
152
+ children: ['account.addresses'],
153
+ },
154
+ 'account.shell.favorites': {
155
+ type: 'AccountShell',
156
+ visible: { $state: '/accountAuthenticated' },
157
+ props: {},
158
+ children: ['account.favorites'],
159
+ },
160
+ 'account.overview': {
161
+ type: 'AccountOverview',
162
+ visible: { $state: '/accountAuthenticated' },
163
+ props: {},
164
+ },
165
+ 'account.favorites': {
166
+ type: 'AccountModulePlaceholder',
167
+ visible: { $state: '/accountAuthenticated' },
168
+ props: {},
76
169
  },
77
170
  }
78
171
 
79
172
  const catalog = {
80
- AccountBoot: {
81
- props: accountEmptyPropsSchema,
173
+ AccountOrderDetail: {
174
+ props: accountOrderDetailPropsSchema,
82
175
  description:
83
- 'Passive account boundary: shows a retryable unavailable status when the session cannot be resolved, otherwise nothing. Never fetches identity.',
176
+ 'Route-only order detail surface for one authenticated customer order; the host port supplies the data and the block owns its states.',
177
+ },
178
+ AccountFulfillmentEvidence: {
179
+ props: accountFulfillmentEvidencePropsSchema,
180
+ description:
181
+ 'Route-only fulfillment evidence gallery for one order fulfillment; the host port supplies the snapshot and signed asset URLs, and the block owns its states.',
84
182
  },
85
183
  AccountLogin: {
86
184
  props: accountLoginPropsSchema,
@@ -90,14 +188,38 @@ const catalog = {
90
188
  props: accountRegisterPropsSchema,
91
189
  description: 'Registration page with name, email, and password and a link to sign in.',
92
190
  },
93
- AccountPanel: {
191
+ AccountFrame: {
192
+ props: accountFramePropsSchema,
193
+ description:
194
+ 'Signed-in account frame: identity summary plus module navigation (presentations: stack, tabs).',
195
+ },
196
+ AccountOrdersAdvanced: {
197
+ props: accountOrdersAdvancedPropsSchema,
198
+ description:
199
+ "Signed-in customer's order history rendered by the default `OrderHistoryAdvanced` port block: search, quick filters, sort, counts and cards from the host `OrdersPort`. The canonical `OrderHistory` variant remains selectable as the minimal fallback.",
200
+ },
201
+ CustomerProfile: {
202
+ props: customerProfilePropsSchema,
203
+ description: "Designer customer profile surface: identity, contact, preferences, professional data and store-defined fields, supplied by the customerProfile host port.",
204
+ },
205
+ AddressBookAdvanced: {
206
+ props: addressBookAdvancedPropsSchema,
207
+ description: "Designer address book: saved personal addresses with search, filters, default shipping/billing and a full create/edit form, supplied by the addresses host port.",
208
+ },
209
+ AccountShell: {
210
+ props: accountEmptyPropsSchema,
211
+ description:
212
+ 'Signed-in designer account shell: identity header, module context bar and the active module as children. The host supplies the customer, capabilities and labels; the shell chooses no panel.',
213
+ },
214
+ AccountOverview: {
94
215
  props: accountEmptyPropsSchema,
95
- description: 'Minimal signed-in state with the customer name and a logout control.',
216
+ description:
217
+ 'Signed-in account overview: a capability-gated card dashboard that links to the account modules. No summaries or counters are invented.',
96
218
  },
97
- AccountOrders: {
98
- props: accountOrdersPropsSchema,
219
+ AccountModulePlaceholder: {
220
+ props: accountEmptyPropsSchema,
99
221
  description:
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.",
222
+ 'Documented planned-module panel for the account shell. It describes what the module will hold and exposes no fake data or mutation.',
101
223
  },
102
224
  }
103
225
 
@@ -106,21 +228,120 @@ export const account: ViewModule = {
106
228
  elements,
107
229
  catalog,
108
230
  registry,
109
- route: {
110
- path: '/account',
111
- loaderName: 'account',
112
- layout: 'default',
113
- metadata: {
114
- title: 'Mi cuenta',
115
- description: 'Inicia sesión o crea una cuenta para gestionar tu cuenta.',
231
+ route: [
232
+ {
233
+ path: '/account',
234
+ loaderName: 'account',
235
+ layout: 'default',
236
+ metadata: {
237
+ title: 'Mi cuenta',
238
+ description: 'Inicia sesión o crea una cuenta para gestionar tu cuenta.',
239
+ },
240
+ entry: pageRoot('account', ['account.boot', 'account.login', 'account.register', 'account.shell.overview'], elements),
116
241
  },
117
- entry: pageRoot(
118
- 'account',
119
- ['account.boot', 'account.login', 'account.register', 'account.panel', 'account.orders'],
120
- elements,
121
- ),
122
- },
242
+ {
243
+ path: '/account/orders',
244
+ loaderName: 'account',
245
+ layout: 'default',
246
+ metadata: {
247
+ title: 'Mis pedidos',
248
+ description: 'Consulta tus pedidos y su estado.',
249
+ },
250
+ entry: pageRoot(
251
+ 'accountOrders',
252
+ ['account.boot', 'account.login', 'account.register', 'account.shell.orders'],
253
+ elements,
254
+ ),
255
+ },
256
+ {
257
+ path: '/account/profile',
258
+ loaderName: 'account',
259
+ layout: 'default',
260
+ metadata: {
261
+ title: 'Mi perfil',
262
+ description: 'Actualiza tus datos personales y de contacto.',
263
+ },
264
+ entry: pageRoot(
265
+ 'accountProfile',
266
+ ['account.boot', 'account.login', 'account.register', 'account.shell.profile'],
267
+ elements,
268
+ ),
269
+ },
270
+ {
271
+ path: '/account/addresses',
272
+ loaderName: 'account',
273
+ layout: 'default',
274
+ metadata: {
275
+ title: 'Direcciones',
276
+ description: 'Gestiona tus direcciones de envío y facturación.',
277
+ },
278
+ entry: pageRoot(
279
+ 'accountAddresses',
280
+ ['account.boot', 'account.login', 'account.register', 'account.shell.addresses'],
281
+ elements,
282
+ ),
283
+ },
284
+ {
285
+ path: '/account/favorites',
286
+ loaderName: 'account',
287
+ layout: 'default',
288
+ metadata: {
289
+ title: 'Listas de compras',
290
+ description: 'Guarda productos para comprarlos más adelante.',
291
+ },
292
+ entry: pageRoot(
293
+ 'accountFavorites',
294
+ ['account.boot', 'account.login', 'account.register', 'account.shell.favorites'],
295
+ elements,
296
+ ),
297
+ },
298
+ {
299
+ // The order detail is a second route of the account view: it inherits the
300
+ // account feature gating and session lifecycle without a new view or
301
+ // feature. The loader only binds the dynamic segment; the loader-free port
302
+ // owns the data read and its typed states.
303
+ path: '/account/orders/[id]',
304
+ loaderName: 'orderDetail',
305
+ layout: 'default',
306
+ metadata: {
307
+ title: 'Pedido',
308
+ description: 'Detalle de tu pedido.',
309
+ },
310
+ entry: pageRoot('accountOrderDetail', ['account.orderDetail'], {
311
+ 'account.orderDetail': elements['account.orderDetail'],
312
+ }),
313
+ },
314
+ {
315
+ // The evidence route is nested under the order detail and binds both
316
+ // dynamic segments. The gallery only needs the fulfillment id; the order
317
+ // id keeps the URL scoped to the purchase. The evidence port owns the read
318
+ // and fails closed until the backend exists.
319
+ path: '/account/orders/[id]/fulfillments/[fulfillmentId]',
320
+ loaderName: 'fulfillmentEvidence',
321
+ layout: 'default',
322
+ metadata: {
323
+ title: 'Evidencias de entrega',
324
+ description: 'Consulta las evidencias de una entrega o recogida.',
325
+ },
326
+ entry: pageRoot('accountFulfillmentEvidence', ['account.fulfillmentEvidence'], {
327
+ 'account.fulfillmentEvidence': elements['account.fulfillmentEvidence'],
328
+ }),
329
+ },
330
+ ],
123
331
  loader: {
124
332
  account: async () => ({ dataSource: getDataSource(), dataError: null }),
333
+ orderDetail: async (params) => {
334
+ const orderId = Array.isArray(params.id) ? params.id[0] : params.id
335
+ if (!orderId) notFound()
336
+ return { orderDetailId: orderId }
337
+ },
338
+ fulfillmentEvidence: async (params) => {
339
+ const orderId = Array.isArray(params.id) ? params.id[0] : params.id
340
+ const fulfillmentId = Array.isArray(params.fulfillmentId)
341
+ ? params.fulfillmentId[0]
342
+ : params.fulfillmentId
343
+ if (!orderId || !fulfillmentId) notFound()
344
+ return { orderDetailId: orderId, fulfillmentEvidenceId: fulfillmentId }
345
+ },
125
346
  },
126
347
  }
@@ -0,0 +1,35 @@
1
+ 'use client'
2
+
3
+ import { OrderDetail as OrderDetailSurface } from '@thorprovider/blocks'
4
+ import type { OrderDetailProps } from '@thorprovider/blocks'
5
+
6
+ import { ports } from '../../ports'
7
+ import { accountOrderDetailPropsSchema } from './schema'
8
+
9
+ type PanelProps = {
10
+ props: Record<string, unknown>
11
+ }
12
+
13
+ /**
14
+ * Host panel for the /account/orders/[id] route. It parses the element props,
15
+ * injects the fail-closed `orderDetail` port and renders the landed surface with
16
+ * its own loading, error, not-found and forbidden states.
17
+ */
18
+ export function AccountOrderDetailPanel({ props }: PanelProps) {
19
+ const parsed = accountOrderDetailPropsSchema.parse(props)
20
+
21
+ return (
22
+ <div className="mx-auto w-full max-w-7xl px-4 py-8 sm:px-6 lg:px-8">
23
+ <OrderDetailSurface
24
+ orderId={parsed.orderId}
25
+ labels={parsed.labels as OrderDetailProps['labels']}
26
+ settings={parsed.settings as OrderDetailProps['settings']}
27
+ locale={parsed.locale}
28
+ presentation={parsed.presentation as OrderDetailProps['presentation']}
29
+ openSections={parsed.openSections as OrderDetailProps['openSections']}
30
+ access={parsed.access}
31
+ port={ports.orderDetail}
32
+ />
33
+ </div>
34
+ )
35
+ }