@fayz-ai/plugin-shop 0.24.14 → 0.25.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/ProductListingTab-7DBLFDBH.js +4 -0
- package/dist/{ProductListingTab-55Y5RXU7.js.map → ProductListingTab-7DBLFDBH.js.map} +1 -1
- package/dist/{chunk-53Y6VLAW.js → chunk-IECL5S7D.js} +36 -3
- package/dist/chunk-IECL5S7D.js.map +1 -0
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/views/ProductListingTab.d.ts.map +1 -1
- package/dist/views/productEntity.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/ProductListingTab-55Y5RXU7.js +0 -4
- package/dist/chunk-53Y6VLAW.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ProductListingTab-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ProductListingTab-7DBLFDBH.js"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorMessage } from './chunk-2MXOKJQO.js';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
|
-
import { Skeleton, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Button, Badge } from '@fayz-ai/ui';
|
|
3
|
+
import { Skeleton, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Button, Badge, Switch } from '@fayz-ai/ui';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
var NO_CATEGORY = "__none__";
|
|
@@ -16,6 +16,7 @@ function ProductListingTab({ item, getProvider }) {
|
|
|
16
16
|
const [categories, setCategories] = useState([]);
|
|
17
17
|
const [categoryId, setCategoryId] = useState(NO_CATEGORY);
|
|
18
18
|
const [busy, setBusy] = useState(false);
|
|
19
|
+
const [featuring, setFeaturing] = useState(false);
|
|
19
20
|
const [error, setError] = useState(null);
|
|
20
21
|
useEffect(() => {
|
|
21
22
|
if (!catalogId) {
|
|
@@ -77,6 +78,21 @@ function ProductListingTab({ item, getProvider }) {
|
|
|
77
78
|
setError(errorMessage(err));
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
async function changeFeatured(next) {
|
|
82
|
+
if (!listing) return;
|
|
83
|
+
const previous = listing;
|
|
84
|
+
setListing({ ...listing, isFeatured: next });
|
|
85
|
+
setFeaturing(true);
|
|
86
|
+
setError(null);
|
|
87
|
+
try {
|
|
88
|
+
setListing(await getProvider().updateProduct(listing.id, { isFeatured: next }));
|
|
89
|
+
} catch (err) {
|
|
90
|
+
setListing(previous);
|
|
91
|
+
setError(errorMessage(err));
|
|
92
|
+
} finally {
|
|
93
|
+
setFeaturing(false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
80
96
|
if (listing === void 0) {
|
|
81
97
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", "aria-busy": "true", children: [
|
|
82
98
|
/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-48" }),
|
|
@@ -123,10 +139,27 @@ function ProductListingTab({ item, getProvider }) {
|
|
|
123
139
|
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: "Nome, pre\xE7o e descri\xE7\xE3o v\xEAm deste cadastro. Para tirar o produto da loja, desative-o no cadastro; ativ\xE1-lo de novo o devolve \xE0 venda. Fotos ficam na aba Conte\xFAdo." })
|
|
124
140
|
] }),
|
|
125
141
|
categoryPicker,
|
|
142
|
+
/* @__PURE__ */ jsxs("label", { className: "flex max-w-xl cursor-pointer items-start justify-between gap-4 rounded-lg border px-3 py-2.5", children: [
|
|
143
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
144
|
+
/* @__PURE__ */ jsx("span", { className: "block text-sm", children: "Destaque no site" }),
|
|
145
|
+
/* @__PURE__ */ jsx("span", { className: "block text-[11px] leading-snug text-muted-foreground", children: listing.status === "active" ? "Aparece em \xABDestaques\xBB, no topo do card\xE1pio do site, na ordem da loja." : "Fora da venda n\xE3o aparece em \xABDestaques\xBB \u2014 ative o produto para ele aparecer." })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ jsx(
|
|
148
|
+
Switch,
|
|
149
|
+
{
|
|
150
|
+
checked: listing.isFeatured === true,
|
|
151
|
+
disabled: featuring,
|
|
152
|
+
onCheckedChange: (v) => {
|
|
153
|
+
void changeFeatured(v);
|
|
154
|
+
},
|
|
155
|
+
"aria-label": "Destaque no site"
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
] }),
|
|
126
159
|
error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error })
|
|
127
160
|
] });
|
|
128
161
|
}
|
|
129
162
|
|
|
130
163
|
export { ProductListingTab };
|
|
131
|
-
//# sourceMappingURL=chunk-
|
|
132
|
-
//# sourceMappingURL=chunk-
|
|
164
|
+
//# sourceMappingURL=chunk-IECL5S7D.js.map
|
|
165
|
+
//# sourceMappingURL=chunk-IECL5S7D.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/views/ProductListingTab.tsx"],"names":[],"mappings":";;;;;AAKA,IAAM,WAAA,GAAc,UAAA;AAapB,IAAM,YAAA,GAAgG;AAAA,EACpG,MAAA,EAAQ,EAAE,KAAA,EAAO,oBAAA,EAAmB,SAAS,SAAA,EAAU;AAAA,EACvD,KAAA,EAAO,EAAE,KAAA,EAAO,UAAA,EAAY,SAAS,WAAA,EAAY;AAAA,EACjD,QAAA,EAAU,EAAE,KAAA,EAAO,cAAA,EAAgB,SAAS,SAAA;AAC9C,CAAA;AAeO,SAAS,iBAAA,CAAkB,EAAE,IAAA,EAAM,WAAA,EAAY,EAGnD;AACD,EAAA,MAAM,OAAA,GAAW,QAAQ,EAAC;AAC1B,EAAA,MAAM,YAAY,OAAA,CAAQ,EAAA;AAC1B,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAqC,MAAS,CAAA;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U,sCAAA,EAAuC,QAAA,EAAA,yLAAA,EAGpD;AAAA,KAAA,EACF,CAAA;AAAA,IACC,cAAA;AAAA,oBAGD,IAAA,CAAC,OAAA,EAAA,EAAM,SAAA,EAAU,8FAAA,EACf,QAAA,EAAA;AAAA,sBAAA,IAAA,CAAC,MAAA,EAAA,EAAK,WAAU,SAAA,EACd,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,eAAA,EAAgB,QAAA,EAAA,kBAAA,EAAgB,CAAA;AAAA,wBAChD,GAAA,CAAC,UAAK,SAAA,EAAU,sDAAA,EACb,kBAAQ,MAAA,KAAW,QAAA,GAChB,oFACA,6FAAA,EACN;AAAA,OAAA,EACF,CAAA;AAAA,sBACA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,OAAA,EAAS,QAAQ,UAAA,KAAe,IAAA;AAAA,UAChC,QAAA,EAAU,SAAA;AAAA,UACV,eAAA,EAAiB,CAAC,CAAA,KAAM;AAAE,YAAA,KAAK,eAAe,CAAC,CAAA;AAAA,UAAE,CAAA;AAAA,UACjD,YAAA,EAAW;AAAA;AAAA;AACb,KAAA,EACF,CAAA;AAAA,IACC,KAAA,oBAAS,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,4BAA4B,QAAA,EAAA,KAAA,EAAM;AAAA,GAAA,EAC3D,CAAA;AAEJ","file":"chunk-IECL5S7D.js","sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { Badge, Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Skeleton, Switch } from '@fayz-ai/ui'\nimport type { Category, Product, ShopProvider } from '@fayz-ai/shop'\nimport { errorMessage } from '../settings/error-message'\n\nconst NO_CATEGORY = '__none__'\n\n/** What the tab reads off the stock's product record. */\ninterface CatalogItem {\n id?: string\n name?: string\n description?: string | null\n sku?: string | null\n salePrice?: number | null\n price?: number | null\n isActive?: boolean\n}\n\nconst STATUS_LABEL: Record<string, { label: string; variant: 'success' | 'secondary' | 'outline' }> = {\n active: { label: 'À venda na loja', variant: 'success' },\n draft: { label: 'Rascunho', variant: 'secondary' },\n archived: { label: 'Fora da loja', variant: 'outline' },\n}\n\n/**\n * Loja — whether a CATALOGUE product is sold in the store, and the one thing\n * the listing owns that the record does not: its category in the store menu.\n *\n * Mounted on the product record of whichever plugin owns the catalogue (stock,\n * in the Control app), where the shop's own Produtos screen is off. Without it\n * a product created in the stock had no way into the store: the listing row\n * (`plg_shop_products`) was only ever born from the shop's screen.\n *\n * Name, price, SKU and description are NOT edited here: the database mirrors\n * them from the record both ways, and so does the status — the record's Ativo\n * switch is what takes a product out of the store and puts it back.\n */\nexport function ProductListingTab({ item, getProvider }: {\n item: unknown\n getProvider: () => ShopProvider\n}) {\n const catalog = (item ?? {}) as CatalogItem\n const catalogId = catalog.id\n const [listing, setListing] = useState<Product | null | undefined>(undefined)\n const [categories, setCategories] = useState<Category[]>([])\n const [categoryId, setCategoryId] = useState<string>(NO_CATEGORY)\n const [busy, setBusy] = useState(false)\n const [featuring, setFeaturing] = useState(false)\n const [error, setError] = useState<string | null>(null)\n\n useEffect(() => {\n if (!catalogId) { setListing(null); return }\n let alive = true\n setListing(undefined)\n const provider = getProvider()\n const lookup = provider.getProductByCatalogId\n ? provider.getProductByCatalogId(catalogId)\n : Promise.resolve(null)\n Promise.all([lookup, provider.listCategories().catch(() => [] as Category[])])\n .then(([found, cats]) => {\n if (!alive) return\n setListing(found)\n setCategories(cats)\n setCategoryId(found?.categoryId ?? NO_CATEGORY)\n })\n .catch((err: unknown) => { if (alive) { setListing(null); setError(errorMessage(err)) } })\n return () => { alive = false }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [catalogId])\n\n async function publish() {\n if (!catalogId || !catalog.name) return\n setBusy(true)\n setError(null)\n try {\n const created = await getProvider().createProduct({\n catalogProductId: catalogId,\n name: catalog.name,\n description: catalog.description ?? undefined,\n sku: catalog.sku ?? undefined,\n price: Number(catalog.salePrice ?? catalog.price ?? 0),\n // An inactive record goes in as a draft: listed, not sold, until the\n // record's Ativo switch is turned on.\n status: catalog.isActive === false ? 'draft' : 'active',\n categoryId: categoryId === NO_CATEGORY ? undefined : categoryId,\n })\n setListing(created)\n } catch (err) {\n setError(errorMessage(err))\n } finally {\n setBusy(false)\n }\n }\n\n async function changeCategory(next: string) {\n if (!listing) return\n const previous = categoryId\n setCategoryId(next)\n setError(null)\n try {\n const updated = await getProvider().updateProduct(listing.id, { categoryId: next === NO_CATEGORY ? null : next })\n setListing(updated)\n } catch (err) {\n setCategoryId(previous)\n setError(errorMessage(err))\n }\n }\n\n /** «Destaque no site» (shop 0136): the listing leads the storefront's\n * «Destaques», in the store's own order. Optimistic, reverted on failure. */\n async function changeFeatured(next: boolean) {\n if (!listing) return\n const previous = listing\n setListing({ ...listing, isFeatured: next })\n setFeaturing(true)\n setError(null)\n try {\n setListing(await getProvider().updateProduct(listing.id, { isFeatured: next }))\n } catch (err) {\n setListing(previous)\n setError(errorMessage(err))\n } finally {\n setFeaturing(false)\n }\n }\n\n if (listing === undefined) {\n return (\n <div className=\"space-y-3\" aria-busy=\"true\">\n <Skeleton className=\"h-5 w-48\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n )\n }\n\n const categoryPicker = (\n <div className=\"space-y-1.5\">\n <p className=\"text-xs font-medium text-muted-foreground\">Categoria na loja</p>\n <Select value={categoryId} onValueChange={(v) => { if (listing) void changeCategory(v); else setCategoryId(v) }}>\n <SelectTrigger className=\"w-72\"><SelectValue placeholder=\"Sem categoria\" /></SelectTrigger>\n <SelectContent>\n <SelectItem value={NO_CATEGORY}>Sem categoria</SelectItem>\n {categories.map((c) => <SelectItem key={c.id} value={c.id}>{c.name}</SelectItem>)}\n </SelectContent>\n </Select>\n </div>\n )\n\n if (!listing) {\n return (\n <div className=\"space-y-4\">\n <div>\n <h3 className=\"text-sm font-semibold\">Loja e delivery</h3>\n <p className=\"mt-0.5 text-xs text-muted-foreground\">\n Este produto ainda não está na loja. Ao colocar, ele aparece no site e no delivery com o nome, o preço e a\n descrição deste cadastro{catalog.isActive === false ? ' — como rascunho, até o produto ser ativado' : ''}.\n </p>\n </div>\n {categoryPicker}\n {error && <p className=\"text-sm text-destructive\">{error}</p>}\n <Button onClick={() => { void publish() }} disabled={busy || !catalog.name}>\n {busy ? 'Colocando…' : 'Colocar na loja'}\n </Button>\n </div>\n )\n }\n\n const status = STATUS_LABEL[listing.status] ?? { label: listing.status, variant: 'outline' as const }\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"flex items-center gap-2\">\n <h3 className=\"text-sm font-semibold\">Loja e delivery</h3>\n <Badge variant={status.variant}>{status.label}</Badge>\n </div>\n <p className=\"mt-0.5 text-xs text-muted-foreground\">\n Nome, preço e descrição vêm deste cadastro. Para tirar o produto da loja, desative-o no cadastro; ativá-lo de\n novo o devolve à venda. Fotos ficam na aba Conteúdo.\n </p>\n </div>\n {categoryPicker}\n {/* The store that runs its site from here chooses its «Destaques» here\n too: the Cardápio star only reaches products that have a menu item. */}\n <label className=\"flex max-w-xl cursor-pointer items-start justify-between gap-4 rounded-lg border px-3 py-2.5\">\n <span className=\"min-w-0\">\n <span className=\"block text-sm\">Destaque no site</span>\n <span className=\"block text-[11px] leading-snug text-muted-foreground\">\n {listing.status === 'active'\n ? 'Aparece em «Destaques», no topo do cardápio do site, na ordem da loja.'\n : 'Fora da venda não aparece em «Destaques» — ative o produto para ele aparecer.'}\n </span>\n </span>\n <Switch\n checked={listing.isFeatured === true}\n disabled={featuring}\n onCheckedChange={(v) => { void changeFeatured(v) }}\n aria-label=\"Destaque no site\"\n />\n </label>\n {error && <p className=\"text-sm text-destructive\">{error}</p>}\n </div>\n )\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { shippingRegistryPath } from './chunk-6V2VAUWP.js';
|
|
|
2
2
|
import { ProductImagesTab } from './chunk-JYT6BTRE.js';
|
|
3
3
|
export { ProductContentTab } from './chunk-JYT6BTRE.js';
|
|
4
4
|
export { ProductMarketPricesTab } from './chunk-MFEOIJI7.js';
|
|
5
|
-
export { ProductListingTab } from './chunk-
|
|
5
|
+
export { ProductListingTab } from './chunk-IECL5S7D.js';
|
|
6
6
|
import { shopCustomerLookup, resolveTerm, candidateMeta } from './chunk-TDV3SFXT.js';
|
|
7
7
|
import { PACKAGES_REGISTRY, SHIPPING_ZONES_REGISTRY, SHIPPING_PROFILES_REGISTRY, packageMeasureLabel, packagesRegistry } from './chunk-STZYH32S.js';
|
|
8
8
|
import { resolve, invalidateProductLists, listProductsDetailed, applyQuery, listProductsCached } from './chunk-YUG6XQHJ.js';
|
|
@@ -1921,6 +1921,16 @@ function buildShopProductEntity(currencyCode = "BRL", getProvider) {
|
|
|
1921
1921
|
hint: "Menor aparece primeiro.",
|
|
1922
1922
|
showInTable: false
|
|
1923
1923
|
},
|
|
1924
|
+
{
|
|
1925
|
+
// shop 0136: the storefront's «Destaques», in this same «Ordem na vitrine».
|
|
1926
|
+
key: "isFeatured",
|
|
1927
|
+
label: "Destaque no site",
|
|
1928
|
+
type: "boolean",
|
|
1929
|
+
group: "publishing",
|
|
1930
|
+
hint: "Aparece em \xABDestaques\xBB, no topo do card\xE1pio do site.",
|
|
1931
|
+
showInTable: false,
|
|
1932
|
+
defaultValue: false
|
|
1933
|
+
},
|
|
1924
1934
|
// — Busca (SEO) —
|
|
1925
1935
|
// A coleção já tinha estes dois; o produto — que é a página onde alguém
|
|
1926
1936
|
// CAI vindo do Google — não tinha nenhum, então cada página herdava o que
|
|
@@ -6538,7 +6548,7 @@ function shopProductMarketPricesTab(options) {
|
|
|
6538
6548
|
props: { getProvider: options.provider, settingsHref: options.settingsHref ?? "#/settings/shop-markets" }
|
|
6539
6549
|
};
|
|
6540
6550
|
}
|
|
6541
|
-
var ProductListingTabView = lazyComponent(() => import('./ProductListingTab-
|
|
6551
|
+
var ProductListingTabView = lazyComponent(() => import('./ProductListingTab-7DBLFDBH.js').then((m) => m.ProductListingTab));
|
|
6542
6552
|
var ContentPage = React.lazy(() => import('./ContentPage-2PHOZSFZ.js').then((m) => ({ default: m.ContentPage })));
|
|
6543
6553
|
var StoreGeneralSettings = lazyComponent(() => import('./StoreGeneralSettings-DEZ2CMVG.js').then((m) => m.StoreGeneralSettings));
|
|
6544
6554
|
var PaymentsSettings = lazyComponent(() => import('./PaymentsSettings-5CI74TY2.js').then((m) => m.PaymentsSettings));
|