@fayz-ai/plugin-shop 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Faya Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @fayz-ai/plugin-shop
2
+
3
+ > Drop a real storefront admin into any Fayz app — products, orders, customers, discounts.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@fayz-ai/plugin-shop.svg)](https://www.npmjs.com/package/@fayz-ai/plugin-shop)
6
+ [![license](https://img.shields.io/npm/l/@fayz-ai/plugin-shop.svg)](https://github.com/FayaLabs/fayz-sdk/blob/main/LICENSE)
7
+
8
+ Every vertical eventually wants to sell something. A salon sells retail product, a restaurant sells gift cards, a clinic sells packages. `plugin-shop` is the e-commerce admin surface that snaps into that need — a catalog, orders, customers, and discounts — without making you rebuild Shopify from scratch.
9
+
10
+ It builds on the `@fayz-ai/shop` engine, so the data layer is real and pluggable. Wire it to your own backend with a `provider`, scope it to the active organization automatically, and let the host AI assistant query your catalog and orders out of the box. The philosophy: commerce is a plugin, not a platform — compose it alongside inventory, orders, and menu to make a real SaaS.
11
+
12
+ ## What's inside
13
+ - **Navigation + page** — a `/shop` admin surface (products, orders, customers, discounts) rendered with `@fayz-ai/ui` data tables
14
+ - **Pluggable data** — inject a `ShopProvider` via `provider`, or fall back to the SDK runtime scoped to the active org
15
+ - **AI tools** — `listProducts` (filter by name/status) and `listOrders` (filter by financial/fulfillment status), with built-in prompt suggestions
16
+ - **Settings tab** — a Shop settings panel showing configured currency
17
+ - **Re-exported domain types** — `Product`, `Order`, `ShopCustomer`, `Discount`, `Category`, and their input types, so you only depend on this package
18
+
19
+ ## Install
20
+ ```bash
21
+ npm install @fayz-ai/plugin-shop
22
+ ```
23
+ Peer deps: `@fayz-ai/core`, `@fayz-ai/ui`, `@fayz-ai/saas`, `@fayz-ai/shop` (+ react, react-dom).
24
+
25
+ ## Usage
26
+ ```tsx
27
+ import { defineSaas } from '@fayz-ai/saas'
28
+ import { createShopPlugin } from '@fayz-ai/plugin-shop'
29
+
30
+ export const app = defineSaas({
31
+ // ...
32
+ plugins: [
33
+ createShopPlugin({
34
+ navLabel: 'Store',
35
+ currency: { code: 'BRL', locale: 'pt-BR', symbol: 'R$' },
36
+ // provider: myShopProvider, // optional — wire your own data access
37
+ }),
38
+ ],
39
+ })
40
+ ```
41
+
42
+ Options: `navPosition`, `navSection`, `navLabel`, `scope`, `verticalId`, `currency`, `provider`.
43
+
44
+ ## Part of the Fayz SDK
45
+ A composable plugin for the Fayz SDK. Pairs naturally with `@fayz-ai/plugin-orders`, `@fayz-ai/plugin-inventory`, and `@fayz-ai/plugin-menu` to build a full order-to-cash storefront.
46
+
47
+ ## Roadmap & contributing
48
+ Built and evolving in the open. See the [Fayz SDK roadmap](../../docs/ROADMAP.md#plugin-shop) for current gaps, missing features, and good first issues.
@@ -0,0 +1,271 @@
1
+ import { useState, useCallback, useEffect, useMemo } from 'react';
2
+ import { DataTable } from '@fayz-ai/ui';
3
+ import { getShopProvider } from '@fayz-ai/shop';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ // src/ShopPage.tsx
7
+ function currency(value, code = "BRL", locale = "pt-BR") {
8
+ return new Intl.NumberFormat(locale, { style: "currency", currency: code }).format(value);
9
+ }
10
+ function badge(label, color) {
11
+ return /* @__PURE__ */ jsx("span", { className: `inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${color}`, children: label });
12
+ }
13
+ var statusColors = {
14
+ active: "bg-emerald-100 text-emerald-800",
15
+ draft: "bg-gray-100 text-gray-700",
16
+ archived: "bg-orange-100 text-orange-700",
17
+ open: "bg-blue-100 text-blue-800",
18
+ cancelled: "bg-red-100 text-red-700",
19
+ paid: "bg-emerald-100 text-emerald-800",
20
+ pending: "bg-yellow-100 text-yellow-800",
21
+ fulfilled: "bg-emerald-100 text-emerald-800",
22
+ unfulfilled: "bg-gray-100 text-gray-700",
23
+ "partially_fulfilled": "bg-blue-100 text-blue-800"
24
+ };
25
+ function resolveShopProvider(provider) {
26
+ return typeof provider === "function" ? provider() : provider ?? getShopProvider();
27
+ }
28
+ function ProductsTab({ provider }) {
29
+ const [products, setProducts] = useState([]);
30
+ const [loading, setLoading] = useState(true);
31
+ const [search, setSearch] = useState("");
32
+ const load = useCallback(async (opts) => {
33
+ setLoading(true);
34
+ try {
35
+ const data = await resolveShopProvider(provider).listProducts(opts);
36
+ setProducts(data);
37
+ } finally {
38
+ setLoading(false);
39
+ }
40
+ }, [provider]);
41
+ useEffect(() => {
42
+ load();
43
+ }, [load]);
44
+ const handleSearch = (e) => {
45
+ const q = e.target.value;
46
+ setSearch(q);
47
+ load(q ? { search: q } : void 0);
48
+ };
49
+ const columns = useMemo(() => [
50
+ { accessorKey: "name", header: "Produto", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: getValue() }) },
51
+ { accessorKey: "sku", header: "SKU", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: getValue() ?? "\u2014" }) },
52
+ {
53
+ accessorKey: "price",
54
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Pre\xE7o" }),
55
+ cell: ({ getValue, row }) => /* @__PURE__ */ jsx("div", { className: "text-right", children: currency(getValue(), row.original.currency) })
56
+ },
57
+ {
58
+ accessorKey: "inventoryCount",
59
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Estoque" }),
60
+ cell: ({ getValue }) => {
61
+ const count = getValue();
62
+ return /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsx("span", { className: count === 0 ? "text-red-600 font-medium" : "", children: count }) });
63
+ }
64
+ },
65
+ {
66
+ accessorKey: "status",
67
+ header: "Status",
68
+ cell: ({ getValue }) => {
69
+ const status = getValue();
70
+ return badge(status, statusColors[status] ?? "bg-gray-100 text-gray-700");
71
+ }
72
+ }
73
+ ], []);
74
+ return /* @__PURE__ */ jsxs("div", { children: [
75
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4", children: [
76
+ /* @__PURE__ */ jsx(
77
+ "input",
78
+ {
79
+ type: "search",
80
+ value: search,
81
+ onChange: handleSearch,
82
+ placeholder: "Buscar produtos...",
83
+ className: "border rounded-lg px-3 py-2 text-sm w-64 focus:outline-none focus:ring-2 focus:ring-primary/50"
84
+ }
85
+ ),
86
+ /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
87
+ products.length,
88
+ " produtos"
89
+ ] })
90
+ ] }),
91
+ loading ? /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-muted-foreground", children: "Carregando..." }) : /* @__PURE__ */ jsx(
92
+ DataTable,
93
+ {
94
+ columns,
95
+ data: products,
96
+ variant: "card",
97
+ emptyMessage: "Nenhum produto encontrado."
98
+ }
99
+ )
100
+ ] });
101
+ }
102
+ function OrdersTab({ provider }) {
103
+ const [orders, setOrders] = useState([]);
104
+ const [loading, setLoading] = useState(true);
105
+ useEffect(() => {
106
+ resolveShopProvider(provider).listOrders({ limit: 50 }).then(setOrders).finally(() => setLoading(false));
107
+ }, [provider]);
108
+ const columns = useMemo(() => [
109
+ { accessorKey: "orderNumber", header: "Pedido", cell: ({ getValue }) => /* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
110
+ "#",
111
+ getValue()
112
+ ] }) },
113
+ {
114
+ id: "customer",
115
+ accessorFn: (o) => o.customerName ?? o.customerEmail ?? "\u2014",
116
+ header: "Cliente",
117
+ cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { children: getValue() })
118
+ },
119
+ {
120
+ accessorKey: "total",
121
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Total" }),
122
+ cell: ({ getValue, row }) => /* @__PURE__ */ jsx("div", { className: "text-right font-medium", children: currency(getValue(), row.original.currency) })
123
+ },
124
+ {
125
+ accessorKey: "financialStatus",
126
+ header: "Pagamento",
127
+ cell: ({ getValue }) => {
128
+ const status = getValue();
129
+ return badge(status, statusColors[status] ?? "bg-gray-100 text-gray-700");
130
+ }
131
+ },
132
+ {
133
+ accessorKey: "fulfillmentStatus",
134
+ header: "Entrega",
135
+ cell: ({ getValue }) => {
136
+ const status = getValue();
137
+ return badge(status, statusColors[status] ?? "bg-gray-100 text-gray-700");
138
+ }
139
+ },
140
+ {
141
+ accessorKey: "createdAt",
142
+ header: "Data",
143
+ cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: new Date(getValue()).toLocaleDateString("pt-BR") })
144
+ }
145
+ ], []);
146
+ return /* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-muted-foreground", children: "Carregando..." }) : /* @__PURE__ */ jsx(
147
+ DataTable,
148
+ {
149
+ columns,
150
+ data: orders,
151
+ variant: "card",
152
+ emptyMessage: "Nenhum pedido ainda."
153
+ }
154
+ ) });
155
+ }
156
+ function CustomersTab({ provider }) {
157
+ const [customers, setCustomers] = useState([]);
158
+ const [loading, setLoading] = useState(true);
159
+ useEffect(() => {
160
+ resolveShopProvider(provider).listCustomers({ limit: 50 }).then(setCustomers).finally(() => setLoading(false));
161
+ }, [provider]);
162
+ const columns = useMemo(() => [
163
+ {
164
+ id: "name",
165
+ accessorFn: (c) => `${c.firstName} ${c.lastName}`,
166
+ header: "Nome",
167
+ cell: ({ row }) => /* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
168
+ row.original.firstName,
169
+ " ",
170
+ row.original.lastName
171
+ ] })
172
+ },
173
+ { accessorKey: "email", header: "Email", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: getValue() ?? "\u2014" }) },
174
+ { accessorKey: "phone", header: "Telefone", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: getValue() ?? "\u2014" }) },
175
+ {
176
+ accessorKey: "ordersCount",
177
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Pedidos" }),
178
+ cell: ({ getValue }) => /* @__PURE__ */ jsx("div", { className: "text-right", children: getValue() })
179
+ },
180
+ {
181
+ accessorKey: "totalSpent",
182
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Total Gasto" }),
183
+ cell: ({ getValue }) => /* @__PURE__ */ jsx("div", { className: "text-right", children: currency(getValue()) })
184
+ }
185
+ ], []);
186
+ return /* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-muted-foreground", children: "Carregando..." }) : /* @__PURE__ */ jsx(
187
+ DataTable,
188
+ {
189
+ columns,
190
+ data: customers,
191
+ variant: "card",
192
+ emptyMessage: "Nenhum cliente ainda."
193
+ }
194
+ ) });
195
+ }
196
+ function DiscountsTab({ provider }) {
197
+ const [discounts, setDiscounts] = useState([]);
198
+ const [loading, setLoading] = useState(true);
199
+ useEffect(() => {
200
+ resolveShopProvider(provider).listDiscounts({ limit: 50 }).then(setDiscounts).finally(() => setLoading(false));
201
+ }, [provider]);
202
+ const columns = useMemo(() => [
203
+ { accessorKey: "title", header: "T\xEDtulo", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: getValue() }) },
204
+ { accessorKey: "code", header: "C\xF3digo", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-sm", children: getValue() ?? "\u2014" }) },
205
+ { accessorKey: "type", header: "Tipo", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: getValue() }) },
206
+ {
207
+ accessorKey: "value",
208
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Valor" }),
209
+ cell: ({ row }) => /* @__PURE__ */ jsx("div", { className: "text-right", children: row.original.type === "percentage" ? `${row.original.value}%` : currency(row.original.value) })
210
+ },
211
+ {
212
+ id: "usos",
213
+ accessorKey: "timesUsed",
214
+ header: () => /* @__PURE__ */ jsx("span", { className: "block text-right", children: "Usos" }),
215
+ cell: ({ row }) => /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
216
+ row.original.timesUsed,
217
+ row.original.usageLimit ? ` / ${row.original.usageLimit}` : ""
218
+ ] })
219
+ },
220
+ {
221
+ accessorKey: "status",
222
+ header: "Status",
223
+ cell: ({ getValue }) => {
224
+ const status = getValue();
225
+ return badge(status, statusColors[status] ?? "bg-gray-100 text-gray-700");
226
+ }
227
+ }
228
+ ], []);
229
+ return /* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx("div", { className: "py-12 text-center text-sm text-muted-foreground", children: "Carregando..." }) : /* @__PURE__ */ jsx(
230
+ DataTable,
231
+ {
232
+ columns,
233
+ data: discounts,
234
+ variant: "card",
235
+ emptyMessage: "Nenhum desconto cadastrado."
236
+ }
237
+ ) });
238
+ }
239
+ var TABS = [
240
+ { id: "products", label: "Produtos" },
241
+ { id: "orders", label: "Pedidos" },
242
+ { id: "customers", label: "Clientes" },
243
+ { id: "discounts", label: "Descontos" }
244
+ ];
245
+ var ShopPage = ({ provider }) => {
246
+ const [tab, setTab] = useState("products");
247
+ return /* @__PURE__ */ jsxs("div", { className: "p-6 max-w-7xl mx-auto", children: [
248
+ /* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
249
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold", children: "Loja" }),
250
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1", children: "Gerencie produtos, pedidos, clientes e descontos." })
251
+ ] }),
252
+ /* @__PURE__ */ jsx("div", { className: "border-b mb-6", children: /* @__PURE__ */ jsx("nav", { className: "flex gap-1", children: TABS.map((t) => /* @__PURE__ */ jsx(
253
+ "button",
254
+ {
255
+ onClick: () => setTab(t.id),
256
+ 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"}`,
257
+ children: t.label
258
+ },
259
+ t.id
260
+ )) }) }),
261
+ tab === "products" && /* @__PURE__ */ jsx(ProductsTab, { provider }),
262
+ tab === "orders" && /* @__PURE__ */ jsx(OrdersTab, { provider }),
263
+ tab === "customers" && /* @__PURE__ */ jsx(CustomersTab, { provider }),
264
+ tab === "discounts" && /* @__PURE__ */ jsx(DiscountsTab, { provider })
265
+ ] });
266
+ };
267
+ ShopPage.displayName = "ShopPage";
268
+
269
+ export { ShopPage };
270
+ //# sourceMappingURL=ShopPage-65PPVKBD.js.map
271
+ //# sourceMappingURL=ShopPage-65PPVKBD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ShopPage.tsx"],"names":[],"mappings":";;;;;;AAgBA,SAAS,QAAA,CAAS,KAAA,EAAe,IAAA,GAAO,KAAA,EAAO,SAAS,OAAA,EAAS;AAC/D,EAAA,OAAO,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,EAAQ,EAAE,KAAA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AA,2DAAA,EACT,GAAA,KAAQ,CAAA,CAAE,EAAA,GACN,gCACA,gEACN,CAAA,CAAA;AAAA,QAEC,QAAA,EAAA,CAAA,CAAE;AAAA,OAAA;AAAA,MARE,CAAA,CAAE;AAAA,KAUV,GACH,CAAA,EACF,CAAA;AAAA,IAEC,GAAA,KAAQ,UAAA,oBAAe,GAAA,CAAC,WAAA,EAAA,EAAY,QAAA,EAAoB,CAAA;AAAA,IACxD,GAAA,KAAQ,QAAA,oBAAe,GAAA,CAAC,SAAA,EAAA,EAAU,QAAA,EAAoB,CAAA;AAAA,IACtD,GAAA,KAAQ,WAAA,oBAAe,GAAA,CAAC,YAAA,EAAA,EAAa,QAAA,EAAoB,CAAA;AAAA,IACzD,GAAA,KAAQ,WAAA,oBAAe,GAAA,CAAC,YAAA,EAAA,EAAa,QAAA,EAAoB;AAAA,GAAA,EAC5D,CAAA;AAEJ;AAEA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"ShopPage-65PPVKBD.js","sourcesContent":["import React, { useEffect, useState, useCallback, useMemo } from 'react'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { DataTable } from '@fayz-ai/ui'\nimport { getShopProvider } from '@fayz-ai/shop'\nimport type { Product, Order, ShopCustomer, Discount, ListProductsOptions, ShopProvider } from '@fayz-ai/shop'\n\nexport type ShopProviderResolver = ShopProvider | (() => ShopProvider)\n\nexport interface ShopPageProps {\n provider?: ShopProviderResolver\n}\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\nfunction currency(value: number, code = 'BRL', locale = 'pt-BR') {\n return new Intl.NumberFormat(locale, { style: 'currency', currency: code }).format(value)\n}\n\nfunction badge(label: string, color: string) {\n return (\n <span className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${color}`}>\n {label}\n </span>\n )\n}\n\nconst statusColors: Record<string, string> = {\n active: 'bg-emerald-100 text-emerald-800',\n draft: 'bg-gray-100 text-gray-700',\n archived: 'bg-orange-100 text-orange-700',\n open: 'bg-blue-100 text-blue-800',\n cancelled: 'bg-red-100 text-red-700',\n paid: 'bg-emerald-100 text-emerald-800',\n pending: 'bg-yellow-100 text-yellow-800',\n fulfilled: 'bg-emerald-100 text-emerald-800',\n unfulfilled: 'bg-gray-100 text-gray-700',\n 'partially_fulfilled': 'bg-blue-100 text-blue-800',\n}\n\nfunction resolveShopProvider(provider?: ShopProviderResolver): ShopProvider {\n return typeof provider === 'function' ? provider() : provider ?? getShopProvider()\n}\n\n// ---------------------------------------------------------------------------\n// Products tab\n// ---------------------------------------------------------------------------\n\nfunction ProductsTab({ provider }: ShopPageProps) {\n const [products, setProducts] = useState<Product[]>([])\n const [loading, setLoading] = useState(true)\n const [search, setSearch] = useState('')\n\n const load = useCallback(async (opts?: ListProductsOptions) => {\n setLoading(true)\n try {\n const data = await resolveShopProvider(provider).listProducts(opts)\n setProducts(data)\n } finally {\n setLoading(false)\n }\n }, [provider])\n\n useEffect(() => { load() }, [load])\n\n const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {\n const q = e.target.value\n setSearch(q)\n load(q ? { search: q } : undefined)\n }\n\n const columns = useMemo<ColumnDef<Product, any>[]>(() => [\n { accessorKey: 'name', header: 'Produto', cell: ({ getValue }) => <span className=\"font-medium\">{getValue() as string}</span> },\n { accessorKey: 'sku', header: 'SKU', cell: ({ getValue }) => <span className=\"text-muted-foreground\">{(getValue() as string | undefined) ?? '—'}</span> },\n {\n accessorKey: 'price', header: () => <span className=\"block text-right\">Preço</span>,\n cell: ({ getValue, row }) => <div className=\"text-right\">{currency(getValue() as number, row.original.currency)}</div>,\n },\n {\n accessorKey: 'inventoryCount', header: () => <span className=\"block text-right\">Estoque</span>,\n cell: ({ getValue }) => {\n const count = getValue() as number\n return <div className=\"text-right\"><span className={count === 0 ? 'text-red-600 font-medium' : ''}>{count}</span></div>\n },\n },\n {\n accessorKey: 'status', header: 'Status',\n cell: ({ getValue }) => {\n const status = getValue() as string\n return badge(status, statusColors[status] ?? 'bg-gray-100 text-gray-700')\n },\n },\n ], [])\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4\">\n <input\n type=\"search\" value={search} onChange={handleSearch}\n placeholder=\"Buscar produtos...\"\n className=\"border rounded-lg px-3 py-2 text-sm w-64 focus:outline-none focus:ring-2 focus:ring-primary/50\"\n />\n <span className=\"text-sm text-muted-foreground\">{products.length} produtos</span>\n </div>\n\n {loading ? (\n <div className=\"py-12 text-center text-sm text-muted-foreground\">Carregando...</div>\n ) : (\n <DataTable\n columns={columns}\n data={products}\n variant=\"card\"\n emptyMessage=\"Nenhum produto encontrado.\"\n />\n )}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Orders tab\n// ---------------------------------------------------------------------------\n\nfunction OrdersTab({ provider }: ShopPageProps) {\n const [orders, setOrders] = useState<Order[]>([])\n const [loading, setLoading] = useState(true)\n\n useEffect(() => {\n resolveShopProvider(provider).listOrders({ limit: 50 }).then(setOrders).finally(() => setLoading(false))\n }, [provider])\n\n const columns = useMemo<ColumnDef<Order, any>[]>(() => [\n { accessorKey: 'orderNumber', header: 'Pedido', cell: ({ getValue }) => <span className=\"font-medium\">#{getValue() as string}</span> },\n {\n id: 'customer', accessorFn: (o) => o.customerName ?? o.customerEmail ?? '—', header: 'Cliente',\n cell: ({ getValue }) => <span>{getValue() as string}</span>,\n },\n {\n accessorKey: 'total', header: () => <span className=\"block text-right\">Total</span>,\n cell: ({ getValue, row }) => <div className=\"text-right font-medium\">{currency(getValue() as number, row.original.currency)}</div>,\n },\n {\n accessorKey: 'financialStatus', header: 'Pagamento',\n cell: ({ getValue }) => {\n const status = getValue() as string\n return badge(status, statusColors[status] ?? 'bg-gray-100 text-gray-700')\n },\n },\n {\n accessorKey: 'fulfillmentStatus', header: 'Entrega',\n cell: ({ getValue }) => {\n const status = getValue() as string\n return badge(status, statusColors[status] ?? 'bg-gray-100 text-gray-700')\n },\n },\n {\n accessorKey: 'createdAt', header: 'Data',\n cell: ({ getValue }) => <span className=\"text-muted-foreground\">{new Date(getValue() as string).toLocaleDateString('pt-BR')}</span>,\n },\n ], [])\n\n return (\n <div>\n {loading ? (\n <div className=\"py-12 text-center text-sm text-muted-foreground\">Carregando...</div>\n ) : (\n <DataTable\n columns={columns}\n data={orders}\n variant=\"card\"\n emptyMessage=\"Nenhum pedido ainda.\"\n />\n )}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Customers tab\n// ---------------------------------------------------------------------------\n\nfunction CustomersTab({ provider }: ShopPageProps) {\n const [customers, setCustomers] = useState<ShopCustomer[]>([])\n const [loading, setLoading] = useState(true)\n\n useEffect(() => {\n resolveShopProvider(provider).listCustomers({ limit: 50 }).then(setCustomers).finally(() => setLoading(false))\n }, [provider])\n\n const columns = useMemo<ColumnDef<ShopCustomer, any>[]>(() => [\n {\n id: 'name', accessorFn: (c) => `${c.firstName} ${c.lastName}`, header: 'Nome',\n cell: ({ row }) => <span className=\"font-medium\">{row.original.firstName} {row.original.lastName}</span>,\n },\n { accessorKey: 'email', header: 'Email', cell: ({ getValue }) => <span className=\"text-muted-foreground\">{(getValue() as string | undefined) ?? '—'}</span> },\n { accessorKey: 'phone', header: 'Telefone', cell: ({ getValue }) => <span className=\"text-muted-foreground\">{(getValue() as string | undefined) ?? '—'}</span> },\n {\n accessorKey: 'ordersCount', header: () => <span className=\"block text-right\">Pedidos</span>,\n cell: ({ getValue }) => <div className=\"text-right\">{getValue() as number}</div>,\n },\n {\n accessorKey: 'totalSpent', header: () => <span className=\"block text-right\">Total Gasto</span>,\n cell: ({ getValue }) => <div className=\"text-right\">{currency(getValue() as number)}</div>,\n },\n ], [])\n\n return (\n <div>\n {loading ? (\n <div className=\"py-12 text-center text-sm text-muted-foreground\">Carregando...</div>\n ) : (\n <DataTable\n columns={columns}\n data={customers}\n variant=\"card\"\n emptyMessage=\"Nenhum cliente ainda.\"\n />\n )}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Discounts tab\n// ---------------------------------------------------------------------------\n\nfunction DiscountsTab({ provider }: ShopPageProps) {\n const [discounts, setDiscounts] = useState<Discount[]>([])\n const [loading, setLoading] = useState(true)\n\n useEffect(() => {\n resolveShopProvider(provider).listDiscounts({ limit: 50 }).then(setDiscounts).finally(() => setLoading(false))\n }, [provider])\n\n const columns = useMemo<ColumnDef<Discount, any>[]>(() => [\n { accessorKey: 'title', header: 'Título', cell: ({ getValue }) => <span className=\"font-medium\">{getValue() as string}</span> },\n { accessorKey: 'code', header: 'Código', cell: ({ getValue }) => <span className=\"font-mono text-sm\">{(getValue() as string | undefined) ?? '—'}</span> },\n { accessorKey: 'type', header: 'Tipo', cell: ({ getValue }) => <span className=\"text-muted-foreground\">{getValue() as string}</span> },\n {\n accessorKey: 'value', header: () => <span className=\"block text-right\">Valor</span>,\n cell: ({ row }) => <div className=\"text-right\">{row.original.type === 'percentage' ? `${row.original.value}%` : currency(row.original.value)}</div>,\n },\n {\n id: 'usos', accessorKey: 'timesUsed', header: () => <span className=\"block text-right\">Usos</span>,\n cell: ({ row }) => <div className=\"text-right\">{row.original.timesUsed}{row.original.usageLimit ? ` / ${row.original.usageLimit}` : ''}</div>,\n },\n {\n accessorKey: 'status', header: 'Status',\n cell: ({ getValue }) => {\n const status = getValue() as string\n return badge(status, statusColors[status] ?? 'bg-gray-100 text-gray-700')\n },\n },\n ], [])\n\n return (\n <div>\n {loading ? (\n <div className=\"py-12 text-center text-sm text-muted-foreground\">Carregando...</div>\n ) : (\n <DataTable\n columns={columns}\n data={discounts}\n variant=\"card\"\n emptyMessage=\"Nenhum desconto cadastrado.\"\n />\n )}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Main page\n// ---------------------------------------------------------------------------\n\nconst TABS = [\n { id: 'products', label: 'Produtos' },\n { id: 'orders', label: 'Pedidos' },\n { id: 'customers', label: 'Clientes' },\n { id: 'discounts', label: 'Descontos' },\n] as const\n\ntype TabId = typeof TABS[number]['id']\n\nexport const ShopPage: React.FC<ShopPageProps> = ({ provider }) => {\n const [tab, setTab] = useState<TabId>('products')\n\n return (\n <div className=\"p-6 max-w-7xl mx-auto\">\n <div className=\"mb-6\">\n <h1 className=\"text-2xl font-semibold\">Loja</h1>\n <p className=\"text-muted-foreground mt-1\">Gerencie produtos, pedidos, clientes e descontos.</p>\n </div>\n\n {/* Tabs */}\n <div className=\"border-b mb-6\">\n <nav className=\"flex gap-1\">\n {TABS.map(t => (\n <button\n key={t.id}\n onClick={() => setTab(t.id)}\n className={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${\n tab === t.id\n ? 'border-primary text-primary'\n : 'border-transparent text-muted-foreground hover:text-foreground'\n }`}\n >\n {t.label}\n </button>\n ))}\n </nav>\n </div>\n\n {tab === 'products' && <ProductsTab provider={provider} />}\n {tab === 'orders' && <OrdersTab provider={provider} />}\n {tab === 'customers' && <CustomersTab provider={provider} />}\n {tab === 'discounts' && <DiscountsTab provider={provider} />}\n </div>\n )\n}\n\nShopPage.displayName = 'ShopPage'\n"]}