@fayz-ai/plugin-shop 0.18.2 → 0.19.1

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 (52) hide show
  1. package/dist/{ShopPage-J34V43NW.js → ShopPage-2CTRGQTX.js} +176 -247
  2. package/dist/ShopPage-2CTRGQTX.js.map +1 -0
  3. package/dist/{chunk-6DRDPROL.js → chunk-XV3KZRQX.js} +136 -31
  4. package/dist/chunk-XV3KZRQX.js.map +1 -0
  5. package/dist/data/registries.d.ts +2 -0
  6. package/dist/data/registries.d.ts.map +1 -1
  7. package/dist/index.d.ts +23 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +757 -511
  10. package/dist/index.js.map +1 -1
  11. package/dist/integrations/abacatepay/connectorDef.d.ts.map +1 -1
  12. package/dist/settings/ChoiceCards.d.ts.map +1 -1
  13. package/dist/settings/HandlingSettings.d.ts.map +1 -1
  14. package/dist/settings/MarketsSettings.d.ts +12 -0
  15. package/dist/settings/MarketsSettings.d.ts.map +1 -0
  16. package/dist/settings/PaymentProviderRow.d.ts.map +1 -1
  17. package/dist/settings/ShippingSettings.d.ts.map +1 -1
  18. package/dist/views/DeliveryAreaPicker.d.ts.map +1 -1
  19. package/dist/views/DeliveryRulesDraft.d.ts.map +1 -1
  20. package/dist/views/EmailTemplatePage.d.ts.map +1 -1
  21. package/dist/views/EmailsPage.d.ts.map +1 -1
  22. package/dist/views/FulfillmentProviderSelect.d.ts.map +1 -1
  23. package/dist/views/NewOrderCharge.d.ts.map +1 -1
  24. package/dist/views/NewOrderPage.d.ts.map +1 -1
  25. package/dist/views/OrderDetailView.d.ts.map +1 -1
  26. package/dist/views/OrderPaymentDetail.d.ts.map +1 -1
  27. package/dist/views/ProductMarketPricesTab.d.ts +19 -0
  28. package/dist/views/ProductMarketPricesTab.d.ts.map +1 -0
  29. package/dist/views/ProductPositionsTab.d.ts.map +1 -1
  30. package/dist/views/ProductStockTab.d.ts.map +1 -1
  31. package/dist/views/ProductVariantsTab.d.ts.map +1 -1
  32. package/dist/views/ShipOrderForm.d.ts.map +1 -1
  33. package/dist/views/ShipmentActions.d.ts.map +1 -1
  34. package/dist/views/ShippingProfileSelect.d.ts.map +1 -1
  35. package/dist/views/ShopPage.d.ts.map +1 -1
  36. package/dist/views/StockEntryModal.d.ts.map +1 -1
  37. package/dist/views/customerEntity.d.ts.map +1 -1
  38. package/dist/views/customerSegmentEntity.d.ts.map +1 -1
  39. package/dist/views/discountEntity.d.ts.map +1 -1
  40. package/dist/views/giftCardEntity.d.ts.map +1 -1
  41. package/dist/views/product-matching.d.ts.map +1 -1
  42. package/dist/views/productEntity.d.ts.map +1 -1
  43. package/dist/views/shippingZoneEntity.d.ts.map +1 -1
  44. package/package.json +7 -7
  45. package/dist/ShopPage-J34V43NW.js.map +0 -1
  46. package/dist/chunk-6DRDPROL.js.map +0 -1
  47. package/dist/integrations/bling/index.d.ts +0 -9
  48. package/dist/integrations/bling/index.d.ts.map +0 -1
  49. package/dist/integrations/neochef/index.d.ts +0 -8
  50. package/dist/integrations/neochef/index.d.ts.map +0 -1
  51. package/dist/settings/index.d.ts +0 -12
  52. package/dist/settings/index.d.ts.map +0 -1
@@ -1,12 +1,12 @@
1
- import { errorMessage, shopCustomerLookup, listProductsDetailed, invalidateProductLists, buildStockLocationsRegistry, listProductsCached, resolveTerm, candidateMeta } from './chunk-6DRDPROL.js';
1
+ import { errorMessage, shopCustomerLookup, listProductsDetailed, invalidateProductLists, buildStockLocationsRegistry, listProductsCached, resolveTerm, candidateMeta } from './chunk-XV3KZRQX.js';
2
2
  import * as React2 from 'react';
3
3
  import React2__default, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
4
- import { Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalFooter, Button, formatPhone, toast, DataTable, ConfirmDialog, Skeleton, ModalPortal, ModalOverlay, ModalBody, SearchSelect } from '@fayz-ai/ui';
5
- import { RotateCcw, QrCode, Pencil, Archive, Ban, CreditCard, XCircle, ShoppingBag, Package, Wallet, Plus, WandSparkles, CheckCircle2, Printer, RefreshCw, ExternalLink, Truck, AlertTriangle, Loader2, Check, Copy, Link2, HandCoins, Share2, MessageCircle, X, MapPin } from 'lucide-react';
4
+ import { Button, Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, Input, ModalFooter, formatPhone, toast, Textarea, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, DataTable, ConfirmDialog, Skeleton, ModalPortal, ModalOverlay, ModalBody, SearchSelect } from '@fayz-ai/ui';
5
+ import { RotateCcw, QrCode, Pencil, Archive, Ban, CreditCard, XCircle, ShoppingBag, Package, Wallet, Plus, WandSparkles, CheckCircle2, Printer, RefreshCw, ExternalLink, Truck, AlertTriangle, Loader2, Check, Copy, Link2, HandCoins, Share2, MessageCircle, MapPin, X } from 'lucide-react';
6
6
  import { formatDocument, getShopProvider, CHARGEABLE_PROVIDERS, supportsPaymentLink, resolveShippingLabelProvider, documentDigits, isValidDocument } from '@fayz-ai/shop';
7
- import { useAdminPath, adminNavigateTo, useOrderReceivable, OrderDetailSkeleton, PageActions, OrderDetailBlock, OrderDetailRow, toOrderDetailReceivable, PersonLink, OrderDetailView as OrderDetailView$1, OrderFormBlock, OrderCreateScreen, OrderListView, askAI, useConnectors, CrudRecordModal, useAgentSurface, ClientOrdersTab, createClientOrdersProvider, duplicateWrite } from '@fayz-ai/admin';
8
- import { ReceivePaymentModal } from '@fayz-ai/plugin-financial';
9
- import { usePluginRuntimeOptional, getSupabaseClientOptional } from '@fayz-ai/core';
7
+ import { useAdminPath, adminNavigateTo, useOrderReceivable, OrderDetailSkeleton, PageActions, OrderDetailBlock, OrderDetailRow, toOrderDetailReceivable, PersonLink, OrderDetailView as OrderDetailView$1, WidgetSlot, OrderFormBlock, OrderCreateScreen, OrderListView, askAI, useConnectors, CrudRecordModal, AddressFormModal, useAgentSurface, ClientOrdersTab, createClientOrdersProvider, duplicateWrite } from '@fayz-ai/admin';
8
+ import { FINANCIAL_ZONES } from '@fayz-ai/financial/views/zones';
9
+ import { usePluginRuntimeOptional, getWidgetsForZone, getSupabaseClientOptional, formatCurrency } from '@fayz-ai/core';
10
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import { listStockReasonCodes } from '@fayz-ai/shop/inventory';
12
12
 
@@ -63,8 +63,10 @@ function ShipOrderForm({ orderId, provider, onShipped }) {
63
63
  }
64
64
  if (!open) {
65
65
  return /* @__PURE__ */ jsxs(
66
- "button",
66
+ Button,
67
67
  {
68
+ variant: "bare",
69
+ size: "bare",
68
70
  type: "button",
69
71
  onClick: () => setOpen(true),
70
72
  "data-testid": "order-ship",
@@ -81,26 +83,26 @@ function ShipOrderForm({ orderId, provider, onShipped }) {
81
83
  /* @__PURE__ */ jsxs("label", { className: "block", children: [
82
84
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "Transportadora" }),
83
85
  /* @__PURE__ */ jsx(
84
- "input",
86
+ Input,
85
87
  {
86
88
  value: carrier,
87
89
  onChange: (event) => setCarrier(event.target.value),
88
90
  placeholder: "Correios, motoboy, entrega pr\xF3pria\u2026",
89
91
  "data-testid": "order-ship-carrier",
90
- className: "mt-1 w-full rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none focus:border-primary"
92
+ className: "mt-1 px-2.5"
91
93
  }
92
94
  )
93
95
  ] }),
94
96
  /* @__PURE__ */ jsxs("label", { className: "block", children: [
95
97
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "C\xF3digo de rastreio" }),
96
98
  /* @__PURE__ */ jsx(
97
- "input",
99
+ Input,
98
100
  {
99
101
  value: tracking,
100
102
  onChange: (event) => setTracking(event.target.value),
101
103
  placeholder: "Opcional",
102
104
  "data-testid": "order-ship-tracking",
103
- className: "mt-1 w-full rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none focus:border-primary"
105
+ className: "mt-1 px-2.5"
104
106
  }
105
107
  )
106
108
  ] })
@@ -110,8 +112,10 @@ function ShipOrderForm({ orderId, provider, onShipped }) {
110
112
  error && /* @__PURE__ */ jsx("p", { className: "rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-xs text-red-800", children: error }),
111
113
  /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
112
114
  /* @__PURE__ */ jsx(
113
- "button",
115
+ Button,
114
116
  {
117
+ variant: "bare",
118
+ size: "bare",
115
119
  type: "button",
116
120
  onClick: ship,
117
121
  disabled: saving,
@@ -121,8 +125,10 @@ function ShipOrderForm({ orderId, provider, onShipped }) {
121
125
  }
122
126
  ),
123
127
  /* @__PURE__ */ jsx(
124
- "button",
128
+ Button,
125
129
  {
130
+ variant: "bare",
131
+ size: "bare",
126
132
  type: "button",
127
133
  onClick: () => {
128
134
  setOpen(false);
@@ -220,7 +226,7 @@ function isSenderRefusal(message) {
220
226
  const text2 = String(message ?? "");
221
227
  return /\bfrom\./iu.test(text2) || /remetente/iu.test(text2);
222
228
  }
223
- var money = (value) => new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value) || 0);
229
+ var money = (value) => formatCurrency(Number(value) || 0, "BRL");
224
230
  var eta = (option) => {
225
231
  const min = option.etaMinDays ?? null;
226
232
  const max = option.etaMaxDays ?? null;
@@ -385,8 +391,10 @@ function ShipWithCarrier({ orderId, provider, preferredCarrier, onShipped }) {
385
391
  }
386
392
  if (!open) {
387
393
  return /* @__PURE__ */ jsxs(
388
- "button",
394
+ Button,
389
395
  {
396
+ variant: "bare",
397
+ size: "bare",
390
398
  type: "button",
391
399
  onClick: () => setOpen(true),
392
400
  "data-testid": "carrier-open",
@@ -539,12 +547,14 @@ function CarrierError({ error, onFix }) {
539
547
  children: [
540
548
  /* @__PURE__ */ jsx("p", { children: error }),
541
549
  isSenderRefusal(error) && /* @__PURE__ */ jsx(
542
- "button",
550
+ Button,
543
551
  {
552
+ variant: "bare",
553
+ size: "bare",
544
554
  type: "button",
545
555
  onClick: onFix,
546
556
  "data-testid": "carrier-fix-sender",
547
- className: "mt-1 font-medium underline underline-offset-2",
557
+ className: "mt-1 whitespace-normal text-xs font-medium underline underline-offset-2",
548
558
  children: "Completar o cadastro do remetente"
549
559
  }
550
560
  )
@@ -625,40 +635,42 @@ function ShipmentActions({ fulfillmentId, status, hasTracking, provider, onChang
625
635
  if (mode === "tracking") {
626
636
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 space-y-1.5", children: [
627
637
  /* @__PURE__ */ jsx(
628
- "input",
638
+ Input,
629
639
  {
630
640
  value: carrier,
631
641
  onChange: (event) => setCarrier(event.target.value),
632
642
  placeholder: "Transportadora (Correios, motoboy\u2026)",
633
643
  "data-testid": "shipment-carrier-input",
634
- className: "w-full rounded-md border bg-background px-2 py-1 text-xs outline-none focus:border-primary"
644
+ className: "h-auto rounded-md border-border bg-background px-2 py-1 text-xs shadow-none focus:border-primary focus-visible:ring-0 focus-visible:ring-offset-0"
635
645
  }
636
646
  ),
637
647
  /* @__PURE__ */ jsx(
638
- "input",
648
+ Input,
639
649
  {
640
650
  value: tracking,
641
651
  onChange: (event) => setTracking(event.target.value),
642
652
  placeholder: "C\xF3digo de rastreio",
643
653
  "data-testid": "shipment-tracking-input",
644
- className: "w-full rounded-md border bg-background px-2 py-1 text-xs outline-none focus:border-primary"
654
+ className: "h-auto rounded-md border-border bg-background px-2 py-1 text-xs shadow-none focus:border-primary focus-visible:ring-0 focus-visible:ring-offset-0"
645
655
  }
646
656
  ),
647
657
  /* @__PURE__ */ jsx(
648
- "input",
658
+ Input,
649
659
  {
650
660
  value: trackingUrl,
651
661
  onChange: (event) => setTrackingUrl(event.target.value),
652
662
  placeholder: "Link de rastreio (opcional)",
653
663
  "data-testid": "shipment-tracking-url-input",
654
- className: "w-full rounded-md border bg-background px-2 py-1 text-xs outline-none focus:border-primary"
664
+ className: "h-auto rounded-md border-border bg-background px-2 py-1 text-xs shadow-none focus:border-primary focus-visible:ring-0 focus-visible:ring-offset-0"
655
665
  }
656
666
  ),
657
667
  error && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-red-700", children: error }),
658
668
  /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
659
669
  /* @__PURE__ */ jsx(
660
- "button",
670
+ Button,
661
671
  {
672
+ variant: "bare",
673
+ size: "bare",
662
674
  type: "button",
663
675
  onClick: saveTracking,
664
676
  disabled: busy,
@@ -667,7 +679,7 @@ function ShipmentActions({ fulfillmentId, status, hasTracking, provider, onChang
667
679
  children: busy ? "Salvando\u2026" : "Salvar"
668
680
  }
669
681
  ),
670
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => {
682
+ /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: () => {
671
683
  setMode("idle");
672
684
  setError(null);
673
685
  }, className: `border ${link}`, children: "Voltar" })
@@ -680,8 +692,10 @@ function ShipmentActions({ fulfillmentId, status, hasTracking, provider, onChang
680
692
  error && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-red-700", children: error }),
681
693
  /* @__PURE__ */ jsxs("div", { className: "flex gap-1.5", children: [
682
694
  /* @__PURE__ */ jsx(
683
- "button",
695
+ Button,
684
696
  {
697
+ variant: "bare",
698
+ size: "bare",
685
699
  type: "button",
686
700
  onClick: cancelShipment,
687
701
  disabled: busy,
@@ -690,7 +704,7 @@ function ShipmentActions({ fulfillmentId, status, hasTracking, provider, onChang
690
704
  children: busy ? "Cancelando\u2026" : "Cancelar envio"
691
705
  }
692
706
  ),
693
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => {
707
+ /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: () => {
694
708
  setMode("idle");
695
709
  setError(null);
696
710
  }, className: `border bg-background ${link}`, children: "Voltar" })
@@ -698,9 +712,9 @@ function ShipmentActions({ fulfillmentId, status, hasTracking, provider, onChang
698
712
  ] });
699
713
  }
700
714
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex flex-wrap items-center gap-1.5", children: [
701
- !hasTracking && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setMode("tracking"), "data-testid": "shipment-add-tracking", className: `border ${link}`, children: "Informar rastreio" }),
702
- status !== "delivered" && /* @__PURE__ */ jsx("button", { type: "button", onClick: markDelivered, disabled: busy, "data-testid": "shipment-deliver", className: `border ${link}`, children: busy ? "Salvando\u2026" : "Marcar como entregue" }),
703
- status !== "delivered" && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setMode("cancel"), "data-testid": "shipment-cancel", className: `border border-red-200 text-red-700 hover:bg-red-50 ${link}`, children: "Cancelar envio" }),
715
+ !hasTracking && /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: () => setMode("tracking"), "data-testid": "shipment-add-tracking", className: `border ${link}`, children: "Informar rastreio" }),
716
+ status !== "delivered" && /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: markDelivered, disabled: busy, "data-testid": "shipment-deliver", className: `border ${link}`, children: busy ? "Salvando\u2026" : "Marcar como entregue" }),
717
+ status !== "delivered" && /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: () => setMode("cancel"), "data-testid": "shipment-cancel", className: `border border-red-200 text-red-700 hover:bg-red-50 ${link}`, children: "Cancelar envio" }),
704
718
  error && /* @__PURE__ */ jsx("p", { className: "w-full text-[11px] text-red-700", children: error })
705
719
  ] });
706
720
  }
@@ -808,13 +822,15 @@ function OrderPaymentDetail({ orderId }) {
808
822
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
809
823
  /* @__PURE__ */ jsx("code", { className: "max-w-[16rem] truncate font-mono text-xs", title: link.external_id, children: link.external_id }),
810
824
  /* @__PURE__ */ jsx(
811
- "button",
825
+ Button,
812
826
  {
827
+ variant: "bare",
828
+ size: "bare",
813
829
  type: "button",
814
830
  onClick: copy,
815
831
  "aria-label": "Copiar o c\xF3digo da cobran\xE7a",
816
832
  "data-testid": "order-payment-copy",
817
- className: "rounded p-1 text-muted-foreground transition hover:bg-muted hover:text-foreground",
833
+ className: "font-normal rounded p-1 text-muted-foreground transition hover:bg-muted hover:text-foreground",
818
834
  children: copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" })
819
835
  }
820
836
  ),
@@ -846,12 +862,14 @@ async function cancelShopOrder(provider, orderId, reason) {
846
862
  var POLL_MS = 4e3;
847
863
  function ChargeChoice({ icon: Icon, title, hint, onClick, testId }) {
848
864
  return /* @__PURE__ */ jsxs(
849
- "button",
865
+ Button,
850
866
  {
867
+ variant: "bare",
868
+ size: "bare",
851
869
  type: "button",
852
870
  onClick,
853
871
  "data-testid": testId,
854
- className: "flex w-full items-start gap-3 rounded-md border px-3 py-2.5 text-left transition hover:border-primary hover:bg-muted/40",
872
+ className: "font-normal justify-start whitespace-normal flex w-full items-start gap-3 rounded-md border px-3 py-2.5 text-left transition hover:border-primary hover:bg-muted/40",
855
873
  children: [
856
874
  /* @__PURE__ */ jsx(Icon, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }),
857
875
  /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
@@ -887,7 +905,7 @@ function NewOrderCharge({
887
905
  const [checking, setChecking] = useState(false);
888
906
  const settled = useRef(false);
889
907
  const inFlight = useRef(false);
890
- const money5 = new Intl.NumberFormat("pt-BR", { style: "currency", currency: currency2 }).format(total);
908
+ const money5 = formatCurrency(total, currency2);
891
909
  const check = useCallback(async () => {
892
910
  if (settled.current || !sessionId || inFlight.current) return;
893
911
  inFlight.current = true;
@@ -1126,8 +1144,7 @@ ${payable}`;
1126
1144
  }
1127
1145
  function money2(value) {
1128
1146
  const n = Number(value);
1129
- if (!Number.isFinite(n)) return "R$ 0,00";
1130
- return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(n);
1147
+ return formatCurrency(Number.isFinite(n) ? n : 0, "BRL");
1131
1148
  }
1132
1149
  function buildShopCustomerEntity() {
1133
1150
  const fields = [
@@ -1185,13 +1202,12 @@ function buildShopCustomerEntity() {
1185
1202
  hint: "Necess\xE1rio para emitir nota \u2014 sem ele o cliente n\xE3o sobe para o ERP.",
1186
1203
  showInTable: false,
1187
1204
  renderInput: ({ value, onChange }) => /* @__PURE__ */ jsx(
1188
- "input",
1205
+ Input,
1189
1206
  {
1190
1207
  value: formatDocument(String(value ?? "")),
1191
1208
  onChange: (e) => onChange(documentDigits(e.target.value)),
1192
1209
  placeholder: "000.000.000-00",
1193
- inputMode: "numeric",
1194
- className: "flex h-9 w-full rounded-input border border-input bg-background px-3 py-1.5 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
1210
+ inputMode: "numeric"
1195
1211
  }
1196
1212
  )
1197
1213
  },
@@ -1360,8 +1376,10 @@ function CustomerModal({ open, initialName, customerId, initial, provider, onClo
1360
1376
  ] }) }),
1361
1377
  /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-3", children: [
1362
1378
  conflict.hit && /* @__PURE__ */ jsx(
1363
- "button",
1379
+ Button,
1364
1380
  {
1381
+ variant: "bare",
1382
+ size: "bare",
1365
1383
  type: "button",
1366
1384
  onClick: () => onSaved(conflict.hit),
1367
1385
  "data-testid": "new-customer-use-existing",
@@ -1370,8 +1388,10 @@ function CustomerModal({ open, initialName, customerId, initial, provider, onClo
1370
1388
  }
1371
1389
  ),
1372
1390
  /* @__PURE__ */ jsx(
1373
- "button",
1391
+ Button,
1374
1392
  {
1393
+ variant: "bare",
1394
+ size: "bare",
1375
1395
  type: "button",
1376
1396
  onClick: () => void saveAnyway(),
1377
1397
  disabled: forcing,
@@ -1387,7 +1407,7 @@ function CustomerModal({ open, initialName, customerId, initial, provider, onClo
1387
1407
  }
1388
1408
  );
1389
1409
  }
1390
- var money3 = (v, currency2 = "BRL") => new Intl.NumberFormat("pt-BR", { style: "currency", currency: currency2 }).format(Number(v) || 0);
1410
+ var money3 = (v, currency2 = "BRL") => formatCurrency(Number(v) || 0, currency2);
1391
1411
  var dateTime2 = (iso) => new Intl.DateTimeFormat("pt-BR", { day: "2-digit", month: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit" }).format(new Date(iso));
1392
1412
  var dateOnly = (iso) => new Date(iso).toLocaleDateString("pt-BR");
1393
1413
  var paidAtLabel = (iso) => {
@@ -1515,6 +1535,7 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
1515
1535
  const hasFinancial = (runtime?.activePlugins ?? []).some(
1516
1536
  (p) => p.routes?.some((r) => r.path === "/financial")
1517
1537
  );
1538
+ const receiveMounted = runtime ? getWidgetsForZone(runtime, FINANCIAL_ZONES.receivePayment).length > 0 : false;
1518
1539
  const [order, setOrder] = useState(() => shopOrderCache.get(orderId) ?? null);
1519
1540
  const [shipments, setShipments] = useState(() => shopShipmentsCache.get(orderId) ?? []);
1520
1541
  const [loading, setLoading] = useState(() => !shopOrderCache.has(orderId));
@@ -1708,13 +1729,13 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
1708
1729
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1709
1730
  destructive && order.financialStatus === "paid" && /* @__PURE__ */ jsx("p", { className: "rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-xs font-medium text-red-900", children: "Este pedido est\xE1 pago. Cancelar N\xC3O devolve o dinheiro \u2014 o estorno \xE9 feito na m\xE3o, no Financeiro ou no seu meio de pagamento." }),
1710
1731
  destructive && /* @__PURE__ */ jsx(
1711
- "input",
1732
+ Input,
1712
1733
  {
1713
1734
  value: cancelReason,
1714
1735
  onChange: (event) => setCancelReason(event.target.value),
1715
1736
  placeholder: "Motivo (opcional) \u2014 fica no hist\xF3rico do pedido",
1716
1737
  "data-testid": "order-cancel-reason",
1717
- className: "w-full rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none focus:border-primary"
1738
+ className: "px-2.5"
1718
1739
  }
1719
1740
  ),
1720
1741
  statusError && /* @__PURE__ */ jsx("p", { role: "alert", className: "rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-xs text-red-800", children: statusError })
@@ -1817,8 +1838,10 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
1817
1838
  customer?.phone && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: formatPhone(customer.phone) }),
1818
1839
  customer?.document && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: formatDocument(customer.document) }),
1819
1840
  order.customerId && missingOnCustomer.length > 0 && /* @__PURE__ */ jsx("p", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 pt-1", children: missingOnCustomer.map((field) => /* @__PURE__ */ jsx(
1820
- "button",
1841
+ Button,
1821
1842
  {
1843
+ variant: "bare",
1844
+ size: "bare",
1822
1845
  type: "button",
1823
1846
  onClick: () => setEditingCustomer(true),
1824
1847
  "data-testid": `order-customer-add-${field.key}`,
@@ -1857,7 +1880,7 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
1857
1880
  {
1858
1881
  dateOnly: (value) => value ? dateOnly(value) : "",
1859
1882
  actions: /* @__PURE__ */ jsxs(Fragment, { children: [
1860
- receivable && receivable.balance.balance > 0 && receivable.balance.status !== "cancelled" && /* @__PURE__ */ jsx(
1883
+ receiveMounted && receivable && receivable.balance.balance > 0 && receivable.balance.status !== "cancelled" && /* @__PURE__ */ jsx(
1861
1884
  Button,
1862
1885
  {
1863
1886
  onClick: () => {
@@ -1869,8 +1892,10 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
1869
1892
  }
1870
1893
  ),
1871
1894
  hasFinancial && /* @__PURE__ */ jsx(
1872
- "button",
1895
+ Button,
1873
1896
  {
1897
+ variant: "bare",
1898
+ size: "bare",
1874
1899
  type: "button",
1875
1900
  onClick: () => adminNavigateTo("/financial"),
1876
1901
  className: "rounded-md border px-3 py-1.5 text-sm font-medium transition hover:bg-muted",
@@ -1979,11 +2004,11 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
1979
2004
  onChoose: (asLink) => {
1980
2005
  void openCharge(asLink);
1981
2006
  },
1982
- onRegisterReceipt: () => {
2007
+ onRegisterReceipt: receiveMounted ? () => {
1983
2008
  setChargeOpen(false);
1984
2009
  const open = receivable?.bills.find((b) => Number(b.paid_amount ?? 0) < Number(b.amount));
1985
2010
  if (open) setPayingInstallment(toModalInstallment(open));
1986
- },
2011
+ } : void 0,
1987
2012
  total: charge?.total ?? order.total,
1988
2013
  currency: cur,
1989
2014
  customerName: order.customerName ?? "",
@@ -2003,8 +2028,9 @@ function OrderDetailView({ orderId, provider, onBack, fallback }) {
2003
2028
  }
2004
2029
  ),
2005
2030
  payingInstallment && /* @__PURE__ */ jsx(
2006
- ReceivePaymentModal,
2031
+ WidgetSlot,
2007
2032
  {
2033
+ zone: FINANCIAL_ZONES.receivePayment,
2008
2034
  installment: payingInstallment,
2009
2035
  onClose: () => setPayingInstallment(null),
2010
2036
  onPaid: () => {
@@ -2075,7 +2101,7 @@ function StockEntryModal({
2075
2101
  setSaving(false);
2076
2102
  }
2077
2103
  }
2078
- const inputClass = "mt-1 w-full rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none focus:border-primary";
2104
+ const inputClass = "mt-1 px-2.5";
2079
2105
  return /* @__PURE__ */ jsx(Modal, { open, onOpenChange: (next) => {
2080
2106
  if (!next) onClose();
2081
2107
  }, children: /* @__PURE__ */ jsx(ModalPortal, { children: /* @__PURE__ */ jsx(ModalOverlay, { children: /* @__PURE__ */ jsxs(ModalContent, { size: "lg", "data-testid": "stock-entry-modal", children: [
@@ -2096,7 +2122,7 @@ function StockEntryModal({
2096
2122
  /* @__PURE__ */ jsxs("label", { className: "block", children: [
2097
2123
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "Quantidade recebida" }),
2098
2124
  /* @__PURE__ */ jsx(
2099
- "input",
2125
+ Input,
2100
2126
  {
2101
2127
  type: "number",
2102
2128
  min: 1,
@@ -2116,7 +2142,7 @@ function StockEntryModal({
2116
2142
  /* @__PURE__ */ jsxs("label", { className: "block", children: [
2117
2143
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "Data de entrada" }),
2118
2144
  /* @__PURE__ */ jsx(
2119
- "input",
2145
+ Input,
2120
2146
  {
2121
2147
  type: "date",
2122
2148
  value: arrivedOn,
@@ -2130,21 +2156,15 @@ function StockEntryModal({
2130
2156
  ] }),
2131
2157
  /* @__PURE__ */ jsxs("label", { className: "block", children: [
2132
2158
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "Motivo" }),
2133
- /* @__PURE__ */ jsx(
2134
- "select",
2135
- {
2136
- value: reasonCode,
2137
- onChange: (event) => setReasonCode(event.target.value),
2138
- "data-testid": "stock-entry-reason",
2139
- className: inputClass,
2140
- children: reasons.map((reason) => /* @__PURE__ */ jsx("option", { value: reason.key, children: reason.label }, reason.key))
2141
- }
2142
- )
2159
+ /* @__PURE__ */ jsxs(Select, { value: reasonCode, onValueChange: setReasonCode, children: [
2160
+ /* @__PURE__ */ jsx(SelectTrigger, { "data-testid": "stock-entry-reason", className: inputClass, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2161
+ /* @__PURE__ */ jsx(SelectContent, { children: reasons.map((reason) => /* @__PURE__ */ jsx(SelectItem, { value: reason.key, children: reason.label }, reason.key)) })
2162
+ ] })
2143
2163
  ] }),
2144
2164
  /* @__PURE__ */ jsxs("label", { className: "block", children: [
2145
2165
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: "Observa\xE7\xE3o" }),
2146
2166
  /* @__PURE__ */ jsx(
2147
- "input",
2167
+ Input,
2148
2168
  {
2149
2169
  value: note,
2150
2170
  onChange: (event) => setNote(event.target.value),
@@ -2180,13 +2200,13 @@ var PAYMENT_METHODS = [
2180
2200
  { id: "boleto", label: "Boleto" },
2181
2201
  { id: "other", label: "Outro" }
2182
2202
  ];
2183
- var money4 = (value, currency2 = "BRL") => new Intl.NumberFormat("pt-BR", { style: "currency", currency: currency2 }).format(Number(value) || 0);
2203
+ var money4 = (value, currency2 = "BRL") => formatCurrency(Number(value) || 0, currency2);
2184
2204
  var onlyDigits2 = (value) => value.replace(/\D/gu, "");
2185
2205
  var maskPostal = (value) => {
2186
2206
  const digits2 = onlyDigits2(value).slice(0, 8);
2187
2207
  return digits2.length > 5 ? `${digits2.slice(0, 5)}-${digits2.slice(5)}` : digits2;
2188
2208
  };
2189
- var fieldClass = "mt-1 w-full rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none focus:border-primary";
2209
+ var fieldClass = "mt-1 px-2.5";
2190
2210
  function Field({ label, hint, children }) {
2191
2211
  return /* @__PURE__ */ jsxs("label", { className: "block", children: [
2192
2212
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: label }),
@@ -2460,17 +2480,17 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2460
2480
  const wanted = name.trim().toLowerCase();
2461
2481
  return lines.find((line) => line.name.trim().toLowerCase() === wanted) ?? null;
2462
2482
  }, [error, lines]);
2483
+ const leadSections = /* @__PURE__ */ jsx(OrderFormBlock, { title: "Cliente", children: /* @__PURE__ */ jsx(
2484
+ CustomerPicker,
2485
+ {
2486
+ provider,
2487
+ value: customer,
2488
+ onChange: setCustomer,
2489
+ editing: editingCustomer,
2490
+ onEditing: setEditingCustomer
2491
+ }
2492
+ ) });
2463
2493
  const sideSections = /* @__PURE__ */ jsxs(Fragment, { children: [
2464
- /* @__PURE__ */ jsx(OrderFormBlock, { title: "Cliente", children: /* @__PURE__ */ jsx(
2465
- CustomerPicker,
2466
- {
2467
- provider,
2468
- value: customer,
2469
- onChange: setCustomer,
2470
- editing: editingCustomer,
2471
- onEditing: setEditingCustomer
2472
- }
2473
- ) }),
2474
2494
  /* @__PURE__ */ jsx(OrderFormBlock, { title: "Entrega", children: /* @__PURE__ */ jsx(
2475
2495
  DeliveryAddress,
2476
2496
  {
@@ -2481,14 +2501,14 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2481
2501
  }
2482
2502
  ) }),
2483
2503
  /* @__PURE__ */ jsx(OrderFormBlock, { title: "Observa\xE7\xF5es", children: /* @__PURE__ */ jsx(
2484
- "textarea",
2504
+ Textarea,
2485
2505
  {
2486
2506
  value: notes,
2487
2507
  onChange: (event) => setNotes(event.target.value),
2488
2508
  rows: 2,
2489
2509
  placeholder: "Combinado por telefone: entregar depois das 18h\u2026",
2490
2510
  "data-testid": "new-order-notes",
2491
- className: "w-full resize-y rounded-md border bg-background px-2.5 py-1.5 text-sm outline-none focus:border-primary"
2511
+ className: "min-h-0 resize-y px-2.5 py-1.5"
2492
2512
  }
2493
2513
  ) })
2494
2514
  ] });
@@ -2504,27 +2524,29 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2504
2524
  label: couponOpen || discountCode ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Cupom" }) : (
2505
2525
  // Muted "+ add" rows keep the card empty until it is asked for.
2506
2526
  /* @__PURE__ */ jsx(
2507
- "button",
2527
+ Button,
2508
2528
  {
2529
+ variant: "bare",
2530
+ size: "bare",
2509
2531
  type: "button",
2510
2532
  onClick: () => setCouponOpen(true),
2511
2533
  "data-testid": "new-order-add-coupon",
2512
- className: "text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
2534
+ className: "font-normal text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
2513
2535
  children: "Adicionar cupom"
2514
2536
  }
2515
2537
  )
2516
2538
  ),
2517
- value: couponOpen || discountCode ? /* @__PURE__ */ jsx(
2518
- "input",
2539
+ value: couponOpen || discountCode ? /* @__PURE__ */ jsx("div", { className: "w-40", children: /* @__PURE__ */ jsx(
2540
+ Input,
2519
2541
  {
2520
2542
  value: discountCode,
2521
2543
  onChange: (event) => setDiscountCode(event.target.value.toUpperCase()),
2522
2544
  placeholder: "C\xD3DIGO",
2523
2545
  autoFocus: true,
2524
2546
  "data-testid": "new-order-discount",
2525
- className: "w-40 rounded-md border bg-background px-2 py-1 text-right text-sm uppercase outline-none focus:border-primary"
2547
+ className: "h-auto rounded-md border-border bg-background px-2 py-1 text-right uppercase shadow-none focus:border-primary focus-visible:ring-0 focus-visible:ring-offset-0"
2526
2548
  }
2527
- ) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" })
2549
+ ) }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" })
2528
2550
  },
2529
2551
  {
2530
2552
  key: "shipping",
@@ -2535,12 +2557,14 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2535
2557
  ], [couponOpen, discountCode, delivers, freight, shipping, currency2]);
2536
2558
  const errorActions = /* @__PURE__ */ jsxs(Fragment, { children: [
2537
2559
  customer.id && error && /cliente/iu.test(error) && /* @__PURE__ */ jsxs(
2538
- "button",
2560
+ Button,
2539
2561
  {
2562
+ variant: "bare",
2563
+ size: "bare",
2540
2564
  type: "button",
2541
2565
  onClick: () => setEditingCustomer(true),
2542
2566
  "data-testid": "new-order-fix-customer",
2543
- className: "mt-1 font-medium underline underline-offset-2",
2567
+ className: "mt-1 whitespace-normal font-medium underline underline-offset-2",
2544
2568
  children: [
2545
2569
  "Editar cadastro de ",
2546
2570
  customer.name
@@ -2548,12 +2572,14 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2548
2572
  }
2549
2573
  ),
2550
2574
  blockedLine && /* @__PURE__ */ jsxs(
2551
- "button",
2575
+ Button,
2552
2576
  {
2577
+ variant: "bare",
2578
+ size: "bare",
2553
2579
  type: "button",
2554
2580
  onClick: () => setEntryOpen(true),
2555
2581
  "data-testid": "new-order-stock-entry",
2556
- className: "mt-1 font-medium underline underline-offset-2",
2582
+ className: "mt-1 whitespace-normal font-medium underline underline-offset-2",
2557
2583
  children: [
2558
2584
  "Dar entrada no estoque de ",
2559
2585
  blockedLine.name
@@ -2576,18 +2602,12 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2576
2602
  };
2577
2603
  const endingsNode = /* @__PURE__ */ jsxs(Fragment, { children: [
2578
2604
  settling && /* @__PURE__ */ jsxs("div", { className: "fz-fields fz-fields-2 mt-3 gap-2 rounded-md border bg-muted/30 p-3", children: [
2579
- /* @__PURE__ */ jsx(Field, { label: "Como recebeu", children: /* @__PURE__ */ jsx(
2580
- "select",
2581
- {
2582
- value: method,
2583
- onChange: (event) => setMethod(event.target.value),
2584
- "data-testid": "new-order-method",
2585
- className: fieldClass,
2586
- children: PAYMENT_METHODS.map((option) => /* @__PURE__ */ jsx("option", { value: option.id, children: option.label }, option.id))
2587
- }
2588
- ) }),
2605
+ /* @__PURE__ */ jsx(Field, { label: "Como recebeu", children: /* @__PURE__ */ jsxs(Select, { value: method, onValueChange: (v) => setMethod(v), children: [
2606
+ /* @__PURE__ */ jsx(SelectTrigger, { "data-testid": "new-order-method", className: fieldClass, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
2607
+ /* @__PURE__ */ jsx(SelectContent, { children: PAYMENT_METHODS.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.id, children: option.label }, option.id)) })
2608
+ ] }) }),
2589
2609
  /* @__PURE__ */ jsx(Field, { label: "Comprovante", hint: "Id da transa\xE7\xE3o, n\xFAmero do recibo \u2014 fica no pedido", children: /* @__PURE__ */ jsx(
2590
- "input",
2610
+ Input,
2591
2611
  {
2592
2612
  value: reference,
2593
2613
  onChange: (event) => setReference(event.target.value),
@@ -2711,6 +2731,7 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
2711
2731
  totalsTitle: "Pagamento",
2712
2732
  totalRows,
2713
2733
  extraTotal: shipping,
2734
+ leadSections,
2714
2735
  sideSections,
2715
2736
  error,
2716
2737
  errorActions,
@@ -2748,8 +2769,10 @@ function CustomerPicker({ provider, value, onChange, editing, onEditing }) {
2748
2769
  value.document && /* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: formatDocument(value.document) })
2749
2770
  ] }),
2750
2771
  /* @__PURE__ */ jsx(
2751
- "button",
2772
+ Button,
2752
2773
  {
2774
+ variant: "bare",
2775
+ size: "bare",
2753
2776
  type: "button",
2754
2777
  "aria-label": "Trocar cliente",
2755
2778
  "data-testid": "new-order-customer-clear",
@@ -2761,12 +2784,14 @@ function CustomerPicker({ provider, value, onChange, editing, onEditing }) {
2761
2784
  ] }),
2762
2785
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2763
2786
  /* @__PURE__ */ jsxs(
2764
- "button",
2787
+ Button,
2765
2788
  {
2789
+ variant: "bare",
2790
+ size: "bare",
2766
2791
  type: "button",
2767
2792
  onClick: () => setEditing(true),
2768
2793
  "data-testid": "new-order-customer-edit",
2769
- className: "inline-flex items-center gap-1.5 text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
2794
+ className: "font-normal inline-flex items-center gap-1.5 text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
2770
2795
  children: [
2771
2796
  /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5" }),
2772
2797
  "Editar cadastro"
@@ -2888,15 +2913,17 @@ function DeliveryAddress({ provider, customerId, address, onChange }) {
2888
2913
  };
2889
2914
  }, [customerId, provider]);
2890
2915
  const filled = Boolean(address.postalCode && address.street);
2891
- if (!editing) {
2892
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2916
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2917
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2893
2918
  saved.map((row) => /* @__PURE__ */ jsxs(
2894
- "button",
2919
+ Button,
2895
2920
  {
2921
+ variant: "bare",
2922
+ size: "bare",
2896
2923
  type: "button",
2897
2924
  onClick: () => use(row),
2898
2925
  "data-testid": "new-order-saved-address",
2899
- className: `block w-full rounded-md border p-2.5 text-left text-sm transition ${chosen === row.id ? "border-primary bg-primary/5" : "hover:bg-muted/50"}`,
2926
+ className: `font-normal whitespace-normal justify-start block w-full rounded-md border p-2.5 text-left text-sm transition ${chosen === row.id ? "border-primary bg-primary/5" : "hover:bg-muted/50"}`,
2900
2927
  children: [
2901
2928
  /* @__PURE__ */ jsx("span", { className: "block", children: [row.street, row.number].filter(Boolean).join(", ") }),
2902
2929
  /* @__PURE__ */ jsxs("span", { className: "block text-xs text-muted-foreground", children: [
@@ -2917,152 +2944,61 @@ function DeliveryAddress({ provider, customerId, address, onChange }) {
2917
2944
  ] }),
2918
2945
  saved.length === 0 && !filled && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Sem endere\xE7o = retirada." }),
2919
2946
  /* @__PURE__ */ jsxs(
2920
- "button",
2947
+ Button,
2921
2948
  {
2949
+ variant: "bare",
2950
+ size: "bare",
2922
2951
  type: "button",
2923
2952
  onClick: () => setEditing(true),
2924
2953
  "data-testid": "new-order-add-address",
2925
- className: "inline-flex items-center gap-1.5 text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
2954
+ className: "font-normal whitespace-normal inline-flex items-center gap-1.5 text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
2926
2955
  children: [
2927
2956
  /* @__PURE__ */ jsx(MapPin, { className: "h-3.5 w-3.5" }),
2928
2957
  filled ? "Usar outro endere\xE7o" : "Adicionar endere\xE7o"
2929
2958
  ]
2930
2959
  }
2931
- )
2932
- ] });
2933
- }
2934
- return /* @__PURE__ */ jsxs("div", { className: "fz-fields fz-fields-2 gap-2", children: [
2935
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
2936
- PostalField,
2937
- {
2938
- value: address.postalCode,
2939
- onChange: (postalCode) => onChange({ ...address, postalCode }),
2940
- onResolved: (found) => onChange({ ...address, ...found })
2941
- }
2942
- ) }),
2943
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Field, { label: "N\xFAmero", children: /* @__PURE__ */ jsx(
2944
- "input",
2945
- {
2946
- value: address.number,
2947
- onChange: (e) => onChange({ ...address, number: e.target.value }),
2948
- "data-testid": "new-order-number",
2949
- className: fieldClass
2950
- }
2951
- ) }) }),
2952
- /* @__PURE__ */ jsx("div", { className: "fz-field-wide", children: /* @__PURE__ */ jsx(Field, { label: "Rua", children: /* @__PURE__ */ jsx(
2953
- "input",
2954
- {
2955
- value: address.street,
2956
- onChange: (e) => onChange({ ...address, street: e.target.value }),
2957
- "data-testid": "new-order-street",
2958
- className: fieldClass
2959
- }
2960
- ) }) }),
2961
- /* @__PURE__ */ jsx("div", { className: "fz-field-wide", children: /* @__PURE__ */ jsx(Field, { label: "Complemento", children: /* @__PURE__ */ jsx(
2962
- "input",
2963
- {
2964
- value: address.complement,
2965
- onChange: (e) => onChange({ ...address, complement: e.target.value }),
2966
- placeholder: "Apto, bloco, ponto de refer\xEAncia",
2967
- className: fieldClass
2968
- }
2969
- ) }) }),
2970
- /* @__PURE__ */ jsx("div", { className: "fz-field-wide", children: /* @__PURE__ */ jsx(Field, { label: "Bairro", children: /* @__PURE__ */ jsx(
2971
- "input",
2972
- {
2973
- value: address.district,
2974
- onChange: (e) => onChange({ ...address, district: e.target.value }),
2975
- className: fieldClass
2976
- }
2977
- ) }) }),
2978
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Field, { label: "Cidade", children: /* @__PURE__ */ jsx(
2979
- "input",
2980
- {
2981
- value: address.city,
2982
- onChange: (e) => onChange({ ...address, city: e.target.value }),
2983
- className: fieldClass
2984
- }
2985
- ) }) }),
2986
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Field, { label: "UF", children: /* @__PURE__ */ jsx(
2987
- "input",
2988
- {
2989
- value: address.state,
2990
- maxLength: 2,
2991
- onChange: (e) => onChange({ ...address, state: e.target.value.toUpperCase() }),
2992
- className: fieldClass
2993
- }
2994
- ) }) }),
2995
- /* @__PURE__ */ jsxs("div", { className: "fz-field-wide flex gap-3", children: [
2996
- /* @__PURE__ */ jsx(
2997
- "button",
2998
- {
2999
- type: "button",
3000
- onClick: () => setEditing(false),
3001
- "data-testid": "new-order-address-done",
3002
- className: "text-sm font-medium text-primary underline-offset-2 hover:underline",
3003
- children: "Pronto"
3004
- }
3005
2960
  ),
3006
2961
  filled && /* @__PURE__ */ jsx(
3007
- "button",
2962
+ Button,
3008
2963
  {
2964
+ variant: "bare",
2965
+ size: "bare",
3009
2966
  type: "button",
3010
2967
  "data-testid": "new-order-address-clear",
3011
2968
  onClick: () => {
3012
2969
  onChange(EMPTY_ADDRESS);
3013
2970
  setChosen(null);
3014
- setEditing(false);
3015
2971
  },
3016
- className: "text-sm text-muted-foreground underline-offset-2 hover:underline",
2972
+ className: "font-normal whitespace-normal ml-4 text-sm text-muted-foreground underline-offset-2 transition hover:text-foreground hover:underline",
3017
2973
  children: "Remover entrega"
3018
2974
  }
3019
2975
  )
3020
- ] })
3021
- ] });
3022
- }
3023
- function PostalField({ value, onChange, onResolved }) {
3024
- const [looking, setLooking] = useState(false);
3025
- const [missing, setMissing] = useState(false);
3026
- useEffect(() => {
3027
- const digits2 = onlyDigits2(value);
3028
- if (digits2.length !== 8) {
3029
- setMissing(false);
3030
- return;
3031
- }
3032
- let cancelled = false;
3033
- setLooking(true);
3034
- fetch(`https://viacep.com.br/ws/${digits2}/json/`).then((response) => response.json()).then((found) => {
3035
- if (cancelled) return;
3036
- if (found?.erro) {
3037
- setMissing(true);
3038
- return;
2976
+ ] }),
2977
+ /* @__PURE__ */ jsx(
2978
+ AddressFormModal,
2979
+ {
2980
+ open: editing,
2981
+ onClose: () => setEditing(false),
2982
+ ownerId: customerId,
2983
+ onSaved: (row) => {
2984
+ const picked = {
2985
+ id: row.id || "typed",
2986
+ postalCode: row.postal_code,
2987
+ street: row.street,
2988
+ number: row.number ?? void 0,
2989
+ complement: row.complement ?? void 0,
2990
+ district: row.district ?? void 0,
2991
+ city: row.city,
2992
+ state: row.state,
2993
+ recipient: row.recipient ?? void 0,
2994
+ phone: row.phone ?? void 0
2995
+ };
2996
+ if (row.id) setSaved((prev) => [picked, ...prev.filter((r) => r.id !== row.id)]);
2997
+ use(picked);
2998
+ }
3039
2999
  }
3040
- setMissing(false);
3041
- onResolved({
3042
- street: found.logradouro || "",
3043
- district: found.bairro || "",
3044
- city: found.localidade || "",
3045
- state: (found.uf || "").toUpperCase()
3046
- });
3047
- }).catch(() => {
3048
- }).finally(() => {
3049
- if (!cancelled) setLooking(false);
3050
- });
3051
- return () => {
3052
- cancelled = true;
3053
- };
3054
- }, [value]);
3055
- return /* @__PURE__ */ jsx(Field, { label: "CEP", hint: looking ? "Buscando\u2026" : missing ? "CEP n\xE3o encontrado \u2014 preencha \xE0 m\xE3o" : void 0, children: /* @__PURE__ */ jsx(
3056
- "input",
3057
- {
3058
- value: maskPostal(value),
3059
- onChange: (event) => onChange(event.target.value),
3060
- placeholder: "00000-000",
3061
- inputMode: "numeric",
3062
- "data-testid": "new-order-postal",
3063
- className: fieldClass
3064
- }
3065
- ) });
3000
+ )
3001
+ ] });
3066
3002
  }
3067
3003
 
3068
3004
  // src/views/orders-agent.ts
@@ -3554,8 +3490,8 @@ function OrdersAgentSurface({
3554
3490
  useAgentSurface(contribution);
3555
3491
  return null;
3556
3492
  }
3557
- function currency(value, code = "BRL", locale = "pt-BR") {
3558
- return new Intl.NumberFormat(locale, { style: "currency", currency: code }).format(value);
3493
+ function currency(value, code = "BRL") {
3494
+ return formatCurrency(value, code);
3559
3495
  }
3560
3496
  function badge(label, color) {
3561
3497
  return /* @__PURE__ */ jsx("span", { className: `inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${color}`, children: label });
@@ -3666,16 +3602,7 @@ function ProductsTab({ provider }) {
3666
3602
  ], []);
3667
3603
  return /* @__PURE__ */ jsxs("div", { children: [
3668
3604
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4", children: [
3669
- /* @__PURE__ */ jsx(
3670
- "input",
3671
- {
3672
- type: "search",
3673
- value: search,
3674
- onChange: handleSearch,
3675
- placeholder: "Buscar produtos...",
3676
- className: "border rounded-lg px-3 py-2 text-sm w-64 focus:outline-none focus:ring-2 focus:ring-primary/50"
3677
- }
3678
- ),
3605
+ /* @__PURE__ */ jsx("div", { className: "w-64", children: /* @__PURE__ */ jsx(Input, { type: "search", value: search, onChange: handleSearch, placeholder: "Buscar produtos..." }) }),
3679
3606
  /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
3680
3607
  products.length,
3681
3608
  " produtos"
@@ -4095,10 +4022,12 @@ var ShopPage = ({ provider, section }) => {
4095
4022
  /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1", children: copy.subtitle })
4096
4023
  ] }),
4097
4024
  !section && /* @__PURE__ */ jsx("div", { className: "border-b mb-6", children: /* @__PURE__ */ jsx("nav", { className: "flex gap-1", children: TABS.map((t) => /* @__PURE__ */ jsx(
4098
- "button",
4025
+ Button,
4099
4026
  {
4027
+ variant: "bare",
4028
+ size: "bare",
4100
4029
  onClick: () => setTab(t.id),
4101
- className: `px-4 py-2 text-sm font-medium border-b-2 transition-colors ${tab === t.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground"}`,
4030
+ className: `rounded-none px-4 py-2 text-sm font-medium border-b-2 transition-colors ${tab === t.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground"}`,
4102
4031
  children: t.label
4103
4032
  },
4104
4033
  t.id
@@ -4113,5 +4042,5 @@ var ShopPage = ({ provider, section }) => {
4113
4042
  ShopPage.displayName = "ShopPage";
4114
4043
 
4115
4044
  export { ShopOrderDetailSlot, ShopPage };
4116
- //# sourceMappingURL=ShopPage-J34V43NW.js.map
4117
- //# sourceMappingURL=ShopPage-J34V43NW.js.map
4045
+ //# sourceMappingURL=ShopPage-2CTRGQTX.js.map
4046
+ //# sourceMappingURL=ShopPage-2CTRGQTX.js.map