@thorprovider/storefront 0.9.0 → 0.11.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 (66) hide show
  1. package/README.md +8 -5
  2. package/assets/templates/app/app/globals.css +0 -1
  3. package/assets/templates/app/lib/__STOREFRONT__/account-session.core.ts +4 -2
  4. package/assets/templates/app/lib/__STOREFRONT__/account-user.core.ts +2 -1
  5. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +130 -12
  6. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +156 -9
  7. package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +38 -3
  8. package/assets/templates/app/lib/__STOREFRONT__/fulfillment-evidence-port.ts +31 -0
  9. package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +21 -4
  10. package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +6 -2
  11. package/assets/templates/app/lib/__STOREFRONT__/order-detail-aftersales.ts +55 -0
  12. package/assets/templates/app/lib/__STOREFRONT__/order-detail-capabilities.ts +79 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/order-detail-mapper.ts +653 -0
  14. package/assets/templates/app/lib/__STOREFRONT__/order-detail-money.ts +39 -0
  15. package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +6 -7
  16. package/assets/templates/app/lib/__STOREFRONT__/order-detail-reorder.ts +62 -0
  17. package/assets/templates/app/lib/__STOREFRONT__/ports.ts +13 -3
  18. package/assets/templates/views/account/assembly/assembly.json +0 -5
  19. package/assets/templates/views/account/assembly/index.skeleton.tsx +51 -0
  20. package/assets/templates/views/account/assembly/registry.skeleton.tsx +120 -68
  21. package/assets/templates/views/account/content.ts +13 -7
  22. package/assets/templates/views/account/fulfillment-evidence.client.tsx +34 -0
  23. package/assets/templates/views/account/fulfillment-evidence.defaults.ts +145 -0
  24. package/assets/templates/views/account/fulfillment-evidence.schema.ts +15 -0
  25. package/assets/templates/views/account/index.tsx +44 -3
  26. package/assets/templates/views/account/order-detail-flows.defaults.ts +106 -0
  27. package/assets/templates/views/account/order-detail-invoice.ts +136 -0
  28. package/assets/templates/views/account/order-detail-sheet.tsx +100 -0
  29. package/assets/templates/views/account/order-detail-sheets.tsx +122 -0
  30. package/assets/templates/views/account/order-detail.client.tsx +401 -1
  31. package/assets/templates/views/account/orders-advanced.client.tsx +10 -99
  32. package/assets/templates/views/account/orders-advanced.defaults.ts +7 -7
  33. package/assets/templates/views/account/registry.tsx +120 -69
  34. package/assets/templates/views/account/schema.ts +2 -0
  35. package/assets/templates/views/home/assembly/assembly.json +1 -1
  36. package/assets/templates/views/home/assembly/index.skeleton.tsx +3 -1
  37. package/assets/templates/views/home/assembly/registry.skeleton.tsx +1 -0
  38. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/binding.json +5 -0
  39. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/catalog.part +4 -0
  40. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/element.part +4 -0
  41. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +10 -0
  42. package/assets/templates/views/home/content.ts +248 -2
  43. package/assets/templates/views/home/data.ts +10 -1
  44. package/assets/templates/views/home/index.tsx +7 -6
  45. package/assets/templates/views/home/props.ts +7 -1
  46. package/assets/templates/views/home/registry.tsx +11 -28
  47. package/assets/templates/views/home/schema.ts +163 -0
  48. package/assets/templates/views/product/data.ts +13 -6
  49. package/assets/templates/views/product/index.tsx +3 -3
  50. package/bin/storefront.js +18 -18
  51. package/package.json +1 -1
  52. package/recipes/adapter-surface.json +1 -0
  53. package/recipes/archetypes.json +5 -1
  54. package/recipes/catalog.json +9 -1
  55. package/recipes/recipes.json +5 -4
  56. package/scripts/candidate.mjs +59 -14
  57. package/scripts/file-classes.mjs +4 -0
  58. package/scripts/mock-capabilities.mjs +22 -0
  59. package/scripts/reconcile.mjs +5 -2
  60. package/scripts/render-templates.mjs +126 -43
  61. package/skills/sf-view-gen/assets/recipes/archetypes.json +5 -1
  62. package/skills/sf-view-gen/assets/recipes/catalog.json +9 -1
  63. package/skills/sf-view-gen/assets/recipes/recipes.json +5 -4
  64. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +0 -5
  65. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +0 -5
  66. package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +0 -1
@@ -5,13 +5,12 @@ export type OrderDetailRunner = OrderDetailPort['get']
5
5
 
6
6
  /**
7
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.
8
+ * `STOREFRONT_BACKEND_WIRING/components/order-detail.md`. The generated host
9
+ * injects its ownership-scoped runner (`loadOrderDetailAction`): mock mode
10
+ * serves the same customer-owned order store as the history, while a live
11
+ * provider without a detail endpoint fails closed through that runner. With no
12
+ * runner at all the port throws the same typed `unavailable` error, so the
13
+ * surface renders its own error state and never synthesizes an order.
15
14
  */
16
15
  export function createOrderDetailPort(run?: OrderDetailRunner): OrderDetailPort {
17
16
  return {
@@ -0,0 +1,62 @@
1
+ import type { Order } from '@thorprovider/types'
2
+
3
+ /** One cart line a reorder would add, derived from the stored order. */
4
+ export type ReorderLine = {
5
+ variantId: string
6
+ quantity: number
7
+ title: string
8
+ }
9
+
10
+ export type ReorderSkip = { title: string; reason: string }
11
+
12
+ export type ReorderOrderResult =
13
+ | { ok: true; added: number; skipped: ReorderSkip[] }
14
+ | { ok: false; error: string }
15
+
16
+ /**
17
+ * Project a stored order into cart lines.
18
+ *
19
+ * The backend order is the only source: the browser sends an order id, never
20
+ * variants or quantities. A line without a backend variant cannot be re-added,
21
+ * and an empty quantity means there is nothing to buy — both are reported so the
22
+ * shopper sees what was left out instead of a clean "added" claim.
23
+ */
24
+ export function toReorderLines(order: Order): {
25
+ lines: ReorderLine[]
26
+ skipped: ReorderSkip[]
27
+ } {
28
+ const lines: ReorderLine[] = []
29
+ const skipped: ReorderSkip[] = []
30
+
31
+ for (const item of order.items ?? []) {
32
+ const quantity = Math.max(0, Math.floor(Number(item.quantity) || 0))
33
+ if (!item.variantId) {
34
+ skipped.push({ title: item.title, reason: 'Sin variante disponible' })
35
+ continue
36
+ }
37
+ if (quantity === 0) {
38
+ skipped.push({ title: item.title, reason: 'Sin unidades disponibles' })
39
+ continue
40
+ }
41
+ lines.push({ variantId: item.variantId, quantity, title: item.title })
42
+ }
43
+
44
+ return { lines, skipped }
45
+ }
46
+
47
+ /**
48
+ * Run the reorder server action, turning a transport failure into the same
49
+ * readable result the UI already renders. A rejected server-action call is not
50
+ * an exception the shopper can act on, and it must never look like success.
51
+ */
52
+ export async function runReorder(
53
+ action: (input: { orderId: string }) => Promise<ReorderOrderResult>,
54
+ orderId: string,
55
+ fallback = 'No se pudo repetir la compra.',
56
+ ): Promise<ReorderOrderResult> {
57
+ try {
58
+ return await action({ orderId })
59
+ } catch {
60
+ return { ok: false, error: fallback }
61
+ }
62
+ }
@@ -1,18 +1,28 @@
1
+ import { PortError } from '@thorprovider/blocks/ports'
2
+
1
3
  import { createAddressesPort } from './addresses-port'
2
4
  import { createCustomerProfilePort } from './customer-profile-port'
5
+ import { createFulfillmentEvidencePort } from './fulfillment-evidence-port'
3
6
  import { createOrderDetailPort } from './order-detail-port'
4
7
  import { createOrdersPort } from './orders-port'
8
+ import { loadOrderDetailAction } from './actions'
5
9
 
6
10
  /**
7
11
  * Host-injected asynchronous ports. `orders` is the seam for the advanced
8
12
  * account order history (the default `account.orders` surface); its runner is
9
13
  * 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.
14
+ * `orderDetail` is the seam for the /account/orders/[id] route; its runner is
15
+ * the ownership-scoped customer detail read, wired for mock mode. A live
16
+ * provider without a detail endpoint reports a typed `unavailable` outcome.
12
17
  */
13
18
  export const ports = {
14
19
  orders: createOrdersPort(),
15
- orderDetail: createOrderDetailPort(),
20
+ orderDetail: createOrderDetailPort(async (orderId) => {
21
+ const result = await loadOrderDetailAction({ id: orderId })
22
+ if (!result.ok) throw new PortError(result.code, result.error)
23
+ return result.snapshot
24
+ }),
25
+ fulfillmentEvidence: createFulfillmentEvidencePort(),
16
26
  customerProfile: createCustomerProfilePort(),
17
27
  addresses: createAddressesPort(),
18
28
  }
@@ -1,11 +1,6 @@
1
1
  {
2
2
  "view": "account",
3
3
  "slots": [
4
- {
5
- "id": "account.boot",
6
- "slot": "boot",
7
- "default": "AccountBoot"
8
- },
9
4
  {
10
5
  "id": "account.login",
11
6
  "slot": "login",
@@ -24,6 +24,8 @@ import { registry } from './registry'
24
24
  import { sectionData } from './sections-data'
25
25
  import { accountContent } from './content'
26
26
  import { orderDetailDefaults } from './order-detail.defaults'
27
+ import { orderDetailFlowLabels, orderDetailSupport } from './order-detail-flows.defaults'
28
+ import { fulfillmentEvidenceDefaults } from './fulfillment-evidence.defaults'
27
29
  import { accountOrdersAdvancedDefaults } from './orders-advanced.defaults'@@SECTION_IMPORTS@@
28
30
  import {
29
31
  accountAddressPropsSchema,
@@ -36,6 +38,7 @@ import {
36
38
  accountProfilePropsSchema,
37
39
  accountRegisterPropsSchema,
38
40
  } from './schema'
41
+ import { accountFulfillmentEvidencePropsSchema } from './fulfillment-evidence.schema'
39
42
  import { customerProfileDefaults } from './customer-profile.defaults'
40
43
  import { customerProfilePropsSchema } from '../sections/schema.customer-profile'
41
44
  import { addressBookAdvancedDefaults } from './address-book-advanced.defaults'
@@ -57,6 +60,25 @@ const elements: Record<string, StorefrontElement> = {
57
60
  props: {
58
61
  orderId: { $state: '/orderDetailId' },
59
62
  ...orderDetailDefaults,
63
+ supportHref: orderDetailSupport.href,
64
+ flows: orderDetailFlowLabels,
65
+ },
66
+ },
67
+ // Headless account boundary. It is fixed infrastructure, not a selectable
68
+ // slot, so a generated store's normalized composition cannot drop it and
69
+ // leave every account route referencing a missing element.
70
+ 'account.boot': {
71
+ type: 'AccountBoot',
72
+ props: {},
73
+ on: { retry: { action: 'retryAccountSession' } },
74
+ },
75
+ // Route-only evidence element: it belongs to the nested fulfillment route,
76
+ // never to the account page root or the order-detail page root.
77
+ 'account.fulfillmentEvidence': {
78
+ type: 'AccountFulfillmentEvidence',
79
+ props: {
80
+ fulfillmentId: { $state: '/fulfillmentEvidenceId' },
81
+ ...fulfillmentEvidenceDefaults,
60
82
  },
61
83
  },
62
84
  @@ELEMENTS@@
@@ -111,6 +133,11 @@ const catalog = {
111
133
  description:
112
134
  'Route-only order detail surface for one authenticated customer order; the host port supplies the data and the block owns its states.',
113
135
  },
136
+ AccountFulfillmentEvidence: {
137
+ props: accountFulfillmentEvidencePropsSchema,
138
+ description:
139
+ '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.',
140
+ },
114
141
  @@CATALOG@@
115
142
  AccountShell: {
116
143
  props: accountEmptyPropsSchema,
@@ -217,6 +244,22 @@ export const account: ViewModule = {
217
244
  'account.orderDetail': elements['account.orderDetail'],
218
245
  }),
219
246
  },
247
+ {
248
+ // The evidence route is nested under the order detail and binds both
249
+ // dynamic segments. The gallery only needs the fulfillment id; the order
250
+ // id keeps the URL scoped to the purchase. The evidence port owns the read
251
+ // and fails closed until the backend exists.
252
+ path: '/account/orders/[id]/fulfillments/[fulfillmentId]',
253
+ loaderName: 'fulfillmentEvidence',
254
+ layout: 'default',
255
+ metadata: {
256
+ title: 'Evidencias de entrega',
257
+ description: 'Consulta las evidencias de una entrega o recogida.',
258
+ },
259
+ entry: pageRoot('accountFulfillmentEvidence', ['account.fulfillmentEvidence'], {
260
+ 'account.fulfillmentEvidence': elements['account.fulfillmentEvidence'],
261
+ }),
262
+ },
220
263
  ],
221
264
  loader: {
222
265
  account: async () => ({ dataSource: getDataSource(), dataError: null }),
@@ -225,5 +268,13 @@ export const account: ViewModule = {
225
268
  if (!orderId) notFound()
226
269
  return { orderDetailId: orderId }
227
270
  },
271
+ fulfillmentEvidence: async (params) => {
272
+ const orderId = Array.isArray(params.id) ? params.id[0] : params.id
273
+ const fulfillmentId = Array.isArray(params.fulfillmentId)
274
+ ? params.fulfillmentId[0]
275
+ : params.fulfillmentId
276
+ if (!orderId || !fulfillmentId) notFound()
277
+ return { orderDetailId: orderId, fulfillmentEvidenceId: fulfillmentId }
278
+ },
228
279
  },
229
280
  }
@@ -32,7 +32,6 @@ import {
32
32
  OrderHistory as OrderHistoryBlock,
33
33
  ProfileForm as ProfileFormBlock,
34
34
  SignUpPage1 as SignUpBlock,
35
- formatMoney,
36
35
  } from '@thorprovider/blocks'
37
36
  import type {
38
37
  AddressBookLabels,
@@ -62,6 +61,7 @@ import type { AccountAddressView, AccountOrderView } from '../../state.core'
62
61
  import type { ViewRegistry } from '../types'
63
62
  import { accountContent } from './content'
64
63
  import { AccountOrderDetailPanel } from './order-detail.client'
64
+ import { AccountFulfillmentEvidencePanel } from './fulfillment-evidence.client'
65
65
  import {
66
66
  accountAddressPropsSchema,
67
67
  accountFramePropsSchema,
@@ -118,6 +118,15 @@ const SHELL_DEFAULTS = {
118
118
  },
119
119
  overview: {
120
120
  sections: 'Secciones de tu cuenta',
121
+ // The card summaries are preformatted text, exactly what the host passes. A
122
+ // module with nothing inside keeps its card summary-less: the overview never
123
+ // prints a zero to fill space.
124
+ summaries: {
125
+ orders: '{count} pedidos',
126
+ ordersOne: '1 pedido',
127
+ addresses: '{count} guardadas',
128
+ addressesOne: '1 guardada',
129
+ },
121
130
  },
122
131
  placeholder: {
123
132
  badge: 'Próximamente',
@@ -182,6 +191,10 @@ const shellContent = {
182
191
  overview: {
183
192
  ...SHELL_DEFAULTS.overview,
184
193
  ...(accountContentCompat.overview ?? {}),
194
+ summaries: {
195
+ ...SHELL_DEFAULTS.overview.summaries,
196
+ ...(accountContentCompat.overview?.summaries ?? {}),
197
+ },
185
198
  },
186
199
  placeholder: {
187
200
  ...SHELL_DEFAULTS.placeholder,
@@ -360,14 +373,29 @@ function shellCustomer(customer: Customer): CustomerAccountV1Props['context']['c
360
373
  .map((part) => part[0])
361
374
  .join('')
362
375
  .toUpperCase() || customer.email.slice(0, 2).toUpperCase()
376
+ const memberSince = memberSinceLabel(customer.createdAt)
363
377
  return {
364
378
  name,
365
379
  email: customer.email,
366
380
  initials,
367
381
  ...(customer.phone ? { phone: customer.phone } : {}),
382
+ ...(memberSince ? { memberSince } : {}),
368
383
  }
369
384
  }
370
385
 
386
+ /**
387
+ * The join date the header prints as "Cliente desde {date}". Only the month and
388
+ * year leave the store ("marzo de 2023"), the same granularity the account
389
+ * surface needs; an absent or unparseable date simply hides the line instead of
390
+ * inventing one.
391
+ */
392
+ function memberSinceLabel(createdAt: string | null | undefined): string | undefined {
393
+ if (!createdAt) return undefined
394
+ const date = new Date(createdAt)
395
+ if (Number.isNaN(date.getTime())) return undefined
396
+ return new Intl.DateTimeFormat('es-ES', { month: 'long', year: 'numeric' }).format(date)
397
+ }
398
+
371
399
  function shellState(state: AccountState): CustomerAccountV1Props['state'] {
372
400
  if (state.accountReconciling === true) return { status: 'loading' }
373
401
  if (state.accountResolution === 'unavailable') {
@@ -432,10 +460,93 @@ function AccountShellPanel({ children }: ShellPanelProps) {
432
460
  )
433
461
  }
434
462
 
463
+ /** One order row is enough to read the authoritative page count. */
464
+ const OVERVIEW_ORDERS_PAGE_SIZE = 1
465
+
466
+ function summaryText(template: string, single: string, count: number): string {
467
+ return count === 1 ? single : template.replaceAll('{count}', String(count))
468
+ }
469
+
470
+ /**
471
+ * Preformatted card summaries. The overview names how much is waiting inside the
472
+ * modules, so it reads the two counters the modules load anyway: the order page
473
+ * count and the saved-address list. Nothing is invented — a module the store
474
+ * does not offer is never counted, a failed read leaves the card summary-less,
475
+ * and an empty module prints no zero.
476
+ */
477
+ function overviewSummaries(
478
+ state: AccountState,
479
+ capabilities: CustomerAccountOverviewProps['capabilities'],
480
+ ): Record<string, string> {
481
+ const summaries: Record<string, string> = {}
482
+ const orderCount =
483
+ typeof state.accountOrdersCount === 'number' ? state.accountOrdersCount : 0
484
+ const addressCount = Array.isArray(state.accountAddresses)
485
+ ? state.accountAddresses.length
486
+ : 0
487
+ if (capabilities.orderHistory === true && orderCount > 0) {
488
+ summaries.orders = summaryText(
489
+ shellContent.overview.summaries.orders,
490
+ shellContent.overview.summaries.ordersOne,
491
+ orderCount,
492
+ )
493
+ }
494
+ if (capabilities.addressBook === true && addressCount > 0) {
495
+ summaries.addresses = summaryText(
496
+ shellContent.overview.summaries.addresses,
497
+ shellContent.overview.summaries.addressesOne,
498
+ addressCount,
499
+ )
500
+ }
501
+ return summaries
502
+ }
503
+
435
504
  function AccountOverviewPanel() {
436
- const { state } = useStateStore()
505
+ const { state, set } = useStateStore()
437
506
  const pathname = usePathname()
438
507
  const router = useRouter()
508
+ const { identityKey, reconciling } = useAccountLifecycle()
509
+ const loadedKeyRef = useRef<string | null>(null)
510
+ const capabilities = shellCapabilities(state)
511
+ const authenticated = state.accountAuthenticated === true
512
+ const wantsOrders = capabilities.orderHistory === true
513
+ const wantsAddresses = capabilities.addressBook === true
514
+
515
+ // The overview is the only surface that needs a count without rendering the
516
+ // module, so it performs the same reads the module would and stores their
517
+ // result in the shared account state. Keyed by identity: a new shopper never
518
+ // inherits the previous one's counters, and a read that lands after an
519
+ // identity change is dropped instead of overwriting the new state.
520
+ useEffect(() => {
521
+ if (!authenticated || reconciling) return
522
+ if (pathname !== '/account') return
523
+ if (identityKey === 'anonymous') return
524
+ if (loadedKeyRef.current === identityKey) return
525
+ loadedKeyRef.current = identityKey
526
+ if (wantsOrders) {
527
+ void loadOrdersPageAction({ page: 1, pageSize: OVERVIEW_ORDERS_PAGE_SIZE })
528
+ .then((result) => {
529
+ if (result.ok && loadedKeyRef.current === identityKey) {
530
+ set('/accountOrdersCount', result.count)
531
+ }
532
+ })
533
+ .catch(() => {
534
+ // A failed count read is not an account error: the card keeps its
535
+ // description and simply shows no summary.
536
+ })
537
+ }
538
+ if (wantsAddresses) {
539
+ void loadAccountAddressesAction()
540
+ .then((result) => {
541
+ if (result.ok && loadedKeyRef.current === identityKey) {
542
+ set('/accountAddresses', result.addresses)
543
+ }
544
+ })
545
+ .catch(() => {
546
+ // Same rule as the order count: no summary beats a made-up number.
547
+ })
548
+ }
549
+ }, [authenticated, reconciling, pathname, identityKey, wantsOrders, wantsAddresses, set])
439
550
 
440
551
  useEffect(() => {
441
552
  if (pathname !== '/account') return
@@ -448,12 +559,12 @@ function AccountOverviewPanel() {
448
559
  return () => cancelAnimationFrame(frame)
449
560
  }, [pathname])
450
561
 
451
- if (!state.accountAuthenticated) return null
562
+ if (!authenticated) return null
452
563
  return (
453
564
  <AccountOverviewBlock
454
565
  title={shellContent.shellModules.overview.label}
455
- model={{ cards: shellCards(), summaries: {}, notice: null }}
456
- capabilities={shellCapabilities(state)}
566
+ model={{ cards: shellCards(), summaries: overviewSummaries(state, capabilities), notice: null }}
567
+ capabilities={capabilities}
457
568
  labels={{ sections: shellContent.overview.sections }}
458
569
  onOpenCard={(cardId) => {
459
570
  sessionStorage.setItem('account:origin-card', cardId)
@@ -564,62 +675,6 @@ function toOrderHistoryOrder(order: AccountOrderView): OrderHistoryOrder {
564
675
  }
565
676
  }
566
677
 
567
- function OrderDetail({ order, onClose }: { order: AccountOrderView; onClose: () => void }) {
568
- const amount = (value: AccountOrderView['total']) => formatMoney(value) ?? '—'
569
- const totals = (
570
- [
571
- { label: 'Subtotal', value: order.subtotal },
572
- { label: 'Impuestos', value: order.tax },
573
- { label: 'Envío', value: order.shipping },
574
- { label: 'Total', value: order.total },
575
- ] as { label: string; value?: AccountOrderView['total'] }[]
576
- ).filter(
577
- (row): row is { label: string; value: AccountOrderView['total'] } => row.value !== undefined,
578
- )
579
- return (
580
- <div className="mx-auto w-full max-w-7xl px-4 pb-12 sm:px-6 lg:px-8">
581
- <div className="rounded-lg border p-6">
582
- <div className="flex items-start justify-between gap-4">
583
- <div>
584
- <h3 className="text-lg font-semibold">Pedido {order.number}</h3>
585
- <p className="text-muted-foreground mt-1 text-sm">
586
- {order.date} · {order.status}
587
- </p>
588
- </div>
589
- <Button type="button" variant="outline" size="sm" onClick={onClose}>
590
- Cerrar
591
- </Button>
592
- </div>
593
- {order.address ? (
594
- <p className="text-muted-foreground mt-2 text-sm">{order.address}</p>
595
- ) : null}
596
- <ul className="mt-4 divide-y">
597
- {order.items.map((item) => (
598
- <li key={item.id} className="flex items-center justify-between py-2 text-sm">
599
- <span>
600
- {item.name}
601
- {item.variant ? (
602
- <span className="text-muted-foreground"> · {item.variant}</span>
603
- ) : null}
604
- <span className="text-muted-foreground"> × {item.quantity}</span>
605
- </span>
606
- <span>{amount(item.lineTotal)}</span>
607
- </li>
608
- ))}
609
- </ul>
610
- <dl className="mt-4 space-y-1 border-t pt-4 text-sm">
611
- {totals.map((row) => (
612
- <div key={row.label} className="flex justify-between">
613
- <dt className="text-muted-foreground">{row.label}</dt>
614
- <dd>{amount(row.value)}</dd>
615
- </div>
616
- ))}
617
- </dl>
618
- </div>
619
- </div>
620
- )
621
- }
622
-
623
678
  function AccountLoginPanel({ props, emit }: PanelProps) {
624
679
  const { state } = useStateStore()
625
680
  const lifecycle = useAccountLifecycle()
@@ -941,6 +996,7 @@ function AccountAddressesPanel({ props }: PanelProps) {
941
996
  }
942
997
 
943
998
  function AccountOrdersPanel({ props }: PanelProps) {
999
+ const router = useRouter()
944
1000
  const { state, set, getSnapshot } = useStateStore()
945
1001
  const parsed = accountOrdersPropsSchema.parse(props)
946
1002
  const { identityKey, reconciling } = useAccountLifecycle()
@@ -1025,9 +1081,6 @@ function AccountOrdersPanel({ props }: PanelProps) {
1025
1081
  typeof state.accountOrdersPageSize === 'number' && state.accountOrdersPageSize > 0
1026
1082
  ? state.accountOrdersPageSize
1027
1083
  : ORDERS_PAGE_SIZE
1028
- const selectedId =
1029
- typeof state.accountSelectedOrderId === 'string' ? state.accountSelectedOrderId : null
1030
- const selected = selectedId ? orders.find((order) => order.id === selectedId) ?? null : null
1031
1084
  const labels: Partial<OrderHistoryLabels> = {
1032
1085
  ...(parsed.labels ?? {}),
1033
1086
  ...(parsed.titleLabel === undefined ? {} : { title: parsed.titleLabel }),
@@ -1072,7 +1125,7 @@ function AccountOrdersPanel({ props }: PanelProps) {
1072
1125
  orders={orders.map(toOrderHistoryOrder)}
1073
1126
  presentation="cards"
1074
1127
  labels={labels}
1075
- onViewOrder={(id) => set('/accountSelectedOrderId', id)}
1128
+ onViewOrder={(id) => router.push(`/account/orders/${encodeURIComponent(id)}`)}
1076
1129
  />
1077
1130
  {count > pageSize ? (
1078
1131
  <div className="mx-auto flex w-full max-w-7xl items-center justify-between gap-4 px-4 pb-6 sm:px-6 lg:px-8">
@@ -1099,15 +1152,14 @@ function AccountOrdersPanel({ props }: PanelProps) {
1099
1152
  </div>
1100
1153
  </div>
1101
1154
  ) : null}
1102
- {selected ? (
1103
- <OrderDetail order={selected} onClose={() => set('/accountSelectedOrderId', null)} />
1104
- ) : null}
1105
1155
  </div>
1106
1156
  )
1107
1157
  }
1108
1158
 
1109
1159
  export const registry: ViewRegistry = {
1160
+ AccountBoot: ({ emit }) => <AccountBoundary emit={emit} />,
1110
1161
  AccountOrderDetail: (ctx) => <AccountOrderDetailPanel {...ctx} />,
1162
+ AccountFulfillmentEvidence: (ctx) => <AccountFulfillmentEvidencePanel {...ctx} />,
1111
1163
  AccountShell: (ctx) => <AccountShellPanel {...ctx} />,
1112
1164
  AccountOverview: () => <AccountOverviewPanel />,
1113
1165
  AccountModulePlaceholder: () => <AccountModulePlaceholderPanel />,
@@ -29,6 +29,12 @@ export const accountContent = {
29
29
  },
30
30
  overview: {
31
31
  sections: 'Secciones de tu cuenta',
32
+ summaries: {
33
+ orders: '{count} pedidos',
34
+ ordersOne: '1 pedido',
35
+ addresses: '{count} guardadas',
36
+ addressesOne: '1 guardada',
37
+ },
32
38
  },
33
39
  placeholder: {
34
40
  badge: 'Próximamente',
@@ -167,14 +173,14 @@ export const accountContent = {
167
173
  paymentLabel: 'Pago',
168
174
  fulfilmentLabel: 'Entrega',
169
175
  capabilities: {
170
- tableView: false,
171
- shipmentTracking: false,
172
- pickupTracking: false,
173
- returns: false,
174
- exchanges: false,
176
+ tableView: true,
177
+ shipmentTracking: true,
178
+ pickupTracking: true,
179
+ returns: true,
180
+ exchanges: true,
175
181
  claims: false,
176
- reorder: false,
177
- invoices: false,
182
+ reorder: true,
183
+ invoices: true,
178
184
  bulkSelection: false,
179
185
  export: false,
180
186
  companyOrders: false,
@@ -0,0 +1,34 @@
1
+ 'use client'
2
+
3
+ import {
4
+ FulfillmentEvidenceGallery as FulfillmentEvidenceGallerySurface,
5
+ } from '@thorprovider/blocks'
6
+ import type { FulfillmentEvidenceGalleryProps } from '@thorprovider/blocks'
7
+
8
+ import { ports } from '../../ports'
9
+ import { accountFulfillmentEvidencePropsSchema } from './fulfillment-evidence.schema'
10
+
11
+ type PanelProps = {
12
+ props: Record<string, unknown>
13
+ }
14
+
15
+ /**
16
+ * Host panel for the /account/orders/[id]/fulfillments/[fulfillmentId] route.
17
+ * It parses the element props, injects the fail-closed evidence port and renders
18
+ * the landed surface with its own loading, error, forbidden and not-found states.
19
+ */
20
+ export function AccountFulfillmentEvidencePanel({ props }: PanelProps) {
21
+ const parsed = accountFulfillmentEvidencePropsSchema.parse(props)
22
+
23
+ return (
24
+ <div className="mx-auto w-full max-w-5xl px-4 py-8 sm:px-6 lg:px-8">
25
+ <FulfillmentEvidenceGallerySurface
26
+ fulfillmentId={parsed.fulfillmentId}
27
+ labels={parsed.labels as FulfillmentEvidenceGalleryProps['labels']}
28
+ capabilities={parsed.capabilities as FulfillmentEvidenceGalleryProps['capabilities']}
29
+ presentation={parsed.presentation as FulfillmentEvidenceGalleryProps['presentation']}
30
+ port={ports.fulfillmentEvidence}
31
+ />
32
+ </div>
33
+ )
34
+ }