@fayz-ai/pos 0.24.0 → 0.24.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.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { haptic, createKeymap, directionOf, moveFocus } from '@fayz-ai/core/interaction';
2
2
  export { comboOf, createKeymap, haptic, setHapticsEnabled } from '@fayz-ai/core/interaction';
3
3
  import { forwardRef, memo, useState, useRef, useCallback, useEffect, useMemo, useReducer, Fragment as Fragment$1 } from 'react';
4
- import { UserPlus, X, Check, Phone, User, Receipt, RotateCcw, FileCheck, FileWarning, ChevronDown, Pencil, ChevronLeft, ChevronRight, Plus, ChevronUp, ChefHat, AlertTriangle, Printer, Percent, QrCode, CreditCard, Banknote, Trash2, Clock, Minus, Bike, History, PackageCheck, CheckCheck, Package, MapPin, ShieldCheck, Keyboard, CalendarClock, Users, UserRound, Search, Utensils, BellRing, UserX, UserCheck, Delete, UtensilsCrossed, Info, ClipboardList, LayoutGrid, ShoppingBag, ConciergeBell, Map as Map$1, Settings2, Square, Circle, PenLine, MoreHorizontal, Store, Tag, Star, Ticket, Ban, ArrowLeftRight, Gift, UserMinus, CheckCircle2, Crosshair, Unlink, MousePointerClick, PencilRuler, RefreshCw, MapPinOff, Eye, EyeOff, Undo2, TriangleAlert, ArrowRight, Pizza, Wheat, Sandwich, IceCreamCone, CakeSlice, Coffee, Croissant, CupSoda, Salad, Beef, Wine, GlassWater, Soup, Fish, Wrench, CalendarCheck } from 'lucide-react';
4
+ import { UserPlus, X, Check, Phone, User, Receipt, RotateCcw, FileCheck, FileWarning, ChevronDown, Pencil, ChevronLeft, ChevronRight, Plus, ChevronUp, ChefHat, AlertTriangle, Printer, Percent, QrCode, CreditCard, Banknote, Trash2, Clock, Minus, Bike, History, PackageCheck, CheckCheck, Package, MapPin, ShieldCheck, Loader2, Keyboard, CalendarClock, Users, UserRound, Search, Utensils, BellRing, UserX, UserCheck, Delete, UtensilsCrossed, Info, ClipboardList, LayoutGrid, ShoppingBag, ConciergeBell, Map as Map$1, Settings2, Square, Circle, PenLine, MoreHorizontal, Store, Tag, Star, Ticket, Ban, ArrowLeftRight, Gift, UserMinus, CheckCircle2, Crosshair, Unlink, MousePointerClick, PencilRuler, RefreshCw, MapPinOff, Eye, EyeOff, Undo2, TriangleAlert, ArrowRight, Pizza, Wheat, Sandwich, IceCreamCone, CakeSlice, Coffee, Croissant, CupSoda, Salad, Beef, Wine, GlassWater, Soup, Fish, Wrench, CalendarCheck } from 'lucide-react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { describeError, channelOfOrder } from '@fayz-ai/core';
7
7
  import { createPortal } from 'react-dom';
@@ -4968,12 +4968,12 @@ function DeliveryBoard({ orders, activeId, onSelect, now, channelsConnected, his
4968
4968
  }
4969
4969
  ),
4970
4970
  /* @__PURE__ */ jsxs("div", { className: "pos-board__bar", children: [
4971
- /* @__PURE__ */ jsx("p", { className: "pos-board__note", children: DELIVERED_LINGER_NOTE }),
4972
4971
  onToggleHistory && /* @__PURE__ */ jsxs(PosButton, { className: "pos-pill", "aria-pressed": !!historyOpen, onClick: onToggleHistory, children: [
4973
4972
  /* @__PURE__ */ jsx(History, { size: 14 }),
4974
4973
  " ",
4975
4974
  historyOpen ? "Ocultar hist\xF3rico" : "Hist\xF3rico do dia"
4976
- ] })
4975
+ ] }),
4976
+ /* @__PURE__ */ jsx("p", { className: "pos-board__note", children: DELIVERED_LINGER_NOTE })
4977
4977
  ] }),
4978
4978
  /* @__PURE__ */ jsx("div", { className: "pos-board", children: DELIVERY_COLUMNS.map(({ name, states, tone }) => {
4979
4979
  const Icon = ICONE[name] ?? Clock;
@@ -5079,7 +5079,8 @@ function DispatchRail({
5079
5079
  open,
5080
5080
  containerRef,
5081
5081
  extra,
5082
- carrier
5082
+ carrier,
5083
+ waiting
5083
5084
  }) {
5084
5085
  const status = order.dispatch ?? "received";
5085
5086
  const next = nextDispatch(status);
@@ -5190,11 +5191,15 @@ function DispatchRail({
5190
5191
  ] }),
5191
5192
  extra,
5192
5193
  /* @__PURE__ */ jsxs("div", { className: "pos-cta", style: { display: "grid", gap: "var(--pos-2x)" }, children: [
5193
- held ? /* @__PURE__ */ jsxs(Fragment, { children: [
5194
+ waiting ? /* @__PURE__ */ jsxs(PosButton, { className: "pos-btn", disabled: true, "aria-busy": true, children: [
5195
+ /* @__PURE__ */ jsx(Loader2, { size: 18, className: "pos-spin", "aria-hidden": true }),
5196
+ " ",
5197
+ waiting
5198
+ ] }) : held ? /* @__PURE__ */ jsxs(Fragment, { children: [
5194
5199
  /* @__PURE__ */ jsx(PosButton, { className: "pos-btn", disabled: true, children: carrier.label }),
5195
5200
  /* @__PURE__ */ jsx("p", { className: "pos-t-sm", style: { margin: 0, textAlign: "center", color: "var(--pos-fg-3)" }, children: carrier.note })
5196
5201
  ] }) : next ? /* @__PURE__ */ jsx(PosButton, { className: "pos-btn", onClick: () => onAdvance(next), children: ADVANCE_LABEL[next] }) : /* @__PURE__ */ jsx(PosButton, { className: "pos-btn", disabled: true, children: "Entregue" }),
5197
- /* @__PURE__ */ jsx(PosButton, { className: "pos-btn pos-btn--ghost", style: { width: "100%" }, onClick: onCancel, children: "Cancelar pedido" })
5202
+ /* @__PURE__ */ jsx(PosButton, { className: "pos-btn pos-btn--ghost", style: { width: "100%" }, onClick: onCancel, disabled: !!waiting, children: "Cancelar pedido" })
5198
5203
  ] })
5199
5204
  ]
5200
5205
  }
@@ -7909,6 +7914,7 @@ function PosScreen({
7909
7914
  ),
7910
7915
  [closedTickets, canalMarcado, menu?.view]
7911
7916
  );
7917
+ const [dispatchWaiting, setDispatchWaiting] = useState({});
7912
7918
  const [deliveryHistory, setDeliveryHistory] = useState(false);
7913
7919
  const closeDetailsRef = useRef(() => {
7914
7920
  });
@@ -9102,9 +9108,23 @@ function PosScreen({
9102
9108
  now,
9103
9109
  open: railOpen,
9104
9110
  onAdvance: (to) => {
9105
- setDispatched((prev) => ({ ...prev, [activePosition.id]: to }));
9106
- void onDispatch?.(activePosition.id, to);
9111
+ const id = activePosition.id;
9112
+ const sent = onDispatch?.(id, to);
9113
+ if (!sent || typeof sent.then !== "function") {
9114
+ setDispatched((prev) => ({ ...prev, [id]: to }));
9115
+ return;
9116
+ }
9117
+ setDispatchWaiting((w) => ({ ...w, [id]: to }));
9118
+ void sent.then((ok) => {
9119
+ if (ok !== false) setDispatched((prev) => ({ ...prev, [id]: to }));
9120
+ }).catch(() => {
9121
+ }).finally(() => setDispatchWaiting((w) => {
9122
+ const next = { ...w };
9123
+ delete next[id];
9124
+ return next;
9125
+ }));
9107
9126
  },
9127
+ waiting: dispatchWaiting[activePosition.id] ? `Aguardando confirma\xE7\xE3o do ${activePosition.channel ?? "canal"}\u2026` : null,
9108
9128
  onCancel: () => handleAction("cancel_order"),
9109
9129
  onCloseDetails: () => closeDetailsRef.current(),
9110
9130
  extra: renderDispatchExtra?.(activePosition, ticket),