@asteby/storefront-react 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/account-server.cjs +405 -7
- package/dist/account-server.cjs.map +1 -1
- package/dist/account-server.d.cts +41 -1
- package/dist/account-server.d.ts +41 -1
- package/dist/account-server.js +73 -3
- package/dist/account-server.js.map +1 -1
- package/dist/account.cjs +1393 -4
- package/dist/account.cjs.map +1 -1
- package/dist/account.css +203 -0
- package/dist/account.d.cts +467 -3
- package/dist/account.d.ts +467 -3
- package/dist/account.js +1033 -2
- package/dist/account.js.map +1 -1
- package/dist/checkout.js +2 -2
- package/dist/chunk-PPQEUTXJ.js +260 -0
- package/dist/chunk-PPQEUTXJ.js.map +1 -0
- package/dist/chunk-TXEYBDFG.js +182 -0
- package/dist/chunk-TXEYBDFG.js.map +1 -0
- package/dist/fiscal.d.cts +34 -34
- package/dist/fiscal.d.ts +34 -34
- package/dist/fiscal.js +4 -258
- package/dist/fiscal.js.map +1 -1
- package/dist/payments.css +15 -14
- package/dist/payments.js +2 -2
- package/dist/voucher-document-SFWJCLTN.js +124 -0
- package/dist/voucher-document-SFWJCLTN.js.map +1 -0
- package/package.json +2 -2
package/dist/account.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { fill } from './chunk-PPQEUTXJ.js';
|
|
2
|
+
import { barcodeGeometry, voucherOf, barcodeValue } from './chunk-TXEYBDFG.js';
|
|
3
|
+
export { barcodeGeometry, barcodeValue, code128Modules, voucherOf } from './chunk-TXEYBDFG.js';
|
|
1
4
|
import { useFieldErrors, CheckoutField, ErrorSummary } from './chunk-DFGLCIEG.js';
|
|
2
|
-
import {
|
|
5
|
+
import { useResolvedLocale } from './chunk-T52H5HL3.js';
|
|
6
|
+
import { useOptionalStorefront } from './chunk-DQBL2DFJ.js';
|
|
7
|
+
import { useState, useRef, useEffect, useId, useMemo, useCallback } from 'react';
|
|
3
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { orderProgress, nextAction, safeTrackingUrl, isTestShipment, sortTrackingEvents, isTestInvoice, groupInvoiceDocs, formatMoney } from '@asteby/storefront';
|
|
4
10
|
|
|
5
11
|
var ES = {
|
|
6
12
|
titles: {
|
|
@@ -320,6 +326,1031 @@ function PostPurchaseAccountPrompt({
|
|
|
320
326
|
] });
|
|
321
327
|
}
|
|
322
328
|
|
|
323
|
-
|
|
329
|
+
// src/account/orders-messages.ts
|
|
330
|
+
var ES3 = {
|
|
331
|
+
// order list
|
|
332
|
+
"order.number": "Pedido {number}",
|
|
333
|
+
"order.placed": "Realizado el {date}",
|
|
334
|
+
"order.total": "Total",
|
|
335
|
+
"order.view": "Ver pedido",
|
|
336
|
+
"order.items.one": "{count} art\xEDculo",
|
|
337
|
+
"order.items.other": "{count} art\xEDculos",
|
|
338
|
+
"order.stepOf": "Paso {n} de {total}: {step}",
|
|
339
|
+
"order.listLabel": "Tus pedidos",
|
|
340
|
+
"order.loading": "Cargando tus pedidos",
|
|
341
|
+
"order.loadMore": "Ver m\xE1s pedidos",
|
|
342
|
+
"order.loadingMore": "Cargando\u2026",
|
|
343
|
+
"order.error": "No pudimos cargar tus pedidos. Tus compras est\xE1n a salvo.",
|
|
344
|
+
"order.retry": "Reintentar",
|
|
345
|
+
"order.emptyTitle": "A\xFAn no tienes pedidos",
|
|
346
|
+
"order.emptyBody": "Cuando compres, aqu\xED ver\xE1s el estado y el env\xEDo de cada pedido.",
|
|
347
|
+
"order.emptyGuest": "\xBFCompraste como invitado? Verifica tu correo para ver aqu\xED tus pedidos.",
|
|
348
|
+
// stage (order status)
|
|
349
|
+
"stage.pending_payment": "Esperando pago",
|
|
350
|
+
"stage.paid": "Pagado",
|
|
351
|
+
"stage.preparing": "En preparaci\xF3n",
|
|
352
|
+
"stage.ready_for_pickup": "Listo para recoger",
|
|
353
|
+
"stage.shipped": "Enviado",
|
|
354
|
+
"stage.in_transit": "En camino",
|
|
355
|
+
"stage.out_for_delivery": "En reparto",
|
|
356
|
+
"stage.delivered": "Entregado",
|
|
357
|
+
"stage.cancelled": "Cancelado",
|
|
358
|
+
"stage.refunded": "Reembolsado",
|
|
359
|
+
"stage.unknown": "En proceso",
|
|
360
|
+
// progress
|
|
361
|
+
"progress.label": "Progreso del pedido",
|
|
362
|
+
"step.paid": "Pagado",
|
|
363
|
+
"step.preparing": "En preparaci\xF3n",
|
|
364
|
+
"step.shipped": "Enviado",
|
|
365
|
+
"step.in_transit": "En camino",
|
|
366
|
+
"step.ready_for_pickup": "Listo para recoger",
|
|
367
|
+
"step.delivered": "Entregado",
|
|
368
|
+
"step.unknown": "Siguiente paso",
|
|
369
|
+
"stepState.done": "completado",
|
|
370
|
+
"stepState.current": "paso actual",
|
|
371
|
+
"stepState.pending": "pendiente",
|
|
372
|
+
"stepState.problem": "con incidencia",
|
|
373
|
+
"problem.delivery_exception": "Hubo un problema con la entrega. Contacta a la tienda si no se resuelve.",
|
|
374
|
+
"problem.returned": "El paquete regres\xF3 a la tienda. Cont\xE1ctanos para coordinar un nuevo env\xEDo.",
|
|
375
|
+
"problem.lost": "No encontramos tu paquete. Cont\xE1ctanos y lo resolvemos.",
|
|
376
|
+
"problem.payment_failed": "El pago no se complet\xF3. Puedes intentarlo de nuevo.",
|
|
377
|
+
"problem.unknown": "Tu pedido tiene una incidencia. Contacta a la tienda.",
|
|
378
|
+
"progress.cancelled": "Este pedido fue cancelado.",
|
|
379
|
+
"progress.refunded": "Este pedido fue reembolsado.",
|
|
380
|
+
// next action
|
|
381
|
+
"action.pay": "Pagar ahora",
|
|
382
|
+
"action.track": "Rastrear env\xEDo",
|
|
383
|
+
"action.pickup": "Recoger en sucursal",
|
|
384
|
+
"action.download_invoice": "Descargar factura",
|
|
385
|
+
"action.request_invoice": "Solicitar factura",
|
|
386
|
+
"action.correct_invoice_data": "Corregir datos de facturaci\xF3n",
|
|
387
|
+
"action.contact_store": "Contactar a la tienda",
|
|
388
|
+
"action.unknown": "Ver detalle",
|
|
389
|
+
"action.newTab": "(se abre en una pesta\xF1a nueva)",
|
|
390
|
+
"action.label": "Siguiente paso del pedido",
|
|
391
|
+
// shipment
|
|
392
|
+
"shipment.title": "Env\xEDo",
|
|
393
|
+
"shipment.return": "Devoluci\xF3n",
|
|
394
|
+
"shipment.carrier": "Paqueter\xEDa",
|
|
395
|
+
"shipment.service": "Servicio",
|
|
396
|
+
"shipment.number": "N\xFAmero de gu\xEDa",
|
|
397
|
+
"shipment.copy": "Copiar",
|
|
398
|
+
"shipment.copied": "Copiado",
|
|
399
|
+
"shipment.copyFailed": "No pudimos copiar; selecciona el texto.",
|
|
400
|
+
"shipment.track": "Rastrear con {carrier}",
|
|
401
|
+
"shipment.trackGeneric": "Rastrear env\xEDo",
|
|
402
|
+
"shipment.promised": "Llega a m\xE1s tardar el {date}",
|
|
403
|
+
"shipment.delivered": "Entregado el {date}",
|
|
404
|
+
"shipment.shipped": "Enviado el {date}",
|
|
405
|
+
"shipment.events": "Movimientos",
|
|
406
|
+
"shipment.noEvents": "La paqueter\xEDa a\xFAn no registra movimientos; suele tardar 24 horas.",
|
|
407
|
+
"shipment.showAll": "Ver todo ({count})",
|
|
408
|
+
"shipment.showLess": "Ver menos",
|
|
409
|
+
"shipment.returnLabel": "Gu\xEDa de devoluci\xF3n",
|
|
410
|
+
"shipment.test": "De prueba",
|
|
411
|
+
"shipment.testNote": "Env\xEDo de prueba: no es un env\xEDo real.",
|
|
412
|
+
"shipment.preparing": "Preparando tu env\xEDo",
|
|
413
|
+
"shipment.status.pending": "Preparando env\xEDo",
|
|
414
|
+
"shipment.status.label_created": "Gu\xEDa generada",
|
|
415
|
+
"shipment.status.in_transit": "En camino",
|
|
416
|
+
"shipment.status.out_for_delivery": "En reparto",
|
|
417
|
+
"shipment.status.delivered": "Entregado",
|
|
418
|
+
"shipment.status.exception": "Incidencia en la entrega",
|
|
419
|
+
"shipment.status.returned": "Devuelto a la tienda",
|
|
420
|
+
"shipment.status.lost": "Extraviado",
|
|
421
|
+
"shipment.status.cancelled": "Cancelado",
|
|
422
|
+
"shipment.status.unknown": "En proceso",
|
|
423
|
+
"shipment.eventFrom": "{location}",
|
|
424
|
+
// invoices
|
|
425
|
+
"invoice.title": "Facturas",
|
|
426
|
+
"invoice.invoice": "Factura",
|
|
427
|
+
"invoice.creditNote": "Nota de cr\xE9dito",
|
|
428
|
+
"invoice.creditNoteOf": "Corrige la factura {folio}",
|
|
429
|
+
"invoice.folio": "Folio fiscal",
|
|
430
|
+
"invoice.series": "Serie y folio",
|
|
431
|
+
"invoice.issued": "Emitida el {date}",
|
|
432
|
+
"invoice.total": "Total",
|
|
433
|
+
"invoice.pdf": "Descargar PDF",
|
|
434
|
+
"invoice.xml": "Descargar XML",
|
|
435
|
+
"invoice.downloadOf": "{action}, {kind} {name}",
|
|
436
|
+
"invoice.none": "A\xFAn no hay facturas de este pedido.",
|
|
437
|
+
"invoice.test": "Factura de prueba, sin validez",
|
|
438
|
+
"invoice.status.issued": "Emitida",
|
|
439
|
+
"invoice.status.pending": "En proceso",
|
|
440
|
+
"invoice.status.cancelled": "Cancelada",
|
|
441
|
+
"invoice.status.error": "No se pudo emitir",
|
|
442
|
+
"invoice.status.unknown": "En proceso",
|
|
443
|
+
"invoice.statusNote.pending": "La estamos generando; te avisaremos cuando est\xE9 lista.",
|
|
444
|
+
"invoice.statusNote.error": "Contacta a la tienda para resolverlo.",
|
|
445
|
+
"invoice.statusNote.cancelled": "Esta factura fue cancelada y ya no tiene validez.",
|
|
446
|
+
// pending payment
|
|
447
|
+
"pending.title": "Pendientes de pago",
|
|
448
|
+
"pending.intro": "Tu pedido se genera en cuanto confirmamos el pago. Paga con la ficha antes de que venza.",
|
|
449
|
+
"pending.waiting": "Esperando pago",
|
|
450
|
+
"pending.expired": "Vencida",
|
|
451
|
+
"pending.reference": "Referencia",
|
|
452
|
+
"pending.clabe": "CLABE",
|
|
453
|
+
"pending.expires": "Vence el {date}",
|
|
454
|
+
"pending.expiredOn": "Venci\xF3 el {date}",
|
|
455
|
+
"pending.total": "Total",
|
|
456
|
+
"pending.copyReference": "Copiar referencia",
|
|
457
|
+
"pending.copyClabe": "Copiar CLABE",
|
|
458
|
+
"pending.copied": "Copiada",
|
|
459
|
+
"pending.copyFailed": "No pudimos copiar; selecciona el texto.",
|
|
460
|
+
"pending.print": "Ver e imprimir ficha",
|
|
461
|
+
"pending.download": "Descargar ficha",
|
|
462
|
+
"pending.expiredNote": "Esta ficha ya no es v\xE1lida. Haz tu pedido de nuevo.",
|
|
463
|
+
"pending.barcode": "C\xF3digo de barras {code}",
|
|
464
|
+
"pending.method.oxxo": "OXXO",
|
|
465
|
+
"pending.method.spei": "Transferencia SPEI",
|
|
466
|
+
"pending.method.bank_transfer": "Transferencia bancaria",
|
|
467
|
+
"pending.method.bank_deposit": "Dep\xF3sito bancario",
|
|
468
|
+
"pending.method.cash": "Pago en efectivo",
|
|
469
|
+
"pending.method.unknown": "Pago en efectivo",
|
|
470
|
+
// refunds & payments
|
|
471
|
+
"refund.title": "Reembolsos",
|
|
472
|
+
"refund.status.requested": "Solicitado",
|
|
473
|
+
"refund.status.processing": "En proceso",
|
|
474
|
+
"refund.status.completed": "Completado",
|
|
475
|
+
"refund.status.failed": "No se pudo completar",
|
|
476
|
+
"refund.status.unknown": "En proceso",
|
|
477
|
+
"refund.requested": "Solicitado el {date}",
|
|
478
|
+
"refund.completed": "Completado el {date}",
|
|
479
|
+
"refund.none": "Este pedido no tiene reembolsos.",
|
|
480
|
+
"payment.title": "Pagos",
|
|
481
|
+
"payment.status.paid": "Pagado",
|
|
482
|
+
"payment.status.pending": "Pendiente",
|
|
483
|
+
"payment.status.failed": "Fallido",
|
|
484
|
+
"payment.status.refunded": "Reembolsado",
|
|
485
|
+
"payment.status.partially_refunded": "Reembolsado parcialmente",
|
|
486
|
+
"payment.status.unknown": "En proceso",
|
|
487
|
+
"payment.paidOn": "Pagado el {date}",
|
|
488
|
+
// sections
|
|
489
|
+
"section.error": "No pudimos cargar esta secci\xF3n.",
|
|
490
|
+
"section.retry": "Reintentar",
|
|
491
|
+
"section.loading": "Cargando"
|
|
492
|
+
};
|
|
493
|
+
var EN3 = {
|
|
494
|
+
"order.number": "Order {number}",
|
|
495
|
+
"order.placed": "Placed on {date}",
|
|
496
|
+
"order.total": "Total",
|
|
497
|
+
"order.view": "View order",
|
|
498
|
+
"order.items.one": "{count} item",
|
|
499
|
+
"order.items.other": "{count} items",
|
|
500
|
+
"order.stepOf": "Step {n} of {total}: {step}",
|
|
501
|
+
"order.listLabel": "Your orders",
|
|
502
|
+
"order.loading": "Loading your orders",
|
|
503
|
+
"order.loadMore": "Show more orders",
|
|
504
|
+
"order.loadingMore": "Loading\u2026",
|
|
505
|
+
"order.error": "We could not load your orders. Your purchases are safe.",
|
|
506
|
+
"order.retry": "Try again",
|
|
507
|
+
"order.emptyTitle": "You have no orders yet",
|
|
508
|
+
"order.emptyBody": "When you buy, you will see the status and shipment of each order here.",
|
|
509
|
+
"order.emptyGuest": "Did you buy as a guest? Verify your email to see your orders here.",
|
|
510
|
+
"stage.pending_payment": "Waiting for payment",
|
|
511
|
+
"stage.paid": "Paid",
|
|
512
|
+
"stage.preparing": "Being prepared",
|
|
513
|
+
"stage.ready_for_pickup": "Ready for pickup",
|
|
514
|
+
"stage.shipped": "Shipped",
|
|
515
|
+
"stage.in_transit": "On its way",
|
|
516
|
+
"stage.out_for_delivery": "Out for delivery",
|
|
517
|
+
"stage.delivered": "Delivered",
|
|
518
|
+
"stage.cancelled": "Cancelled",
|
|
519
|
+
"stage.refunded": "Refunded",
|
|
520
|
+
"stage.unknown": "In progress",
|
|
521
|
+
"progress.label": "Order progress",
|
|
522
|
+
"step.paid": "Paid",
|
|
523
|
+
"step.preparing": "Being prepared",
|
|
524
|
+
"step.shipped": "Shipped",
|
|
525
|
+
"step.in_transit": "On its way",
|
|
526
|
+
"step.ready_for_pickup": "Ready for pickup",
|
|
527
|
+
"step.delivered": "Delivered",
|
|
528
|
+
"step.unknown": "Next step",
|
|
529
|
+
"stepState.done": "completed",
|
|
530
|
+
"stepState.current": "current step",
|
|
531
|
+
"stepState.pending": "pending",
|
|
532
|
+
"stepState.problem": "has a problem",
|
|
533
|
+
"problem.delivery_exception": "There was a problem with the delivery. Contact the store if it is not resolved.",
|
|
534
|
+
"problem.returned": "The package went back to the store. Contact us to arrange a new shipment.",
|
|
535
|
+
"problem.lost": "We could not find your package. Contact us and we will sort it out.",
|
|
536
|
+
"problem.payment_failed": "The payment did not go through. You can try again.",
|
|
537
|
+
"problem.unknown": "Your order has a problem. Contact the store.",
|
|
538
|
+
"progress.cancelled": "This order was cancelled.",
|
|
539
|
+
"progress.refunded": "This order was refunded.",
|
|
540
|
+
"action.pay": "Pay now",
|
|
541
|
+
"action.track": "Track shipment",
|
|
542
|
+
"action.pickup": "Pick up in store",
|
|
543
|
+
"action.download_invoice": "Download invoice",
|
|
544
|
+
"action.request_invoice": "Request invoice",
|
|
545
|
+
"action.correct_invoice_data": "Fix billing details",
|
|
546
|
+
"action.contact_store": "Contact the store",
|
|
547
|
+
"action.unknown": "View details",
|
|
548
|
+
"action.newTab": "(opens in a new tab)",
|
|
549
|
+
"action.label": "Next step of the order",
|
|
550
|
+
"shipment.title": "Shipment",
|
|
551
|
+
"shipment.return": "Return",
|
|
552
|
+
"shipment.carrier": "Carrier",
|
|
553
|
+
"shipment.service": "Service",
|
|
554
|
+
"shipment.number": "Tracking number",
|
|
555
|
+
"shipment.copy": "Copy",
|
|
556
|
+
"shipment.copied": "Copied",
|
|
557
|
+
"shipment.copyFailed": "We could not copy; select the text.",
|
|
558
|
+
"shipment.track": "Track with {carrier}",
|
|
559
|
+
"shipment.trackGeneric": "Track shipment",
|
|
560
|
+
"shipment.promised": "Arrives by {date}",
|
|
561
|
+
"shipment.delivered": "Delivered on {date}",
|
|
562
|
+
"shipment.shipped": "Shipped on {date}",
|
|
563
|
+
"shipment.events": "Updates",
|
|
564
|
+
"shipment.noEvents": "The carrier has not reported any movement yet; it usually takes 24 hours.",
|
|
565
|
+
"shipment.showAll": "Show all ({count})",
|
|
566
|
+
"shipment.showLess": "Show less",
|
|
567
|
+
"shipment.returnLabel": "Return label",
|
|
568
|
+
"shipment.test": "Test",
|
|
569
|
+
"shipment.testNote": "Test shipment: it is not a real shipment.",
|
|
570
|
+
"shipment.preparing": "Preparing your shipment",
|
|
571
|
+
"shipment.status.pending": "Preparing shipment",
|
|
572
|
+
"shipment.status.label_created": "Label created",
|
|
573
|
+
"shipment.status.in_transit": "On its way",
|
|
574
|
+
"shipment.status.out_for_delivery": "Out for delivery",
|
|
575
|
+
"shipment.status.delivered": "Delivered",
|
|
576
|
+
"shipment.status.exception": "Delivery problem",
|
|
577
|
+
"shipment.status.returned": "Returned to the store",
|
|
578
|
+
"shipment.status.lost": "Lost",
|
|
579
|
+
"shipment.status.cancelled": "Cancelled",
|
|
580
|
+
"shipment.status.unknown": "In progress",
|
|
581
|
+
"shipment.eventFrom": "{location}",
|
|
582
|
+
"invoice.title": "Invoices",
|
|
583
|
+
"invoice.invoice": "Invoice",
|
|
584
|
+
"invoice.creditNote": "Credit note",
|
|
585
|
+
"invoice.creditNoteOf": "Corrects invoice {folio}",
|
|
586
|
+
"invoice.folio": "Tax folio",
|
|
587
|
+
"invoice.series": "Series and number",
|
|
588
|
+
"invoice.issued": "Issued on {date}",
|
|
589
|
+
"invoice.total": "Total",
|
|
590
|
+
"invoice.pdf": "Download PDF",
|
|
591
|
+
"invoice.xml": "Download XML",
|
|
592
|
+
"invoice.downloadOf": "{action}, {kind} {name}",
|
|
593
|
+
"invoice.none": "There are no invoices for this order yet.",
|
|
594
|
+
"invoice.test": "Test invoice, not valid",
|
|
595
|
+
"invoice.status.issued": "Issued",
|
|
596
|
+
"invoice.status.pending": "In progress",
|
|
597
|
+
"invoice.status.cancelled": "Cancelled",
|
|
598
|
+
"invoice.status.error": "Could not be issued",
|
|
599
|
+
"invoice.status.unknown": "In progress",
|
|
600
|
+
"invoice.statusNote.pending": "We are generating it; we will let you know when it is ready.",
|
|
601
|
+
"invoice.statusNote.error": "Contact the store to resolve it.",
|
|
602
|
+
"invoice.statusNote.cancelled": "This invoice was cancelled and is no longer valid.",
|
|
603
|
+
"pending.title": "Waiting for payment",
|
|
604
|
+
"pending.intro": "Your order is created as soon as we confirm the payment. Pay with the voucher before it expires.",
|
|
605
|
+
"pending.waiting": "Waiting for payment",
|
|
606
|
+
"pending.expired": "Expired",
|
|
607
|
+
"pending.reference": "Reference",
|
|
608
|
+
"pending.clabe": "CLABE",
|
|
609
|
+
"pending.expires": "Expires on {date}",
|
|
610
|
+
"pending.expiredOn": "Expired on {date}",
|
|
611
|
+
"pending.total": "Total",
|
|
612
|
+
"pending.copyReference": "Copy reference",
|
|
613
|
+
"pending.copyClabe": "Copy CLABE",
|
|
614
|
+
"pending.copied": "Copied",
|
|
615
|
+
"pending.copyFailed": "We could not copy; select the text.",
|
|
616
|
+
"pending.print": "View and print voucher",
|
|
617
|
+
"pending.download": "Download voucher",
|
|
618
|
+
"pending.expiredNote": "This voucher is no longer valid. Place your order again.",
|
|
619
|
+
"pending.barcode": "Barcode {code}",
|
|
620
|
+
"pending.method.oxxo": "OXXO",
|
|
621
|
+
"pending.method.spei": "SPEI transfer",
|
|
622
|
+
"pending.method.bank_transfer": "Bank transfer",
|
|
623
|
+
"pending.method.bank_deposit": "Bank deposit",
|
|
624
|
+
"pending.method.cash": "Cash payment",
|
|
625
|
+
"pending.method.unknown": "Cash payment",
|
|
626
|
+
"refund.title": "Refunds",
|
|
627
|
+
"refund.status.requested": "Requested",
|
|
628
|
+
"refund.status.processing": "In progress",
|
|
629
|
+
"refund.status.completed": "Completed",
|
|
630
|
+
"refund.status.failed": "Could not be completed",
|
|
631
|
+
"refund.status.unknown": "In progress",
|
|
632
|
+
"refund.requested": "Requested on {date}",
|
|
633
|
+
"refund.completed": "Completed on {date}",
|
|
634
|
+
"refund.none": "This order has no refunds.",
|
|
635
|
+
"payment.title": "Payments",
|
|
636
|
+
"payment.status.paid": "Paid",
|
|
637
|
+
"payment.status.pending": "Pending",
|
|
638
|
+
"payment.status.failed": "Failed",
|
|
639
|
+
"payment.status.refunded": "Refunded",
|
|
640
|
+
"payment.status.partially_refunded": "Partially refunded",
|
|
641
|
+
"payment.status.unknown": "In progress",
|
|
642
|
+
"payment.paidOn": "Paid on {date}",
|
|
643
|
+
"section.error": "We could not load this section.",
|
|
644
|
+
"section.retry": "Try again",
|
|
645
|
+
"section.loading": "Loading"
|
|
646
|
+
};
|
|
647
|
+
function accountMessages(locale, overrides) {
|
|
648
|
+
const base = (locale ?? "es-MX").toLowerCase().startsWith("en") ? EN3 : ES3;
|
|
649
|
+
return overrides ? { ...base, ...overrides } : base;
|
|
650
|
+
}
|
|
651
|
+
function enumText(m, group, value) {
|
|
652
|
+
const key = `${group}.${typeof value === "string" ? value : ""}`;
|
|
653
|
+
return Object.prototype.hasOwnProperty.call(m, key) ? m[key] : m[`${group}.unknown`];
|
|
654
|
+
}
|
|
655
|
+
var SR_ONLY = {
|
|
656
|
+
position: "absolute",
|
|
657
|
+
width: 1,
|
|
658
|
+
height: 1,
|
|
659
|
+
padding: 0,
|
|
660
|
+
margin: -1,
|
|
661
|
+
overflow: "hidden",
|
|
662
|
+
clip: "rect(0 0 0 0)",
|
|
663
|
+
whiteSpace: "nowrap",
|
|
664
|
+
border: 0
|
|
665
|
+
};
|
|
666
|
+
function str(v) {
|
|
667
|
+
if (typeof v === "number") return Number.isFinite(v) ? String(v) : null;
|
|
668
|
+
if (typeof v !== "string") return null;
|
|
669
|
+
const s = v.trim();
|
|
670
|
+
return s ? s : null;
|
|
671
|
+
}
|
|
672
|
+
function moneyText(v, locale) {
|
|
673
|
+
if (!v || typeof v !== "object") return null;
|
|
674
|
+
const { amount, currency_code } = v;
|
|
675
|
+
const a = typeof amount === "number" ? String(amount) : amount;
|
|
676
|
+
if (typeof a !== "string" || !a.trim() || !Number.isFinite(Number(a)) || typeof currency_code !== "string" || !/^[A-Za-z]{3}$/.test(currency_code)) return null;
|
|
677
|
+
return formatMoney({ amount: a.trim(), currency_code: currency_code.toUpperCase() }, locale);
|
|
678
|
+
}
|
|
679
|
+
function Hidden({ children }) {
|
|
680
|
+
return /* @__PURE__ */ jsx("span", { style: SR_ONLY, children });
|
|
681
|
+
}
|
|
682
|
+
function useAccountText({ locale, messages, timeZone }) {
|
|
683
|
+
const resolved = useResolvedLocale(locale);
|
|
684
|
+
const m = accountMessages(resolved, messages);
|
|
685
|
+
const date = (iso, style = "date") => formatDate(iso, resolved, style, timeZone);
|
|
686
|
+
const t = (key, vars) => vars ? fill(m[key], vars) : m[key];
|
|
687
|
+
return { locale: resolved, m, t, date, timeZone };
|
|
688
|
+
}
|
|
689
|
+
function formatDate(iso, locale, style = "date", timeZone) {
|
|
690
|
+
if (!iso || typeof iso !== "string") return null;
|
|
691
|
+
const dayOnly = /^\d{4}-\d{2}-\d{2}$/.test(iso);
|
|
692
|
+
const d = new Date(dayOnly ? `${iso}T12:00:00Z` : iso);
|
|
693
|
+
if (Number.isNaN(d.getTime())) return null;
|
|
694
|
+
const zone = dayOnly ? "UTC" : timeZone;
|
|
695
|
+
try {
|
|
696
|
+
return new Intl.DateTimeFormat(locale, { dateStyle: "long", ...style === "datetime" && !dayOnly ? { timeStyle: "short" } : {}, ...zone ? { timeZone: zone } : {} }).format(d);
|
|
697
|
+
} catch {
|
|
698
|
+
return d.toISOString().slice(0, 10);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function Time({ value, text, className }) {
|
|
702
|
+
if (!value || !text) return null;
|
|
703
|
+
return /* @__PURE__ */ jsx("time", { dateTime: value, className, suppressHydrationWarning: true, children: text });
|
|
704
|
+
}
|
|
705
|
+
function plural(m, base, count) {
|
|
706
|
+
return fill(count === 1 ? m["order.items.one"] : m["order.items.other"], { count });
|
|
707
|
+
}
|
|
708
|
+
function CopyButton({ value, label, copiedLabel, failedLabel, className, ariaLabel, ...rest }) {
|
|
709
|
+
const [state, setState] = useState("idle");
|
|
710
|
+
const timer = useRef(void 0);
|
|
711
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
712
|
+
const copy = useCallback(async () => {
|
|
713
|
+
try {
|
|
714
|
+
await navigator.clipboard.writeText(value);
|
|
715
|
+
setState("copied");
|
|
716
|
+
} catch {
|
|
717
|
+
setState("failed");
|
|
718
|
+
}
|
|
719
|
+
clearTimeout(timer.current);
|
|
720
|
+
timer.current = setTimeout(() => setState("idle"), 3e3);
|
|
721
|
+
}, [value]);
|
|
722
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
723
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: copy, className, "aria-label": ariaLabel, "data-sf-copy": rest["data-sf-copy"] ?? "", "data-state": state, children: state === "copied" ? copiedLabel : label }),
|
|
724
|
+
/* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", "data-sf-copy-status": true, style: state === "failed" ? void 0 : SR_ONLY, children: state === "copied" ? copiedLabel : state === "failed" ? failedLabel : "" })
|
|
725
|
+
] });
|
|
726
|
+
}
|
|
727
|
+
var STEP_STATES = /* @__PURE__ */ new Set(["done", "current", "pending", "problem"]);
|
|
728
|
+
var stepState = (s) => typeof s === "string" && STEP_STATES.has(s) ? s : "pending";
|
|
729
|
+
var GLYPH = { done: "\u2713", current: "\u25CF", pending: "\u25CB", problem: "!" };
|
|
730
|
+
function stageTone(stage, problem) {
|
|
731
|
+
if (problem) return "problem";
|
|
732
|
+
if (stage === "delivered") return "done";
|
|
733
|
+
if (stage === "cancelled" || stage === "refunded") return "muted";
|
|
734
|
+
if (["pending_payment", "paid", "preparing", "ready_for_pickup", "shipped", "in_transit", "out_for_delivery"].includes(stage)) return "current";
|
|
735
|
+
return "muted";
|
|
736
|
+
}
|
|
737
|
+
function OrderStatusBadge({ order, progress, className, ...text }) {
|
|
738
|
+
const { m } = useAccountText(text);
|
|
739
|
+
const p = progress ?? (order ? orderProgress(order) : null);
|
|
740
|
+
if (!p) return null;
|
|
741
|
+
return /* @__PURE__ */ jsxs("span", { className, "data-sf-order-badge": true, "data-sf-stage": p.stage, "data-sf-tone": stageTone(p.stage, p.problem), children: [
|
|
742
|
+
enumText(m, "stage", p.stage),
|
|
743
|
+
p.problem ? /* @__PURE__ */ jsx(Hidden, { children: `, ${m["stepState.problem"]}` }) : null
|
|
744
|
+
] });
|
|
745
|
+
}
|
|
746
|
+
function OrderProgress({ order, progress, variant = "full", classNames: cx = {}, ...text }) {
|
|
747
|
+
const { m, t, date } = useAccountText(text);
|
|
748
|
+
const p = progress ?? (order ? orderProgress(order) : null);
|
|
749
|
+
if (!p) return null;
|
|
750
|
+
const steps = Array.isArray(p.steps) ? p.steps.filter((s) => s && typeof s === "object") : [];
|
|
751
|
+
const stepLabel = (s) => enumText(m, "step", s.key);
|
|
752
|
+
if (steps.length === 0 || p.stage === "cancelled" || p.stage === "refunded") {
|
|
753
|
+
const note = p.stage === "cancelled" ? m["progress.cancelled"] : p.stage === "refunded" ? m["progress.refunded"] : enumText(m, "stage", p.stage);
|
|
754
|
+
return /* @__PURE__ */ jsx("div", { className: cx.root, "data-sf-progress": true, "data-sf-stage": p.stage, "data-sf-variant": variant, children: /* @__PURE__ */ jsx("p", { className: cx.terminal, "data-sf-progress-terminal": true, children: note }) });
|
|
755
|
+
}
|
|
756
|
+
if (variant === "compact") {
|
|
757
|
+
const at = Math.max(0, steps.findIndex((s) => stepState(s.state) === "current" || stepState(s.state) === "problem"));
|
|
758
|
+
const index = steps.some((s) => stepState(s.state) === "current" || stepState(s.state) === "problem") ? at : steps.every((s) => stepState(s.state) === "done") ? steps.length - 1 : 0;
|
|
759
|
+
return /* @__PURE__ */ jsx("div", { className: cx.root, "data-sf-progress": true, "data-sf-stage": p.stage, "data-sf-variant": "compact", children: /* @__PURE__ */ jsx("p", { className: cx.label, "data-sf-progress-summary": true, children: t("order.stepOf", { n: index + 1, total: steps.length, step: stepLabel(steps[index]) }) }) });
|
|
760
|
+
}
|
|
761
|
+
return /* @__PURE__ */ jsxs("div", { className: cx.root, "data-sf-progress": true, "data-sf-stage": p.stage, "data-sf-variant": "full", children: [
|
|
762
|
+
/* @__PURE__ */ jsx("ol", { className: cx.list, "aria-label": m["progress.label"], "data-sf-progress-list": true, children: steps.map((s, i) => {
|
|
763
|
+
const state = stepState(s.state);
|
|
764
|
+
return /* @__PURE__ */ jsxs("li", { className: cx.step, "data-sf-step": typeof s.key === "string" ? s.key : "unknown", "data-sf-step-state": state, ...state === "current" || state === "problem" ? { "aria-current": "step" } : {}, children: [
|
|
765
|
+
/* @__PURE__ */ jsx("span", { className: cx.marker, "aria-hidden": "true", "data-sf-step-marker": true, children: GLYPH[state] }),
|
|
766
|
+
/* @__PURE__ */ jsxs("span", { className: cx.label, "data-sf-step-label": true, children: [
|
|
767
|
+
stepLabel(s),
|
|
768
|
+
/* @__PURE__ */ jsx(Hidden, { children: `, ${m[`stepState.${state}`]}` })
|
|
769
|
+
] }),
|
|
770
|
+
/* @__PURE__ */ jsx(Time, { value: s.at, text: date(s.at), className: cx.time })
|
|
771
|
+
] }, `${s.key}-${i}`);
|
|
772
|
+
}) }),
|
|
773
|
+
p.problem ? /* @__PURE__ */ jsx("p", { className: cx.problem, "data-sf-progress-problem": typeof p.problem.code === "string" ? p.problem.code : "unknown", children: enumText(m, "problem", p.problem.code) }) : null
|
|
774
|
+
] });
|
|
775
|
+
}
|
|
776
|
+
function NextActionBar({ order, action, hrefFor, onAction, secondary, classNames: cx = {}, ...text }) {
|
|
777
|
+
const { m } = useAccountText(text);
|
|
778
|
+
const a = action ?? (order ? nextAction(order) : null);
|
|
779
|
+
if (!a || a.kind === "none") return secondary ? /* @__PURE__ */ jsx("div", { className: cx.root, "data-sf-action-bar": true, children: secondary }) : null;
|
|
780
|
+
const fromApi = a.kind === "track" || a.kind === "pickup" ? safeTrackingUrl(a.href) : null;
|
|
781
|
+
const href = hrefFor?.(a) ?? fromApi;
|
|
782
|
+
const external = !!href && /^https:\/\//i.test(href);
|
|
783
|
+
const label = enumText(m, "action", a.kind);
|
|
784
|
+
const common = { className: cx.primary, "data-sf-action": typeof a.kind === "string" ? a.kind : "unknown" };
|
|
785
|
+
let primary = null;
|
|
786
|
+
if (href) {
|
|
787
|
+
primary = /* @__PURE__ */ jsxs("a", { href, ...common, ...external ? { target: "_blank", rel: "noopener noreferrer" } : {}, onClick: onAction ? (e) => onAction(a, e) : void 0, children: [
|
|
788
|
+
label,
|
|
789
|
+
external ? /* @__PURE__ */ jsxs(Hidden, { children: [
|
|
790
|
+
" ",
|
|
791
|
+
m["action.newTab"]
|
|
792
|
+
] }) : null
|
|
793
|
+
] });
|
|
794
|
+
} else if (onAction) {
|
|
795
|
+
primary = /* @__PURE__ */ jsx("button", { type: "button", ...common, onClick: (e) => onAction(a, e), children: label });
|
|
796
|
+
}
|
|
797
|
+
if (!primary && !secondary) return null;
|
|
798
|
+
return /* @__PURE__ */ jsxs("div", { className: cx.root, role: "group", "aria-label": m["action.label"], "data-sf-action-bar": true, children: [
|
|
799
|
+
primary,
|
|
800
|
+
secondary
|
|
801
|
+
] });
|
|
802
|
+
}
|
|
803
|
+
function OrderCard({ order, orderHref, actionHref, onAction, headingLevel = 3, classNames: cx = {}, ...text }) {
|
|
804
|
+
const { m, date, locale } = useAccountText(text);
|
|
805
|
+
const Heading = `h${headingLevel}`;
|
|
806
|
+
const progress = orderProgress(order);
|
|
807
|
+
const items = (Array.isArray(order.lines) ? order.lines : []).reduce((n, l) => n + (Number.isFinite(l?.quantity) ? l.quantity : 0), 0);
|
|
808
|
+
const summary = order.shipments_summary && typeof order.shipments_summary === "object" ? order.shipments_summary : null;
|
|
809
|
+
const shipments = Array.isArray(order.shipments) ? order.shipments : [];
|
|
810
|
+
const showShipment = !!summary && typeof summary.count === "number" && summary.count > 0 && !(shipments.length > 0 && shipments.every(isTestShipment)) && !["pending_payment", "cancelled", "refunded"].includes(progress.stage);
|
|
811
|
+
const action = nextAction(order);
|
|
812
|
+
const total = moneyText(order.total, locale);
|
|
813
|
+
const carrier = summary ? str(summary.carrier) : null;
|
|
814
|
+
return /* @__PURE__ */ jsxs("article", { className: cx.root, "data-sf-order": true, "data-sf-order-status": progress.stage, "data-sf-order-id": order.id, children: [
|
|
815
|
+
/* @__PURE__ */ jsxs("header", { className: cx.header, children: [
|
|
816
|
+
/* @__PURE__ */ jsx(Heading, { className: cx.number, "data-sf-order-number": true, children: /* @__PURE__ */ jsx("a", { href: orderHref(order), className: cx.link, "data-sf-order-link": true, children: fill(m["order.number"], { number: str(order.number) ?? (str(order.id) ?? "").slice(0, 8) }) }) }),
|
|
817
|
+
/* @__PURE__ */ jsx(OrderStatusBadge, { progress, ...text, ...cx.badge ? { className: cx.badge } : {} })
|
|
818
|
+
] }),
|
|
819
|
+
/* @__PURE__ */ jsxs("p", { className: cx.meta, "data-sf-order-meta": true, children: [
|
|
820
|
+
/* @__PURE__ */ jsx(Time, { value: order.created_at, text: date(order.created_at) ? fill(m["order.placed"], { date: date(order.created_at) }) : null }),
|
|
821
|
+
items > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
822
|
+
" \xB7 ",
|
|
823
|
+
plural(m, "order.items", items)
|
|
824
|
+
] }) : null
|
|
825
|
+
] }),
|
|
826
|
+
/* @__PURE__ */ jsxs("div", { className: cx.summary, "data-sf-order-summary": true, children: [
|
|
827
|
+
/* @__PURE__ */ jsx(OrderProgress, { progress, variant: "compact", ...text, ...cx.progress ? { classNames: cx.progress } : {} }),
|
|
828
|
+
showShipment ? /* @__PURE__ */ jsxs("p", { className: cx.shipment, "data-sf-order-shipment": true, children: [
|
|
829
|
+
carrier ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
830
|
+
carrier,
|
|
831
|
+
" \xB7 "
|
|
832
|
+
] }) : null,
|
|
833
|
+
enumText(m, "shipment.status", summary.status)
|
|
834
|
+
] }) : null
|
|
835
|
+
] }),
|
|
836
|
+
/* @__PURE__ */ jsxs("div", { className: cx.footer, children: [
|
|
837
|
+
total ? /* @__PURE__ */ jsxs("p", { className: cx.total, "data-sf-order-total": true, children: [
|
|
838
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
839
|
+
m["order.total"],
|
|
840
|
+
": "
|
|
841
|
+
] }),
|
|
842
|
+
/* @__PURE__ */ jsx("strong", { children: total })
|
|
843
|
+
] }) : null,
|
|
844
|
+
/* @__PURE__ */ jsx(
|
|
845
|
+
NextActionBar,
|
|
846
|
+
{
|
|
847
|
+
action,
|
|
848
|
+
...text,
|
|
849
|
+
hrefFor: (a) => actionHref?.(a, order) ?? void 0,
|
|
850
|
+
...onAction ? { onAction: (a) => onAction(a, order) } : {},
|
|
851
|
+
classNames: { ...cx.actions ? { root: cx.actions } : {}, ...cx.action ?? {} }
|
|
852
|
+
}
|
|
853
|
+
)
|
|
854
|
+
] })
|
|
855
|
+
] });
|
|
856
|
+
}
|
|
857
|
+
function OrderList({ orders, status = "ready", skeletons = 3, onRetry, hasMore, loadingMore, onLoadMore, emptyAction, guestHint = true, orderHref, actionHref, onAction, headingLevel = 3, classNames: cx = {}, ...text }) {
|
|
858
|
+
const { m } = useAccountText(text);
|
|
859
|
+
const list = (Array.isArray(orders) ? orders : []).filter((o) => !!o && typeof o === "object" && typeof o.id === "string");
|
|
860
|
+
if (status === "loading" && list.length === 0) {
|
|
861
|
+
return /* @__PURE__ */ jsxs("div", { className: cx.root, role: "status", "aria-busy": "true", "data-sf-orders": true, "data-sf-orders-state": "loading", children: [
|
|
862
|
+
/* @__PURE__ */ jsx(Hidden, { children: m["order.loading"] }),
|
|
863
|
+
/* @__PURE__ */ jsx("ul", { className: cx.list, "aria-hidden": "true", children: Array.from({ length: Math.max(1, skeletons) }, (_, i) => /* @__PURE__ */ jsx("li", { className: cx.skeleton, "data-sf-skeleton": true }, i)) })
|
|
864
|
+
] });
|
|
865
|
+
}
|
|
866
|
+
if (status === "error" && list.length === 0) {
|
|
867
|
+
return /* @__PURE__ */ jsx("div", { className: cx.root, "data-sf-orders": true, "data-sf-orders-state": "error", children: /* @__PURE__ */ jsxs("div", { className: cx.error, role: "alert", "data-sf-orders-error": true, children: [
|
|
868
|
+
/* @__PURE__ */ jsx("p", { children: m["order.error"] }),
|
|
869
|
+
onRetry ? /* @__PURE__ */ jsx("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: m["order.retry"] }) : null
|
|
870
|
+
] }) });
|
|
871
|
+
}
|
|
872
|
+
if (list.length === 0) {
|
|
873
|
+
return /* @__PURE__ */ jsx("div", { className: cx.root, "data-sf-orders": true, "data-sf-orders-state": "empty", children: /* @__PURE__ */ jsxs("div", { className: cx.empty, "data-sf-orders-empty": true, children: [
|
|
874
|
+
/* @__PURE__ */ jsx("p", { className: cx.emptyTitle, children: /* @__PURE__ */ jsx("strong", { children: m["order.emptyTitle"] }) }),
|
|
875
|
+
/* @__PURE__ */ jsx("p", { className: cx.emptyBody, children: m["order.emptyBody"] }),
|
|
876
|
+
guestHint ? /* @__PURE__ */ jsx("p", { className: cx.emptyGuest, "data-sf-orders-guest-hint": true, children: m["order.emptyGuest"] }) : null,
|
|
877
|
+
emptyAction
|
|
878
|
+
] }) });
|
|
879
|
+
}
|
|
880
|
+
return /* @__PURE__ */ jsxs("div", { className: cx.root, "data-sf-orders": true, "data-sf-orders-state": "ready", children: [
|
|
881
|
+
/* @__PURE__ */ jsx("ul", { className: cx.list, "aria-label": m["order.listLabel"], "data-sf-orders-list": true, children: list.map((o) => /* @__PURE__ */ jsx("li", { className: cx.item, children: /* @__PURE__ */ jsx(OrderCard, { order: o, orderHref, ...actionHref ? { actionHref } : {}, ...onAction ? { onAction } : {}, headingLevel, ...text, ...cx.card ? { classNames: cx.card } : {} }) }, o.id)) }),
|
|
882
|
+
status === "error" ? /* @__PURE__ */ jsxs("div", { className: cx.error, role: "alert", "data-sf-orders-error": true, children: [
|
|
883
|
+
/* @__PURE__ */ jsx("p", { children: m["order.error"] }),
|
|
884
|
+
onRetry ? /* @__PURE__ */ jsx("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: m["order.retry"] }) : null
|
|
885
|
+
] }) : null,
|
|
886
|
+
hasMore && onLoadMore ? /* @__PURE__ */ jsx("button", { type: "button", className: cx.more, onClick: onLoadMore, disabled: loadingMore, "aria-disabled": loadingMore || void 0, "data-sf-orders-more": true, children: loadingMore ? m["order.loadingMore"] : m["order.loadMore"] }) : null
|
|
887
|
+
] });
|
|
888
|
+
}
|
|
889
|
+
function ShipmentCard({ shipment, testMode = "hide", eventsPreview = 3, renderCarrierMark, renderMap, headingLevel = 3, classNames: cx = {}, ...text }) {
|
|
890
|
+
const { m, t, date } = useAccountText(text);
|
|
891
|
+
const [open, setOpen] = useState(false);
|
|
892
|
+
const id = useId().replace(/:/g, "");
|
|
893
|
+
if (!shipment || typeof shipment !== "object") return null;
|
|
894
|
+
const test = isTestShipment(shipment);
|
|
895
|
+
if (test && testMode === "hide") return null;
|
|
896
|
+
const isReturn = shipment.kind === "return";
|
|
897
|
+
const Heading = `h${headingLevel}`;
|
|
898
|
+
const SubHeading = `h${headingLevel + 1}`;
|
|
899
|
+
const carrier = str(shipment.carrier);
|
|
900
|
+
const service = test ? null : str(shipment.service);
|
|
901
|
+
const number = test ? null : str(shipment.tracking_number);
|
|
902
|
+
const trackUrl = test ? null : safeTrackingUrl(shipment.tracking_url);
|
|
903
|
+
const labelUrl = isReturn && !test ? safeTrackingUrl(shipment.label_url) : null;
|
|
904
|
+
const events = test ? [] : sortTrackingEvents(shipment.events);
|
|
905
|
+
const shown = open ? events : events.slice(0, Math.max(1, eventsPreview));
|
|
906
|
+
const status = test ? m["shipment.preparing"] : enumText(m, "shipment.status", shipment.status);
|
|
907
|
+
const promised = !test && shipment.status !== "delivered" ? date(shipment.promised_by) : null;
|
|
908
|
+
const delivered = !test ? date(shipment.delivered_at) : null;
|
|
909
|
+
const shipped = !test && !delivered ? date(shipment.shipped_at) : null;
|
|
910
|
+
const titleId = `sf-shp-${id}`;
|
|
911
|
+
const eventsId = `sf-shp-ev-${id}`;
|
|
912
|
+
return /* @__PURE__ */ jsxs("article", { className: cx.root, "aria-labelledby": titleId, "data-sf-shipment": true, "data-sf-shipment-status": test ? "test" : typeof shipment.status === "string" ? shipment.status : "unknown", "data-sf-shipment-kind": isReturn ? "return" : "outbound", ...test ? { "data-sf-test": "" } : {}, children: [
|
|
913
|
+
/* @__PURE__ */ jsxs("header", { className: cx.header, "data-sf-shipment-header": true, children: [
|
|
914
|
+
renderCarrierMark && !test ? /* @__PURE__ */ jsx("span", { "data-sf-shipment-mark": true, children: renderCarrierMark(shipment) }) : null,
|
|
915
|
+
/* @__PURE__ */ jsxs(Heading, { id: titleId, className: cx.carrier, "data-sf-shipment-title": true, children: [
|
|
916
|
+
isReturn ? m["shipment.return"] : carrier ?? m["shipment.title"],
|
|
917
|
+
isReturn && carrier ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
918
|
+
" \xB7 ",
|
|
919
|
+
carrier
|
|
920
|
+
] }) : null
|
|
921
|
+
] }),
|
|
922
|
+
/* @__PURE__ */ jsx("span", { className: cx.status, "data-sf-shipment-state": true, children: status }),
|
|
923
|
+
test ? /* @__PURE__ */ jsx("span", { className: cx.test, "data-sf-shipment-test": true, children: m["shipment.test"] }) : null
|
|
924
|
+
] }),
|
|
925
|
+
test ? /* @__PURE__ */ jsx("p", { className: cx.meta, "data-sf-shipment-test-note": true, children: m["shipment.testNote"] }) : null,
|
|
926
|
+
service ? /* @__PURE__ */ jsxs("p", { className: cx.meta, "data-sf-shipment-service": true, children: [
|
|
927
|
+
m["shipment.service"],
|
|
928
|
+
": ",
|
|
929
|
+
service
|
|
930
|
+
] }) : null,
|
|
931
|
+
number ? /* @__PURE__ */ jsxs("p", { className: cx.number, "data-sf-shipment-number": true, children: [
|
|
932
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
933
|
+
m["shipment.number"],
|
|
934
|
+
": "
|
|
935
|
+
] }),
|
|
936
|
+
/* @__PURE__ */ jsx("code", { children: number }),
|
|
937
|
+
" ",
|
|
938
|
+
/* @__PURE__ */ jsx(CopyButton, { value: number, label: m["shipment.copy"], copiedLabel: m["shipment.copied"], failedLabel: m["shipment.copyFailed"], ariaLabel: `${m["shipment.copy"]} ${m["shipment.number"]}`, className: cx.copy, "data-sf-copy": "tracking" })
|
|
939
|
+
] }) : null,
|
|
940
|
+
promised || delivered || shipped ? /* @__PURE__ */ jsx("p", { className: cx.meta, "data-sf-shipment-dates": true, children: delivered ? /* @__PURE__ */ jsx(Time, { value: shipment.delivered_at, text: t("shipment.delivered", { date: delivered }) }) : promised ? /* @__PURE__ */ jsx(Time, { value: shipment.promised_by, text: t("shipment.promised", { date: promised }) }) : /* @__PURE__ */ jsx(Time, { value: shipment.shipped_at, text: t("shipment.shipped", { date: shipped ?? "" }) }) }) : null,
|
|
941
|
+
trackUrl || labelUrl ? /* @__PURE__ */ jsxs("p", { className: cx.actions, "data-sf-shipment-actions": true, children: [
|
|
942
|
+
trackUrl ? /* @__PURE__ */ jsxs("a", { href: trackUrl, target: "_blank", rel: "noopener noreferrer", className: cx.link, "data-sf-shipment-track": true, children: [
|
|
943
|
+
carrier ? t("shipment.track", { carrier }) : m["shipment.trackGeneric"],
|
|
944
|
+
/* @__PURE__ */ jsxs(Hidden, { children: [
|
|
945
|
+
" ",
|
|
946
|
+
m["action.newTab"]
|
|
947
|
+
] })
|
|
948
|
+
] }) : null,
|
|
949
|
+
labelUrl ? /* @__PURE__ */ jsxs("a", { href: labelUrl, target: "_blank", rel: "noopener noreferrer", className: cx.link, "data-sf-shipment-label": true, children: [
|
|
950
|
+
m["shipment.returnLabel"],
|
|
951
|
+
/* @__PURE__ */ jsxs(Hidden, { children: [
|
|
952
|
+
" ",
|
|
953
|
+
m["action.newTab"]
|
|
954
|
+
] })
|
|
955
|
+
] }) : null
|
|
956
|
+
] }) : null,
|
|
957
|
+
renderMap && !test && shipment.map ? /* @__PURE__ */ jsx("div", { className: cx.map, "data-sf-shipment-map-slot": true, children: renderMap({ shipment, map: shipment.map }) }) : null,
|
|
958
|
+
!test ? events.length === 0 ? /* @__PURE__ */ jsx("p", { className: cx.empty, "data-sf-shipment-empty": true, children: m["shipment.noEvents"] }) : /* @__PURE__ */ jsxs("div", { "data-sf-shipment-events-wrap": true, children: [
|
|
959
|
+
/* @__PURE__ */ jsx(SubHeading, { className: cx.meta, "data-sf-shipment-events-title": true, children: m["shipment.events"] }),
|
|
960
|
+
/* @__PURE__ */ jsx("ol", { className: cx.events, id: eventsId, "data-sf-shipment-events": true, children: shown.map((e, i) => {
|
|
961
|
+
const description = str(e.description);
|
|
962
|
+
const location = str(e.location);
|
|
963
|
+
return /* @__PURE__ */ jsxs("li", { className: cx.event, "data-sf-event-status": typeof e.status === "string" ? e.status : "unknown", children: [
|
|
964
|
+
/* @__PURE__ */ jsx("span", { "data-sf-event-state": true, children: enumText(m, "shipment.status", e.status) }),
|
|
965
|
+
description ? /* @__PURE__ */ jsxs("span", { "data-sf-event-description": true, children: [
|
|
966
|
+
" \xB7 ",
|
|
967
|
+
description
|
|
968
|
+
] }) : null,
|
|
969
|
+
location ? /* @__PURE__ */ jsxs("span", { "data-sf-event-location": true, children: [
|
|
970
|
+
" \xB7 ",
|
|
971
|
+
location
|
|
972
|
+
] }) : null,
|
|
973
|
+
" ",
|
|
974
|
+
/* @__PURE__ */ jsx(Time, { value: e.occurred_at, text: date(e.occurred_at, "datetime") })
|
|
975
|
+
] }, `${str(e.id) ?? ""}-${i}`);
|
|
976
|
+
}) }),
|
|
977
|
+
events.length > Math.max(1, eventsPreview) ? /* @__PURE__ */ jsx("button", { type: "button", className: cx.toggle, "aria-expanded": open, "aria-controls": eventsId, onClick: () => setOpen((v) => !v), "data-sf-shipment-toggle": true, children: open ? m["shipment.showLess"] : t("shipment.showAll", { count: events.length }) }) : null
|
|
978
|
+
] }) : null
|
|
979
|
+
] });
|
|
980
|
+
}
|
|
981
|
+
var known = (s) => s === "issued" || s === "pending" || s === "cancelled" || s === "error";
|
|
982
|
+
function InvoiceList({ invoices, summary, renderSummary, fileHref, onDownload, degraded, onRetry, testMode = "mark", headingLevel = 3, children, classNames: cx = {}, ...text }) {
|
|
983
|
+
const { m, date, locale } = useAccountText(text);
|
|
984
|
+
const Heading = `h${headingLevel}`;
|
|
985
|
+
const titleId = `sf-invoices-${useId().replace(/:/g, "")}`;
|
|
986
|
+
const all = (Array.isArray(invoices) ? invoices : []).filter((d) => !!d && typeof d === "object" && typeof d.id === "string");
|
|
987
|
+
const docs = testMode === "hide" ? all.filter((d) => !isTestInvoice(d)) : all;
|
|
988
|
+
const { groups, orphans } = groupInvoiceDocs(docs);
|
|
989
|
+
const renderDoc = (doc, parent) => {
|
|
990
|
+
const test = isTestInvoice(doc);
|
|
991
|
+
const status = known(doc.status) ? doc.status : "unknown";
|
|
992
|
+
const kindLabel = doc.kind === "credit_note" ? m["invoice.creditNote"] : m["invoice.invoice"];
|
|
993
|
+
const docName = (d) => [str(d.series), str(d.folio_number)].filter(Boolean).join("-");
|
|
994
|
+
const name = docName(doc);
|
|
995
|
+
const folio = str(doc.folio);
|
|
996
|
+
const canDownload = status === "issued" && !test;
|
|
997
|
+
const total = moneyText(doc.total, locale);
|
|
998
|
+
const link = (kind) => {
|
|
999
|
+
const label = kind === "pdf" ? m["invoice.pdf"] : m["invoice.xml"];
|
|
1000
|
+
const aria = fill(m["invoice.downloadOf"], { action: label, kind: kindLabel.toLowerCase(), name: name || folio || "" }).replace(/\s+,/g, ",").replace(/,\s*$/, "").trim();
|
|
1001
|
+
const href = fileHref?.(doc, kind);
|
|
1002
|
+
if (href) {
|
|
1003
|
+
return /* @__PURE__ */ jsx("a", { href, download: true, className: cx.download, "aria-label": aria, "data-sf-invoice-download": kind, children: label }, kind);
|
|
1004
|
+
}
|
|
1005
|
+
if (onDownload) {
|
|
1006
|
+
return /* @__PURE__ */ jsx("button", { type: "button", className: cx.download, "aria-label": aria, onClick: () => onDownload(doc, kind), "data-sf-invoice-download": kind, children: label }, kind);
|
|
1007
|
+
}
|
|
1008
|
+
return null;
|
|
1009
|
+
};
|
|
1010
|
+
return /* @__PURE__ */ jsxs("li", { className: cx.doc, "data-sf-invoice-doc": true, "data-sf-invoice-kind": doc.kind === "credit_note" ? "credit_note" : "invoice", "data-sf-invoice-status": status, children: [
|
|
1011
|
+
/* @__PURE__ */ jsxs("p", { className: cx.status, "data-sf-invoice-heading": true, children: [
|
|
1012
|
+
/* @__PURE__ */ jsx("strong", { children: kindLabel }),
|
|
1013
|
+
name ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1014
|
+
" ",
|
|
1015
|
+
name
|
|
1016
|
+
] }) : null,
|
|
1017
|
+
" \xB7 ",
|
|
1018
|
+
/* @__PURE__ */ jsx("span", { "data-sf-invoice-state": true, children: enumText(m, "invoice.status", doc.status) }),
|
|
1019
|
+
test ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1020
|
+
" ",
|
|
1021
|
+
/* @__PURE__ */ jsx("span", { className: cx.test, "data-sf-invoice-test": true, children: m["invoice.test"] })
|
|
1022
|
+
] }) : null
|
|
1023
|
+
] }),
|
|
1024
|
+
parent ? /* @__PURE__ */ jsx("p", { className: cx.meta, "data-sf-invoice-parent": true, children: fill(m["invoice.creditNoteOf"], { folio: docName(parent) || str(parent.folio) || "" }).trim() }) : null,
|
|
1025
|
+
folio && !test ? /* @__PURE__ */ jsxs("p", { className: cx.meta, "data-sf-invoice-folio": true, children: [
|
|
1026
|
+
m["invoice.folio"],
|
|
1027
|
+
": ",
|
|
1028
|
+
/* @__PURE__ */ jsx("code", { children: folio })
|
|
1029
|
+
] }) : null,
|
|
1030
|
+
/* @__PURE__ */ jsxs("p", { className: cx.meta, children: [
|
|
1031
|
+
doc.issued_at ? /* @__PURE__ */ jsx(Time, { value: doc.issued_at, text: fill(m["invoice.issued"], { date: date(doc.issued_at) ?? "" }) }) : null,
|
|
1032
|
+
total ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1033
|
+
" \xB7 ",
|
|
1034
|
+
m["invoice.total"],
|
|
1035
|
+
": ",
|
|
1036
|
+
total
|
|
1037
|
+
] }) : null
|
|
1038
|
+
] }),
|
|
1039
|
+
status === "pending" || status === "error" || status === "cancelled" ? /* @__PURE__ */ jsx("p", { className: cx.note, "data-sf-invoice-note": true, children: m[`invoice.statusNote.${status}`] }) : null,
|
|
1040
|
+
canDownload && (fileHref || onDownload) ? /* @__PURE__ */ jsxs("p", { className: cx.actions, "data-sf-invoice-actions": true, children: [
|
|
1041
|
+
link("pdf"),
|
|
1042
|
+
link("xml")
|
|
1043
|
+
] }) : null
|
|
1044
|
+
] }, doc.id);
|
|
1045
|
+
};
|
|
1046
|
+
const hasDocs = groups.length + orphans.length > 0;
|
|
1047
|
+
return /* @__PURE__ */ jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-invoices": true, children: [
|
|
1048
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.title, children: m["invoice.title"] }),
|
|
1049
|
+
degraded ? /* @__PURE__ */ jsxs("div", { className: cx.error, role: "alert", "data-sf-section-error": "invoices", children: [
|
|
1050
|
+
/* @__PURE__ */ jsx("p", { children: m["section.error"] }),
|
|
1051
|
+
onRetry ? /* @__PURE__ */ jsxs("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: [
|
|
1052
|
+
m["section.retry"],
|
|
1053
|
+
/* @__PURE__ */ jsxs(Hidden, { children: [
|
|
1054
|
+
" ",
|
|
1055
|
+
m["invoice.title"]
|
|
1056
|
+
] })
|
|
1057
|
+
] }) : null
|
|
1058
|
+
] }) : hasDocs ? /* @__PURE__ */ jsxs("ul", { "data-sf-invoice-list": true, children: [
|
|
1059
|
+
groups.map(({ invoice, creditNotes }) => /* @__PURE__ */ jsxs("li", { className: cx.group, "data-sf-invoice-group": true, children: [
|
|
1060
|
+
/* @__PURE__ */ jsx("ul", { children: renderDoc(invoice) }),
|
|
1061
|
+
creditNotes.length ? /* @__PURE__ */ jsx("ul", { className: cx.creditNotes, "data-sf-invoice-credit-notes": true, children: creditNotes.map((nc) => renderDoc(nc, invoice)) }) : null
|
|
1062
|
+
] }, invoice.id)),
|
|
1063
|
+
orphans.map((nc) => /* @__PURE__ */ jsx("li", { className: cx.group, "data-sf-invoice-group": true, children: /* @__PURE__ */ jsx("ul", { children: renderDoc(nc) }) }, nc.id))
|
|
1064
|
+
] }) : summary && renderSummary ? /* @__PURE__ */ jsx("div", { "data-sf-invoice-summary": true, children: renderSummary(summary) }) : /* @__PURE__ */ jsx("p", { className: cx.empty, "data-sf-invoice-empty": true, children: m["invoice.none"] }),
|
|
1065
|
+
children
|
|
1066
|
+
] });
|
|
1067
|
+
}
|
|
1068
|
+
function Barcode({ value, label, height = 56, className }) {
|
|
1069
|
+
const g = useMemo(() => barcodeGeometry(value, { height }), [value, height]);
|
|
1070
|
+
if (!g) return null;
|
|
1071
|
+
return /* @__PURE__ */ jsx("svg", { className, viewBox: `0 0 ${g.width} ${g.height}`, width: g.width, height: g.height, role: "img", "aria-label": label, shapeRendering: "crispEdges", fill: "#000", "data-sf-voucher-barcode-svg": true, children: g.rects.map((r) => /* @__PURE__ */ jsx("rect", { x: r.x, y: 0, width: r.w, height: g.height }, r.x)) });
|
|
1072
|
+
}
|
|
1073
|
+
async function openDocument(payment, mode, opts) {
|
|
1074
|
+
const v = voucherOf(payment);
|
|
1075
|
+
if (!v) return;
|
|
1076
|
+
const { renderVoucherDocument } = await import('./voucher-document-SFWJCLTN.js');
|
|
1077
|
+
const html = renderVoucherDocument(v, { locale: opts.locale, ...opts.shopName ? { shopName: opts.shopName } : {}, ...opts.timeZone ? { timeZone: opts.timeZone } : {}, printButton: mode === "print", autoPrint: mode === "print" });
|
|
1078
|
+
const url = URL.createObjectURL(new Blob([html], { type: "text/html;charset=utf-8" }));
|
|
1079
|
+
const download = () => {
|
|
1080
|
+
const a = document.createElement("a");
|
|
1081
|
+
a.href = url;
|
|
1082
|
+
a.download = "ficha-de-pago.html";
|
|
1083
|
+
a.click();
|
|
1084
|
+
};
|
|
1085
|
+
if (mode === "print") {
|
|
1086
|
+
const w = window.open(url, "_blank");
|
|
1087
|
+
if (w) w.opener = null;
|
|
1088
|
+
else download();
|
|
1089
|
+
} else download();
|
|
1090
|
+
setTimeout(() => URL.revokeObjectURL(url), 6e4);
|
|
1091
|
+
}
|
|
1092
|
+
function PendingPaymentCard({ payment, voucherHref, shopName, headingLevel = 3, classNames: cx = {}, children, ...text }) {
|
|
1093
|
+
const { m, date, locale, timeZone } = useAccountText(text);
|
|
1094
|
+
const titleId = `sf-voucher-${useId().replace(/:/g, "")}`;
|
|
1095
|
+
const v = voucherOf(payment);
|
|
1096
|
+
if (!v) return null;
|
|
1097
|
+
const expired = payment.status === "expired";
|
|
1098
|
+
const Heading = `h${headingLevel}`;
|
|
1099
|
+
const code = barcodeValue(v);
|
|
1100
|
+
const methodLabel = enumText(m, "pending.method", v.method?.toLowerCase());
|
|
1101
|
+
const total = moneyText(payment.total, locale) ?? moneyText(v.amount, locale);
|
|
1102
|
+
const copyValue = v.reference ?? v.clabe;
|
|
1103
|
+
const expires = date(v.expires_at ?? payment.expires_at, "datetime");
|
|
1104
|
+
return /* @__PURE__ */ jsxs("article", { className: cx.root, "aria-labelledby": titleId, "data-sf-voucher": true, "data-sf-voucher-status": expired ? "expired" : "pending_payment", children: [
|
|
1105
|
+
/* @__PURE__ */ jsxs("header", { className: cx.header, children: [
|
|
1106
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.method, "data-sf-voucher-method": true, children: methodLabel }),
|
|
1107
|
+
/* @__PURE__ */ jsx("span", { className: cx.badge, "data-sf-voucher-badge": true, "data-sf-tone": expired ? "muted" : "current", children: expired ? m["pending.expired"] : m["pending.waiting"] })
|
|
1108
|
+
] }),
|
|
1109
|
+
v.reference ? /* @__PURE__ */ jsxs("div", { className: cx.field, "data-sf-voucher-reference": true, children: [
|
|
1110
|
+
/* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.reference"] }),
|
|
1111
|
+
/* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.reference })
|
|
1112
|
+
] }) : null,
|
|
1113
|
+
v.clabe ? /* @__PURE__ */ jsxs("div", { className: cx.field, "data-sf-voucher-clabe": true, children: [
|
|
1114
|
+
/* @__PURE__ */ jsx("p", { className: cx.label, children: m["pending.clabe"] }),
|
|
1115
|
+
/* @__PURE__ */ jsx("p", { className: cx.value, "data-sf-voucher-value": true, children: v.clabe })
|
|
1116
|
+
] }) : null,
|
|
1117
|
+
code && !expired ? /* @__PURE__ */ jsx("div", { className: cx.barcode, "data-sf-voucher-barcode": true, children: /* @__PURE__ */ jsx(Barcode, { value: code, label: fill(m["pending.barcode"], { code }) }) }) : null,
|
|
1118
|
+
expires ? /* @__PURE__ */ jsx("p", { className: cx.expiry, "data-sf-voucher-expiry": true, children: /* @__PURE__ */ jsx(Time, { value: v.expires_at ?? payment.expires_at, text: fill(m[expired ? "pending.expiredOn" : "pending.expires"], { date: expires }) }) }) : null,
|
|
1119
|
+
total ? /* @__PURE__ */ jsxs("p", { className: cx.total, "data-sf-voucher-total": true, children: [
|
|
1120
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1121
|
+
m["pending.total"],
|
|
1122
|
+
": "
|
|
1123
|
+
] }),
|
|
1124
|
+
/* @__PURE__ */ jsx("strong", { children: total })
|
|
1125
|
+
] }) : null,
|
|
1126
|
+
expired ? /* @__PURE__ */ jsx("p", { className: cx.note, "data-sf-voucher-expired-note": true, children: m["pending.expiredNote"] }) : /* @__PURE__ */ jsxs("div", { className: cx.actions, "data-sf-voucher-actions": true, children: [
|
|
1127
|
+
voucherHref ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1128
|
+
/* @__PURE__ */ jsxs("a", { href: voucherHref(payment, { download: false }), target: "_blank", rel: "noopener", className: cx.primary, "data-sf-voucher-print": true, children: [
|
|
1129
|
+
m["pending.print"],
|
|
1130
|
+
/* @__PURE__ */ jsxs(Hidden, { children: [
|
|
1131
|
+
" ",
|
|
1132
|
+
m["action.newTab"]
|
|
1133
|
+
] })
|
|
1134
|
+
] }),
|
|
1135
|
+
/* @__PURE__ */ jsx("a", { href: voucherHref(payment, { download: true }), download: true, className: cx.secondary, "data-sf-voucher-download": true, children: m["pending.download"] })
|
|
1136
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1137
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: cx.primary, onClick: () => void openDocument(payment, "print", { locale, shopName, timeZone }), "data-sf-voucher-print": true, children: m["pending.print"] }),
|
|
1138
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: cx.secondary, onClick: () => void openDocument(payment, "download", { locale, shopName, timeZone }), "data-sf-voucher-download": true, children: m["pending.download"] })
|
|
1139
|
+
] }),
|
|
1140
|
+
copyValue ? /* @__PURE__ */ jsx(CopyButton, { value: copyValue, label: v.reference ? m["pending.copyReference"] : m["pending.copyClabe"], copiedLabel: m["pending.copied"], failedLabel: m["pending.copyFailed"], className: cx.secondary, "data-sf-copy": "voucher" }) : null
|
|
1141
|
+
] }),
|
|
1142
|
+
children
|
|
1143
|
+
] });
|
|
1144
|
+
}
|
|
1145
|
+
function PendingPaymentList({ payments, voucherHref, shopName, classNames, listClassNames: lc = {}, headingLevel = 2, ...text }) {
|
|
1146
|
+
const { m } = useAccountText(text);
|
|
1147
|
+
const titleId = `sf-pending-${useId().replace(/:/g, "")}`;
|
|
1148
|
+
const items = (Array.isArray(payments) ? payments : []).filter((p) => !!voucherOf(p));
|
|
1149
|
+
if (items.length === 0) return null;
|
|
1150
|
+
const sorted = [...items.filter((p) => p.status !== "expired"), ...items.filter((p) => p.status === "expired")];
|
|
1151
|
+
const Heading = `h${headingLevel}`;
|
|
1152
|
+
const cardHeading = headingLevel + 1;
|
|
1153
|
+
return /* @__PURE__ */ jsxs("section", { className: lc.root, "aria-labelledby": titleId, "data-sf-pending": true, children: [
|
|
1154
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: lc.title, children: m["pending.title"] }),
|
|
1155
|
+
/* @__PURE__ */ jsx("p", { className: lc.intro, children: m["pending.intro"] }),
|
|
1156
|
+
/* @__PURE__ */ jsx("ul", { className: lc.list, children: sorted.map((p) => /* @__PURE__ */ jsx("li", { className: lc.item, children: /* @__PURE__ */ jsx(PendingPaymentCard, { payment: p, ...voucherHref ? { voucherHref } : {}, ...shopName ? { shopName } : {}, ...classNames ? { classNames } : {}, headingLevel: cardHeading, ...text }) }, p.id)) })
|
|
1157
|
+
] });
|
|
1158
|
+
}
|
|
1159
|
+
var tone = (s) => s === "completed" ? "done" : s === "failed" ? "problem" : "current";
|
|
1160
|
+
function RefundList({ refunds, showEmpty = false, degraded, onRetry, headingLevel = 3, classNames: cx = {}, ...text }) {
|
|
1161
|
+
const { m, locale, date } = useAccountText(text);
|
|
1162
|
+
const titleId = `sf-refunds-${useId().replace(/:/g, "")}`;
|
|
1163
|
+
const items = (Array.isArray(refunds) ? refunds : []).filter((r) => !!r && typeof r === "object" && typeof r.id === "string");
|
|
1164
|
+
if (!degraded && items.length === 0 && !showEmpty) return null;
|
|
1165
|
+
const Heading = `h${headingLevel}`;
|
|
1166
|
+
return /* @__PURE__ */ jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-refunds": true, children: [
|
|
1167
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.title, children: m["refund.title"] }),
|
|
1168
|
+
degraded ? /* @__PURE__ */ jsxs("div", { className: cx.error, role: "alert", "data-sf-section-error": "refunds", children: [
|
|
1169
|
+
/* @__PURE__ */ jsx("p", { children: m["section.error"] }),
|
|
1170
|
+
onRetry ? /* @__PURE__ */ jsxs("button", { type: "button", className: cx.retry, onClick: onRetry, "data-sf-retry": true, children: [
|
|
1171
|
+
m["section.retry"],
|
|
1172
|
+
/* @__PURE__ */ jsxs(Hidden, { children: [
|
|
1173
|
+
" ",
|
|
1174
|
+
m["refund.title"]
|
|
1175
|
+
] })
|
|
1176
|
+
] }) : null
|
|
1177
|
+
] }) : items.length === 0 ? /* @__PURE__ */ jsx("p", { className: cx.empty, children: m["refund.none"] }) : /* @__PURE__ */ jsx("ul", { className: cx.list, children: items.map((r) => /* @__PURE__ */ jsxs("li", { className: cx.item, "data-sf-refund": true, "data-sf-refund-status": typeof r.status === "string" ? r.status : "unknown", children: [
|
|
1178
|
+
/* @__PURE__ */ jsx("span", { className: cx.amount, "data-sf-refund-amount": true, children: moneyText(r.amount, locale) ?? "" }),
|
|
1179
|
+
" ",
|
|
1180
|
+
/* @__PURE__ */ jsx("span", { className: cx.status, "data-sf-tone": tone(r.status), children: enumText(m, "refund.status", r.status) }),
|
|
1181
|
+
/* @__PURE__ */ jsxs("span", { className: cx.meta, children: [
|
|
1182
|
+
str(r.method_label) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1183
|
+
" \xB7 ",
|
|
1184
|
+
str(r.method_label)
|
|
1185
|
+
] }) : null,
|
|
1186
|
+
r.completed_at ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1187
|
+
" \xB7 ",
|
|
1188
|
+
/* @__PURE__ */ jsx(Time, { value: r.completed_at, text: fill(m["refund.completed"], { date: date(r.completed_at) ?? "" }) })
|
|
1189
|
+
] }) : r.created_at ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1190
|
+
" \xB7 ",
|
|
1191
|
+
/* @__PURE__ */ jsx(Time, { value: r.created_at, text: fill(m["refund.requested"], { date: date(r.created_at) ?? "" }) })
|
|
1192
|
+
] }) : null
|
|
1193
|
+
] })
|
|
1194
|
+
] }, r.id)) })
|
|
1195
|
+
] });
|
|
1196
|
+
}
|
|
1197
|
+
function PaymentSummary({ payments, headingLevel = 3, classNames: cx = {}, ...text }) {
|
|
1198
|
+
const { m, locale, date } = useAccountText(text);
|
|
1199
|
+
const titleId = `sf-payments-${useId().replace(/:/g, "")}`;
|
|
1200
|
+
const items = (Array.isArray(payments) ? payments : []).filter((p) => !!p && typeof p === "object" && typeof p.method_label === "string");
|
|
1201
|
+
if (items.length === 0) return null;
|
|
1202
|
+
const Heading = `h${headingLevel}`;
|
|
1203
|
+
return /* @__PURE__ */ jsxs("section", { className: cx.root, "aria-labelledby": titleId, "data-sf-payments": true, children: [
|
|
1204
|
+
/* @__PURE__ */ jsx(Heading, { id: titleId, className: cx.title, children: m["payment.title"] }),
|
|
1205
|
+
/* @__PURE__ */ jsx("ul", { className: cx.list, children: items.map((p, i) => /* @__PURE__ */ jsxs("li", { className: cx.item, "data-sf-payment": true, "data-sf-payment-status": typeof p.status === "string" ? p.status : "unknown", children: [
|
|
1206
|
+
/* @__PURE__ */ jsx("span", { children: p.method_label }),
|
|
1207
|
+
moneyText(p.amount, locale) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1208
|
+
" \xB7 ",
|
|
1209
|
+
/* @__PURE__ */ jsx("span", { children: moneyText(p.amount, locale) })
|
|
1210
|
+
] }) : null,
|
|
1211
|
+
" \xB7",
|
|
1212
|
+
" ",
|
|
1213
|
+
/* @__PURE__ */ jsx("span", { className: cx.status, "data-sf-tone": p.status === "failed" ? "problem" : p.status === "paid" ? "done" : "current", children: enumText(m, "payment.status", p.status) }),
|
|
1214
|
+
p.paid_at ? /* @__PURE__ */ jsxs("span", { className: cx.meta, children: [
|
|
1215
|
+
" \xB7 ",
|
|
1216
|
+
/* @__PURE__ */ jsx(Time, { value: p.paid_at, text: fill(m["payment.paidOn"], { date: date(p.paid_at) ?? "" }) })
|
|
1217
|
+
] }) : null
|
|
1218
|
+
] }, `${p.method_label}-${i}`)) })
|
|
1219
|
+
] });
|
|
1220
|
+
}
|
|
1221
|
+
function useClient(client) {
|
|
1222
|
+
const ctx = useOptionalStorefront();
|
|
1223
|
+
return client ?? ctx?.client ?? null;
|
|
1224
|
+
}
|
|
1225
|
+
var asError = (e) => e instanceof Error ? e : new Error("Request failed");
|
|
1226
|
+
var ids = /* @__PURE__ */ new WeakMap();
|
|
1227
|
+
var seq = 0;
|
|
1228
|
+
function clientKey(c) {
|
|
1229
|
+
if (!c) return "none";
|
|
1230
|
+
let k = ids.get(c);
|
|
1231
|
+
if (!k) ids.set(c, k = `c${++seq}`);
|
|
1232
|
+
return k;
|
|
1233
|
+
}
|
|
1234
|
+
function useConnection(fetchPage, client, initial, key) {
|
|
1235
|
+
const owner = `${clientKey(client)}|${key}`;
|
|
1236
|
+
const empty = (status) => ({ status, nodes: [], error: null, cursor: null, hasMore: false, total: null, owner });
|
|
1237
|
+
const [state, setState] = useState(
|
|
1238
|
+
() => initial ? { status: "ready", nodes: initial.nodes ?? [], error: null, cursor: initial.page_info?.end_cursor ?? null, hasMore: !!initial.page_info?.has_next_page, total: initial.total_count ?? null, owner } : empty("loading")
|
|
1239
|
+
);
|
|
1240
|
+
const [loadingMore, setLoadingMore] = useState(false);
|
|
1241
|
+
const alive = useRef(null);
|
|
1242
|
+
const more = useRef(null);
|
|
1243
|
+
const fetchRef = useRef(fetchPage);
|
|
1244
|
+
fetchRef.current = fetchPage;
|
|
1245
|
+
const first = useCallback(() => {
|
|
1246
|
+
alive.current?.abort();
|
|
1247
|
+
more.current?.abort();
|
|
1248
|
+
setLoadingMore(false);
|
|
1249
|
+
if (!client) {
|
|
1250
|
+
setState(empty("loading"));
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
const ctl = new AbortController();
|
|
1254
|
+
alive.current = ctl;
|
|
1255
|
+
setState((s) => s.owner === owner && s.nodes.length ? { ...s, error: null } : empty("loading"));
|
|
1256
|
+
fetchRef.current(client, null, ctl.signal).then(
|
|
1257
|
+
(page) => !ctl.signal.aborted && setState({ status: "ready", nodes: page.nodes ?? [], error: null, cursor: page.page_info?.end_cursor ?? null, hasMore: !!page.page_info?.has_next_page, total: page.total_count ?? null, owner }),
|
|
1258
|
+
(e) => !ctl.signal.aborted && setState((s) => s.owner === owner ? { ...s, status: "error", error: asError(e) } : { ...empty("error"), error: asError(e) })
|
|
1259
|
+
);
|
|
1260
|
+
}, [client, owner]);
|
|
1261
|
+
useEffect(() => {
|
|
1262
|
+
if (!(initial && state.owner === owner)) first();
|
|
1263
|
+
return () => {
|
|
1264
|
+
alive.current?.abort();
|
|
1265
|
+
more.current?.abort();
|
|
1266
|
+
};
|
|
1267
|
+
}, [first, owner]);
|
|
1268
|
+
const loadMore = useCallback(() => {
|
|
1269
|
+
if (!client || state.owner !== owner || !state.hasMore || loadingMore) return;
|
|
1270
|
+
const ctl = new AbortController();
|
|
1271
|
+
more.current = ctl;
|
|
1272
|
+
setLoadingMore(true);
|
|
1273
|
+
fetchRef.current(client, state.cursor, ctl.signal).then(
|
|
1274
|
+
(page) => {
|
|
1275
|
+
if (ctl.signal.aborted) return;
|
|
1276
|
+
setLoadingMore(false);
|
|
1277
|
+
setState((s) => s.owner !== owner ? s : { ...s, nodes: [...s.nodes, ...page.nodes ?? []], cursor: page.page_info?.end_cursor ?? null, hasMore: !!page.page_info?.has_next_page, total: page.total_count ?? s.total, error: null });
|
|
1278
|
+
},
|
|
1279
|
+
(e) => {
|
|
1280
|
+
if (ctl.signal.aborted) return;
|
|
1281
|
+
setLoadingMore(false);
|
|
1282
|
+
setState((s) => s.owner !== owner ? s : { ...s, error: asError(e) });
|
|
1283
|
+
}
|
|
1284
|
+
);
|
|
1285
|
+
}, [client, owner, state.owner, state.hasMore, state.cursor, loadingMore]);
|
|
1286
|
+
const view = state.owner === owner ? state : empty("loading");
|
|
1287
|
+
return { status: view.status, nodes: view.nodes, error: view.error, hasMore: view.hasMore, loadingMore: state.owner === owner && loadingMore, totalCount: view.total, reload: first, loadMore };
|
|
1288
|
+
}
|
|
1289
|
+
function useCustomerOrders({ client, first = 20, initial } = {}) {
|
|
1290
|
+
return useConnection((c, after, signal) => c.customer.orders({ first, ...after ? { after } : {} }, { signal }), useClient(client), initial, `orders:${first}`);
|
|
1291
|
+
}
|
|
1292
|
+
function usePendingPayments({ client, first = 20, initial } = {}) {
|
|
1293
|
+
return useConnection((c, after, signal) => c.customer.pendingPayments({ first, ...after ? { after } : {} }, { signal }), useClient(client), initial, `pending:${first}`);
|
|
1294
|
+
}
|
|
1295
|
+
function useCustomerOrder(id, { client, initial, poll } = {}) {
|
|
1296
|
+
const c = useClient(client);
|
|
1297
|
+
const given = initial !== void 0;
|
|
1298
|
+
const owner = `${clientKey(c)}|${id ?? ""}`;
|
|
1299
|
+
const [state, setState] = useState(() => given ? { status: initial ? "ready" : "not_found", order: initial, error: null, owner } : { status: "loading", order: null, error: null, owner });
|
|
1300
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
1301
|
+
const ctlRef = useRef(null);
|
|
1302
|
+
const initialOwner = useRef(given ? owner : null);
|
|
1303
|
+
const load = useCallback(
|
|
1304
|
+
(silent) => {
|
|
1305
|
+
ctlRef.current?.abort();
|
|
1306
|
+
setRefreshing(false);
|
|
1307
|
+
if (!c || !id) {
|
|
1308
|
+
setState({ status: "loading", order: null, error: null, owner });
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
const ctl = new AbortController();
|
|
1312
|
+
ctlRef.current = ctl;
|
|
1313
|
+
if (silent) setRefreshing(true);
|
|
1314
|
+
else setState((s) => s.owner === owner && s.order ? { ...s, error: null } : { status: "loading", order: null, error: null, owner });
|
|
1315
|
+
c.customer.order(id, { signal: ctl.signal }).then(
|
|
1316
|
+
(o) => {
|
|
1317
|
+
if (ctl.signal.aborted) return;
|
|
1318
|
+
setRefreshing(false);
|
|
1319
|
+
setState(o ? { status: "ready", order: o, error: null, owner } : { status: "not_found", order: null, error: null, owner });
|
|
1320
|
+
},
|
|
1321
|
+
(e) => {
|
|
1322
|
+
if (ctl.signal.aborted) return;
|
|
1323
|
+
setRefreshing(false);
|
|
1324
|
+
setState((s) => s.owner === owner && s.order ? { ...s, error: asError(e) } : { status: "error", order: null, error: asError(e), owner });
|
|
1325
|
+
}
|
|
1326
|
+
);
|
|
1327
|
+
},
|
|
1328
|
+
[c, id, owner]
|
|
1329
|
+
);
|
|
1330
|
+
useEffect(() => {
|
|
1331
|
+
if (initialOwner.current !== owner) load(false);
|
|
1332
|
+
initialOwner.current = null;
|
|
1333
|
+
return () => ctlRef.current?.abort();
|
|
1334
|
+
}, [load, owner]);
|
|
1335
|
+
const mine = state.owner === owner;
|
|
1336
|
+
const order = mine ? state.order : null;
|
|
1337
|
+
const keepPolling = !!poll && !!order && poll.while(order);
|
|
1338
|
+
const everyMs = poll?.everyMs ?? 1e4;
|
|
1339
|
+
const forMs = poll?.forMs ?? 6e4;
|
|
1340
|
+
useEffect(() => {
|
|
1341
|
+
if (!keepPolling) return;
|
|
1342
|
+
const t0 = Date.now();
|
|
1343
|
+
const timer = setInterval(() => {
|
|
1344
|
+
if (Date.now() - t0 >= forMs) clearInterval(timer);
|
|
1345
|
+
else load(true);
|
|
1346
|
+
}, everyMs);
|
|
1347
|
+
return () => clearInterval(timer);
|
|
1348
|
+
}, [keepPolling, everyMs, forMs, load]);
|
|
1349
|
+
const hasOrder = order !== null;
|
|
1350
|
+
const reload = useCallback(() => load(hasOrder), [load, hasOrder]);
|
|
1351
|
+
return { status: mine ? state.status : "loading", order, error: mine ? state.error : null, refreshing: mine && refreshing, reload };
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
export { AccountAuth, Barcode, InvoiceList, NextActionBar, OrderCard, OrderList, OrderProgress, OrderStatusBadge, PaymentSummary, PendingPaymentCard, PendingPaymentList, PostPurchaseAccountPrompt, RefundList, ShipmentCard, accountAuthMessages, accountMessages, enumText, postPurchaseAccountPromptMessages, stageTone, useCustomerOrder, useCustomerOrders, usePendingPayments };
|
|
324
1355
|
//# sourceMappingURL=account.js.map
|
|
325
1356
|
//# sourceMappingURL=account.js.map
|