@ecomiq/storefront 2.1.3 → 3.0.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 (317) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -123
  3. package/dist/account-Dx4e3syi.js +258 -0
  4. package/dist/account-forms-AVk71ko7.js +39 -0
  5. package/dist/account-forms.d.ts +13 -0
  6. package/dist/account.d.ts +240 -0
  7. package/dist/address-defaults-BqjRhS82.js +14 -0
  8. package/dist/address-defaults.d.ts +11 -0
  9. package/dist/analytics/analytics-CG1Qagwl.js +148 -0
  10. package/dist/analytics/analytics.d.ts +1 -0
  11. package/dist/analytics/config-DJr-GRhs.js +62 -0
  12. package/dist/analytics/config.d.ts +22 -0
  13. package/dist/analytics/consent-B13rBpBs.js +57 -0
  14. package/dist/analytics/consent-banner-9QvRRy8v.js +239 -0
  15. package/dist/analytics/consent-banner.d.ts +20 -0
  16. package/dist/analytics/cookies-pLozllyB.js +100 -0
  17. package/dist/analytics/cookies.d.ts +6 -0
  18. package/dist/analytics/destinations-iECrlLIr.js +144 -0
  19. package/dist/analytics/events-Dt81tIp1.js +102 -0
  20. package/dist/analytics/events.d.ts +51 -0
  21. package/dist/analytics/tracker-p4yaoOyk.js +51 -0
  22. package/dist/api-cache-DsuIn5hX.js +159 -0
  23. package/dist/bank-accounts-DlEczQQ5.js +81 -0
  24. package/dist/bank-accounts.d.ts +4 -0
  25. package/dist/captcha-DAqaIx8m.js +117 -0
  26. package/dist/captcha.d.ts +34 -0
  27. package/dist/cart-D7DxZ2lD.js +30 -0
  28. package/dist/cart-actions-Bsub_FFG.js +116 -0
  29. package/dist/cart-actions.d.ts +15 -0
  30. package/dist/cart-drawer-B7PPsR69.js +22 -0
  31. package/dist/cart-drawer.d.ts +9 -0
  32. package/dist/cart-form-y9P1r_EX.js +81 -0
  33. package/dist/cart-form.d.ts +24 -0
  34. package/dist/cart-summary-ur2VWKr-.js +89 -0
  35. package/dist/cart-summary.d.ts +31 -0
  36. package/dist/cart.d.ts +4 -0
  37. package/dist/catalog-7gJ-l5hW.js +67 -0
  38. package/dist/catalog-hooks-B7ZP4wYY.js +312 -0
  39. package/dist/catalog-hooks.d.ts +111 -0
  40. package/dist/catalog.d.ts +5 -0
  41. package/dist/checkout-DVWSXANi.js +474 -0
  42. package/dist/checkout-form-CbOIdENC.js +131 -0
  43. package/dist/checkout-form.d.ts +20 -0
  44. package/dist/checkout.d.ts +86 -0
  45. package/dist/complaint-book-BvwLvfx0.js +117 -0
  46. package/dist/complaint-book.d.ts +62 -0
  47. package/dist/culqi-authentication-BGr20vAJ.js +204 -0
  48. package/dist/culqi-authentication.d.ts +15 -0
  49. package/dist/culqi-checkout-CTXpKgp_.js +55 -0
  50. package/dist/culqi-three-ds-HP3mfrvV.js +33 -0
  51. package/dist/culqi-three-ds.d.ts +29 -0
  52. package/dist/customer-avatar-CJXSDroK.js +12 -0
  53. package/dist/customer-avatar.d.ts +5 -0
  54. package/dist/customer-cookies-DHOgFAMV.js +45 -0
  55. package/dist/customer-csrf-C1oDX-Py.js +17 -0
  56. package/dist/customer-csrf.d.ts +3 -0
  57. package/dist/customer-document-fields-C1K-_DAD.js +70 -0
  58. package/dist/customer-document-fields.d.ts +9 -0
  59. package/dist/customer-login-form-C7AC6vXd.js +144 -0
  60. package/dist/customer-login-form.d.ts +17 -0
  61. package/dist/customer-registration-form-BEm_NEfP.js +93 -0
  62. package/dist/customer-registration-form.d.ts +8 -0
  63. package/dist/document-url-CGsAl5Tf.js +9 -0
  64. package/dist/documents-T1mzc_j8.js +38 -0
  65. package/dist/documents.d.ts +16 -0
  66. package/dist/entries/account.d.ts +11 -0
  67. package/dist/entries/account.js +10 -0
  68. package/dist/entries/analytics.d.ts +6 -0
  69. package/dist/entries/analytics.js +5 -0
  70. package/dist/entries/cart.d.ts +8 -0
  71. package/dist/entries/cart.js +7 -0
  72. package/dist/entries/checkout.d.ts +12 -0
  73. package/dist/entries/checkout.js +11 -0
  74. package/dist/entries/order.d.ts +11 -0
  75. package/dist/entries/order.js +11 -0
  76. package/dist/favicon-YpyhVJ9H.js +28 -0
  77. package/dist/favicon.d.ts +4 -0
  78. package/dist/form-BtQcbXlJ.js +18 -0
  79. package/dist/form-contracts-BNpHaTGJ.js +166 -0
  80. package/dist/form-contracts.d.ts +42 -0
  81. package/dist/form.d.ts +3 -0
  82. package/dist/hidden-CCWtOWKR.js +3 -0
  83. package/dist/hidden.d.ts +4 -0
  84. package/dist/index.d.ts +50 -0
  85. package/dist/index.js +50 -0
  86. package/dist/invoice-fields-BG0HjL6T.js +103 -0
  87. package/dist/invoice-fields.d.ts +39 -0
  88. package/dist/links-kFxBZfdb.js +96 -0
  89. package/dist/links.d.ts +21 -0
  90. package/dist/mercadopago-checkout-DC7RXa8k.js +27 -0
  91. package/dist/mercadopago-dialog-UTQev0MG.js +180 -0
  92. package/dist/mercadopago-dialog.d.ts +21 -0
  93. package/dist/money-DtGOtDri.js +32 -0
  94. package/dist/money.d.ts +1 -0
  95. package/dist/optimistic-cart-BveVOHuh.js +53 -0
  96. package/dist/optimistic-cart.d.ts +16 -0
  97. package/dist/order-display-DTt5WBbc.js +112 -0
  98. package/dist/order-display.d.ts +20 -0
  99. package/dist/order-draft-DxV1Uhm3.js +38 -0
  100. package/dist/order-draft.d.ts +16 -0
  101. package/dist/order-pages-Dm6l5m0m.js +38 -0
  102. package/dist/order-pages.d.ts +12 -0
  103. package/dist/order-payment-continuation-D_d5PGA4.js +212 -0
  104. package/dist/order-payment-continuation.d.ts +10 -0
  105. package/dist/order-payment-in-review-x4gdLFHZ.js +65 -0
  106. package/dist/order-payment-in-review.d.ts +5 -0
  107. package/dist/order-status-BJXLJwxq.js +162 -0
  108. package/dist/order-status.d.ts +89 -0
  109. package/dist/order-view-9IlBg5AF.js +62 -0
  110. package/dist/order-view.d.ts +12 -0
  111. package/dist/page-action-Ctkf4xC6.js +7 -0
  112. package/dist/page-seo-a5FJl8x5.js +262 -0
  113. package/dist/page-seo.d.ts +34 -0
  114. package/dist/pages-Ca_Gt6mq.js +150 -0
  115. package/dist/pages.d.ts +45 -0
  116. package/dist/payment-dialog-frame-B-Q_xQ94.js +57 -0
  117. package/dist/payment-logo-BoPaGJc_.js +46 -0
  118. package/dist/payment-logo-svgs-By9lDTLK.js +20 -0
  119. package/dist/payment-logo.d.ts +11 -0
  120. package/dist/payment-logos-BYvdwYyJ.js +23 -0
  121. package/dist/payment-methods-B8ocTgFZ.js +73 -0
  122. package/dist/payment-methods.d.ts +58 -0
  123. package/dist/payment-return-5cjypwIw.js +7 -0
  124. package/dist/place-CmW4hBWY.js +13 -0
  125. package/dist/place.d.ts +4 -0
  126. package/dist/preview-BiIBif3C.js +427 -0
  127. package/dist/preview-address-Cf0sJ-9p.js +21 -0
  128. package/dist/preview-cart-Dg2CVktS.js +376 -0
  129. package/dist/product-preview-BspMAecJ.js +51 -0
  130. package/dist/product-preview.d.ts +5 -0
  131. package/dist/product-variants-BNDHvs1y.js +46 -0
  132. package/dist/product-variants.d.ts +12 -0
  133. package/dist/public-pages-XtwlaLwt.js +194 -0
  134. package/dist/public-pages.d.ts +67 -0
  135. package/dist/registration-CpDcv8ql.js +91 -0
  136. package/dist/registration.d.ts +12 -0
  137. package/dist/request-security-CRsRMgwj.js +76 -0
  138. package/dist/rich-text-M-Ju8RL4.js +9 -0
  139. package/dist/rich-text.d.ts +5 -0
  140. package/dist/route-text-DcJw2SsK.js +9 -0
  141. package/dist/route-text.d.ts +4 -0
  142. package/dist/section-preview-CmsMl3yu.js +83 -0
  143. package/dist/section-preview.d.ts +12 -0
  144. package/dist/sections/account-addresses.d.ts +18 -0
  145. package/dist/sections/account-addresses.js +375 -0
  146. package/dist/sections/account-order.d.ts +12 -0
  147. package/dist/sections/account-order.js +592 -0
  148. package/dist/sections/account-orders.d.ts +8 -0
  149. package/dist/sections/account-orders.js +359 -0
  150. package/dist/sections/account-profile.d.ts +16 -0
  151. package/dist/sections/account-profile.js +123 -0
  152. package/dist/sections/checkout.d.ts +24 -0
  153. package/dist/sections/checkout.js +963 -0
  154. package/dist/sections/complaint-book.d.ts +8 -0
  155. package/dist/sections/complaint-book.js +538 -0
  156. package/dist/sections/design-system.d.ts +1 -0
  157. package/dist/sections/design-system.js +310 -0
  158. package/dist/sections/draft-invoice.d.ts +20 -0
  159. package/dist/sections/draft-invoice.js +158 -0
  160. package/dist/sections/order-tracking.d.ts +19 -0
  161. package/dist/sections/order-tracking.js +141 -0
  162. package/dist/sections-CNUMWTF_.js +77 -0
  163. package/dist/sections.d.ts +19 -0
  164. package/dist/seo-GpDRhAAA.js +78 -0
  165. package/dist/session-CKvmFJyg.js +379 -0
  166. package/dist/session.d.ts +24 -0
  167. package/dist/settings-B0NO2A6Y.js +78 -0
  168. package/dist/settings.d.ts +51 -0
  169. package/dist/source-marker-DhqSkW7n.js +4 -0
  170. package/dist/sources-B-3JFJfb.js +46 -0
  171. package/dist/sources.d.ts +7 -0
  172. package/dist/store-8Q-_LFrQ.js +152 -0
  173. package/dist/store-contact--hY6CoFb.js +19 -0
  174. package/dist/store-contact.d.ts +6 -0
  175. package/dist/store.d.ts +17 -0
  176. package/dist/storefront-language-DrMjVbmk.js +29 -0
  177. package/dist/storefront-language.d.ts +14 -0
  178. package/dist/storefront-text-D25ae1qf.js +11 -0
  179. package/dist/storefront-text-en-ljjjSS4q.js +1030 -0
  180. package/dist/storefront-text-pt-BtHaJLcp.js +1030 -0
  181. package/dist/storefront-text.d.ts +4 -0
  182. package/dist/stripe-dialog-Ev9s3Z62.js +396 -0
  183. package/dist/stripe-dialog.d.ts +30 -0
  184. package/dist/telemetry-HuZXWBPi.js +114 -0
  185. package/dist/telemetry.d.ts +10 -0
  186. package/dist/templates-CAqoNyTW.js +40 -0
  187. package/dist/templates.d.ts +15 -0
  188. package/dist/urls-CpGQPxvf.js +71 -0
  189. package/dist/urls.d.ts +18 -0
  190. package/dist/use-checkout-CZcxXJXi.js +42 -0
  191. package/dist/use-checkout-payment-9R-zacrJ.js +80 -0
  192. package/dist/use-checkout-payment.d.ts +18 -0
  193. package/dist/use-checkout.d.ts +36 -0
  194. package/dist/use-culqi-checkout-CrjLAipU.js +109 -0
  195. package/dist/use-order-payment-BKIz_IO0.js +45 -0
  196. package/dist/use-order-payment.d.ts +18 -0
  197. package/dist/use-payment-token-CErx-tN-.js +105 -0
  198. package/dist/vite-payment-logos-kziu7wKb.js +27 -0
  199. package/dist/vite-payment-logos.d.ts +24 -0
  200. package/dist/vite-public-assets-DW2fgtVb.js +209 -0
  201. package/dist/vite-public-assets.d.ts +29 -0
  202. package/dist/vite-sections-DTBr0-Kg.js +464 -0
  203. package/dist/vite-sections.d.ts +21 -0
  204. package/dist/vite-theme-ui-BMO-CDi3.js +41 -0
  205. package/dist/vite-theme-ui.d.ts +10 -0
  206. package/dist/vite.d.ts +36 -0
  207. package/dist/vite.js +127 -0
  208. package/dist/voucher-payment-CVFDZ1L8.js +66 -0
  209. package/dist/worker-CNi-gzCu.js +86 -0
  210. package/dist/worker.d.ts +27 -0
  211. package/package.json +100 -81
  212. package/src/sections/account-addresses.tsx +215 -0
  213. package/src/sections/account-order.tsx +424 -0
  214. package/src/sections/account-orders.tsx +259 -0
  215. package/src/sections/account-profile.tsx +70 -0
  216. package/src/sections/checkout.tsx +586 -0
  217. package/src/sections/complaint-book.tsx +325 -0
  218. package/src/sections/design-system.tsx +146 -0
  219. package/src/sections/draft-invoice.tsx +105 -0
  220. package/src/sections/order-tracking.tsx +81 -0
  221. package/src/vite-client.d.ts +4 -0
  222. package/bin/ecomiq.mjs +0 -179
  223. package/public/design-bridge.js +0 -318
  224. package/src/api-proxy.ts +0 -194
  225. package/src/auth/create-storefront-auth.ts +0 -94
  226. package/src/auth/ecomiq-oauth-password-client.ts +0 -26
  227. package/src/auth/ecomiq-oauth-password-constants.ts +0 -24
  228. package/src/auth/ecomiq-oauth-password-plugin.ts +0 -294
  229. package/src/auth/ecomiq-oauth-password-types.ts +0 -24
  230. package/src/auth/ecomiq-storefront-sign-in.ts +0 -44
  231. package/src/auth/env.ts +0 -7
  232. package/src/auth/secure-cookies.ts +0 -23
  233. package/src/auth/storefront-auth-base-url.ts +0 -117
  234. package/src/auth/storefront-auth.ts +0 -7
  235. package/src/cart-session.ts +0 -239
  236. package/src/client.ts +0 -48
  237. package/src/cloud-runtime-client.ts +0 -378
  238. package/src/codegen.mjs +0 -789
  239. package/src/components/account/customer-addresses-panel.tsx +0 -678
  240. package/src/components/account/customer-order-detail-panel.tsx +0 -285
  241. package/src/components/account/customer-orders-panel.tsx +0 -192
  242. package/src/components/account/customer-profile-panel.tsx +0 -379
  243. package/src/components/checkout/cart-sync.ts +0 -143
  244. package/src/components/checkout/checkout-contact-section.tsx +0 -76
  245. package/src/components/checkout/checkout-external-update-banner.tsx +0 -15
  246. package/src/components/checkout/checkout-form-controls.tsx +0 -139
  247. package/src/components/checkout/checkout-line-items.tsx +0 -43
  248. package/src/components/checkout/checkout-order-summary.tsx +0 -165
  249. package/src/components/checkout/checkout-payment-section.tsx +0 -212
  250. package/src/components/checkout/checkout-session-view.tsx +0 -564
  251. package/src/components/checkout/checkout-shipping-address-section.tsx +0 -400
  252. package/src/components/checkout/checkout-shipping-section.tsx +0 -98
  253. package/src/components/checkout/checkout-states.tsx +0 -73
  254. package/src/components/checkout/checkout-step-card.tsx +0 -101
  255. package/src/components/checkout/checkout-steps.ts +0 -111
  256. package/src/components/checkout/form-schema.ts +0 -281
  257. package/src/components/checkout/format.ts +0 -15
  258. package/src/components/checkout/index.ts +0 -5
  259. package/src/components/checkout/map-customer-to-checkout.ts +0 -188
  260. package/src/components/checkout/types.ts +0 -41
  261. package/src/components/checkout/use-checkout-customer-prefill.ts +0 -409
  262. package/src/components/checkout/use-checkout-geo.ts +0 -50
  263. package/src/components/checkout/use-checkout-session.ts +0 -640
  264. package/src/components/hero.tsx +0 -291
  265. package/src/config.d.ts +0 -94
  266. package/src/config.mjs +0 -146
  267. package/src/format-money.ts +0 -31
  268. package/src/health.ts +0 -90
  269. package/src/hooks/index.ts +0 -9
  270. package/src/hooks/recently-viewed.ts +0 -125
  271. package/src/index.ts +0 -354
  272. package/src/link.tsx +0 -2
  273. package/src/pages/account/account-page-skeleton.tsx +0 -69
  274. package/src/pages/account/account-page-view.tsx +0 -270
  275. package/src/pages/account/account-shell.tsx +0 -101
  276. package/src/pages/account/parse-account-route.ts +0 -36
  277. package/src/pages/account.tsx +0 -16
  278. package/src/pages/api.$.ts +0 -20
  279. package/src/pages/api.auth.$.ts +0 -16
  280. package/src/pages/checkout.$checkoutId.tsx +0 -60
  281. package/src/pages/checkout.tsx +0 -31
  282. package/src/pages/pages.$pageSlug.tsx +0 -111
  283. package/src/pages/thank-you.tsx +0 -53
  284. package/src/providers/auth.tsx +0 -96
  285. package/src/providers/cart.tsx +0 -275
  286. package/src/providers/ecomiq.ts +0 -137
  287. package/src/providers/index.ts +0 -26
  288. package/src/proxy-api.ts +0 -20
  289. package/src/public-config.ts +0 -24
  290. package/src/review-submission.ts +0 -89
  291. package/src/runtime/context.ts +0 -2
  292. package/src/runtime/default-layout.tsx +0 -64
  293. package/src/runtime/head.ts +0 -149
  294. package/src/runtime/page.tsx +0 -143
  295. package/src/runtime/postcss-browser-stub.mjs +0 -5
  296. package/src/server-config-store.ts +0 -35
  297. package/src/server.ts +0 -301
  298. package/src/storefront-definition/contract.ts +0 -1
  299. package/src/storefront-definition/data.ts +0 -188
  300. package/src/storefront-definition/index.ts +0 -2
  301. package/src/storefront-definition/renderer.tsx +0 -1481
  302. package/src/storefront-layout.ts +0 -59
  303. package/src/storefront-runtime.ts +0 -173
  304. package/src/styles.css +0 -97
  305. package/src/ui/badge.tsx +0 -32
  306. package/src/ui/button.tsx +0 -31
  307. package/src/ui/card.tsx +0 -31
  308. package/src/ui/carousel.tsx +0 -218
  309. package/src/ui/cn.ts +0 -6
  310. package/src/ui/index.ts +0 -8
  311. package/src/ui/separator.tsx +0 -6
  312. package/src/ui/skeleton.tsx +0 -6
  313. package/src/ui/storefront-error.tsx +0 -49
  314. package/src/utils.ts +0 -36
  315. package/src/vite-inline.mjs +0 -263
  316. package/templates/__root.tsx +0 -83
  317. package/templates/router.tsx +0 -19
@@ -1,285 +0,0 @@
1
- import { ArrowLeft, CreditCard, Loader2, MapPin, Package } from 'lucide-react'
2
- import {
3
- customerOrderStatusTone,
4
- formatCustomerOrderStatus,
5
- formatOrderDate,
6
- formatOrderDateTime,
7
- type CustomerOrderDetail,
8
- } from '@ecomiq/core'
9
- import { Link } from '../../link'
10
- import { buttonVariants, cn } from '../../ui'
11
- import { formatMoney } from '../checkout/format'
12
-
13
- function statusBadgeClass(
14
- tone: ReturnType<typeof customerOrderStatusTone>,
15
- ): string {
16
- switch (tone) {
17
- case 'success':
18
- return 'bg-emerald-50 text-emerald-800 ring-emerald-200'
19
- case 'warning':
20
- return 'bg-amber-50 text-amber-900 ring-amber-200'
21
- case 'danger':
22
- return 'bg-red-50 text-red-800 ring-red-200'
23
- case 'info':
24
- return 'bg-sky-50 text-sky-900 ring-sky-200'
25
- default:
26
- return 'bg-muted text-foreground ring-border'
27
- }
28
- }
29
-
30
- export type CustomerOrderDetailPanelProps = {
31
- order?: CustomerOrderDetail | null
32
- isLoading: boolean
33
- errorMessage?: string | null
34
- backHref: string
35
- /** Genera URL de producto si hay handle (p. ej. `/products/{handle}`). */
36
- productHref?: (handle: string) => string
37
- language?: string
38
- }
39
-
40
- export function CustomerOrderDetailPanel({
41
- order,
42
- isLoading,
43
- errorMessage,
44
- backHref,
45
- productHref,
46
- language = 'es-PE',
47
- }: CustomerOrderDetailPanelProps) {
48
- if (isLoading) {
49
- return (
50
- <div className="flex items-center gap-2 rounded-lg border border-border bg-background px-4 py-10 text-sm text-muted-foreground">
51
- <Loader2 className="size-4 shrink-0 animate-spin" />
52
- Cargando detalle del pedido…
53
- </div>
54
- )
55
- }
56
-
57
- if (errorMessage) {
58
- return (
59
- <div className="space-y-4">
60
- <Link
61
- to={backHref}
62
- className={cn(buttonVariants({ variant: 'outline', size: 'sm' }), 'gap-2')}
63
- >
64
- <ArrowLeft className="size-4" />
65
- Volver a mis pedidos
66
- </Link>
67
- <p className="rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive">
68
- {errorMessage}
69
- </p>
70
- </div>
71
- )
72
- }
73
-
74
- if (!order) return null
75
-
76
- const tone = customerOrderStatusTone(order.status)
77
- const timeline = [...order.statusTimeline].sort(
78
- (a, b) =>
79
- new Date(b.occurredAt).getTime() - new Date(a.occurredAt).getTime(),
80
- )
81
- const money = (value: number) =>
82
- formatMoney(value, language, order.currencyCode)
83
-
84
- return (
85
- <div className="space-y-6">
86
- <Link
87
- to={backHref}
88
- className={cn(
89
- buttonVariants({ variant: 'ghost', size: 'sm' }),
90
- '-ml-2 gap-2 text-muted-foreground',
91
- )}
92
- >
93
- <ArrowLeft className="size-4" />
94
- Volver a mis pedidos
95
- </Link>
96
-
97
- <div className="rounded-lg border border-border bg-background p-5 sm:p-6">
98
- <div className="flex flex-wrap items-start justify-between gap-4">
99
- <div>
100
- <p className="text-sm text-muted-foreground">
101
- Pedido del {formatOrderDate(order.orderDate)}
102
- </p>
103
- <h2 className="mt-1 text-xl font-semibold text-foreground sm:text-2xl">
104
- Pedido n.º {order.orderNumber}
105
- </h2>
106
- </div>
107
- <span
108
- className={cn(
109
- 'inline-flex rounded-full px-3 py-1 text-sm font-medium ring-1 ring-inset',
110
- statusBadgeClass(tone),
111
- )}
112
- >
113
- {formatCustomerOrderStatus(order.status)}
114
- </span>
115
- </div>
116
-
117
- <div className="mt-6 grid gap-6 lg:grid-cols-3">
118
- <div className="space-y-6 lg:col-span-2">
119
- <section>
120
- <h3 className="text-base font-semibold text-foreground">Productos</h3>
121
- <ul className="mt-3 divide-y divide-border rounded-lg border border-border">
122
- {order.items.map((item) => {
123
- const href =
124
- item.productHandle && productHref
125
- ? productHref(item.productHandle)
126
- : null
127
- return (
128
- <li key={item.id} className="flex gap-4 p-4">
129
- <div className="size-20 shrink-0 overflow-hidden rounded-md border border-border bg-muted/40">
130
- {item.thumbnail ? (
131
- <img
132
- src={item.thumbnail}
133
- alt=""
134
- className="size-full object-cover"
135
- />
136
- ) : (
137
- <div className="flex size-full items-center justify-center text-muted-foreground">
138
- <Package className="size-8" />
139
- </div>
140
- )}
141
- </div>
142
- <div className="min-w-0 flex-1">
143
- {href ? (
144
- <Link
145
- to={href}
146
- className="font-medium text-primary hover:underline"
147
- >
148
- {item.title}
149
- </Link>
150
- ) : (
151
- <p className="font-medium text-foreground">{item.title}</p>
152
- )}
153
- {item.variantTitle ? (
154
- <p className="text-sm text-muted-foreground">
155
- {item.variantTitle}
156
- </p>
157
- ) : null}
158
- <p className="mt-1 text-sm text-muted-foreground">
159
- Cantidad: {item.quantity}
160
- </p>
161
- <p className="mt-1 text-sm font-medium text-foreground">
162
- {money(item.total)}
163
- </p>
164
- </div>
165
- </li>
166
- )
167
- })}
168
- </ul>
169
- </section>
170
-
171
- {timeline.length > 0 ? (
172
- <section>
173
- <h3 className="text-base font-semibold text-foreground">
174
- Seguimiento
175
- </h3>
176
- <ol className="mt-3 space-y-0 border-l-2 border-primary/30 pl-4">
177
- {timeline.map((entry, index) => (
178
- <li
179
- key={`${entry.key}-${entry.occurredAt}`}
180
- className="relative pb-6 last:pb-0"
181
- >
182
- <span
183
- className={cn(
184
- 'absolute -left-[21px] top-1 size-2.5 rounded-full ring-2 ring-background',
185
- index === 0 ? 'bg-primary' : 'bg-muted-foreground/40',
186
- )}
187
- />
188
- <p className="text-sm font-medium text-foreground">
189
- {entry.label}
190
- </p>
191
- <p className="text-xs text-muted-foreground">
192
- {formatOrderDateTime(entry.occurredAt)}
193
- </p>
194
- {entry.description ? (
195
- <p className="mt-1 text-sm text-muted-foreground">
196
- {entry.description}
197
- </p>
198
- ) : null}
199
- </li>
200
- ))}
201
- </ol>
202
- </section>
203
- ) : null}
204
- </div>
205
-
206
- <div className="space-y-4">
207
- <section className="rounded-lg border border-border bg-muted/30 p-4">
208
- <h3 className="flex items-center gap-2 text-sm font-semibold text-foreground">
209
- <MapPin className="size-4" />
210
- Dirección de envío
211
- </h3>
212
- <p className="mt-2 text-sm leading-relaxed text-muted-foreground">
213
- {order.shippingAddressSummary ??
214
- [
215
- order.shippingAddress?.address1,
216
- order.shippingAddress?.address2,
217
- order.shippingAddress?.district,
218
- order.shippingAddress?.province,
219
- order.shippingAddress?.postalCode,
220
- ]
221
- .filter(Boolean)
222
- .join(', ')}
223
- </p>
224
- {order.shippingAddress?.phone ? (
225
- <p className="mt-2 text-sm text-muted-foreground">
226
- {order.shippingAddress.phone}
227
- </p>
228
- ) : null}
229
- </section>
230
-
231
- <section className="rounded-lg border border-border bg-muted/30 p-4">
232
- <h3 className="flex items-center gap-2 text-sm font-semibold text-foreground">
233
- <CreditCard className="size-4" />
234
- Resumen de pago
235
- </h3>
236
- <dl className="mt-3 space-y-2 text-sm">
237
- <div className="flex justify-between text-muted-foreground">
238
- <dt>Subtotal</dt>
239
- <dd>{money(order.subTotal)}</dd>
240
- </div>
241
- {order.discount > 0 ? (
242
- <div className="flex justify-between text-muted-foreground">
243
- <dt>Descuento</dt>
244
- <dd className="text-emerald-700">-{money(order.discount)}</dd>
245
- </div>
246
- ) : null}
247
- <div className="flex justify-between text-muted-foreground">
248
- <dt>Envío</dt>
249
- <dd>{money(order.shipping)}</dd>
250
- </div>
251
- {order.tax > 0 ? (
252
- <div className="flex justify-between text-muted-foreground">
253
- <dt>Impuestos</dt>
254
- <dd>{money(order.tax)}</dd>
255
- </div>
256
- ) : null}
257
- <div className="flex justify-between border-t border-border pt-2 font-semibold text-foreground">
258
- <dt>Total</dt>
259
- <dd>{money(order.total)}</dd>
260
- </div>
261
- </dl>
262
- {order.payments.length > 0 ? (
263
- <ul className="mt-4 space-y-2 border-t border-border pt-3 text-sm">
264
- {order.payments.map((p) => (
265
- <li key={p.id} className="text-muted-foreground">
266
- <span className="font-medium text-foreground">
267
- {p.paymentMethod}
268
- </span>
269
- {' · '}
270
- {money(p.amount)}
271
- <span className="text-muted-foreground">
272
- {' '}
273
- ({p.paymentStatus})
274
- </span>
275
- </li>
276
- ))}
277
- </ul>
278
- ) : null}
279
- </section>
280
- </div>
281
- </div>
282
- </div>
283
- </div>
284
- )
285
- }
@@ -1,192 +0,0 @@
1
- import { ChevronRight, Loader2, Package } from 'lucide-react'
2
- import {
3
- customerOrderStatusTone,
4
- formatCustomerOrderStatus,
5
- formatOrderDate,
6
- type CustomerOrderListItem,
7
- } from '@ecomiq/core'
8
- import { Link } from '../../link'
9
- import { buttonVariants, cn } from '../../ui'
10
- import { formatMoney } from '../checkout/format'
11
-
12
- function statusBadgeClass(
13
- tone: ReturnType<typeof customerOrderStatusTone>,
14
- ): string {
15
- switch (tone) {
16
- case 'success':
17
- return 'bg-emerald-50 text-emerald-800 ring-emerald-200'
18
- case 'warning':
19
- return 'bg-amber-50 text-amber-900 ring-amber-200'
20
- case 'danger':
21
- return 'bg-red-50 text-red-800 ring-red-200'
22
- case 'info':
23
- return 'bg-sky-50 text-sky-900 ring-sky-200'
24
- default:
25
- return 'bg-muted text-foreground ring-border'
26
- }
27
- }
28
-
29
- export type CustomerOrdersPanelProps = {
30
- orders?: CustomerOrderListItem[]
31
- isLoading: boolean
32
- errorMessage?: string | null
33
- /** Prefijo de ruta, p. ej. `/account/orders` → enlace a `{base}/{orderId}`. */
34
- orderDetailBasePath: string
35
- shopHref?: string
36
- language?: string
37
- }
38
-
39
- export function CustomerOrdersPanel({
40
- orders,
41
- isLoading,
42
- errorMessage,
43
- orderDetailBasePath,
44
- shopHref = '/',
45
- language = 'es-PE',
46
- }: CustomerOrdersPanelProps) {
47
- const list = orders ?? []
48
- const base = orderDetailBasePath.replace(/\/$/, '')
49
-
50
- return (
51
- <div className="space-y-6">
52
- <div>
53
- <h2 className="text-lg font-medium text-foreground">Mis pedidos</h2>
54
- <p className="mt-1 text-sm text-muted-foreground">
55
- Rastrea envíos, revisa totales y vuelve a ver lo que compraste.
56
- </p>
57
- </div>
58
-
59
- {isLoading ? (
60
- <div className="flex items-center gap-2 rounded-lg border border-border bg-background px-4 py-8 text-sm text-muted-foreground">
61
- <Loader2 className="size-4 shrink-0 animate-spin" />
62
- Cargando pedidos…
63
- </div>
64
- ) : null}
65
-
66
- {errorMessage && !isLoading ? (
67
- <p className="rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive">
68
- {errorMessage}
69
- </p>
70
- ) : null}
71
-
72
- {!isLoading && !errorMessage && list.length === 0 ? (
73
- <div className="rounded-lg border border-dashed border-border bg-muted/30 px-6 py-12 text-center">
74
- <Package className="mx-auto mb-3 size-12 text-muted-foreground/70" />
75
- <p className="text-base font-medium text-foreground">
76
- Aún no tienes pedidos
77
- </p>
78
- <p className="mt-2 text-sm text-muted-foreground">
79
- Cuando compres en esta tienda, aparecerán aquí con su estado de
80
- envío.
81
- </p>
82
- <Link to={shopHref} className={cn(buttonVariants(), 'mt-6')}>
83
- Seguir comprando
84
- </Link>
85
- </div>
86
- ) : null}
87
-
88
- {!isLoading && list.length > 0 ? (
89
- <ul className="space-y-4">
90
- {list.map((order) => {
91
- const tone = customerOrderStatusTone(order.status)
92
- const visibleItems = order.items.slice(0, 4)
93
- const extraCount = Math.max(0, order.items.length - visibleItems.length)
94
-
95
- return (
96
- <li
97
- key={order.orderId}
98
- className="overflow-hidden rounded-lg border border-border bg-background"
99
- >
100
- <div className="flex flex-wrap items-center justify-between gap-3 border-b border-border bg-muted/40 px-4 py-3 sm:px-5">
101
- <div className="min-w-0 space-y-0.5">
102
- <p className="text-sm text-muted-foreground">
103
- Pedido realizado el{' '}
104
- <span className="font-medium text-foreground">
105
- {formatOrderDate(order.orderDate)}
106
- </span>
107
- </p>
108
- <p className="text-sm font-semibold text-foreground">
109
- N.º de pedido: {order.orderNumber}
110
- </p>
111
- </div>
112
- <div className="flex flex-wrap items-center gap-3">
113
- <span
114
- className={cn(
115
- 'inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ring-1 ring-inset',
116
- statusBadgeClass(tone),
117
- )}
118
- >
119
- {formatCustomerOrderStatus(order.status)}
120
- </span>
121
- <p className="text-base font-semibold text-foreground">
122
- {formatMoney(order.total, language, order.currencyCode)}
123
- </p>
124
- </div>
125
- </div>
126
-
127
- <div className="px-4 py-4 sm:px-5">
128
- <div className="flex flex-wrap gap-3">
129
- {visibleItems.map((item) => (
130
- <div
131
- key={item.id}
132
- className="flex w-full max-w-[280px] gap-3 sm:w-auto sm:min-w-[220px] sm:flex-1"
133
- >
134
- <div className="size-16 shrink-0 overflow-hidden rounded-md border border-border bg-muted/40">
135
- {item.thumbnail ? (
136
- <img
137
- src={item.thumbnail}
138
- alt=""
139
- className="size-full object-cover"
140
- />
141
- ) : (
142
- <div className="flex size-full items-center justify-center text-muted-foreground">
143
- <Package className="size-6" />
144
- </div>
145
- )}
146
- </div>
147
- <div className="min-w-0 flex-1 text-sm">
148
- <p className="line-clamp-2 font-medium text-foreground">
149
- {item.title}
150
- </p>
151
- {item.variantTitle ? (
152
- <p className="text-muted-foreground">
153
- {item.variantTitle}
154
- </p>
155
- ) : null}
156
- <p className="text-muted-foreground">
157
- Cant.: {item.quantity}
158
- </p>
159
- </div>
160
- </div>
161
- ))}
162
- {extraCount > 0 ? (
163
- <p className="self-center text-sm text-muted-foreground">
164
- +{extraCount} producto{extraCount === 1 ? '' : 's'} más
165
- </p>
166
- ) : null}
167
- </div>
168
-
169
- {order.shippingAddressSummary ? (
170
- <p className="mt-3 line-clamp-2 text-xs text-muted-foreground">
171
- Enviar a: {order.shippingAddressSummary}
172
- </p>
173
- ) : null}
174
-
175
- <div className="mt-4 flex flex-wrap gap-2 border-t border-border pt-4">
176
- <Link
177
- to={`${base}/${encodeURIComponent(order.orderId)}`}
178
- className={cn(buttonVariants({ variant: 'outline', size: 'sm' }), 'gap-1')}
179
- >
180
- Ver detalles del pedido
181
- <ChevronRight className="size-4" />
182
- </Link>
183
- </div>
184
- </div>
185
- </li>
186
- )
187
- })}
188
- </ul>
189
- ) : null}
190
- </div>
191
- )
192
- }