@fayz-ai/plugin-shop 0.26.0 → 0.27.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/{ShopPage-7UKCFJKT.js → ShopPage-V3WMDTRY.js} +29 -11
- package/dist/ShopPage-V3WMDTRY.js.map +1 -0
- package/dist/data/sale-price-table.d.ts +8 -1
- package/dist/data/sale-price-table.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/views/NewOrderPage.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/ShopPage-7UKCFJKT.js.map +0 -1
|
@@ -2340,7 +2340,11 @@ async function quoteSaleUnitPrices(tableId, lines) {
|
|
|
2340
2340
|
});
|
|
2341
2341
|
if (error) throw new Error(error.message);
|
|
2342
2342
|
for (const row of data ?? []) {
|
|
2343
|
-
prices.set(saleLineKey(row.product_id, row.variant_id),
|
|
2343
|
+
prices.set(saleLineKey(row.product_id, row.variant_id), {
|
|
2344
|
+
price: Number(row.unit_price),
|
|
2345
|
+
inTable: row.in_table !== false,
|
|
2346
|
+
pending: row.price_pending === true
|
|
2347
|
+
});
|
|
2344
2348
|
}
|
|
2345
2349
|
return prices;
|
|
2346
2350
|
}
|
|
@@ -2669,17 +2673,20 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
|
|
|
2669
2673
|
priceTableId ? quoteSaleUnitPrices(null, wanted) : Promise.resolve(null)
|
|
2670
2674
|
]).then(([table, site]) => {
|
|
2671
2675
|
if (cancelled) return;
|
|
2676
|
+
const tableName = priceTables.find((pt) => pt.id === priceTableId)?.name;
|
|
2672
2677
|
setLines((current) => current.map((line) => {
|
|
2673
|
-
const
|
|
2674
|
-
|
|
2678
|
+
const quote = table.get(saleLineKey(line.itemId, line.variantId));
|
|
2679
|
+
if (!quote) return line;
|
|
2680
|
+
const notice = !tableName ? null : !quote.inTable ? `Fora da tabela ${tableName}: cobrando o pre\xE7o normal.` : quote.pending ? `Pre\xE7o da tabela ${tableName} ainda n\xE3o definido: cobrando o pre\xE7o normal.` : null;
|
|
2681
|
+
return quote.price === line.unitPrice && notice === (line.notice ?? null) ? line : { ...line, unitPrice: quote.price, notice };
|
|
2675
2682
|
}));
|
|
2676
|
-
setTablePriced(Boolean(site && [...table].some(([key,
|
|
2683
|
+
setTablePriced(Boolean(site && [...table].some(([key, quote]) => site.get(key)?.price !== quote.price)));
|
|
2677
2684
|
}).catch(() => {
|
|
2678
2685
|
});
|
|
2679
2686
|
return () => {
|
|
2680
2687
|
cancelled = true;
|
|
2681
2688
|
};
|
|
2682
|
-
}, [priceTableId, lineSignature]);
|
|
2689
|
+
}, [priceTableId, lineSignature, priceTables]);
|
|
2683
2690
|
const acquirer = settings?.paymentProvider ?? null;
|
|
2684
2691
|
const canCharge = Boolean(acquirer && CHARGEABLE_PROVIDERS.includes(acquirer));
|
|
2685
2692
|
const canLink = canCharge && supportsPaymentLink(acquirer);
|
|
@@ -2913,10 +2920,21 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
|
|
|
2913
2920
|
] });
|
|
2914
2921
|
const [fromCache, setFromCache] = useState(false);
|
|
2915
2922
|
const searchProducts = useCallback(async (term) => {
|
|
2916
|
-
const answer = await listProductsDetailed(provider, { search: term || void 0,
|
|
2923
|
+
const answer = await listProductsDetailed(provider, { search: term || void 0, limit: 50 });
|
|
2917
2924
|
setFromCache(Boolean(answer.cached || answer.stale));
|
|
2918
|
-
|
|
2919
|
-
|
|
2925
|
+
const rows = answer.rows.filter((product) => product.status !== "archived");
|
|
2926
|
+
if (!priceTableId || rows.length === 0) return rows.filter((product) => product.status === "active");
|
|
2927
|
+
try {
|
|
2928
|
+
const quotes = await quoteSaleUnitPrices(priceTableId, rows.map((product) => ({ productId: product.id })));
|
|
2929
|
+
return rows.flatMap((product) => {
|
|
2930
|
+
const quote = quotes.get(saleLineKey(product.id));
|
|
2931
|
+
if (!quote?.inTable) return [];
|
|
2932
|
+
return [{ ...product, price: quote.price }];
|
|
2933
|
+
});
|
|
2934
|
+
} catch {
|
|
2935
|
+
return rows.filter((product) => product.status === "active");
|
|
2936
|
+
}
|
|
2937
|
+
}, [provider, priceTableId]);
|
|
2920
2938
|
const totalRows = useMemo(() => [
|
|
2921
2939
|
{
|
|
2922
2940
|
key: "coupon",
|
|
@@ -3108,7 +3126,7 @@ function NewOrderPage({ provider, onDone, onCancel, orderId }) {
|
|
|
3108
3126
|
itemSearch: {
|
|
3109
3127
|
placeholder: "Buscar produto por nome ou SKU",
|
|
3110
3128
|
title: "Selecionar produtos",
|
|
3111
|
-
emptyLabel: "Nenhum produto encontrado.",
|
|
3129
|
+
emptyLabel: priceTableId ? "Nenhum produto desta tabela de pre\xE7o encontrado." : "Nenhum produto encontrado.",
|
|
3112
3130
|
columns: { product: "Produto", meta: "Estoque", value: "Pre\xE7o" },
|
|
3113
3131
|
// Same cache funnel as the products page: a catalogue the merchant just
|
|
3114
3132
|
// browsed answers the picker without a round-trip.
|
|
@@ -4442,5 +4460,5 @@ var ShopPage = ({ provider, section }) => {
|
|
|
4442
4460
|
ShopPage.displayName = "ShopPage";
|
|
4443
4461
|
|
|
4444
4462
|
export { ShopOrderDetailSlot, ShopPage };
|
|
4445
|
-
//# sourceMappingURL=ShopPage-
|
|
4446
|
-
//# sourceMappingURL=ShopPage-
|
|
4463
|
+
//# sourceMappingURL=ShopPage-V3WMDTRY.js.map
|
|
4464
|
+
//# sourceMappingURL=ShopPage-V3WMDTRY.js.map
|