@fayz-ai/plugin-shop 0.21.4 → 0.21.6
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,6 +1,6 @@
|
|
|
1
1
|
import { errorMessage, shopCustomerLookup, resolve, invalidateProductLists, listProductsDetailed, applyQuery, listProductsCached, resolveTerm, candidateMeta, SHIPPING_PROFILES_REGISTRY, packageMeasureLabel, PACKAGES_REGISTRY, packagesRegistry, SHIPPING_ZONES_REGISTRY, marketsRegistry, buildShopRegistries, locationSummary, LOCATIONS_REGISTRY } from './chunk-XV3KZRQX.js';
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as React14 from 'react';
|
|
3
|
+
import React14__default, { useState, useEffect, useMemo, useRef, useCallback } from 'react';
|
|
4
4
|
import { createConnectionStore, connectionSettings, connectionStatus, settingsStatus, connectionRuns, tl, getActiveTenantId, getSupabaseClientOptional, registerMessageDefaults, registerComponent, formatCurrency, connectorRuntimeToken, CONNECTOR_RUNTIME_TOKEN_HEADER, countByTenant, describeError, errorMessage as errorMessage$1, emitDataChanged, resolveDataProvider } from '@fayz-ai/core';
|
|
5
5
|
import { getShopTenantId, setShopTenantResolver, buildShopMessageDefaults, registerShippingLabelProvider, getShopProvider, buildShopDomainEvents, axesFromOptions, planVariantMatrix, validateVariantAxes, hasOnlyDefaultVariant, MAX_VARIANT_AXES, leavesNothingSellable, productImageToMediaFile, formatVariantCombination, applyVariantMatrix } from '@fayz-ai/shop';
|
|
6
6
|
import { fayzConnectorOAuth, describeConnectorAccount, useOrganizationStore, registerEntityPath, registerPersonLookup, createCrudPage, registerCrudNavTabs, adminNavigateTo, DetailTabHeader, AskAIButton, PageActions, useAgentSurface, askAI, CrudFormPage, SettingsGroup, SelectRow, ToggleRow, RegistryCrudView, useConnectors, useConnectorsPanelAvailable, openConnectorsPanel, MultiSelectRow, AddConnectorButton, AddConnectorPanel, ConnectorDetail, TextRow, ConnectorRow, ConnectorMark, StateChip } from '@fayz-ai/admin';
|
|
@@ -440,21 +440,21 @@ function ProductVariantsTab({ item, getProvider }) {
|
|
|
440
440
|
const product = item;
|
|
441
441
|
const shop = getProvider();
|
|
442
442
|
const supported = typeof shop.getProductVariants === "function" && typeof shop.saveProductOptions === "function" && typeof shop.createProductVariant === "function" && typeof shop.updateProductVariant === "function";
|
|
443
|
-
const [axes, setAxes] =
|
|
444
|
-
const [variants, setVariants] =
|
|
445
|
-
const [busy, setBusy] =
|
|
446
|
-
const [adding, setAdding] =
|
|
447
|
-
const [error, setError] =
|
|
448
|
-
const [selected, setSelected] =
|
|
449
|
-
const [dirty, setDirty] =
|
|
450
|
-
const reload =
|
|
443
|
+
const [axes, setAxes] = React14__default.useState([]);
|
|
444
|
+
const [variants, setVariants] = React14__default.useState([]);
|
|
445
|
+
const [busy, setBusy] = React14__default.useState(false);
|
|
446
|
+
const [adding, setAdding] = React14__default.useState(false);
|
|
447
|
+
const [error, setError] = React14__default.useState(null);
|
|
448
|
+
const [selected, setSelected] = React14__default.useState(/* @__PURE__ */ new Set());
|
|
449
|
+
const [dirty, setDirty] = React14__default.useState(false);
|
|
450
|
+
const reload = React14__default.useCallback(async () => {
|
|
451
451
|
const set = await getProvider().getProductVariants(product.id, { includeArchived: true });
|
|
452
452
|
setAxes(axesFromOptions(set.options));
|
|
453
453
|
setVariants(set.variants);
|
|
454
454
|
setSelected(/* @__PURE__ */ new Set());
|
|
455
455
|
setDirty(false);
|
|
456
456
|
}, [getProvider, product.id]);
|
|
457
|
-
|
|
457
|
+
React14__default.useEffect(() => {
|
|
458
458
|
if (!supported) return;
|
|
459
459
|
void reload().catch((e) => setError(message(e)));
|
|
460
460
|
}, [reload, supported]);
|
|
@@ -470,7 +470,7 @@ function ProductVariantsTab({ item, getProvider }) {
|
|
|
470
470
|
setBusy(false);
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
const plan =
|
|
473
|
+
const plan = React14__default.useMemo(() => planVariantMatrix(axes, variants), [axes, variants]);
|
|
474
474
|
const axisError = validateVariantAxes(axes);
|
|
475
475
|
const onlyDefault = hasOnlyDefaultVariant(variants);
|
|
476
476
|
const rows = plan.rows;
|
|
@@ -590,7 +590,7 @@ function ProductVariantsTab({ item, getProvider }) {
|
|
|
590
590
|
] });
|
|
591
591
|
}
|
|
592
592
|
function AxisEditor({ axis, index, count, disabled, onChange, onMove, onRemove }) {
|
|
593
|
-
const [draft2, setDraft] =
|
|
593
|
+
const [draft2, setDraft] = React14__default.useState("");
|
|
594
594
|
function commit(raw) {
|
|
595
595
|
const values = raw.split(",").map((v) => v.trim()).filter(Boolean);
|
|
596
596
|
if (values.length === 0) return;
|
|
@@ -873,9 +873,9 @@ function VariantRow({ row, axes, product, busy, checked, onToggle, onSave, onSto
|
|
|
873
873
|
] });
|
|
874
874
|
}
|
|
875
875
|
function BulkBar({ count, disabled, onApply, onClear }) {
|
|
876
|
-
const [price, setPrice] =
|
|
877
|
-
const [weight, setWeight] =
|
|
878
|
-
const [unit, setUnit] =
|
|
876
|
+
const [price, setPrice] = React14__default.useState("");
|
|
877
|
+
const [weight, setWeight] = React14__default.useState("");
|
|
878
|
+
const [unit, setUnit] = React14__default.useState("");
|
|
879
879
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 rounded-lg border bg-muted/30 px-3 py-2 text-xs", children: [
|
|
880
880
|
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
881
881
|
count,
|
|
@@ -952,8 +952,8 @@ function parseNumber(raw) {
|
|
|
952
952
|
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
953
953
|
}
|
|
954
954
|
function NumberCell({ value, disabled, placeholder, onCommit, width = "w-20", integer }) {
|
|
955
|
-
const [draft2, setDraft] =
|
|
956
|
-
|
|
955
|
+
const [draft2, setDraft] = React14__default.useState(value == null ? "" : String(value));
|
|
956
|
+
React14__default.useEffect(() => {
|
|
957
957
|
setDraft(value == null ? "" : String(value));
|
|
958
958
|
}, [value]);
|
|
959
959
|
return /* @__PURE__ */ jsx("div", { className: width, children: /* @__PURE__ */ jsx(
|
|
@@ -972,8 +972,8 @@ function NumberCell({ value, disabled, placeholder, onCommit, width = "w-20", in
|
|
|
972
972
|
) });
|
|
973
973
|
}
|
|
974
974
|
function TextCell({ value, disabled, placeholder, onCommit }) {
|
|
975
|
-
const [draft2, setDraft] =
|
|
976
|
-
|
|
975
|
+
const [draft2, setDraft] = React14__default.useState(value);
|
|
976
|
+
React14__default.useEffect(() => {
|
|
977
977
|
setDraft(value);
|
|
978
978
|
}, [value]);
|
|
979
979
|
return /* @__PURE__ */ jsx("div", { className: "w-28", children: /* @__PURE__ */ jsx(
|
|
@@ -1023,9 +1023,9 @@ function message(error) {
|
|
|
1023
1023
|
return errorMessage$1(error);
|
|
1024
1024
|
}
|
|
1025
1025
|
function NewAxisModal({ open, onClose, onCreate }) {
|
|
1026
|
-
const [name, setName] =
|
|
1027
|
-
const [values, setValues] =
|
|
1028
|
-
|
|
1026
|
+
const [name, setName] = React14__default.useState("");
|
|
1027
|
+
const [values, setValues] = React14__default.useState([""]);
|
|
1028
|
+
React14__default.useEffect(() => {
|
|
1029
1029
|
if (open) {
|
|
1030
1030
|
setName("");
|
|
1031
1031
|
setValues([""]);
|
|
@@ -1403,7 +1403,7 @@ function ProductPositionsTab({ item, getProvider }) {
|
|
|
1403
1403
|
const [noteOpen, setNoteOpen] = useState(false);
|
|
1404
1404
|
const [occurredOn, setOccurredOn] = useState(() => todayISO());
|
|
1405
1405
|
const [saving, setSaving] = useState(false);
|
|
1406
|
-
const quantityRef =
|
|
1406
|
+
const quantityRef = React14__default.useRef(null);
|
|
1407
1407
|
const load = useCallback(async () => {
|
|
1408
1408
|
setLoading(true);
|
|
1409
1409
|
try {
|
|
@@ -1482,7 +1482,7 @@ function ProductPositionsTab({ item, getProvider }) {
|
|
|
1482
1482
|
const amount = Math.abs(Number(quantity) || 0);
|
|
1483
1483
|
const outgoing = type === "saida" || type === "perda";
|
|
1484
1484
|
const nextBalance = amount > 0 ? outgoing ? total.available - amount : total.available + amount : null;
|
|
1485
|
-
const live =
|
|
1485
|
+
const live = React14__default.useRef({ product, variantId, total, getProvider, load });
|
|
1486
1486
|
live.current = { product, variantId, total, getProvider, load };
|
|
1487
1487
|
const contribution = useMemo(() => ({
|
|
1488
1488
|
id: "shop.product.positions",
|
|
@@ -1766,20 +1766,20 @@ function shippingRegistryIdFromHash(hash) {
|
|
|
1766
1766
|
}
|
|
1767
1767
|
var PACKAGES_ROUTE = shippingRegistryPath(PACKAGES_REGISTRY);
|
|
1768
1768
|
function PackageSelect({ value, onChange, getProvider }) {
|
|
1769
|
-
const shop =
|
|
1770
|
-
const [rows, setRows] =
|
|
1771
|
-
const [open, setOpen] =
|
|
1772
|
-
const [creating, setCreating] =
|
|
1773
|
-
const ref =
|
|
1774
|
-
const load =
|
|
1769
|
+
const shop = React14__default.useMemo(() => getProvider?.() ?? getShopProvider(), [getProvider]);
|
|
1770
|
+
const [rows, setRows] = React14__default.useState(null);
|
|
1771
|
+
const [open, setOpen] = React14__default.useState(false);
|
|
1772
|
+
const [creating, setCreating] = React14__default.useState(false);
|
|
1773
|
+
const ref = React14__default.useRef(null);
|
|
1774
|
+
const load = React14__default.useCallback(() => {
|
|
1775
1775
|
if (typeof shop.listShippingPackages !== "function") {
|
|
1776
1776
|
setRows([]);
|
|
1777
1777
|
return;
|
|
1778
1778
|
}
|
|
1779
1779
|
void shop.listShippingPackages().then(setRows).catch(() => setRows([]));
|
|
1780
1780
|
}, [shop]);
|
|
1781
|
-
|
|
1782
|
-
|
|
1781
|
+
React14__default.useEffect(load, [load]);
|
|
1782
|
+
React14__default.useEffect(() => {
|
|
1783
1783
|
if (!open) return;
|
|
1784
1784
|
const away = (event) => {
|
|
1785
1785
|
if (ref.current && !ref.current.contains(event.target)) setOpen(false);
|
|
@@ -1880,8 +1880,8 @@ function PackageSelect({ value, onChange, getProvider }) {
|
|
|
1880
1880
|
] });
|
|
1881
1881
|
}
|
|
1882
1882
|
function NewPackageModal({ onClose, onCreated }) {
|
|
1883
|
-
const [error, setError] =
|
|
1884
|
-
const provider =
|
|
1883
|
+
const [error, setError] = React14__default.useState(null);
|
|
1884
|
+
const provider = React14__default.useMemo(
|
|
1885
1885
|
() => resolveDataProvider(packagesRegistry.entity),
|
|
1886
1886
|
[]
|
|
1887
1887
|
);
|
|
@@ -1930,9 +1930,9 @@ function Option({ label, hint, active, onClick }) {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
var GENERAL = "__general__";
|
|
1932
1932
|
function ShippingProfileSelect({ value, onChange, getProvider }) {
|
|
1933
|
-
const shop =
|
|
1934
|
-
const [rows, setRows] =
|
|
1935
|
-
|
|
1933
|
+
const shop = React14__default.useMemo(() => getProvider?.() ?? getShopProvider(), [getProvider]);
|
|
1934
|
+
const [rows, setRows] = React14__default.useState(null);
|
|
1935
|
+
React14__default.useEffect(() => {
|
|
1936
1936
|
let cancelled = false;
|
|
1937
1937
|
if (typeof shop.listShippingProfiles !== "function") {
|
|
1938
1938
|
setRows([]);
|
|
@@ -3316,17 +3316,17 @@ function createShopCustomerSegmentDataProvider(provider) {
|
|
|
3316
3316
|
}
|
|
3317
3317
|
var DEBOUNCE_MS = 400;
|
|
3318
3318
|
function useStoreSettings(provider, defaults = {}) {
|
|
3319
|
-
const shop =
|
|
3319
|
+
const shop = React14__default.useMemo(
|
|
3320
3320
|
() => provider ? resolve(provider) : getShopProvider(),
|
|
3321
3321
|
[provider]
|
|
3322
3322
|
);
|
|
3323
3323
|
const supported = typeof shop.getStoreSettings === "function" && typeof shop.updateStoreSettings === "function";
|
|
3324
|
-
const [stored, setStored] =
|
|
3325
|
-
const [loading, setLoading] =
|
|
3326
|
-
const [saving, setSaving] =
|
|
3327
|
-
const [error, setError] =
|
|
3328
|
-
const [loadError, setLoadError] =
|
|
3329
|
-
|
|
3324
|
+
const [stored, setStored] = React14__default.useState(null);
|
|
3325
|
+
const [loading, setLoading] = React14__default.useState(supported);
|
|
3326
|
+
const [saving, setSaving] = React14__default.useState(false);
|
|
3327
|
+
const [error, setError] = React14__default.useState(null);
|
|
3328
|
+
const [loadError, setLoadError] = React14__default.useState(null);
|
|
3329
|
+
React14__default.useEffect(() => {
|
|
3330
3330
|
if (!supported) return;
|
|
3331
3331
|
let cancelled = false;
|
|
3332
3332
|
setLoading(true);
|
|
@@ -3342,12 +3342,12 @@ function useStoreSettings(provider, defaults = {}) {
|
|
|
3342
3342
|
cancelled = true;
|
|
3343
3343
|
};
|
|
3344
3344
|
}, [shop, supported]);
|
|
3345
|
-
const pendingRef =
|
|
3346
|
-
const timerRef =
|
|
3347
|
-
|
|
3345
|
+
const pendingRef = React14__default.useRef({});
|
|
3346
|
+
const timerRef = React14__default.useRef(null);
|
|
3347
|
+
React14__default.useEffect(() => () => {
|
|
3348
3348
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
3349
3349
|
}, []);
|
|
3350
|
-
const set =
|
|
3350
|
+
const set = React14__default.useCallback(
|
|
3351
3351
|
(patch) => {
|
|
3352
3352
|
setStored((current) => ({ ...current ?? {}, ...patch }));
|
|
3353
3353
|
if (!supported) return;
|
|
@@ -3363,7 +3363,7 @@ function useStoreSettings(provider, defaults = {}) {
|
|
|
3363
3363
|
},
|
|
3364
3364
|
[shop, supported]
|
|
3365
3365
|
);
|
|
3366
|
-
const value =
|
|
3366
|
+
const value = React14__default.useMemo(() => ({ ...defaults, ...stored ?? {} }), [defaults, stored]);
|
|
3367
3367
|
return { value, stored, set, loading, saving, error, loadError, supported };
|
|
3368
3368
|
}
|
|
3369
3369
|
function SettingsState({
|
|
@@ -3585,6 +3585,80 @@ function ManualChargeRow({ selected, onSelect }) {
|
|
|
3585
3585
|
}
|
|
3586
3586
|
) });
|
|
3587
3587
|
}
|
|
3588
|
+
var NONE = "__none";
|
|
3589
|
+
var CARD_KIND = {
|
|
3590
|
+
credit_card: "card_receivable_credit",
|
|
3591
|
+
debit_card: "card_receivable_debit"
|
|
3592
|
+
};
|
|
3593
|
+
var CARD_LABEL = {
|
|
3594
|
+
credit_card: "Cart\xE3o de cr\xE9dito cai em",
|
|
3595
|
+
debit_card: "Cart\xE3o de d\xE9bito cai em"
|
|
3596
|
+
};
|
|
3597
|
+
function useReceivingAccountOptions() {
|
|
3598
|
+
const [accounts, setAccounts] = React14__default.useState(null);
|
|
3599
|
+
React14__default.useEffect(() => {
|
|
3600
|
+
const db = getSupabaseClientOptional();
|
|
3601
|
+
if (!db) {
|
|
3602
|
+
setAccounts([]);
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
let cancelled = false;
|
|
3606
|
+
db.from("plg_financial_accounts").select("id, name, kind").eq("is_active", true).in("kind", ["bank", "cash_physical", "card_receivable_credit", "card_receivable_debit"]).order("name").then(({ data }) => {
|
|
3607
|
+
if (!cancelled) setAccounts(data ?? []);
|
|
3608
|
+
});
|
|
3609
|
+
return () => {
|
|
3610
|
+
cancelled = true;
|
|
3611
|
+
};
|
|
3612
|
+
}, []);
|
|
3613
|
+
return accounts;
|
|
3614
|
+
}
|
|
3615
|
+
function ReceivingAccountsGroup({ provider, providerName, methods, value, onChange }) {
|
|
3616
|
+
const accounts = useReceivingAccountOptions();
|
|
3617
|
+
const current = value?.[provider] ?? {};
|
|
3618
|
+
const set = (key, id) => {
|
|
3619
|
+
const nextForProvider = { ...current };
|
|
3620
|
+
if (id === NONE) delete nextForProvider[key];
|
|
3621
|
+
else nextForProvider[key] = id;
|
|
3622
|
+
onChange({ ...value ?? {}, [provider]: nextForProvider });
|
|
3623
|
+
};
|
|
3624
|
+
const optionsFor = (kinds) => [
|
|
3625
|
+
{ value: NONE, label: "N\xE3o definido" },
|
|
3626
|
+
...(accounts ?? []).filter((a) => kinds.includes(a.kind)).map((a) => ({ value: a.id, label: a.name }))
|
|
3627
|
+
];
|
|
3628
|
+
const cards = ["credit_card", "debit_card"].filter((m) => methods.length === 0 ? m === "credit_card" : methods.includes(m));
|
|
3629
|
+
return /* @__PURE__ */ jsxs(
|
|
3630
|
+
SettingsGroup,
|
|
3631
|
+
{
|
|
3632
|
+
title: "Onde o dinheiro cai",
|
|
3633
|
+
description: `A conta do Financeiro em que cada venda paga pelo ${providerName} \xE9 lan\xE7ada. Sem uma conta aqui, o lan\xE7amento vai para a \xFAnica conta banc\xE1ria da loja.`,
|
|
3634
|
+
children: [
|
|
3635
|
+
/* @__PURE__ */ jsx(
|
|
3636
|
+
SelectRow,
|
|
3637
|
+
{
|
|
3638
|
+
label: "Pix, boleto e saldo caem em",
|
|
3639
|
+
description: `Normalmente a conta ${providerName} cadastrada em Financeiro \u203A Contas.`,
|
|
3640
|
+
value: current.default ?? NONE,
|
|
3641
|
+
options: optionsFor(["bank", "cash_physical"]),
|
|
3642
|
+
onChange: (id) => set("default", id),
|
|
3643
|
+
disabled: accounts === null
|
|
3644
|
+
}
|
|
3645
|
+
),
|
|
3646
|
+
cards.map((method) => /* @__PURE__ */ jsx(
|
|
3647
|
+
SelectRow,
|
|
3648
|
+
{
|
|
3649
|
+
label: CARD_LABEL[method],
|
|
3650
|
+
description: "Uma conta de cart\xE3o a receber. Sem ela, a venda no cart\xE3o n\xE3o d\xE1 baixa.",
|
|
3651
|
+
value: current[method] ?? NONE,
|
|
3652
|
+
options: optionsFor([CARD_KIND[method]]),
|
|
3653
|
+
onChange: (id) => set(method, id),
|
|
3654
|
+
disabled: accounts === null
|
|
3655
|
+
},
|
|
3656
|
+
method
|
|
3657
|
+
))
|
|
3658
|
+
]
|
|
3659
|
+
}
|
|
3660
|
+
);
|
|
3661
|
+
}
|
|
3588
3662
|
var METHODS = [
|
|
3589
3663
|
{ value: "pix", label: "Pix", hint: "Chave ou QR Code" },
|
|
3590
3664
|
{ value: "credit_card", label: "Cart\xE3o de cr\xE9dito", hint: "Gateway ou maquininha" },
|
|
@@ -3598,25 +3672,26 @@ function PaymentsSettings({ provider }) {
|
|
|
3598
3672
|
const settings = useStoreSettings(provider);
|
|
3599
3673
|
const { value, set } = settings;
|
|
3600
3674
|
const { connectors } = useConnectors({ hostPluginId: "shop", includeGrants: false });
|
|
3601
|
-
const [adding, setAdding] =
|
|
3602
|
-
const [selected, setSelected] =
|
|
3675
|
+
const [adding, setAdding] = React14__default.useState(false);
|
|
3676
|
+
const [selected, setSelected] = React14__default.useState(null);
|
|
3603
3677
|
const panelAvailable = useConnectorsPanelAvailable();
|
|
3604
|
-
const openJourney =
|
|
3678
|
+
const openJourney = React14__default.useCallback(
|
|
3605
3679
|
(connector) => {
|
|
3606
3680
|
if (panelAvailable) openConnectorsPanel(connector);
|
|
3607
3681
|
else setSelected(connector);
|
|
3608
3682
|
},
|
|
3609
3683
|
[panelAvailable]
|
|
3610
3684
|
);
|
|
3611
|
-
const payment =
|
|
3685
|
+
const payment = React14__default.useMemo(
|
|
3612
3686
|
() => (connectors ?? []).filter((c) => c.category && PAYMENT_CATEGORIES.includes(c.category)),
|
|
3613
3687
|
[connectors]
|
|
3614
3688
|
);
|
|
3615
|
-
const live =
|
|
3689
|
+
const live = React14__default.useMemo(() => payment.filter((c) => c.state === "connected"), [payment]);
|
|
3690
|
+
const charging = live.find((c) => c.slug === value.paymentProvider);
|
|
3616
3691
|
const chosen = value.paymentMethods ?? [];
|
|
3617
3692
|
const staleProvider = !!value.paymentProvider && !live.some((c) => c.slug === value.paymentProvider) && live.length === 0;
|
|
3618
|
-
const movedFrom =
|
|
3619
|
-
|
|
3693
|
+
const movedFrom = React14__default.useRef(null);
|
|
3694
|
+
React14__default.useEffect(() => {
|
|
3620
3695
|
if (!settings.supported || settings.loading) return;
|
|
3621
3696
|
const next = resolvePaymentProvider(value.paymentProvider, live.map((c) => c.slug));
|
|
3622
3697
|
if (!next) return;
|
|
@@ -3696,6 +3771,16 @@ function PaymentsSettings({ provider }) {
|
|
|
3696
3771
|
", que n\xE3o est\xE1 conectado agora, e n\xE3o h\xE1 outro para assumir. Enquanto isso os pedidos nascem pendentes."
|
|
3697
3772
|
] })
|
|
3698
3773
|
] }),
|
|
3774
|
+
charging && /* @__PURE__ */ jsx(
|
|
3775
|
+
ReceivingAccountsGroup,
|
|
3776
|
+
{
|
|
3777
|
+
provider: charging.slug,
|
|
3778
|
+
providerName: charging.name,
|
|
3779
|
+
methods: chosen,
|
|
3780
|
+
value: value.receivingAccounts,
|
|
3781
|
+
onChange: (receivingAccounts) => set({ receivingAccounts })
|
|
3782
|
+
}
|
|
3783
|
+
),
|
|
3699
3784
|
/* @__PURE__ */ jsx(
|
|
3700
3785
|
AddConnectorPanel,
|
|
3701
3786
|
{
|
|
@@ -3848,11 +3933,11 @@ function PackagesSettings({ basePath = shippingRegistryPath(PACKAGES_REGISTRY) }
|
|
|
3848
3933
|
] });
|
|
3849
3934
|
}
|
|
3850
3935
|
function HandlingSettings({ settings, provider }) {
|
|
3851
|
-
const shop =
|
|
3936
|
+
const shop = React14__default.useMemo(() => provider ? resolve(provider) : getShopProvider(), [provider]);
|
|
3852
3937
|
const { value, set, loading, supported } = settings;
|
|
3853
|
-
const [noteDraft, setNoteDraft] =
|
|
3854
|
-
const [profiles, setProfiles] =
|
|
3855
|
-
|
|
3938
|
+
const [noteDraft, setNoteDraft] = React14__default.useState(null);
|
|
3939
|
+
const [profiles, setProfiles] = React14__default.useState(null);
|
|
3940
|
+
React14__default.useEffect(() => {
|
|
3856
3941
|
let cancelled = false;
|
|
3857
3942
|
void shop.listShippingProfiles?.().then((list) => {
|
|
3858
3943
|
if (!cancelled) setProfiles(list);
|
|
@@ -4037,7 +4122,7 @@ function subscribeDeliveryDraft(listener) {
|
|
|
4037
4122
|
};
|
|
4038
4123
|
}
|
|
4039
4124
|
function useDeliveryDraft() {
|
|
4040
|
-
return
|
|
4125
|
+
return React14.useSyncExternalStore(subscribeDeliveryDraft, getDeliveryDraft, getDeliveryDraft);
|
|
4041
4126
|
}
|
|
4042
4127
|
|
|
4043
4128
|
// src/views/delivery-agent.ts
|
|
@@ -4440,9 +4525,9 @@ function createDeliveryAreaTools({ getProvider, onSaved }) {
|
|
|
4440
4525
|
|
|
4441
4526
|
// src/views/DeliveryAgentSurface.tsx
|
|
4442
4527
|
function DeliveryAgentSurface({ provider, zones, onSaved }) {
|
|
4443
|
-
const live =
|
|
4528
|
+
const live = React14.useRef({ provider, zones, onSaved });
|
|
4444
4529
|
live.current = { provider, zones, onSaved };
|
|
4445
|
-
const contribution =
|
|
4530
|
+
const contribution = React14.useMemo(() => ({
|
|
4446
4531
|
id: "shop.delivery.settings",
|
|
4447
4532
|
pluginId: "shop",
|
|
4448
4533
|
role: "operations",
|
|
@@ -4525,12 +4610,12 @@ function areaMeta(area) {
|
|
|
4525
4610
|
}
|
|
4526
4611
|
var areaKeyOf = (area) => `${area.kind}:${area.districtKey ?? area.cityCode ?? area.label}`;
|
|
4527
4612
|
function AreaSearch({ provider, outcome, placeholder, onlyCityCodes, emptyHint }) {
|
|
4528
|
-
const [query, setQuery] =
|
|
4529
|
-
const [results, setResults] =
|
|
4530
|
-
const [loading, setLoading] =
|
|
4531
|
-
const [unavailable, setUnavailable] =
|
|
4532
|
-
const [justAdded, setJustAdded] =
|
|
4533
|
-
|
|
4613
|
+
const [query, setQuery] = React14__default.useState("");
|
|
4614
|
+
const [results, setResults] = React14__default.useState(null);
|
|
4615
|
+
const [loading, setLoading] = React14__default.useState(false);
|
|
4616
|
+
const [unavailable, setUnavailable] = React14__default.useState(false);
|
|
4617
|
+
const [justAdded, setJustAdded] = React14__default.useState(null);
|
|
4618
|
+
React14__default.useEffect(() => {
|
|
4534
4619
|
const text3 = query.trim();
|
|
4535
4620
|
if (text3.length < MIN_QUERY) {
|
|
4536
4621
|
setResults(null);
|
|
@@ -4721,10 +4806,10 @@ function ruleArea(rule) {
|
|
|
4721
4806
|
}
|
|
4722
4807
|
function DeliveryRulesDraft({ provider, onSaved }) {
|
|
4723
4808
|
const draft2 = useDeliveryDraft();
|
|
4724
|
-
const [saving, setSaving] =
|
|
4725
|
-
const [error, setError] =
|
|
4726
|
-
const [bulkRate, setBulkRate] =
|
|
4727
|
-
const [bulkFree, setBulkFree] =
|
|
4809
|
+
const [saving, setSaving] = React14__default.useState(false);
|
|
4810
|
+
const [error, setError] = React14__default.useState(null);
|
|
4811
|
+
const [bulkRate, setBulkRate] = React14__default.useState("");
|
|
4812
|
+
const [bulkFree, setBulkFree] = React14__default.useState("");
|
|
4728
4813
|
if (draft2.rules.length === 0 && draft2.gaps.length === 0) return null;
|
|
4729
4814
|
const refusing = draft2.rules.filter((r) => r.outcome === "refuse").length;
|
|
4730
4815
|
const reviewing = draft2.rules.filter((r) => r.outcome === "review").length;
|
|
@@ -5000,48 +5085,48 @@ var FREIGHT_SOURCE = [
|
|
|
5000
5085
|
}
|
|
5001
5086
|
];
|
|
5002
5087
|
function ShippingSettings({ provider }) {
|
|
5003
|
-
const [registryId, setRegistryId] =
|
|
5004
|
-
|
|
5088
|
+
const [registryId, setRegistryId] = React14__default.useState(shippingRegistryIdFromHash);
|
|
5089
|
+
React14__default.useEffect(() => {
|
|
5005
5090
|
const handler = () => setRegistryId(shippingRegistryIdFromHash());
|
|
5006
5091
|
window.addEventListener("hashchange", handler);
|
|
5007
5092
|
return () => window.removeEventListener("hashchange", handler);
|
|
5008
5093
|
}, []);
|
|
5009
|
-
const shop =
|
|
5010
|
-
const registries =
|
|
5094
|
+
const shop = React14__default.useMemo(() => provider ? resolve(provider) : getShopProvider(), [provider]);
|
|
5095
|
+
const registries = React14__default.useMemo(
|
|
5011
5096
|
() => buildShopRegistries(provider ?? getShopProvider),
|
|
5012
5097
|
[provider]
|
|
5013
5098
|
);
|
|
5014
5099
|
const storeSettings = useStoreSettings(provider);
|
|
5015
5100
|
const supported = typeof shop.getShippingSettings === "function" && typeof shop.updateShippingSettings === "function";
|
|
5016
|
-
const [row, setRow] =
|
|
5017
|
-
const [zones, setZones] =
|
|
5018
|
-
const [locations, setLocations] =
|
|
5019
|
-
const [loading, setLoading] =
|
|
5020
|
-
const [saving, setSaving] =
|
|
5021
|
-
const [error, setError] =
|
|
5022
|
-
const [loadError, setLoadError] =
|
|
5023
|
-
const [flatDraft, setFlatDraft] =
|
|
5024
|
-
const [freeDraft, setFreeDraft] =
|
|
5025
|
-
const [flatBad, setFlatBad] =
|
|
5026
|
-
const [freeBad, setFreeBad] =
|
|
5101
|
+
const [row, setRow] = React14__default.useState(null);
|
|
5102
|
+
const [zones, setZones] = React14__default.useState(null);
|
|
5103
|
+
const [locations, setLocations] = React14__default.useState(null);
|
|
5104
|
+
const [loading, setLoading] = React14__default.useState(supported);
|
|
5105
|
+
const [saving, setSaving] = React14__default.useState(false);
|
|
5106
|
+
const [error, setError] = React14__default.useState(null);
|
|
5107
|
+
const [loadError, setLoadError] = React14__default.useState(null);
|
|
5108
|
+
const [flatDraft, setFlatDraft] = React14__default.useState("");
|
|
5109
|
+
const [freeDraft, setFreeDraft] = React14__default.useState("");
|
|
5110
|
+
const [flatBad, setFlatBad] = React14__default.useState(false);
|
|
5111
|
+
const [freeBad, setFreeBad] = React14__default.useState(false);
|
|
5027
5112
|
const { connectors } = useConnectors({ hostPluginId: "shop", includeGrants: false });
|
|
5028
|
-
const [selected, setSelected] =
|
|
5113
|
+
const [selected, setSelected] = React14__default.useState(null);
|
|
5029
5114
|
const panelAvailable = useConnectorsPanelAvailable();
|
|
5030
|
-
const openJourney =
|
|
5115
|
+
const openJourney = React14__default.useCallback(
|
|
5031
5116
|
(connector) => {
|
|
5032
5117
|
if (panelAvailable) openConnectorsPanel(connector);
|
|
5033
5118
|
else setSelected(connector);
|
|
5034
5119
|
},
|
|
5035
5120
|
[panelAvailable]
|
|
5036
5121
|
);
|
|
5037
|
-
const carriers =
|
|
5122
|
+
const carriers = React14__default.useMemo(
|
|
5038
5123
|
() => (connectors ?? []).filter((c) => c.category === "logistics" || c.category === "shipping"),
|
|
5039
5124
|
[connectors]
|
|
5040
5125
|
);
|
|
5041
5126
|
const carriersConnected = carriers.some((c) => c.state !== "ready");
|
|
5042
|
-
const [zonesEpoch, setZonesEpoch] =
|
|
5043
|
-
const reloadZones =
|
|
5044
|
-
|
|
5127
|
+
const [zonesEpoch, setZonesEpoch] = React14__default.useState(0);
|
|
5128
|
+
const reloadZones = React14__default.useCallback(() => setZonesEpoch((n) => n + 1), []);
|
|
5129
|
+
React14__default.useEffect(() => {
|
|
5045
5130
|
let cancelled = false;
|
|
5046
5131
|
if (supported) {
|
|
5047
5132
|
setLoading(true);
|
|
@@ -5070,7 +5155,7 @@ function ShippingSettings({ provider }) {
|
|
|
5070
5155
|
cancelled = true;
|
|
5071
5156
|
};
|
|
5072
5157
|
}, [shop, supported, zonesEpoch]);
|
|
5073
|
-
const save =
|
|
5158
|
+
const save = React14__default.useCallback(
|
|
5074
5159
|
(patch) => {
|
|
5075
5160
|
if (!supported) return;
|
|
5076
5161
|
setSaving(true);
|
|
@@ -6614,18 +6699,18 @@ function formatSize(bytes) {
|
|
|
6614
6699
|
return `${(bytes / 1024 ** i).toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
6615
6700
|
}
|
|
6616
6701
|
function ContentPage({ resolveProvider }) {
|
|
6617
|
-
const provider =
|
|
6702
|
+
const provider = React14__default.useMemo(() => resolve2(resolveProvider), [resolveProvider]);
|
|
6618
6703
|
const supported = typeof provider.listMediaFiles === "function";
|
|
6619
|
-
const [files, setFiles] =
|
|
6620
|
-
const [tab, setTab] =
|
|
6621
|
-
const [uploading, setUploading] =
|
|
6622
|
-
const [pendingDelete, setPendingDelete] =
|
|
6623
|
-
const [deleting, setDeleting] =
|
|
6624
|
-
const [replacing, setReplacing] =
|
|
6625
|
-
const [openId, setOpenId] =
|
|
6626
|
-
const [dimensions, setDimensions] =
|
|
6627
|
-
const uploadInputRef =
|
|
6628
|
-
const reload =
|
|
6704
|
+
const [files, setFiles] = React14__default.useState(null);
|
|
6705
|
+
const [tab, setTab] = React14__default.useState("all");
|
|
6706
|
+
const [uploading, setUploading] = React14__default.useState(false);
|
|
6707
|
+
const [pendingDelete, setPendingDelete] = React14__default.useState(null);
|
|
6708
|
+
const [deleting, setDeleting] = React14__default.useState(false);
|
|
6709
|
+
const [replacing, setReplacing] = React14__default.useState(false);
|
|
6710
|
+
const [openId, setOpenId] = React14__default.useState(null);
|
|
6711
|
+
const [dimensions, setDimensions] = React14__default.useState({});
|
|
6712
|
+
const uploadInputRef = React14__default.useRef(null);
|
|
6713
|
+
const reload = React14__default.useCallback(async () => {
|
|
6629
6714
|
if (!provider.listMediaFiles) {
|
|
6630
6715
|
setFiles([]);
|
|
6631
6716
|
return;
|
|
@@ -6637,10 +6722,10 @@ function ContentPage({ resolveProvider }) {
|
|
|
6637
6722
|
setFiles([]);
|
|
6638
6723
|
}
|
|
6639
6724
|
}, [provider]);
|
|
6640
|
-
|
|
6725
|
+
React14__default.useEffect(() => {
|
|
6641
6726
|
void reload();
|
|
6642
6727
|
}, [reload]);
|
|
6643
|
-
const measure =
|
|
6728
|
+
const measure = React14__default.useCallback((id, d) => {
|
|
6644
6729
|
setDimensions((prev) => prev[id] ? prev : { ...prev, [id]: d });
|
|
6645
6730
|
}, []);
|
|
6646
6731
|
const handleUpload = async (picked) => {
|
|
@@ -6916,8 +7001,8 @@ function MediaDetail({
|
|
|
6916
7001
|
onDelete,
|
|
6917
7002
|
replacing
|
|
6918
7003
|
}) {
|
|
6919
|
-
const replaceRef =
|
|
6920
|
-
|
|
7004
|
+
const replaceRef = React14__default.useRef(null);
|
|
7005
|
+
React14__default.useEffect(() => {
|
|
6921
7006
|
function onKey(e) {
|
|
6922
7007
|
if (e.key === "ArrowLeft") onNavigate(-1);
|
|
6923
7008
|
if (e.key === "ArrowRight") onNavigate(1);
|
|
@@ -9073,13 +9158,13 @@ function ProductListingTab({ item, getProvider }) {
|
|
|
9073
9158
|
}
|
|
9074
9159
|
|
|
9075
9160
|
// src/index.ts
|
|
9076
|
-
var ShopPage =
|
|
9077
|
-
var LazyOrderDetail =
|
|
9161
|
+
var ShopPage = React14__default.lazy(() => import('./ShopPage-2CTRGQTX.js').then((m) => ({ default: m.ShopPage })));
|
|
9162
|
+
var LazyOrderDetail = React14__default.lazy(() => import('./ShopPage-2CTRGQTX.js').then((m) => ({ default: m.ShopOrderDetailSlot })));
|
|
9078
9163
|
function ShopOrderDetail(provider) {
|
|
9079
|
-
const Detail = (props) =>
|
|
9080
|
-
|
|
9164
|
+
const Detail = (props) => React14__default.createElement(
|
|
9165
|
+
React14__default.Suspense,
|
|
9081
9166
|
{ fallback: null },
|
|
9082
|
-
|
|
9167
|
+
React14__default.createElement(LazyOrderDetail, { ...props, provider })
|
|
9083
9168
|
);
|
|
9084
9169
|
Detail.displayName = "ShopOrderDetail";
|
|
9085
9170
|
return Detail;
|
|
@@ -9092,10 +9177,10 @@ function createShopPlugin(options) {
|
|
|
9092
9177
|
registerEntityPath("shop_customer", "/customers");
|
|
9093
9178
|
registerPersonLookup("shop_customer", shopCustomerLookup(() => resolveProvider()));
|
|
9094
9179
|
const pageFor = (section) => {
|
|
9095
|
-
const Wrapped = () =>
|
|
9096
|
-
|
|
9180
|
+
const Wrapped = () => React14__default.createElement(
|
|
9181
|
+
React14__default.Suspense,
|
|
9097
9182
|
{ fallback: null },
|
|
9098
|
-
|
|
9183
|
+
React14__default.createElement(
|
|
9099
9184
|
ShopPage,
|
|
9100
9185
|
{ provider: options?.provider, section }
|
|
9101
9186
|
)
|
|
@@ -9284,7 +9369,7 @@ function createShopPlugin(options) {
|
|
|
9284
9369
|
];
|
|
9285
9370
|
}
|
|
9286
9371
|
});
|
|
9287
|
-
const ContentPageWrapped = () =>
|
|
9372
|
+
const ContentPageWrapped = () => React14__default.createElement(ContentPage, { resolveProvider: options?.provider });
|
|
9288
9373
|
ContentPageWrapped.displayName = "ContentPage";
|
|
9289
9374
|
const navSection = options?.navSection ?? "main";
|
|
9290
9375
|
const navPosition = options?.navPosition ?? 6;
|
|
@@ -9374,7 +9459,7 @@ function createShopPlugin(options) {
|
|
|
9374
9459
|
];
|
|
9375
9460
|
const redirectTo = (target) => {
|
|
9376
9461
|
const Redirect = () => {
|
|
9377
|
-
|
|
9462
|
+
React14__default.useEffect(() => {
|
|
9378
9463
|
adminNavigateTo(target);
|
|
9379
9464
|
}, []);
|
|
9380
9465
|
return null;
|
|
@@ -9517,7 +9602,7 @@ function createShopPlugin(options) {
|
|
|
9517
9602
|
label: label("store", "Loja"),
|
|
9518
9603
|
icon: "ShoppingBag",
|
|
9519
9604
|
group: COMMERCE_GROUP,
|
|
9520
|
-
component: settingsTab("StoreGeneralSettings", () =>
|
|
9605
|
+
component: settingsTab("StoreGeneralSettings", () => React14__default.createElement(StoreGeneralSettings, { currency: curr, provider: options?.provider })),
|
|
9521
9606
|
order: 30,
|
|
9522
9607
|
permission: READ
|
|
9523
9608
|
},
|
|
@@ -9527,7 +9612,7 @@ function createShopPlugin(options) {
|
|
|
9527
9612
|
label: "Mercados",
|
|
9528
9613
|
icon: "Globe",
|
|
9529
9614
|
group: COMMERCE_GROUP,
|
|
9530
|
-
component: settingsTab("MarketsSettings", () =>
|
|
9615
|
+
component: settingsTab("MarketsSettings", () => React14__default.createElement(MarketsSettings, {})),
|
|
9531
9616
|
order: 30.5,
|
|
9532
9617
|
permission: READ
|
|
9533
9618
|
},
|
|
@@ -9536,7 +9621,7 @@ function createShopPlugin(options) {
|
|
|
9536
9621
|
label: "Pagamentos",
|
|
9537
9622
|
icon: "CreditCard",
|
|
9538
9623
|
group: COMMERCE_GROUP,
|
|
9539
|
-
component: settingsTab("PaymentsSettings", () =>
|
|
9624
|
+
component: settingsTab("PaymentsSettings", () => React14__default.createElement(PaymentsSettings, { provider: options?.provider })),
|
|
9540
9625
|
order: 31,
|
|
9541
9626
|
permission: READ
|
|
9542
9627
|
},
|
|
@@ -9545,7 +9630,7 @@ function createShopPlugin(options) {
|
|
|
9545
9630
|
label: "Checkout",
|
|
9546
9631
|
icon: "ShoppingCart",
|
|
9547
9632
|
group: COMMERCE_GROUP,
|
|
9548
|
-
component: settingsTab("CheckoutSettings", () =>
|
|
9633
|
+
component: settingsTab("CheckoutSettings", () => React14__default.createElement(CheckoutSettings, { provider: options?.provider })),
|
|
9549
9634
|
order: 32,
|
|
9550
9635
|
permission: READ
|
|
9551
9636
|
},
|
|
@@ -9554,7 +9639,7 @@ function createShopPlugin(options) {
|
|
|
9554
9639
|
label: label("shipping", "Entrega"),
|
|
9555
9640
|
icon: "Truck",
|
|
9556
9641
|
group: COMMERCE_GROUP,
|
|
9557
|
-
component: settingsTab("ShippingSettings", () =>
|
|
9642
|
+
component: settingsTab("ShippingSettings", () => React14__default.createElement(ShippingSettings, { provider: options?.provider })),
|
|
9558
9643
|
order: 33,
|
|
9559
9644
|
permission: READ
|
|
9560
9645
|
},
|
|
@@ -9563,7 +9648,7 @@ function createShopPlugin(options) {
|
|
|
9563
9648
|
label: "Fulfillment",
|
|
9564
9649
|
icon: "PackageCheck",
|
|
9565
9650
|
group: COMMERCE_GROUP,
|
|
9566
|
-
component: settingsTab("FulfillmentSettings", () =>
|
|
9651
|
+
component: settingsTab("FulfillmentSettings", () => React14__default.createElement(FulfillmentSettings, { provider: options?.provider })),
|
|
9567
9652
|
order: 34,
|
|
9568
9653
|
permission: READ
|
|
9569
9654
|
}
|