@fayz-ai/plugin-shop 0.28.4 → 0.30.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/dist/{DeliveryStoreSettings-L2RXOVB6.js → DeliveryStoreSettings-UUTAR2LY.js} +84 -4
- package/dist/DeliveryStoreSettings-UUTAR2LY.js.map +1 -0
- package/dist/{ShopPage-QL7ZWGMJ.js → ShopPage-NQVQUN7Y.js} +7 -28
- package/dist/ShopPage-NQVQUN7Y.js.map +1 -0
- package/dist/{StoreGeneralSettings-RDUOJYZN.js → StoreGeneralSettings-Y6T3ES7U.js} +26 -3
- package/dist/StoreGeneralSettings-Y6T3ES7U.js.map +1 -0
- package/dist/chunk-QPVZCFU2.js +82 -0
- package/dist/chunk-QPVZCFU2.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/settings/DeliveryStoreSettings.d.ts.map +1 -1
- package/dist/settings/StoreGeneralSettings.d.ts.map +1 -1
- package/dist/views/OrderDeliveryPanel.d.ts.map +1 -1
- package/dist/views/customer-messages.d.ts +32 -0
- package/dist/views/customer-messages.d.ts.map +1 -0
- package/package.json +8 -7
- package/dist/DeliveryStoreSettings-L2RXOVB6.js.map +0 -1
- package/dist/ShopPage-QL7ZWGMJ.js.map +0 -1
- package/dist/StoreGeneralSettings-RDUOJYZN.js.map +0 -1
|
@@ -13,6 +13,7 @@ var CURRENCIES = [
|
|
|
13
13
|
{ value: "GBP", label: "British Pound (\xA3)" }
|
|
14
14
|
];
|
|
15
15
|
var EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
16
|
+
var PIXEL_ID = /^[0-9]{10,20}$/;
|
|
16
17
|
var parseEmails = (raw) => raw.split(/[,;\s]+/).map((e) => e.trim().toLowerCase()).filter(Boolean);
|
|
17
18
|
var LOCALES = [
|
|
18
19
|
{ value: "pt-BR", label: "Portugu\xEAs (Brasil)" },
|
|
@@ -35,6 +36,13 @@ function StoreGeneralSettings({ currency, provider }) {
|
|
|
35
36
|
setEmailsDraft(savedEmails);
|
|
36
37
|
}, [savedEmails]);
|
|
37
38
|
const invalidEmails = parseEmails(emailsDraft).filter((e) => !EMAIL.test(e));
|
|
39
|
+
const savedPixel = value.metaPixelId ?? "";
|
|
40
|
+
const [pixelDraft, setPixelDraft] = React.useState(savedPixel);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
setPixelDraft(savedPixel);
|
|
43
|
+
}, [savedPixel]);
|
|
44
|
+
const pixelDigits = pixelDraft.replace(/\D/g, "");
|
|
45
|
+
const pixelInvalid = pixelDigits !== "" && !PIXEL_ID.test(pixelDigits);
|
|
38
46
|
return /* @__PURE__ */ jsxs(SettingsState, { ...settings, children: [
|
|
39
47
|
/* @__PURE__ */ jsxs(SettingsGroup, { title: "Loja", description: "Moeda e formata\xE7\xE3o da vitrine.", children: [
|
|
40
48
|
/* @__PURE__ */ jsx(
|
|
@@ -113,10 +121,25 @@ function StoreGeneralSettings({ currency, provider }) {
|
|
|
113
121
|
onChange: (v) => set({ notifyLowStock: v })
|
|
114
122
|
}
|
|
115
123
|
)
|
|
116
|
-
] })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ jsx(SettingsGroup, { title: "Rastreamento", description: "Conecte o site \xE0s suas campanhas de an\xFAncios.", children: /* @__PURE__ */ jsx(
|
|
126
|
+
TextRow,
|
|
127
|
+
{
|
|
128
|
+
label: "ID do Pixel da Meta",
|
|
129
|
+
description: "Do Gerenciador de Eventos da Meta (Facebook/Instagram). O site passa a enviar visualiza\xE7\xE3o de produto, carrinho, in\xEDcio de checkout e compra para este pixel.",
|
|
130
|
+
value: pixelDraft,
|
|
131
|
+
placeholder: "Ex.: 698178322416034",
|
|
132
|
+
invalid: pixelInvalid,
|
|
133
|
+
hint: pixelInvalid ? "O ID do pixel tem s\xF3 n\xFAmeros (geralmente 15 ou 16 d\xEDgitos)." : void 0,
|
|
134
|
+
onChange: setPixelDraft,
|
|
135
|
+
onBlurCommit: () => {
|
|
136
|
+
if (!pixelInvalid) set({ metaPixelId: pixelDigits || null });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
) })
|
|
117
140
|
] });
|
|
118
141
|
}
|
|
119
142
|
|
|
120
143
|
export { StoreGeneralSettings };
|
|
121
|
-
//# sourceMappingURL=StoreGeneralSettings-
|
|
122
|
-
//# sourceMappingURL=StoreGeneralSettings-
|
|
144
|
+
//# sourceMappingURL=StoreGeneralSettings-Y6T3ES7U.js.map
|
|
145
|
+
//# sourceMappingURL=StoreGeneralSettings-Y6T3ES7U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/settings/StoreGeneralSettings.tsx"],"names":[],"mappings":";;;;;;;;AAWA,IAAM,UAAA,GAAa;AAAA,EACjB,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,WAAA,EAAY;AAAA,EACnC,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,eAAA,EAAgB;AAAA,EACvC,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,eAAA,EAAW;AAAA,EAClC,EAAE,KAAA,EAAO,KAAA,EAAO,KAAA,EAAO,sBAAA;AACzB,CAAA;AAEA,IAAM,KAAA,GAAQ,4BAAA;AACd,IAAM,QAAA,GAAW,gBAAA;AACjB,IAAM,cAAc,CAAC,GAAA,KAAgB,GAAA,CAAI,KAAA,CAAM,SAAS,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,IAAA,EAAK,CAAE,aAAa,CAAA,CAAE,OAAO,OAAO,CAAA;AAE3G,IAAM,OAAA,GAAU;AAAA,EACd,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,uBAAA,EAAqB;AAAA,EAC9C,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,cAAA,EAAe;AAAA,EACxC,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,YAAA;AAC3B,CAAA;AASO,SAAS,oBAA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AU,CAAC,CAAA,KAAM,IAAI,EAAE,cAAA,EAAgB,GAAG;AAAA;AAAA;AAC5C,KAAA,EACF,CAAA;AAAA,oBAEA,GAAA,CAAC,aAAA,EAAA,EAAc,KAAA,EAAM,cAAA,EAAe,aAAY,qDAAA,EAC9C,QAAA,kBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,KAAA,EAAM,qBAAA;AAAA,QACN,WAAA,EAAY,wKAAA;AAAA,QACZ,KAAA,EAAO,UAAA;AAAA,QACP,WAAA,EAAY,sBAAA;AAAA,QACZ,OAAA,EAAS,YAAA;AAAA,QACT,IAAA,EAAM,eAAe,sEAAA,GAAgE,MAAA;AAAA,QACrF,QAAA,EAAU,aAAA;AAAA,QACV,cAAc,MAAM;AAAE,UAAA,IAAI,CAAC,YAAA,EAAc,GAAA,CAAI,EAAE,WAAA,EAAa,WAAA,IAAe,MAAM,CAAA;AAAA,QAAE;AAAA;AAAA,KACrF,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"StoreGeneralSettings-Y6T3ES7U.js","sourcesContent":["import React from 'react'\nimport { SettingsGroup, SelectRow, TextRow, ToggleRow } from '@fayz-ai/admin'\nimport type { ShopProviderResolver } from '../data/shared'\nimport { useStoreSettings } from './useStoreSettings'\nimport { SettingsState } from './SettingsState'\n\nexport interface StoreGeneralSettingsProps {\n currency?: { code?: string; locale?: string; symbol?: string }\n provider?: ShopProviderResolver\n}\n\nconst CURRENCIES = [\n { value: 'BRL', label: 'Real (R$)' },\n { value: 'USD', label: 'US Dollar ($)' },\n { value: 'EUR', label: 'Euro (€)' },\n { value: 'GBP', label: 'British Pound (£)' },\n]\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\nconst PIXEL_ID = /^[0-9]{10,20}$/\nconst parseEmails = (raw: string) => raw.split(/[,;\\s]+/).map((e) => e.trim().toLowerCase()).filter(Boolean)\n\nconst LOCALES = [\n { value: 'pt-BR', label: 'Português (Brasil)' },\n { value: 'en-US', label: 'English (US)' },\n { value: 'es-ES', label: 'Español' },\n]\n\n/**\n * Loja — moeda, formatação e as regras de catálogo.\n *\n * O `currency` que o app passa na criação do plugin é o VALOR INICIAL mostrado,\n * não o valor salvo: enquanto o lojista não escolhe, a vitrine segue com o que o\n * app declarou, e é isso que a coluna nula significa. Escolher grava.\n */\nexport function StoreGeneralSettings({ currency, provider }: StoreGeneralSettingsProps) {\n const settings = useStoreSettings(provider, {\n currency: currency?.code ?? 'BRL',\n locale: currency?.locale ?? 'pt-BR',\n showOutOfStock: true,\n requireSku: false,\n notifyNewOrder: true,\n notifyLowStock: false,\n })\n const { value, set } = settings\n const savedEmails = (value.orderAlertEmails ?? []).join(', ')\n const [emailsDraft, setEmailsDraft] = React.useState(savedEmails)\n React.useEffect(() => { setEmailsDraft(savedEmails) }, [savedEmails])\n const invalidEmails = parseEmails(emailsDraft).filter((e) => !EMAIL.test(e))\n const savedPixel = value.metaPixelId ?? ''\n const [pixelDraft, setPixelDraft] = React.useState(savedPixel)\n React.useEffect(() => { setPixelDraft(savedPixel) }, [savedPixel])\n const pixelDigits = pixelDraft.replace(/\\D/g, '')\n const pixelInvalid = pixelDigits !== '' && !PIXEL_ID.test(pixelDigits)\n\n return (\n <SettingsState {...settings}>\n <SettingsGroup title=\"Loja\" description=\"Moeda e formatação da vitrine.\">\n <SelectRow\n label=\"Moeda\"\n description=\"Moeda padrão para preços e checkout.\"\n value={value.currency ?? 'BRL'}\n options={CURRENCIES}\n onChange={(v) => set({ currency: v })}\n />\n <SelectRow\n label=\"Idioma / formato\"\n description=\"Formatação de números, preços e datas.\"\n value={value.locale ?? 'pt-BR'}\n options={LOCALES}\n onChange={(v) => set({ locale: v })}\n />\n </SettingsGroup>\n\n <SettingsGroup title=\"Catálogo\" description=\"Como os produtos aparecem e são gerenciados.\">\n <ToggleRow\n label=\"Mostrar produtos esgotados\"\n description=\"Exibir itens sem estoque na vitrine.\"\n checked={value.showOutOfStock ?? true}\n onChange={(v) => set({ showOutOfStock: v })}\n />\n <ToggleRow\n label=\"Exigir SKU\"\n description=\"Tornar o SKU obrigatório ao criar produtos.\"\n checked={value.requireSku ?? false}\n onChange={(v) => set({ requireSku: v })}\n />\n </SettingsGroup>\n\n {/* «Controlar estoque» saiu daqui. Era um interruptor local que não\n governava nada, e a decisão real — quem é dono do número, nosso livro\n ou um ERP — já existe como `stock_ownership` e é escrita pelo conector\n que assume o estoque. Dois controles para a mesma coisa é o caminho\n mais curto para eles discordarem. */}\n\n <SettingsGroup title=\"Notificações\" description=\"Avisos por e-mail da loja.\">\n <ToggleRow\n label=\"E-mail de novo pedido\"\n description=\"Notificar a equipe a cada novo pedido.\"\n checked={value.notifyNewOrder ?? true}\n onChange={(v) => set({ notifyNewOrder: v })}\n />\n <TextRow\n label=\"Enviar para\"\n description=\"E-mails que recebem cada novo pedido, separados por vírgula. O assunto diz se é B2B, Delivery ou Balcão.\"\n value={emailsDraft}\n placeholder=\"voce@empresa.com.br\"\n disabled={value.notifyNewOrder === false}\n invalid={invalidEmails.length > 0}\n hint={invalidEmails.length > 0 ? `E-mail inválido: ${invalidEmails.join(', ')}` : undefined}\n onChange={setEmailsDraft}\n onBlurCommit={() => { if (invalidEmails.length === 0) set({ orderAlertEmails: parseEmails(emailsDraft) }) }}\n />\n <ToggleRow\n label=\"Alerta de estoque baixo\"\n description=\"Avisar quando produtos atingirem o mínimo.\"\n checked={value.notifyLowStock ?? false}\n onChange={(v) => set({ notifyLowStock: v })}\n />\n </SettingsGroup>\n\n <SettingsGroup title=\"Rastreamento\" description=\"Conecte o site às suas campanhas de anúncios.\">\n <TextRow\n label=\"ID do Pixel da Meta\"\n description=\"Do Gerenciador de Eventos da Meta (Facebook/Instagram). O site passa a enviar visualização de produto, carrinho, início de checkout e compra para este pixel.\"\n value={pixelDraft}\n placeholder=\"Ex.: 698178322416034\"\n invalid={pixelInvalid}\n hint={pixelInvalid ? 'O ID do pixel tem só números (geralmente 15 ou 16 dígitos).' : undefined}\n onChange={setPixelDraft}\n onBlurCommit={() => { if (!pixelInvalid) set({ metaPixelId: pixelDigits || null }) }}\n />\n </SettingsGroup>\n </SettingsState>\n )\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MessageCircle, Mail, ChevronDown, ChevronRight } from 'lucide-react';
|
|
3
|
+
import { cn } from '@fayz-ai/ui';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/views/customer-messages.tsx
|
|
7
|
+
var MESSAGE_STAGE = {
|
|
8
|
+
new: "Pedido recebido",
|
|
9
|
+
accepted: "Pedido aceito",
|
|
10
|
+
out_for_delivery: "Saiu para entrega",
|
|
11
|
+
delivered: "Entregue",
|
|
12
|
+
rejected: "Pedido recusado",
|
|
13
|
+
cancelled: "Pedido cancelado"
|
|
14
|
+
};
|
|
15
|
+
var MESSAGE_STAGE_ORDER = ["new", "accepted", "out_for_delivery", "delivered", "rejected", "cancelled"];
|
|
16
|
+
var STATUS = {
|
|
17
|
+
pending: { label: "Na fila", tone: "bg-muted text-muted-foreground" },
|
|
18
|
+
sending: { label: "Enviando", tone: "bg-muted text-muted-foreground" },
|
|
19
|
+
sent: { label: "Enviada", tone: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400" },
|
|
20
|
+
failed: { label: "Falhou", tone: "bg-destructive/10 text-destructive" },
|
|
21
|
+
skipped: { label: "N\xE3o enviada", tone: "bg-amber-500/10 text-amber-700 dark:text-amber-400" }
|
|
22
|
+
};
|
|
23
|
+
function messageFailureReason(error) {
|
|
24
|
+
const raw = (error ?? "").trim();
|
|
25
|
+
if (!raw) return null;
|
|
26
|
+
const lower = raw.toLowerCase();
|
|
27
|
+
if (lower.includes("no phone")) return "O pedido n\xE3o tem telefone.";
|
|
28
|
+
if (lower.includes("no e-mail") || lower.includes("no email")) return "O pedido n\xE3o tem e-mail.";
|
|
29
|
+
if (lower.includes("fetch failed") || lower.includes("econnrefused") || lower.includes("timeout"))
|
|
30
|
+
return "O WhatsApp da loja n\xE3o respondeu (n\xFAmero desconectado ou servi\xE7o fora do ar).";
|
|
31
|
+
if (lower.includes("not connected") || lower.includes("disconnected") || lower.includes("qr"))
|
|
32
|
+
return "O WhatsApp da loja est\xE1 desconectado. Conecte o n\xFAmero de novo para voltar a enviar.";
|
|
33
|
+
if (lower.includes("no active") && lower.includes("whatsapp"))
|
|
34
|
+
return "A loja n\xE3o tem um n\xFAmero de WhatsApp ativo.";
|
|
35
|
+
return `Erro: ${raw}`;
|
|
36
|
+
}
|
|
37
|
+
function messageTime(iso) {
|
|
38
|
+
return iso ? new Date(iso).toLocaleString("pt-BR", { day: "2-digit", month: "2-digit", hour: "2-digit", minute: "2-digit" }) : "";
|
|
39
|
+
}
|
|
40
|
+
function CustomerMessageRow({ message, defaultOpen = false, showStage = true }) {
|
|
41
|
+
const [open, setOpen] = React.useState(defaultOpen);
|
|
42
|
+
const status = STATUS[message.status] ?? { label: message.status, tone: "bg-muted text-muted-foreground" };
|
|
43
|
+
const reason = message.status === "failed" || message.status === "skipped" ? messageFailureReason(message.last_error) : null;
|
|
44
|
+
const Icon = message.channel === "whatsapp" ? MessageCircle : Mail;
|
|
45
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border", "data-testid": `customer-message-${message.stage}-${message.channel}`, children: [
|
|
46
|
+
/* @__PURE__ */ jsxs(
|
|
47
|
+
"button",
|
|
48
|
+
{
|
|
49
|
+
type: "button",
|
|
50
|
+
onClick: () => setOpen((v) => !v),
|
|
51
|
+
className: "flex w-full items-center gap-2 px-3 py-2 text-left text-xs",
|
|
52
|
+
"aria-expanded": open,
|
|
53
|
+
children: [
|
|
54
|
+
open ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
55
|
+
/* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
56
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
57
|
+
showStage ? `${MESSAGE_STAGE[message.stage] ?? message.stage} \xB7 ` : "",
|
|
58
|
+
message.channel === "whatsapp" ? "WhatsApp" : "E-mail"
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ jsx("span", { className: cn("rounded px-1.5 py-0.5 text-[11px] font-medium", status.tone), children: status.label }),
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 text-muted-foreground", children: messageTime(message.sent_at ?? message.created_at) })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
reason && /* @__PURE__ */ jsx("p", { className: "px-3 pb-2 text-xs text-destructive", children: reason }),
|
|
66
|
+
open && /* @__PURE__ */ jsxs("div", { className: "space-y-2 border-t px-3 py-2", children: [
|
|
67
|
+
message.recipient && /* @__PURE__ */ jsxs("p", { className: "text-[11px] text-muted-foreground", children: [
|
|
68
|
+
"Para: ",
|
|
69
|
+
message.recipient
|
|
70
|
+
] }),
|
|
71
|
+
message.subject && /* @__PURE__ */ jsx("p", { className: "text-xs font-medium", children: message.subject }),
|
|
72
|
+
message.html ? (
|
|
73
|
+
// The e-mail as it was sent. Sandboxed: no scripts, no navigation out of the frame.
|
|
74
|
+
/* @__PURE__ */ jsx("iframe", { title: "E-mail enviado", sandbox: "", srcDoc: message.html, className: "h-80 w-full rounded border bg-white" })
|
|
75
|
+
) : /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap text-xs", children: message.body })
|
|
76
|
+
] })
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { CustomerMessageRow, MESSAGE_STAGE, MESSAGE_STAGE_ORDER };
|
|
81
|
+
//# sourceMappingURL=chunk-QPVZCFU2.js.map
|
|
82
|
+
//# sourceMappingURL=chunk-QPVZCFU2.js.map
|
|
@@ -0,0 +1 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,MAAA,EAAO,CAAA;AAAA,IACpE,IAAA,oBACC,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,8BAAA,EACZ,QAAA,EAAA;AAAA,MAAA,OAAA,CAAQ,SAAA,oBAAa,IAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,mCAAA,EAAoC,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QAAO,OAAA,CAAQ;AAAA,OAAA,EAAU,CAAA;AAAA,MAC/F,QAAQ,OAAA,oBAAW,GAAA,CAAC,OAAE,SAAA,EAAU,qBAAA,EAAuB,kBAAQ,OAAA,EAAQ,CAAA;AAAA,MACvE,OAAA,CAAQ,IAAA;AAAA;AAAA,wBAEP,GAAA,CAAC,QAAA,EAAA,EAAO,KAAA,EAAM,gBAAA,EAAiB,OAAA,EAAQ,IAAG,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,SAAA,EAAU,qCAAA,EAAsC;AAAA,0BAEhH,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,6BAAA,EAA+B,kBAAQ,IAAA,EAAK;AAAA,KAAA,EAE7D;AAAA,GAAA,EAEJ,CAAA;AAEJ","file":"chunk-QPVZCFU2.js","sourcesContent":["import React from 'react'\nimport { ChevronDown, ChevronRight, Mail, MessageCircle } from 'lucide-react'\nimport { cn } from '@fayz-ai/ui'\n\n// ---------------------------------------------------------------------------\n// What the customer was told about their order, as the store reads it.\n//\n// The messages are rendered and sent by the integration service and queued in\n// plg_shop_order_notifications (shop 0125); this file only DRAWS them — the\n// order page lists one order's, the delivery settings show the latest of each\n// kind. Nothing here re-renders a message: what is on screen is what went out\n// (or what failed to), word for word.\n// ---------------------------------------------------------------------------\n\nexport type CustomerMessage = {\n id: string\n stage: string\n channel: string\n status: string\n recipient?: string | null\n subject?: string | null\n body: string\n /** When the service renders an HTML e-mail, the column appears and is shown as sent. */\n html?: string | null\n last_error: string | null\n sent_at: string | null\n created_at: string\n}\n\nexport const MESSAGE_STAGE: Record<string, string> = {\n new: 'Pedido recebido',\n accepted: 'Pedido aceito',\n out_for_delivery: 'Saiu para entrega',\n delivered: 'Entregue',\n rejected: 'Pedido recusado',\n cancelled: 'Pedido cancelado',\n}\n\n/** The order the stages happen in, for lists that show one of each. */\nexport const MESSAGE_STAGE_ORDER = ['new', 'accepted', 'out_for_delivery', 'delivered', 'rejected', 'cancelled'] as const\n\nconst STATUS: Record<string, { label: string; tone: string }> = {\n pending: { label: 'Na fila', tone: 'bg-muted text-muted-foreground' },\n sending: { label: 'Enviando', tone: 'bg-muted text-muted-foreground' },\n sent: { label: 'Enviada', tone: 'bg-emerald-500/10 text-emerald-700 dark:text-emerald-400' },\n failed: { label: 'Falhou', tone: 'bg-destructive/10 text-destructive' },\n skipped: { label: 'Não enviada', tone: 'bg-amber-500/10 text-amber-700 dark:text-amber-400' },\n}\n\n/**\n * Why a message did not go out, in the store's words. The queue records the\n * technical reason; the known ones read as what to do about it, anything else\n * is shown as it came so nothing is hidden.\n */\nexport function messageFailureReason(error: string | null | undefined): string | null {\n const raw = (error ?? '').trim()\n if (!raw) return null\n const lower = raw.toLowerCase()\n if (lower.includes('no phone')) return 'O pedido não tem telefone.'\n if (lower.includes('no e-mail') || lower.includes('no email')) return 'O pedido não tem e-mail.'\n if (lower.includes('fetch failed') || lower.includes('econnrefused') || lower.includes('timeout'))\n return 'O WhatsApp da loja não respondeu (número desconectado ou serviço fora do ar).'\n if (lower.includes('not connected') || lower.includes('disconnected') || lower.includes('qr'))\n return 'O WhatsApp da loja está desconectado. Conecte o número de novo para voltar a enviar.'\n if (lower.includes('no active') && lower.includes('whatsapp'))\n return 'A loja não tem um número de WhatsApp ativo.'\n return `Erro: ${raw}`\n}\n\nexport function messageTime(iso: string | null | undefined): string {\n return iso ? new Date(iso).toLocaleString('pt-BR', { day: '2-digit', month: '2-digit', hour: '2-digit', minute: '2-digit' }) : ''\n}\n\n/** One message: stage, channel, status and reason on one line; the full text on demand. */\nexport function CustomerMessageRow({ message, defaultOpen = false, showStage = true }: {\n message: CustomerMessage\n defaultOpen?: boolean\n showStage?: boolean\n}) {\n const [open, setOpen] = React.useState(defaultOpen)\n const status = STATUS[message.status] ?? { label: message.status, tone: 'bg-muted text-muted-foreground' }\n const reason = message.status === 'failed' || message.status === 'skipped' ? messageFailureReason(message.last_error) : null\n const Icon = message.channel === 'whatsapp' ? MessageCircle : Mail\n return (\n <div className=\"rounded-md border\" data-testid={`customer-message-${message.stage}-${message.channel}`}>\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n className=\"flex w-full items-center gap-2 px-3 py-2 text-left text-xs\"\n aria-expanded={open}\n >\n {open ? <ChevronDown className=\"h-3.5 w-3.5 shrink-0\" /> : <ChevronRight className=\"h-3.5 w-3.5 shrink-0\" />}\n <Icon className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" aria-hidden />\n <span className=\"font-medium\">\n {showStage ? `${MESSAGE_STAGE[message.stage] ?? message.stage} · ` : ''}\n {message.channel === 'whatsapp' ? 'WhatsApp' : 'E-mail'}\n </span>\n <span className={cn('rounded px-1.5 py-0.5 text-[11px] font-medium', status.tone)}>{status.label}</span>\n <span className=\"ml-auto shrink-0 text-muted-foreground\">{messageTime(message.sent_at ?? message.created_at)}</span>\n </button>\n {reason && <p className=\"px-3 pb-2 text-xs text-destructive\">{reason}</p>}\n {open && (\n <div className=\"space-y-2 border-t px-3 py-2\">\n {message.recipient && <p className=\"text-[11px] text-muted-foreground\">Para: {message.recipient}</p>}\n {message.subject && <p className=\"text-xs font-medium\">{message.subject}</p>}\n {message.html ? (\n // The e-mail as it was sent. Sandboxed: no scripts, no navigation out of the frame.\n <iframe title=\"E-mail enviado\" sandbox=\"\" srcDoc={message.html} className=\"h-80 w-full rounded border bg-white\" />\n ) : (\n <p className=\"whitespace-pre-wrap text-xs\">{message.body}</p>\n )}\n </div>\n )}\n </div>\n )\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -6257,8 +6257,8 @@ function advanceNeoChefCursor(products, overlapMs) {
|
|
|
6257
6257
|
}
|
|
6258
6258
|
|
|
6259
6259
|
// src/index.ts
|
|
6260
|
-
var ShopPage = React.lazy(() => import('./ShopPage-
|
|
6261
|
-
var LazyOrderDetail = React.lazy(() => import('./ShopPage-
|
|
6260
|
+
var ShopPage = React.lazy(() => import('./ShopPage-NQVQUN7Y.js').then((m) => ({ default: m.ShopPage })));
|
|
6261
|
+
var LazyOrderDetail = React.lazy(() => import('./ShopPage-NQVQUN7Y.js').then((m) => ({ default: m.ShopOrderDetailSlot })));
|
|
6262
6262
|
function ShopOrderDetail(provider) {
|
|
6263
6263
|
const Detail = (props) => React.createElement(
|
|
6264
6264
|
React.Suspense,
|
|
@@ -6831,11 +6831,11 @@ function shopProductMarketPricesTab(options) {
|
|
|
6831
6831
|
}
|
|
6832
6832
|
var ProductListingTabView = lazyComponent(() => import('./ProductListingTab-FEIOXECV.js').then((m) => m.ProductListingTab));
|
|
6833
6833
|
var ContentPage = React.lazy(() => import('./ContentPage-2PHOZSFZ.js').then((m) => ({ default: m.ContentPage })));
|
|
6834
|
-
var StoreGeneralSettings = lazyComponent(() => import('./StoreGeneralSettings-
|
|
6834
|
+
var StoreGeneralSettings = lazyComponent(() => import('./StoreGeneralSettings-Y6T3ES7U.js').then((m) => m.StoreGeneralSettings));
|
|
6835
6835
|
var PaymentsSettings = lazyComponent(() => import('./PaymentsSettings-5CI74TY2.js').then((m) => m.PaymentsSettings));
|
|
6836
6836
|
var CheckoutSettings = lazyComponent(() => import('./CheckoutSettings-GQRYZF6I.js').then((m) => m.CheckoutSettings));
|
|
6837
6837
|
var ShippingSettings = lazyComponent(() => import('./ShippingSettings-UBTNRBJ4.js').then((m) => m.ShippingSettings));
|
|
6838
|
-
var DeliveryStoreSettings = lazyComponent(() => import('./DeliveryStoreSettings-
|
|
6838
|
+
var DeliveryStoreSettings = lazyComponent(() => import('./DeliveryStoreSettings-UUTAR2LY.js').then((m) => m.DeliveryStoreSettings));
|
|
6839
6839
|
var FulfillmentSettings = lazyComponent(() => import('./FulfillmentSettings-PW233UOK.js').then((m) => m.FulfillmentSettings));
|
|
6840
6840
|
var MarketsSettings = lazyComponent(() => import('./MarketsSettings-YUEVDLIR.js').then((m) => m.MarketsSettings));
|
|
6841
6841
|
function shopProductListingTab(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeliveryStoreSettings.d.ts","sourceRoot":"","sources":["../../src/settings/DeliveryStoreSettings.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"DeliveryStoreSettings.d.ts","sourceRoot":"","sources":["../../src/settings/DeliveryStoreSettings.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAwL1D,wBAAgB,qBAAqB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,oBAAoB,CAAA;CAAE,qBAuEtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StoreGeneralSettings.d.ts","sourceRoot":"","sources":["../../src/settings/StoreGeneralSettings.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI1D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9D,QAAQ,CAAC,EAAE,oBAAoB,CAAA;CAChC;
|
|
1
|
+
{"version":3,"file":"StoreGeneralSettings.d.ts","sourceRoot":"","sources":["../../src/settings/StoreGeneralSettings.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAI1D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC9D,QAAQ,CAAC,EAAE,oBAAoB,CAAA;CAChC;AAmBD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,yBAAyB,qBAoGrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderDeliveryPanel.d.ts","sourceRoot":"","sources":["../../src/views/OrderDeliveryPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"OrderDeliveryPanel.d.ts","sourceRoot":"","sources":["../../src/views/OrderDeliveryPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AA2CzB,wBAAgB,kBAAkB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;IACtF,OAAO,EAAE,MAAM,CAAA;IACf,uEAAuE;IACvE,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAChC,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,6GAA6G;IAC7G,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;CACzC,4BAkLA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type CustomerMessage = {
|
|
3
|
+
id: string;
|
|
4
|
+
stage: string;
|
|
5
|
+
channel: string;
|
|
6
|
+
status: string;
|
|
7
|
+
recipient?: string | null;
|
|
8
|
+
subject?: string | null;
|
|
9
|
+
body: string;
|
|
10
|
+
/** When the service renders an HTML e-mail, the column appears and is shown as sent. */
|
|
11
|
+
html?: string | null;
|
|
12
|
+
last_error: string | null;
|
|
13
|
+
sent_at: string | null;
|
|
14
|
+
created_at: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const MESSAGE_STAGE: Record<string, string>;
|
|
17
|
+
/** The order the stages happen in, for lists that show one of each. */
|
|
18
|
+
export declare const MESSAGE_STAGE_ORDER: readonly ["new", "accepted", "out_for_delivery", "delivered", "rejected", "cancelled"];
|
|
19
|
+
/**
|
|
20
|
+
* Why a message did not go out, in the store's words. The queue records the
|
|
21
|
+
* technical reason; the known ones read as what to do about it, anything else
|
|
22
|
+
* is shown as it came so nothing is hidden.
|
|
23
|
+
*/
|
|
24
|
+
export declare function messageFailureReason(error: string | null | undefined): string | null;
|
|
25
|
+
export declare function messageTime(iso: string | null | undefined): string;
|
|
26
|
+
/** One message: stage, channel, status and reason on one line; the full text on demand. */
|
|
27
|
+
export declare function CustomerMessageRow({ message, defaultOpen, showStage }: {
|
|
28
|
+
message: CustomerMessage;
|
|
29
|
+
defaultOpen?: boolean;
|
|
30
|
+
showStage?: boolean;
|
|
31
|
+
}): React.JSX.Element;
|
|
32
|
+
//# sourceMappingURL=customer-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer-messages.d.ts","sourceRoot":"","sources":["../../src/views/customer-messages.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAczB,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,wFAAwF;IACxF,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOhD,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,wFAAyF,CAAA;AAUzH;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAapF;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAElE;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,CAAC,EAAE,OAAO,EAAE,WAAmB,EAAE,SAAgB,EAAE,EAAE;IACrF,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,qBAqCA"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"status": "preview",
|
|
5
5
|
"dependencies": []
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.30.0",
|
|
8
8
|
"description": "[experimental] Fayz SDK — plugin-shop plugin",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"sideEffects": false,
|
|
@@ -32,17 +32,18 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@tanstack/react-table": "^8.20.0",
|
|
35
|
-
"@fayz-ai/admin": "^0.
|
|
36
|
-
"@fayz-ai/core": "^0.
|
|
37
|
-
"@fayz-ai/financial": "^0.4.
|
|
38
|
-
"@fayz-ai/inventory": "^0.4.
|
|
39
|
-
"@fayz-ai/shop": "^0.
|
|
40
|
-
"@fayz-ai/ui": "^0.
|
|
35
|
+
"@fayz-ai/admin": "^0.79.3",
|
|
36
|
+
"@fayz-ai/core": "^0.79.0",
|
|
37
|
+
"@fayz-ai/financial": "^0.4.3",
|
|
38
|
+
"@fayz-ai/inventory": "^0.4.8",
|
|
39
|
+
"@fayz-ai/shop": "^0.87.0",
|
|
40
|
+
"@fayz-ai/ui": "^0.79.0",
|
|
41
41
|
"@fayz-ai/contracts": "^0.6.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^20.0.0",
|
|
45
45
|
"@types/react": "^18.3.0",
|
|
46
|
+
"@types/react-dom": "^18.3.0",
|
|
46
47
|
"lucide-react": "^0.400.0",
|
|
47
48
|
"react": "^18.3.0",
|
|
48
49
|
"tsup": "^8.2.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/settings/DeliveryStoreSettings.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAsBA,SAAS,YAAY,GAAA,EAA4B;AAC/C,EAAA,MAAM,KAAA,GAAQ,IAAI,OAAA,CAAQ,WAAA,EAAa,EAAE,CAAA,CAAE,OAAA,CAAQ,KAAK,GAAG,CAAA;AAC3D,EAAA,IAAI,CAAC,KAAA,CAAM,IAAA,EAAK,EAAG,OAAO,IAAA;AAC1B,EAAA,MAAM,CAAA,GAAI,OAAO,KAAK,CAAA;AACtB,EAAA,OAAO,OAAO,QAAA,CAAS,CAAC,CAAA,IAAK,CAAA,IAAK,IAAI,CAAA,GAAI,GAAA;AAC5C;AAEA,IAAM,IAAA,GAAO,CAAC,CAAA,KAAkC,CAAA,IAAK,IAAA,GAAO,EAAA,GAAK,MAAA,CAAO,CAAC,CAAA,CAAE,OAAA,CAAQ,GAAA,EAAK,GAAG,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0DAAA;AAAA,QAEZ,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,SAAA;AAAA,YAAA;AAAA,cACC,KAAA,EAAM,kBAAA;AAAA,cACN,WAAA,EAAY,8DAAA;AAAA,cACZ,IAAA,EAAK,gCAAA;AAAA,cACL,OAAO,KAAA,CAAM,aAAA;AAAA,cACb,WAAA,EAAY,eAAA;AAAA,cACZ,QAAA,EAAU,CAAC,IAAA,KAAS,GAAA,CAAI,EAAE,aAAA,EAAe,IAAA,IAAQ,MAAM;AAAA;AAAA,WACzD;AAAA,0BACA,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAS,KAAA,CAAM,kBAAA,EAAoB,QAAA,EAAU,CAAC,IAAA,KAAS,GAAA,CAAI,EAAE,kBAAA,EAAoB,IAAA,EAAM,CAAA,EAAG;AAAA;AAAA;AAAA,KACpG;AAAA,IACC,QAAA,CAAS,KAAA,oBAAS,IAAA,CAAC,GAAA,EAAA,EAAE,WAAU,+BAAA,EAAgC,QAAA,EAAA;AAAA,MAAA,iCAAA;AAAA,MAA0B,QAAA,CAAS;AAAA,KAAA,EAAM,CAAA;AAAA,oBAIzG,GAAA,CAAC,gBAAA,EAAA,EAAiB,QAAA,EAAoB,OAAA,EAAQ,UAAA,EAAW;AAAA,GAAA,EAC3D,CAAA;AAEJ","file":"DeliveryStoreSettings-L2RXOVB6.js","sourcesContent":["import React from 'react'\nimport { SettingsGroup, TextRow, useSettingKeys } from '@fayz-ai/admin'\nimport { useActiveUnitId } from '@fayz-ai/core'\nimport { Input } from '@fayz-ai/ui'\nimport type { ShopProviderResolver } from '../data/shared'\nimport { useStoreSettings } from './useStoreSettings'\nimport { ShippingSettings } from './ShippingSettings'\n\n/**\n * What a delivery store sets for its SITE, inside Configurações › Delivery.\n *\n * plugin-orders owns that screen (it also lists the marketplaces), but every\n * number here is the shop's: the fee and free delivery are the same\n * plg_shop_shipping_settings the storefront quote charges from, the regions are\n * the shop's zones, and the minimum and the estimate are plg_shop_settings\n * (0130). Registered as `shop.delivery-settings` so the orders plugin can draw\n * it without importing the shop — the same seam as `orders.detail`.\n *\n * Before this the Delivery screen saved its own copies in tenants.settings,\n * badged «Em breve», and the site never read them.\n */\n\nfunction parseNumber(raw: string): number | null {\n const clean = raw.replace(/[^\\d,.-]/g, '').replace(',', '.')\n if (!clean.trim()) return null\n const n = Number(clean)\n return Number.isFinite(n) && n >= 0 ? n : NaN\n}\n\nconst text = (v: number | null | undefined) => (v == null ? '' : String(v).replace('.', ','))\n\nfunction NumberRow({ label, description, hint, value, onCommit, placeholder, integer }: {\n label: string\n description: string\n hint?: string\n value: number | null | undefined\n onCommit: (next: number | null) => void\n placeholder?: string\n integer?: boolean\n}) {\n const [draft, setDraft] = React.useState(() => text(value))\n const [invalid, setInvalid] = React.useState(false)\n React.useEffect(() => { setDraft(text(value)) }, [value])\n return (\n <TextRow\n label={label}\n description={description}\n value={draft}\n onChange={(next) => { setDraft(next); setInvalid(false) }}\n onBlurCommit={() => {\n const parsed = parseNumber(draft)\n if (Number.isNaN(parsed)) { setInvalid(true); return }\n setInvalid(false)\n onCommit(parsed == null ? null : integer ? Math.round(parsed) : Math.round(parsed * 100) / 100)\n }}\n invalid={invalid}\n hint={invalid ? 'Use um número, como 9,90.' : hint}\n placeholder={placeholder}\n />\n )\n}\n\n/**\n * The estimate in the unit the store thinks in. A delivery promised for the\n * next day is typed as 24 h, not 1440 min; it is always STORED in minutes.\n */\nfunction EtaRow({ minutes, onCommit }: { minutes: number | null | undefined; onCommit: (next: number | null) => void }) {\n const [unit, setUnit] = React.useState<'min' | 'h'>(() => (minutes != null && minutes >= 60 && minutes % 60 === 0 ? 'h' : 'min'))\n const shown = (m: number | null | undefined, u: 'min' | 'h') => (m == null ? '' : u === 'h' ? String(+(m / 60).toFixed(2)).replace('.', ',') : String(m))\n const [draft, setDraft] = React.useState(() => shown(minutes, unit))\n const [invalid, setInvalid] = React.useState(false)\n React.useEffect(() => { setDraft(shown(minutes, unit)) }, [minutes, unit])\n\n const commit = (raw: string, u: 'min' | 'h') => {\n const parsed = parseNumber(raw)\n if (Number.isNaN(parsed)) { setInvalid(true); return }\n setInvalid(false)\n onCommit(parsed == null || parsed === 0 ? null : Math.round(u === 'h' ? parsed * 60 : parsed))\n }\n\n return (\n <div className=\"py-3\">\n <p className=\"text-sm font-medium\">Tempo estimado</p>\n <p className=\"mt-0.5 text-xs text-muted-foreground\">\n Da confirmação até a porta. Aparece no topo do cardápio e no aviso de pedido aceito — de 24 h em diante, como «até 24 h».\n </p>\n <div className=\"mt-2 flex max-w-xs items-center gap-2\">\n <Input\n value={draft}\n placeholder=\"Não informar\"\n aria-invalid={invalid || undefined}\n aria-label=\"Tempo estimado\"\n onChange={(e) => { setDraft(e.target.value); setInvalid(false) }}\n onBlur={() => commit(draft, unit)}\n onKeyDown={(e) => { if (e.key === 'Enter') commit(draft, unit) }}\n data-testid=\"delivery-eta-value\"\n />\n <div role=\"radiogroup\" aria-label=\"Unidade\" className=\"flex shrink-0 rounded-md border p-0.5 text-xs\">\n {(['min', 'h'] as const).map((u) => (\n <button\n key={u}\n type=\"button\"\n role=\"radio\"\n aria-checked={unit === u}\n data-testid={`delivery-eta-unit-${u}`}\n onClick={() => { if (u !== unit) { setUnit(u); setDraft(shown(minutes, u)) } }}\n className={`rounded px-2.5 py-1 ${unit === u ? 'bg-primary text-primary-foreground' : 'text-muted-foreground hover:bg-muted'}`}\n >\n {u === 'min' ? 'minutos' : 'horas'}\n </button>\n ))}\n </div>\n </div>\n <p className={`mt-1 text-xs ${invalid ? 'text-destructive' : 'text-muted-foreground'}`}>\n {invalid ? 'Use um número, como 45 ou 1,5.' : 'Vazio = não mostrar.'}\n </p>\n </div>\n )\n}\n\n/**\n * Where the top bar's «Delivery» chip (control-app resto-toggles) stands:\n * `delivery.enabled` at the active unit (or the house), unset reading as open.\n * Read-only on purpose — the chip is the one switch. useSettingKeys keeps every\n * reader of the key in step, so this line moves when the chip is flipped. Off,\n * the site shows delivery closed and refuses orders (shop 0131).\n */\nfunction DeliverySwitchStatus() {\n const unitId = useActiveUnitId()\n const s = useSettingKeys(['delivery.enabled'], unitId ?? null)\n if (!s.supported || s.loading || s.loadError) return null\n const open = s.values['delivery.enabled'] !== false\n return (\n <p data-testid=\"delivery-switch-status\" className=\"flex items-center gap-2 py-3 text-sm\">\n <span className={`h-2 w-2 shrink-0 rounded-full ${open ? 'bg-emerald-500' : 'bg-amber-500'}`} aria-hidden />\n {open\n ? <span><span className=\"font-medium\">Delivery aberto agora</span><span className=\"text-muted-foreground\"> · pause pela chave Delivery no topo</span></span>\n : <span><span className=\"font-medium\">Delivery pausado</span><span className=\"text-muted-foreground\"> · o site mostra fechado</span></span>}\n </p>\n )\n}\n\nexport function DeliveryStoreSettings({ provider }: { provider?: ShopProviderResolver }) {\n const settings = useStoreSettings(provider)\n const { value, set } = settings\n\n return (\n <div className=\"space-y-4\" data-testid=\"delivery-store-settings\">\n <SettingsGroup\n title=\"Pedidos do site\"\n description=\"O delivery do site abre e pausa pela chave Delivery no topo do sistema.\"\n >\n <DeliverySwitchStatus />\n </SettingsGroup>\n\n <SettingsGroup\n title=\"Pedido mínimo e tempo\"\n description=\"O que o site exige e promete em cada pedido de delivery.\"\n >\n <NumberRow\n label=\"Pedido mínimo\"\n description=\"Valor dos itens abaixo do qual o site não fecha o pedido.\"\n hint=\"Vazio ou zero = sem mínimo.\"\n value={value.minOrderTotal}\n placeholder=\"Sem mínimo\"\n onCommit={(next) => set({ minOrderTotal: next ?? null })}\n />\n <EtaRow minutes={value.deliveryEtaMinutes} onCommit={(next) => set({ deliveryEtaMinutes: next })} />\n </SettingsGroup>\n {settings.error && <p className=\"px-1 text-xs text-destructive\">Não foi possível salvar: {settings.error}</p>}\n\n {/* The fee, free delivery and the regions: the same component the\n e-commerce «Entrega» screen draws, in its delivery cut. */}\n <ShippingSettings provider={provider} variant=\"delivery\" />\n </div>\n )\n}\n"]}
|