@thorprovider/storefront 0.9.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.
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +57 -1
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +138 -7
- package/assets/templates/app/lib/__STOREFRONT__/fulfillment-evidence-port.ts +31 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +21 -4
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +6 -2
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-mapper.ts +642 -0
- package/assets/templates/app/lib/__STOREFRONT__/order-detail-port.ts +6 -7
- package/assets/templates/app/lib/__STOREFRONT__/ports.ts +13 -3
- package/assets/templates/views/account/assembly/assembly.json +0 -5
- package/assets/templates/views/account/assembly/index.skeleton.tsx +48 -0
- package/assets/templates/views/account/assembly/registry.skeleton.tsx +5 -64
- package/assets/templates/views/account/content.ts +7 -7
- package/assets/templates/views/account/fulfillment-evidence.client.tsx +34 -0
- package/assets/templates/views/account/fulfillment-evidence.defaults.ts +145 -0
- package/assets/templates/views/account/fulfillment-evidence.schema.ts +15 -0
- package/assets/templates/views/account/index.tsx +41 -3
- package/assets/templates/views/account/orders-advanced.client.tsx +10 -99
- package/assets/templates/views/account/orders-advanced.defaults.ts +7 -7
- package/assets/templates/views/account/registry.tsx +5 -65
- package/assets/templates/views/home/assembly/assembly.json +1 -1
- package/assets/templates/views/home/assembly/index.skeleton.tsx +3 -1
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +1 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/element.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +10 -0
- package/assets/templates/views/home/content.ts +246 -2
- package/assets/templates/views/home/data.ts +10 -1
- package/assets/templates/views/home/index.tsx +7 -6
- package/assets/templates/views/home/props.ts +7 -1
- package/assets/templates/views/home/registry.tsx +11 -28
- package/assets/templates/views/home/schema.ts +163 -0
- package/bin/storefront.js +13 -14
- package/package.json +1 -1
- package/recipes/adapter-surface.json +1 -0
- package/recipes/archetypes.json +5 -1
- package/recipes/catalog.json +9 -1
- package/recipes/recipes.json +5 -4
- package/scripts/candidate.mjs +55 -14
- package/scripts/file-classes.mjs +4 -0
- package/skills/sf-view-gen/assets/recipes/archetypes.json +5 -1
- package/skills/sf-view-gen/assets/recipes/catalog.json +9 -1
- package/skills/sf-view-gen/assets/recipes/recipes.json +5 -4
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/catalog.part +0 -5
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/element.part +0 -5
- package/assets/templates/views/account/assembly/slots/boot/AccountBoot/registry.part +0 -1
|
@@ -24,6 +24,7 @@ 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 { fulfillmentEvidenceDefaults } from './fulfillment-evidence.defaults'
|
|
27
28
|
import { accountOrdersAdvancedDefaults } from './orders-advanced.defaults'@@SECTION_IMPORTS@@
|
|
28
29
|
import {
|
|
29
30
|
accountAddressPropsSchema,
|
|
@@ -36,6 +37,7 @@ import {
|
|
|
36
37
|
accountProfilePropsSchema,
|
|
37
38
|
accountRegisterPropsSchema,
|
|
38
39
|
} from './schema'
|
|
40
|
+
import { accountFulfillmentEvidencePropsSchema } from './fulfillment-evidence.schema'
|
|
39
41
|
import { customerProfileDefaults } from './customer-profile.defaults'
|
|
40
42
|
import { customerProfilePropsSchema } from '../sections/schema.customer-profile'
|
|
41
43
|
import { addressBookAdvancedDefaults } from './address-book-advanced.defaults'
|
|
@@ -59,6 +61,23 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
59
61
|
...orderDetailDefaults,
|
|
60
62
|
},
|
|
61
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.
|
|
67
|
+
'account.boot': {
|
|
68
|
+
type: 'AccountBoot',
|
|
69
|
+
props: {},
|
|
70
|
+
on: { retry: { action: 'retryAccountSession' } },
|
|
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
|
+
},
|
|
62
81
|
@@ELEMENTS@@
|
|
63
82
|
// Route-specific shell roots. The same shell component receives the active
|
|
64
83
|
// module as children; the route, not a client tab, decides which module is
|
|
@@ -111,6 +130,11 @@ const catalog = {
|
|
|
111
130
|
description:
|
|
112
131
|
'Route-only order detail surface for one authenticated customer order; the host port supplies the data and the block owns its states.',
|
|
113
132
|
},
|
|
133
|
+
AccountFulfillmentEvidence: {
|
|
134
|
+
props: accountFulfillmentEvidencePropsSchema,
|
|
135
|
+
description:
|
|
136
|
+
'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.',
|
|
137
|
+
},
|
|
114
138
|
@@CATALOG@@
|
|
115
139
|
AccountShell: {
|
|
116
140
|
props: accountEmptyPropsSchema,
|
|
@@ -217,6 +241,22 @@ export const account: ViewModule = {
|
|
|
217
241
|
'account.orderDetail': elements['account.orderDetail'],
|
|
218
242
|
}),
|
|
219
243
|
},
|
|
244
|
+
{
|
|
245
|
+
// The evidence route is nested under the order detail and binds both
|
|
246
|
+
// dynamic segments. The gallery only needs the fulfillment id; the order
|
|
247
|
+
// id keeps the URL scoped to the purchase. The evidence port owns the read
|
|
248
|
+
// and fails closed until the backend exists.
|
|
249
|
+
path: '/account/orders/[id]/fulfillments/[fulfillmentId]',
|
|
250
|
+
loaderName: 'fulfillmentEvidence',
|
|
251
|
+
layout: 'default',
|
|
252
|
+
metadata: {
|
|
253
|
+
title: 'Evidencias de entrega',
|
|
254
|
+
description: 'Consulta las evidencias de una entrega o recogida.',
|
|
255
|
+
},
|
|
256
|
+
entry: pageRoot('accountFulfillmentEvidence', ['account.fulfillmentEvidence'], {
|
|
257
|
+
'account.fulfillmentEvidence': elements['account.fulfillmentEvidence'],
|
|
258
|
+
}),
|
|
259
|
+
},
|
|
220
260
|
],
|
|
221
261
|
loader: {
|
|
222
262
|
account: async () => ({ dataSource: getDataSource(), dataError: null }),
|
|
@@ -225,5 +265,13 @@ export const account: ViewModule = {
|
|
|
225
265
|
if (!orderId) notFound()
|
|
226
266
|
return { orderDetailId: orderId }
|
|
227
267
|
},
|
|
268
|
+
fulfillmentEvidence: async (params) => {
|
|
269
|
+
const orderId = Array.isArray(params.id) ? params.id[0] : params.id
|
|
270
|
+
const fulfillmentId = Array.isArray(params.fulfillmentId)
|
|
271
|
+
? params.fulfillmentId[0]
|
|
272
|
+
: params.fulfillmentId
|
|
273
|
+
if (!orderId || !fulfillmentId) notFound()
|
|
274
|
+
return { orderDetailId: orderId, fulfillmentEvidenceId: fulfillmentId }
|
|
275
|
+
},
|
|
228
276
|
},
|
|
229
277
|
}
|
|
@@ -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,
|
|
@@ -564,62 +564,6 @@ function toOrderHistoryOrder(order: AccountOrderView): OrderHistoryOrder {
|
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
566
|
|
|
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
567
|
function AccountLoginPanel({ props, emit }: PanelProps) {
|
|
624
568
|
const { state } = useStateStore()
|
|
625
569
|
const lifecycle = useAccountLifecycle()
|
|
@@ -941,6 +885,7 @@ function AccountAddressesPanel({ props }: PanelProps) {
|
|
|
941
885
|
}
|
|
942
886
|
|
|
943
887
|
function AccountOrdersPanel({ props }: PanelProps) {
|
|
888
|
+
const router = useRouter()
|
|
944
889
|
const { state, set, getSnapshot } = useStateStore()
|
|
945
890
|
const parsed = accountOrdersPropsSchema.parse(props)
|
|
946
891
|
const { identityKey, reconciling } = useAccountLifecycle()
|
|
@@ -1025,9 +970,6 @@ function AccountOrdersPanel({ props }: PanelProps) {
|
|
|
1025
970
|
typeof state.accountOrdersPageSize === 'number' && state.accountOrdersPageSize > 0
|
|
1026
971
|
? state.accountOrdersPageSize
|
|
1027
972
|
: 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
973
|
const labels: Partial<OrderHistoryLabels> = {
|
|
1032
974
|
...(parsed.labels ?? {}),
|
|
1033
975
|
...(parsed.titleLabel === undefined ? {} : { title: parsed.titleLabel }),
|
|
@@ -1072,7 +1014,7 @@ function AccountOrdersPanel({ props }: PanelProps) {
|
|
|
1072
1014
|
orders={orders.map(toOrderHistoryOrder)}
|
|
1073
1015
|
presentation="cards"
|
|
1074
1016
|
labels={labels}
|
|
1075
|
-
onViewOrder={(id) =>
|
|
1017
|
+
onViewOrder={(id) => router.push(`/account/orders/${encodeURIComponent(id)}`)}
|
|
1076
1018
|
/>
|
|
1077
1019
|
{count > pageSize ? (
|
|
1078
1020
|
<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 +1041,14 @@ function AccountOrdersPanel({ props }: PanelProps) {
|
|
|
1099
1041
|
</div>
|
|
1100
1042
|
</div>
|
|
1101
1043
|
) : null}
|
|
1102
|
-
{selected ? (
|
|
1103
|
-
<OrderDetail order={selected} onClose={() => set('/accountSelectedOrderId', null)} />
|
|
1104
|
-
) : null}
|
|
1105
1044
|
</div>
|
|
1106
1045
|
)
|
|
1107
1046
|
}
|
|
1108
1047
|
|
|
1109
1048
|
export const registry: ViewRegistry = {
|
|
1049
|
+
AccountBoot: ({ emit }) => <AccountBoundary emit={emit} />,
|
|
1110
1050
|
AccountOrderDetail: (ctx) => <AccountOrderDetailPanel {...ctx} />,
|
|
1051
|
+
AccountFulfillmentEvidence: (ctx) => <AccountFulfillmentEvidencePanel {...ctx} />,
|
|
1111
1052
|
AccountShell: (ctx) => <AccountShellPanel {...ctx} />,
|
|
1112
1053
|
AccountOverview: () => <AccountOverviewPanel />,
|
|
1113
1054
|
AccountModulePlaceholder: () => <AccountModulePlaceholderPanel />,
|
|
@@ -167,14 +167,14 @@ export const accountContent = {
|
|
|
167
167
|
paymentLabel: 'Pago',
|
|
168
168
|
fulfilmentLabel: 'Entrega',
|
|
169
169
|
capabilities: {
|
|
170
|
-
tableView:
|
|
171
|
-
shipmentTracking:
|
|
172
|
-
pickupTracking:
|
|
173
|
-
returns:
|
|
174
|
-
exchanges:
|
|
170
|
+
tableView: true,
|
|
171
|
+
shipmentTracking: true,
|
|
172
|
+
pickupTracking: true,
|
|
173
|
+
returns: true,
|
|
174
|
+
exchanges: true,
|
|
175
175
|
claims: false,
|
|
176
|
-
reorder:
|
|
177
|
-
invoices:
|
|
176
|
+
reorder: true,
|
|
177
|
+
invoices: true,
|
|
178
178
|
bulkSelection: false,
|
|
179
179
|
export: false,
|
|
180
180
|
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
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Generated from the fulfillment-evidence-gallery delivery copy
|
|
2
|
+
// (designs/fulfillment-evidence-gallery/data.ts). The route is host-owned; the
|
|
3
|
+
// block never reads the delivery data module. Serial numbers, downloads and zoom
|
|
4
|
+
// stay opt-in, matching the storefront-safe defaults.
|
|
5
|
+
import type { FulfillmentEvidenceGalleryProps } from '@thorprovider/blocks'
|
|
6
|
+
|
|
7
|
+
export const fulfillmentEvidenceLabels = {
|
|
8
|
+
"titles": {
|
|
9
|
+
"shipping": "Evidencias de tu entrega",
|
|
10
|
+
"pickup": "Evidencias de tu recogida",
|
|
11
|
+
"generic": "Evidencias del pedido"
|
|
12
|
+
},
|
|
13
|
+
"summary": {
|
|
14
|
+
"files": "{count} archivos disponibles",
|
|
15
|
+
"fileOne": "1 archivo disponible",
|
|
16
|
+
"view": "Ver evidencias",
|
|
17
|
+
"viewAll": "Ver todas",
|
|
18
|
+
"empty": "Todavía no hay evidencias"
|
|
19
|
+
},
|
|
20
|
+
"categories": {
|
|
21
|
+
"product_preparation": "Productos preparados",
|
|
22
|
+
"package_preparation": "Paquete preparado",
|
|
23
|
+
"delivery": "Entrega realizada",
|
|
24
|
+
"pickup": "Recogida realizada",
|
|
25
|
+
"shipment": "Envío",
|
|
26
|
+
"other": "Otras evidencias"
|
|
27
|
+
},
|
|
28
|
+
"categoryHints": {
|
|
29
|
+
"product_preparation": "Qué se preparó para tu pedido, unidad por unidad.",
|
|
30
|
+
"package_preparation": "Cómo se embaló cada paquete antes de salir del almacén.",
|
|
31
|
+
"delivery": "Prueba de entrega registrada por la operación logística.",
|
|
32
|
+
"pickup": "Evidencias de la entrega en el punto de recogida.",
|
|
33
|
+
"shipment": "Evidencias del paso por el almacén y la salida del envío.",
|
|
34
|
+
"other": "Otras evidencias autorizadas para tu pedido."
|
|
35
|
+
},
|
|
36
|
+
"mediaTypes": {
|
|
37
|
+
"image": "Fotografía",
|
|
38
|
+
"pdf": "Documento",
|
|
39
|
+
"video": "Vídeo"
|
|
40
|
+
},
|
|
41
|
+
"product": {
|
|
42
|
+
"prepared": "Producto",
|
|
43
|
+
"quantity": "{count} uds. preparadas",
|
|
44
|
+
"variant": "Variante",
|
|
45
|
+
"sku": "SKU",
|
|
46
|
+
"serial": "Número de serie",
|
|
47
|
+
"units": "Unidades preparadas",
|
|
48
|
+
"allUnits": "Todas",
|
|
49
|
+
"unit": "Unidad {index}",
|
|
50
|
+
"noEvidence": "No hay fotografías de esta unidad."
|
|
51
|
+
},
|
|
52
|
+
"package": {
|
|
53
|
+
"title": "Paquete",
|
|
54
|
+
"reference": "Referencia",
|
|
55
|
+
"preparedAt": "Preparado el",
|
|
56
|
+
"files": "{count} archivos"
|
|
57
|
+
},
|
|
58
|
+
"delivery": {
|
|
59
|
+
"confirmed": "Entrega confirmada",
|
|
60
|
+
"notConfirmed": "Entrega sin confirmar",
|
|
61
|
+
"deliveredAt": "Entregada el",
|
|
62
|
+
"reference": "Envío"
|
|
63
|
+
},
|
|
64
|
+
"pickup": {
|
|
65
|
+
"confirmed": "Recogida confirmada",
|
|
66
|
+
"notConfirmed": "Recogida sin confirmar",
|
|
67
|
+
"pickedUpAt": "Recogida el",
|
|
68
|
+
"reference": "Recogida"
|
|
69
|
+
},
|
|
70
|
+
"fulfillment": {
|
|
71
|
+
"method": {
|
|
72
|
+
"shipping": "Envío",
|
|
73
|
+
"pickup": "Recogida"
|
|
74
|
+
},
|
|
75
|
+
"status": {
|
|
76
|
+
"pending": "Pendiente",
|
|
77
|
+
"preparing": "En preparación",
|
|
78
|
+
"ready": "Listo",
|
|
79
|
+
"shipped": "Enviado",
|
|
80
|
+
"delivered": "Entregado",
|
|
81
|
+
"picked_up": "Recogido",
|
|
82
|
+
"cancelled": "Cancelado"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"viewer": {
|
|
86
|
+
"title": "Evidencias",
|
|
87
|
+
"close": "Cerrar",
|
|
88
|
+
"previous": "Anterior",
|
|
89
|
+
"next": "Siguiente",
|
|
90
|
+
"zoomIn": "Ampliar",
|
|
91
|
+
"zoomOut": "Ajustar",
|
|
92
|
+
"download": "Descargar",
|
|
93
|
+
"counter": "{index} de {total}",
|
|
94
|
+
"loading": "Cargando archivo…",
|
|
95
|
+
"unavailable": "Este archivo no está disponible en este momento.",
|
|
96
|
+
"forbidden": "No tienes acceso a este archivo.",
|
|
97
|
+
"revoked": "Esta evidencia se ha retirado.",
|
|
98
|
+
"retry": "Reintentar",
|
|
99
|
+
"openDocument": "Abrir documento",
|
|
100
|
+
"thumbnails": "Evidencias disponibles",
|
|
101
|
+
"goTo": "Ver evidencia {index}",
|
|
102
|
+
"open": "Abrir evidencia",
|
|
103
|
+
"type": "Tipo",
|
|
104
|
+
"product": "Producto",
|
|
105
|
+
"package": "Paquete",
|
|
106
|
+
"fulfillment": "Operación"
|
|
107
|
+
},
|
|
108
|
+
"states": {
|
|
109
|
+
"loading": "Cargando evidencias",
|
|
110
|
+
"emptyTitle": "Todavía no hay evidencias",
|
|
111
|
+
"emptyBody": "Cuando el pedido tenga fotografías de preparación, embalaje, entrega o recogida, aparecerán aquí.",
|
|
112
|
+
"errorTitle": "No pudimos cargar las evidencias",
|
|
113
|
+
"errorBody": "El servicio de evidencias no respondió. Puedes intentarlo de nuevo.",
|
|
114
|
+
"retry": "Reintentar",
|
|
115
|
+
"forbiddenTitle": "Evidencias no disponibles",
|
|
116
|
+
"forbiddenBody": "Tu cuenta no tiene acceso a las evidencias de esta entrega.",
|
|
117
|
+
"notFoundTitle": "Entrega no encontrada",
|
|
118
|
+
"notFoundBody": "Esta entrega no existe o ya no está disponible para tu cuenta.",
|
|
119
|
+
"partialTitle": "Algunas evidencias no se cargaron",
|
|
120
|
+
"restrictedTitle": "Algunas evidencias no están publicadas para tu cuenta",
|
|
121
|
+
"assetError": "Vista previa no disponible",
|
|
122
|
+
"retryAsset": "Reintentar",
|
|
123
|
+
"noEvidence": "Sin fotografías"
|
|
124
|
+
},
|
|
125
|
+
"dates": {
|
|
126
|
+
"captured": "Registrada",
|
|
127
|
+
"prepared": "Preparado"
|
|
128
|
+
}
|
|
129
|
+
} as const satisfies FulfillmentEvidenceGalleryProps['labels']
|
|
130
|
+
|
|
131
|
+
export const fulfillmentEvidenceCapabilities = {
|
|
132
|
+
showSerialNumbers: false,
|
|
133
|
+
allowDownloads: false,
|
|
134
|
+
allowZoom: false,
|
|
135
|
+
} as const satisfies NonNullable<FulfillmentEvidenceGalleryProps['capabilities']>
|
|
136
|
+
|
|
137
|
+
export const fulfillmentEvidencePresentation = {
|
|
138
|
+
mode: 'expanded',
|
|
139
|
+
} as const satisfies NonNullable<FulfillmentEvidenceGalleryProps['presentation']>
|
|
140
|
+
|
|
141
|
+
export const fulfillmentEvidenceDefaults = {
|
|
142
|
+
labels: fulfillmentEvidenceLabels,
|
|
143
|
+
capabilities: fulfillmentEvidenceCapabilities,
|
|
144
|
+
presentation: fulfillmentEvidencePresentation,
|
|
145
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Derived schema for the route-only fulfillment-evidence element. Kept in its
|
|
2
|
+
// own file so an existing store receives it through `storefront sync`; the
|
|
3
|
+
// account `schema.ts` stays user-owned and is never rewritten.
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
|
|
6
|
+
export const accountFulfillmentEvidencePropsSchema = z.object({
|
|
7
|
+
fulfillmentId: z.string().min(1),
|
|
8
|
+
labels: z.record(z.string(), z.unknown()),
|
|
9
|
+
capabilities: z.record(z.string(), z.boolean()).optional(),
|
|
10
|
+
presentation: z.record(z.string(), z.unknown()).optional(),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export type AccountFulfillmentEvidenceProps = z.infer<
|
|
14
|
+
typeof accountFulfillmentEvidencePropsSchema
|
|
15
|
+
>
|
|
@@ -24,6 +24,7 @@ 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 { fulfillmentEvidenceDefaults } from './fulfillment-evidence.defaults'
|
|
27
28
|
import { accountOrdersAdvancedDefaults } from './orders-advanced.defaults'
|
|
28
29
|
import {
|
|
29
30
|
accountAddressPropsSchema,
|
|
@@ -36,6 +37,7 @@ import {
|
|
|
36
37
|
accountProfilePropsSchema,
|
|
37
38
|
accountRegisterPropsSchema,
|
|
38
39
|
} from './schema'
|
|
40
|
+
import { accountFulfillmentEvidencePropsSchema } from './fulfillment-evidence.schema'
|
|
39
41
|
import { customerProfileDefaults } from './customer-profile.defaults'
|
|
40
42
|
import { customerProfilePropsSchema } from '../sections/schema.customer-profile'
|
|
41
43
|
import { addressBookAdvancedDefaults } from './address-book-advanced.defaults'
|
|
@@ -59,11 +61,23 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
59
61
|
...orderDetailDefaults,
|
|
60
62
|
},
|
|
61
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.
|
|
62
67
|
'account.boot': {
|
|
63
68
|
type: 'AccountBoot',
|
|
64
69
|
props: {},
|
|
65
70
|
on: { retry: { action: 'retryAccountSession' } },
|
|
66
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
|
+
},
|
|
67
81
|
'account.login': {
|
|
68
82
|
type: 'AccountLogin',
|
|
69
83
|
visible: {
|
|
@@ -161,10 +175,10 @@ const catalog = {
|
|
|
161
175
|
description:
|
|
162
176
|
'Route-only order detail surface for one authenticated customer order; the host port supplies the data and the block owns its states.',
|
|
163
177
|
},
|
|
164
|
-
|
|
165
|
-
props:
|
|
178
|
+
AccountFulfillmentEvidence: {
|
|
179
|
+
props: accountFulfillmentEvidencePropsSchema,
|
|
166
180
|
description:
|
|
167
|
-
'
|
|
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.',
|
|
168
182
|
},
|
|
169
183
|
AccountLogin: {
|
|
170
184
|
props: accountLoginPropsSchema,
|
|
@@ -297,6 +311,22 @@ export const account: ViewModule = {
|
|
|
297
311
|
'account.orderDetail': elements['account.orderDetail'],
|
|
298
312
|
}),
|
|
299
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
|
+
},
|
|
300
330
|
],
|
|
301
331
|
loader: {
|
|
302
332
|
account: async () => ({ dataSource: getDataSource(), dataError: null }),
|
|
@@ -305,5 +335,13 @@ export const account: ViewModule = {
|
|
|
305
335
|
if (!orderId) notFound()
|
|
306
336
|
return { orderDetailId: orderId }
|
|
307
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
|
+
},
|
|
308
346
|
},
|
|
309
347
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useRouter } from 'next/navigation'
|
|
4
4
|
import { useStateStore } from '@json-render/react'
|
|
5
|
-
import {
|
|
6
|
-
OrderHistoryAdvanced,
|
|
7
|
-
fillOrderHistoryTemplate,
|
|
8
|
-
formatOrderHistoryDate,
|
|
9
|
-
formatOrderHistoryMoney,
|
|
10
|
-
} from '@thorprovider/blocks'
|
|
5
|
+
import { OrderHistoryAdvanced } from '@thorprovider/blocks'
|
|
11
6
|
import type {
|
|
12
7
|
OrderHistoryAdvancedCapabilities,
|
|
13
8
|
OrderHistoryAdvancedLabels,
|
|
14
|
-
OrderHistoryAdvancedRecord,
|
|
15
9
|
} from '@thorprovider/blocks'
|
|
16
|
-
import { Button } from '@thorprovider/blocks/ui/button'
|
|
17
10
|
|
|
18
11
|
import { useAccountLifecycle } from '../../account-lifecycle.client'
|
|
19
12
|
import { isAccountModuleVisible } from '../../account-private.core'
|
|
@@ -27,14 +20,16 @@ type PanelProps = {
|
|
|
27
20
|
|
|
28
21
|
/**
|
|
29
22
|
* Host panel for the advanced order-history block. It owns the port wiring, the
|
|
30
|
-
* account module visibility and the
|
|
31
|
-
* collection, its query lifecycle and every loading/error/empty state.
|
|
23
|
+
* account module visibility and the order-detail navigation; the block owns the
|
|
24
|
+
* collection, its query lifecycle and every loading/error/empty state. Opening
|
|
25
|
+
* an order always leaves the list for its own `/account/orders/[id]` page, so
|
|
26
|
+
* the list never renders a second detail surface.
|
|
32
27
|
*/
|
|
33
28
|
export function AccountOrdersAdvancedPanel({ props }: PanelProps) {
|
|
34
29
|
const { state } = useStateStore()
|
|
30
|
+
const router = useRouter()
|
|
35
31
|
const { identityKey, reconciling } = useAccountLifecycle()
|
|
36
32
|
const parsed = accountOrdersAdvancedPropsSchema.parse(props)
|
|
37
|
-
const [selected, setSelected] = useState<OrderHistoryAdvancedRecord | null>(null)
|
|
38
33
|
|
|
39
34
|
const visible = isAccountModuleVisible(
|
|
40
35
|
typeof state.accountShape === 'string' ? state.accountShape : null,
|
|
@@ -73,94 +68,10 @@ export function AccountOrdersAdvancedPanel({ props }: PanelProps) {
|
|
|
73
68
|
labels={labels}
|
|
74
69
|
locale={locale}
|
|
75
70
|
pageSize={parsed.pageSize ?? 10}
|
|
76
|
-
|
|
71
|
+
onOrderSelect={(orderId) =>
|
|
72
|
+
router.push(`/account/orders/${encodeURIComponent(orderId)}`)
|
|
73
|
+
}
|
|
77
74
|
/>
|
|
78
|
-
{selected ? (
|
|
79
|
-
<AdvancedOrderSummary
|
|
80
|
-
order={selected}
|
|
81
|
-
labels={labels}
|
|
82
|
-
locale={locale}
|
|
83
|
-
closeLabel={parsed.closeLabel ?? 'Cerrar'}
|
|
84
|
-
paymentLabel={parsed.paymentLabel ?? 'Pago'}
|
|
85
|
-
fulfilmentLabel={parsed.fulfilmentLabel ?? 'Entrega'}
|
|
86
|
-
onClose={() => setSelected(null)}
|
|
87
|
-
/>
|
|
88
|
-
) : null}
|
|
89
|
-
</div>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
type SummaryProps = {
|
|
94
|
-
order: OrderHistoryAdvancedRecord
|
|
95
|
-
labels: OrderHistoryAdvancedLabels
|
|
96
|
-
locale: string
|
|
97
|
-
closeLabel: string
|
|
98
|
-
paymentLabel: string
|
|
99
|
-
fulfilmentLabel: string
|
|
100
|
-
onClose: () => void
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Inline summary for the selected record. The rich `order-detail` delivery
|
|
105
|
-
* replaces it; this covers the MVP "view order" without inventing data the
|
|
106
|
-
* advanced record does not carry.
|
|
107
|
-
*/
|
|
108
|
-
function AdvancedOrderSummary({
|
|
109
|
-
order,
|
|
110
|
-
labels,
|
|
111
|
-
locale,
|
|
112
|
-
closeLabel,
|
|
113
|
-
paymentLabel,
|
|
114
|
-
fulfilmentLabel,
|
|
115
|
-
onClose,
|
|
116
|
-
}: SummaryProps) {
|
|
117
|
-
const money = (value: OrderHistoryAdvancedRecord['total']) =>
|
|
118
|
-
formatOrderHistoryMoney(value, locale, labels.card.amountUnavailable)
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<div className="mt-6 rounded-lg border p-6">
|
|
122
|
-
<div className="flex items-start justify-between gap-4">
|
|
123
|
-
<div>
|
|
124
|
-
<h3 className="text-lg font-semibold">
|
|
125
|
-
{fillOrderHistoryTemplate(labels.card.order, { number: order.number })}
|
|
126
|
-
</h3>
|
|
127
|
-
<p className="text-muted-foreground mt-1 text-sm">
|
|
128
|
-
{formatOrderHistoryDate(order.placedAt, locale, order.placedAt)}
|
|
129
|
-
</p>
|
|
130
|
-
</div>
|
|
131
|
-
<Button type="button" variant="outline" size="sm" onClick={onClose}>
|
|
132
|
-
{closeLabel}
|
|
133
|
-
</Button>
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
<dl className="mt-4 grid gap-3 text-sm sm:grid-cols-3">
|
|
137
|
-
<div>
|
|
138
|
-
<dt className="text-muted-foreground">{labels.card.total}</dt>
|
|
139
|
-
<dd className="mt-0.5 font-medium tabular-nums">{money(order.total)}</dd>
|
|
140
|
-
</div>
|
|
141
|
-
<div>
|
|
142
|
-
<dt className="text-muted-foreground">{paymentLabel}</dt>
|
|
143
|
-
<dd className="mt-0.5">{labels.payment[order.payment.status]}</dd>
|
|
144
|
-
</div>
|
|
145
|
-
<div>
|
|
146
|
-
<dt className="text-muted-foreground">{fulfilmentLabel}</dt>
|
|
147
|
-
<dd className="mt-0.5">{labels.fulfilment[order.fulfilment.status]}</dd>
|
|
148
|
-
</div>
|
|
149
|
-
</dl>
|
|
150
|
-
|
|
151
|
-
<ul className="mt-4 divide-y">
|
|
152
|
-
{order.items.map((item) => (
|
|
153
|
-
<li key={item.id} className="flex items-center justify-between gap-4 py-2 text-sm">
|
|
154
|
-
<span>
|
|
155
|
-
{item.name}
|
|
156
|
-
{item.variant ? (
|
|
157
|
-
<span className="text-muted-foreground"> · {item.variant}</span>
|
|
158
|
-
) : null}
|
|
159
|
-
</span>
|
|
160
|
-
<span className="text-muted-foreground shrink-0 tabular-nums">× {item.quantity}</span>
|
|
161
|
-
</li>
|
|
162
|
-
))}
|
|
163
|
-
</ul>
|
|
164
75
|
</div>
|
|
165
76
|
)
|
|
166
77
|
}
|