admin-lib-cms 1.2.18 → 1.2.19
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/README.md +29 -0
- package/dist/index.d.mts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +1350 -1053
- package/dist/index.mjs +1361 -1060
- package/dist/types.d.mts +5 -1
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var index_exports = {};
|
|
|
33
33
|
__export(index_exports, {
|
|
34
34
|
AdminApp: () => AdminApp,
|
|
35
35
|
AdminLogin: () => AdminLogin,
|
|
36
|
+
AdminTimeRangePicker: () => AdminTimeRangePicker,
|
|
36
37
|
CmsProvider: () => CmsProvider,
|
|
37
38
|
EditableFile: () => EditableFile,
|
|
38
39
|
EditableImage: () => EditableImage,
|
|
@@ -40,6 +41,8 @@ __export(index_exports, {
|
|
|
40
41
|
EditableList: () => EditableList,
|
|
41
42
|
EditableReference: () => EditableReference,
|
|
42
43
|
EditableText: () => EditableText,
|
|
44
|
+
FormattedNumberInput: () => FormattedNumberInput,
|
|
45
|
+
SearchableMultiSelect: () => SearchableMultiSelect,
|
|
43
46
|
SubscriptionPage: () => SubscriptionPage,
|
|
44
47
|
SubscriptionProvider: () => SubscriptionProvider,
|
|
45
48
|
generateDefaultTemplate: () => generateDefaultTemplate,
|
|
@@ -881,7 +884,15 @@ function findExistingEntry(item, existingEntries, collection) {
|
|
|
881
884
|
}
|
|
882
885
|
return null;
|
|
883
886
|
}
|
|
884
|
-
function formatValueForExport(val, field) {
|
|
887
|
+
function formatValueForExport(val, field, entry) {
|
|
888
|
+
if (field?.formatExport && typeof field.formatExport === "function") {
|
|
889
|
+
try {
|
|
890
|
+
const res = field.formatExport(val, entry);
|
|
891
|
+
if (res !== void 0 && res !== null) return res;
|
|
892
|
+
} catch (e) {
|
|
893
|
+
console.error("Error en formatExport:", e);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
885
896
|
if (val === void 0 || val === null) return "";
|
|
886
897
|
if (typeof val === "number" || typeof val === "boolean") return val;
|
|
887
898
|
if (Array.isArray(val)) {
|
|
@@ -911,7 +922,7 @@ function exportCollectionToExcel(collection, entries, fileNamePrefix) {
|
|
|
911
922
|
const rowObj = {};
|
|
912
923
|
columns.forEach((col) => {
|
|
913
924
|
const rawVal = entry[col.key];
|
|
914
|
-
rowObj[col.label] = formatValueForExport(rawVal, col.field);
|
|
925
|
+
rowObj[col.label] = formatValueForExport(rawVal, col.field, entry);
|
|
915
926
|
});
|
|
916
927
|
return rowObj;
|
|
917
928
|
});
|
|
@@ -1279,12 +1290,13 @@ function getAdminTranslations(locale) {
|
|
|
1279
1290
|
// src/admin/AdminApp.tsx
|
|
1280
1291
|
var import_lucide_react3 = require("lucide-react");
|
|
1281
1292
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1282
|
-
var AdminI18nContext = import_react5.default.createContext(
|
|
1293
|
+
var AdminI18nContext = import_react5.default.createContext(
|
|
1294
|
+
getAdminTranslations("en")
|
|
1295
|
+
);
|
|
1283
1296
|
function useAdminI18n() {
|
|
1284
1297
|
return import_react5.default.useContext(AdminI18nContext);
|
|
1285
1298
|
}
|
|
1286
1299
|
var TIME_STORAGE_FORMAT = "h:mm a";
|
|
1287
|
-
var TIME_DISPLAY_FORMAT = "h:mm a";
|
|
1288
1300
|
var TIME_PICKER_THEME = {
|
|
1289
1301
|
token: {
|
|
1290
1302
|
borderRadius: 12,
|
|
@@ -1310,6 +1322,21 @@ var TIME_PICKER_THEME = {
|
|
|
1310
1322
|
}
|
|
1311
1323
|
}
|
|
1312
1324
|
};
|
|
1325
|
+
function parseCurrencyInput(value, locale) {
|
|
1326
|
+
if (!value) return 0;
|
|
1327
|
+
const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);
|
|
1328
|
+
const groupSeparator = parts.find((part) => part.type === "group")?.value;
|
|
1329
|
+
const decimalSeparator = parts.find((part) => part.type === "decimal")?.value;
|
|
1330
|
+
let normalized = value;
|
|
1331
|
+
if (groupSeparator) {
|
|
1332
|
+
normalized = normalized.split(groupSeparator).join("");
|
|
1333
|
+
}
|
|
1334
|
+
if (decimalSeparator && decimalSeparator !== ".") {
|
|
1335
|
+
normalized = normalized.split(decimalSeparator).join(".");
|
|
1336
|
+
}
|
|
1337
|
+
const parsed = Number(normalized.replace(/[^\d.-]/g, ""));
|
|
1338
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
1339
|
+
}
|
|
1313
1340
|
function AdminTimeRangePicker(props) {
|
|
1314
1341
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1315
1342
|
import_antd.TimePicker.RangePicker,
|
|
@@ -1339,7 +1366,13 @@ function toDayjsTime(value) {
|
|
|
1339
1366
|
if (match24) {
|
|
1340
1367
|
return (0, import_dayjs2.default)().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
|
|
1341
1368
|
}
|
|
1342
|
-
const parsed = (0, import_dayjs2.default)(str, [
|
|
1369
|
+
const parsed = (0, import_dayjs2.default)(str, [
|
|
1370
|
+
"h:mm a",
|
|
1371
|
+
"h:mm A",
|
|
1372
|
+
"hh:mm a",
|
|
1373
|
+
"hh:mm A",
|
|
1374
|
+
"HH:mm"
|
|
1375
|
+
]);
|
|
1343
1376
|
return parsed.isValid() ? parsed : null;
|
|
1344
1377
|
}
|
|
1345
1378
|
function toStoredTime(value) {
|
|
@@ -1406,7 +1439,15 @@ function FilePickerButton({
|
|
|
1406
1439
|
function AdminApp(props) {
|
|
1407
1440
|
const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.App, { className: "min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminAppContent, { ...props }) });
|
|
1408
1441
|
if (props.projectId) {
|
|
1409
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1443
|
+
SubscriptionProvider,
|
|
1444
|
+
{
|
|
1445
|
+
apiUrl: props.apiUrl,
|
|
1446
|
+
projectId: props.projectId,
|
|
1447
|
+
email: props.email,
|
|
1448
|
+
children: content
|
|
1449
|
+
}
|
|
1450
|
+
);
|
|
1410
1451
|
}
|
|
1411
1452
|
return content;
|
|
1412
1453
|
}
|
|
@@ -1415,7 +1456,9 @@ function AdminAppContent(props) {
|
|
|
1415
1456
|
const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
|
|
1416
1457
|
const t = (0, import_react5.useMemo)(() => getAdminTranslations(rawLocale), [rawLocale]);
|
|
1417
1458
|
const hasDashboard = Boolean(props.dashboard);
|
|
1418
|
-
const [section, setSection] = (0, import_react5.useState)(
|
|
1459
|
+
const [section, setSection] = (0, import_react5.useState)(
|
|
1460
|
+
hasDashboard ? "dashboard" : "pages"
|
|
1461
|
+
);
|
|
1419
1462
|
const [authChecking, setAuthChecking] = (0, import_react5.useState)(true);
|
|
1420
1463
|
const [authenticated, setAuthenticated] = (0, import_react5.useState)(false);
|
|
1421
1464
|
const hideSettings = props.hideSettings ?? ctx.config.hideSettings ?? false;
|
|
@@ -1470,13 +1513,27 @@ function AdminAppContent(props) {
|
|
|
1470
1513
|
daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-rose-600 text-white px-4 py-2.5 text-center text-sm font-bold shadow-sm z-50", children: "Attention: If you do not settle your balance, your account will be suspended soon." }),
|
|
1471
1514
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
|
|
1472
1515
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "lg:hidden flex items-center justify-between bg-white/80 backdrop-blur-xl border-b border-slate-200 px-4 py-3 shrink-0 z-20 relative", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1473
|
-
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1516
|
+
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1517
|
+
"img",
|
|
1518
|
+
{
|
|
1519
|
+
src: String(ctx.overrides["global-logo"]),
|
|
1520
|
+
alt: "Logo",
|
|
1521
|
+
className: "h-5 w-auto object-contain"
|
|
1522
|
+
}
|
|
1523
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
|
|
1474
1524
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
|
|
1475
1525
|
] }) }),
|
|
1476
1526
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: "flex w-full lg:w-64 shrink-0 flex-col border-b lg:border-b-0 lg:border-r border-slate-200 bg-white/80 backdrop-blur-xl shadow-sm z-10 overflow-hidden", children: [
|
|
1477
1527
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "hidden lg:block border-b border-slate-200 px-6 py-5 bg-white/50", children: [
|
|
1478
1528
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
1479
|
-
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1529
|
+
ctx.overrides?.["global-logo"] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1530
|
+
"img",
|
|
1531
|
+
{
|
|
1532
|
+
src: String(ctx.overrides["global-logo"]),
|
|
1533
|
+
alt: "Logo",
|
|
1534
|
+
className: "h-5 w-auto object-contain"
|
|
1535
|
+
}
|
|
1536
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-2 h-2 rounded-full bg-indigo-500 shadow-[0_0_8px_rgba(99,102,241,0.8)]" }),
|
|
1480
1537
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
|
|
1481
1538
|
] }),
|
|
1482
1539
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
|
|
@@ -1613,7 +1670,9 @@ function AdminAppContent(props) {
|
|
|
1613
1670
|
});
|
|
1614
1671
|
} else {
|
|
1615
1672
|
const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
|
|
1616
|
-
const bottomCustom = (props.customSections || []).filter(
|
|
1673
|
+
const bottomCustom = (props.customSections || []).filter(
|
|
1674
|
+
(cs) => cs.position === "bottom" || cs.position === "after-collections"
|
|
1675
|
+
).map((cs) => cs.id);
|
|
1617
1676
|
const otherCustom = (props.customSections || []).filter(
|
|
1618
1677
|
(cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
|
|
1619
1678
|
).map((cs) => cs.id);
|
|
@@ -1634,7 +1693,9 @@ function AdminAppContent(props) {
|
|
|
1634
1693
|
"button",
|
|
1635
1694
|
{
|
|
1636
1695
|
onClick: async () => {
|
|
1637
|
-
await fetch("/api/admin/auth?action=logout", {
|
|
1696
|
+
await fetch("/api/admin/auth?action=logout", {
|
|
1697
|
+
method: "POST"
|
|
1698
|
+
});
|
|
1638
1699
|
window.location.href = "/admin/login";
|
|
1639
1700
|
},
|
|
1640
1701
|
className: "flex items-center justify-center gap-2 w-full px-3 py-2 text-sm font-medium text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",
|
|
@@ -1721,16 +1782,22 @@ function PageListItem({
|
|
|
1721
1782
|
] })
|
|
1722
1783
|
}
|
|
1723
1784
|
) }),
|
|
1724
|
-
hasChildren && expanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1725
|
-
|
|
1785
|
+
hasChildren && expanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1786
|
+
"ul",
|
|
1726
1787
|
{
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1788
|
+
className: `mt-1 space-y-1 ${depth === 0 ? "ml-4 border-l-2 border-slate-100 pl-1" : "ml-2"}`,
|
|
1789
|
+
children: p.children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1790
|
+
PageListItem,
|
|
1791
|
+
{
|
|
1792
|
+
p: child,
|
|
1793
|
+
selected,
|
|
1794
|
+
onSelect,
|
|
1795
|
+
depth: depth + 1
|
|
1796
|
+
},
|
|
1797
|
+
child.id
|
|
1798
|
+
))
|
|
1799
|
+
}
|
|
1800
|
+
)
|
|
1734
1801
|
] });
|
|
1735
1802
|
}
|
|
1736
1803
|
function PagesSection() {
|
|
@@ -1765,14 +1832,20 @@ function PagesSection() {
|
|
|
1765
1832
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid h-full place-items-center text-sm text-slate-500", children: "Select a page to edit its content." }) })
|
|
1766
1833
|
] });
|
|
1767
1834
|
}
|
|
1768
|
-
function PageEditor({
|
|
1835
|
+
function PageEditor({
|
|
1836
|
+
page,
|
|
1837
|
+
showList,
|
|
1838
|
+
onToggleList
|
|
1839
|
+
}) {
|
|
1769
1840
|
const ctx = useCmsContext();
|
|
1770
1841
|
const t = useAdminI18n();
|
|
1771
1842
|
const iframeRef = (0, import_react5.useRef)(null);
|
|
1772
1843
|
const [registered, setRegistered] = (0, import_react5.useState)([]);
|
|
1773
1844
|
const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
|
|
1774
1845
|
const [preview, setPreview] = (0, import_react5.useState)(false);
|
|
1775
|
-
const [drawerState, setDrawerState] = (0, import_react5.useState)(
|
|
1846
|
+
const [drawerState, setDrawerState] = (0, import_react5.useState)(
|
|
1847
|
+
"half"
|
|
1848
|
+
);
|
|
1776
1849
|
const src = (0, import_react5.useMemo)(
|
|
1777
1850
|
() => `${page.path}${preview ? "" : "?__cms=edit"}`,
|
|
1778
1851
|
[page.path, preview]
|
|
@@ -1791,7 +1864,11 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1791
1864
|
}
|
|
1792
1865
|
} else if (d.type === "cms:ready") {
|
|
1793
1866
|
iframeRef.current?.contentWindow?.postMessage(
|
|
1794
|
-
{
|
|
1867
|
+
{
|
|
1868
|
+
__cms: true,
|
|
1869
|
+
type: "cms:set-all-overrides",
|
|
1870
|
+
overrides: ctx.overrides
|
|
1871
|
+
},
|
|
1795
1872
|
"*"
|
|
1796
1873
|
);
|
|
1797
1874
|
}
|
|
@@ -1814,20 +1891,54 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1814
1891
|
[ctx]
|
|
1815
1892
|
);
|
|
1816
1893
|
const selectedMeta = registered.find((r) => r.id === selectedId) ?? null;
|
|
1817
|
-
const [viewMode, setViewMode] = (0, import_react5.useState)(
|
|
1894
|
+
const [viewMode, setViewMode] = (0, import_react5.useState)(
|
|
1895
|
+
"desktop"
|
|
1896
|
+
);
|
|
1818
1897
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex h-full flex-col", children: [
|
|
1819
1898
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 border-b border-slate-200 bg-white/80 backdrop-blur px-4 py-3 shadow-sm z-10 shrink-0", children: [
|
|
1820
1899
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 text-sm shrink-0", children: [
|
|
1821
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1900
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1901
|
+
"button",
|
|
1902
|
+
{
|
|
1903
|
+
onClick: onToggleList,
|
|
1904
|
+
className: "text-slate-400 hover:text-slate-700 p-1 hidden lg:block",
|
|
1905
|
+
title: "Toggle Pages Menu",
|
|
1906
|
+
children: showList ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.PanelLeftClose, { className: "w-5 h-5" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.PanelLeftOpen, { className: "w-5 h-5" })
|
|
1907
|
+
}
|
|
1908
|
+
),
|
|
1822
1909
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-bold text-slate-800 text-sm md:text-base", children: page.name }),
|
|
1823
1910
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-slate-300 hidden sm:inline", children: "|" }),
|
|
1824
1911
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-slate-500 font-mono text-[10px] md:text-xs bg-slate-100 px-2 py-1 rounded hidden sm:inline-block", children: page.path })
|
|
1825
1912
|
] }),
|
|
1826
1913
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 overflow-x-auto w-full sm:w-auto pb-1 sm:pb-0 hide-scrollbar shrink-0", children: [
|
|
1827
1914
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex bg-slate-100/80 p-0.5 rounded-lg mr-2 shrink-0", children: [
|
|
1828
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1829
|
-
|
|
1830
|
-
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1916
|
+
"button",
|
|
1917
|
+
{
|
|
1918
|
+
onClick: () => setViewMode("desktop"),
|
|
1919
|
+
className: `p-1.5 rounded-md transition-all ${viewMode === "desktop" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`,
|
|
1920
|
+
title: "Desktop View",
|
|
1921
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Monitor, { className: "w-4 h-4" })
|
|
1922
|
+
}
|
|
1923
|
+
),
|
|
1924
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1925
|
+
"button",
|
|
1926
|
+
{
|
|
1927
|
+
onClick: () => setViewMode("tablet"),
|
|
1928
|
+
className: `p-1.5 rounded-md transition-all ${viewMode === "tablet" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`,
|
|
1929
|
+
title: "Tablet View",
|
|
1930
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Tablet, { className: "w-4 h-4" })
|
|
1931
|
+
}
|
|
1932
|
+
),
|
|
1933
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1934
|
+
"button",
|
|
1935
|
+
{
|
|
1936
|
+
onClick: () => setViewMode("mobile"),
|
|
1937
|
+
className: `p-1.5 rounded-md transition-all ${viewMode === "mobile" ? "bg-white shadow-sm text-indigo-600" : "text-slate-500 hover:text-slate-800"}`,
|
|
1938
|
+
title: "Mobile View",
|
|
1939
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Smartphone, { className: "w-4 h-4" })
|
|
1940
|
+
}
|
|
1941
|
+
)
|
|
1831
1942
|
] }),
|
|
1832
1943
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1833
1944
|
"button",
|
|
@@ -1880,100 +1991,133 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1880
1991
|
] })
|
|
1881
1992
|
] }),
|
|
1882
1993
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
|
|
1883
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1884
|
-
"
|
|
1994
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-hidden bg-slate-100/80 p-2 sm:p-4 flex flex-col items-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1995
|
+
"div",
|
|
1885
1996
|
{
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
className: "h-full w-full bg-white",
|
|
1890
|
-
allow: "autoplay; encrypted-media; fullscreen"
|
|
1891
|
-
},
|
|
1892
|
-
src
|
|
1893
|
-
) }) }),
|
|
1894
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`, children: [
|
|
1895
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
|
|
1896
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
|
|
1897
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1898
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1 sm:hidden", children: [
|
|
1899
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1900
|
-
"button",
|
|
1901
|
-
{
|
|
1902
|
-
onClick: () => setDrawerState((prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"),
|
|
1903
|
-
className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
|
|
1904
|
-
title: "Shrink",
|
|
1905
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-4 h-4" })
|
|
1906
|
-
}
|
|
1907
|
-
),
|
|
1908
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1909
|
-
"button",
|
|
1910
|
-
{
|
|
1911
|
-
onClick: () => setDrawerState((prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"),
|
|
1912
|
-
className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
|
|
1913
|
-
title: "Expand",
|
|
1914
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-4 h-4" })
|
|
1915
|
-
}
|
|
1916
|
-
)
|
|
1917
|
-
] }),
|
|
1918
|
-
selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setSelectedId(null), className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest", children: "Close" })
|
|
1919
|
-
] })
|
|
1920
|
-
] }),
|
|
1921
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
|
|
1922
|
-
!selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
|
|
1923
|
-
selectedMeta ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1924
|
-
FieldEditor,
|
|
1997
|
+
className: `flex-1 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-lg ring-1 ring-slate-900/5 min-h-[300px] transition-all duration-300 w-full ${viewMode === "mobile" ? "max-w-[375px]" : viewMode === "tablet" ? "max-w-[768px]" : "w-full"}`,
|
|
1998
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1999
|
+
"iframe",
|
|
1925
2000
|
{
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2001
|
+
ref: iframeRef,
|
|
2002
|
+
src,
|
|
2003
|
+
title: page.name,
|
|
2004
|
+
className: "h-full w-full bg-white",
|
|
2005
|
+
allow: "autoplay; encrypted-media; fullscreen"
|
|
2006
|
+
},
|
|
2007
|
+
src
|
|
2008
|
+
)
|
|
2009
|
+
}
|
|
2010
|
+
) }),
|
|
2011
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2012
|
+
"aside",
|
|
2013
|
+
{
|
|
2014
|
+
className: `w-full sm:w-[320px] lg:w-[360px] shrink-0 overflow-y-auto border-t sm:border-t-0 sm:border-l border-slate-200 bg-white shadow-[-4px_0_15px_-3px_rgba(0,0,0,0.05)] z-10 hide-scrollbar transition-all duration-300 ${drawerState === "min" ? "max-h-[52px] sm:max-h-none" : drawerState === "full" ? "max-h-[85vh] sm:max-h-none" : "max-h-[50vh] sm:max-h-none"}`,
|
|
2015
|
+
children: [
|
|
2016
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "sticky top-0 bg-white/90 backdrop-blur border-b border-slate-200 px-5 py-3 md:py-4 z-10 flex items-center justify-between", children: [
|
|
2017
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
|
|
2018
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
2019
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1 sm:hidden", children: [
|
|
2020
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2021
|
+
"button",
|
|
2022
|
+
{
|
|
2023
|
+
onClick: () => setDrawerState(
|
|
2024
|
+
(prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"
|
|
2025
|
+
),
|
|
2026
|
+
className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
|
|
2027
|
+
title: "Shrink",
|
|
2028
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-4 h-4" })
|
|
2029
|
+
}
|
|
2030
|
+
),
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2032
|
+
"button",
|
|
2033
|
+
{
|
|
2034
|
+
onClick: () => setDrawerState(
|
|
2035
|
+
(prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"
|
|
2036
|
+
),
|
|
2037
|
+
className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
|
|
2038
|
+
title: "Expand",
|
|
2039
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-4 h-4" })
|
|
2040
|
+
}
|
|
2041
|
+
)
|
|
2042
|
+
] }),
|
|
2043
|
+
selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2044
|
+
"button",
|
|
1932
2045
|
{
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2046
|
+
onClick: () => setSelectedId(null),
|
|
2047
|
+
className: "sm:hidden text-slate-400 hover:text-slate-700 text-xs font-bold uppercase tracking-widest",
|
|
2048
|
+
children: "Close"
|
|
2049
|
+
}
|
|
2050
|
+
)
|
|
2051
|
+
] })
|
|
2052
|
+
] }),
|
|
2053
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
|
|
2054
|
+
!selectedMeta && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-5 mt-1 mb-2", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-[10px] md:text-xs text-slate-400", children: "Select an element on the left to edit it." }) }),
|
|
2055
|
+
selectedMeta ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2056
|
+
FieldEditor,
|
|
2057
|
+
{
|
|
2058
|
+
meta: selectedMeta,
|
|
2059
|
+
value: ctx.overrides[selectedMeta.id] ?? selectedMeta.defaultValue,
|
|
2060
|
+
onChange: (v) => updateOverride(selectedMeta.id, v),
|
|
2061
|
+
onReset: () => {
|
|
2062
|
+
ctx.reset(selectedMeta.id);
|
|
2063
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
2064
|
+
{
|
|
2065
|
+
__cms: true,
|
|
2066
|
+
type: "cms:set-override",
|
|
2067
|
+
id: selectedMeta.id,
|
|
2068
|
+
value: selectedMeta.defaultValue
|
|
2069
|
+
},
|
|
2070
|
+
"*"
|
|
2071
|
+
);
|
|
1937
2072
|
},
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
2073
|
+
onClose: () => setSelectedId(null)
|
|
2074
|
+
}
|
|
2075
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
2076
|
+
page.hideable && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "px-5 py-4 border-b border-slate-100 bg-slate-50/50", children: [
|
|
2077
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center space-x-3", children: [
|
|
2078
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2079
|
+
"input",
|
|
2080
|
+
{
|
|
2081
|
+
type: "checkbox",
|
|
2082
|
+
id: `page-visible-toggle-${page.id}`,
|
|
2083
|
+
checked: ctx.overrides[`page-${page.id}-visible`] !== false,
|
|
2084
|
+
onChange: (e) => updateOverride(
|
|
2085
|
+
`page-${page.id}-visible`,
|
|
2086
|
+
e.target.checked
|
|
2087
|
+
),
|
|
2088
|
+
className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-600 focus:ring-offset-0"
|
|
2089
|
+
}
|
|
2090
|
+
),
|
|
2091
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2092
|
+
"label",
|
|
2093
|
+
{
|
|
2094
|
+
htmlFor: `page-visible-toggle-${page.id}`,
|
|
2095
|
+
className: "text-sm font-medium text-slate-800 cursor-pointer flex-1",
|
|
2096
|
+
children: "Page is Visible"
|
|
2097
|
+
}
|
|
2098
|
+
)
|
|
2099
|
+
] }),
|
|
2100
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-[11px] text-slate-500 mt-1.5 pl-8", children: "If unchecked, this page will be hidden from navigation and URL access." })
|
|
2101
|
+
] }),
|
|
1946
2102
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1947
|
-
|
|
2103
|
+
SectionAccordion,
|
|
1948
2104
|
{
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2105
|
+
registered,
|
|
2106
|
+
onSelect: (id) => {
|
|
2107
|
+
setSelectedId(id);
|
|
2108
|
+
setDrawerState((prev) => prev === "min" ? "half" : prev);
|
|
2109
|
+
iframeRef.current?.contentWindow?.postMessage(
|
|
2110
|
+
{ __cms: true, type: "cms:select", id },
|
|
2111
|
+
"*"
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
1954
2114
|
}
|
|
1955
|
-
)
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
SectionAccordion,
|
|
1962
|
-
{
|
|
1963
|
-
registered,
|
|
1964
|
-
onSelect: (id) => {
|
|
1965
|
-
setSelectedId(id);
|
|
1966
|
-
setDrawerState((prev) => prev === "min" ? "half" : prev);
|
|
1967
|
-
iframeRef.current?.contentWindow?.postMessage(
|
|
1968
|
-
{ __cms: true, type: "cms:select", id },
|
|
1969
|
-
"*"
|
|
1970
|
-
);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
)
|
|
1974
|
-
] })
|
|
1975
|
-
] })
|
|
1976
|
-
] })
|
|
2115
|
+
)
|
|
2116
|
+
] })
|
|
2117
|
+
] })
|
|
2118
|
+
]
|
|
2119
|
+
}
|
|
2120
|
+
)
|
|
1977
2121
|
] })
|
|
1978
2122
|
] });
|
|
1979
2123
|
}
|
|
@@ -2002,37 +2146,54 @@ function SectionAccordion({
|
|
|
2002
2146
|
sectionNames.map((sectionName) => {
|
|
2003
2147
|
const isOpen = expanded[sectionName] ?? false;
|
|
2004
2148
|
const fields = groups[sectionName];
|
|
2005
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2150
|
+
"div",
|
|
2151
|
+
{
|
|
2152
|
+
className: "rounded-lg border border-slate-200 overflow-hidden",
|
|
2153
|
+
children: [
|
|
2154
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2155
|
+
"button",
|
|
2156
|
+
{
|
|
2157
|
+
onClick: () => toggle(sectionName),
|
|
2158
|
+
className: "flex w-full items-center justify-between px-3 py-2.5 bg-slate-50/80 hover:bg-slate-100 transition-colors text-left",
|
|
2159
|
+
children: [
|
|
2160
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2", children: [
|
|
2161
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold text-sm text-slate-800", children: sectionName }),
|
|
2162
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-400 bg-slate-200/70 px-1.5 py-0.5 rounded-full", children: fields.length })
|
|
2163
|
+
] }),
|
|
2164
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2165
|
+
"svg",
|
|
2166
|
+
{
|
|
2167
|
+
className: `h-4 w-4 text-slate-400 transition-transform duration-200 ${isOpen ? "rotate-180" : ""}`,
|
|
2168
|
+
fill: "none",
|
|
2169
|
+
viewBox: "0 0 24 24",
|
|
2170
|
+
stroke: "currentColor",
|
|
2171
|
+
strokeWidth: 2,
|
|
2172
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2173
|
+
"path",
|
|
2174
|
+
{
|
|
2175
|
+
strokeLinecap: "round",
|
|
2176
|
+
strokeLinejoin: "round",
|
|
2177
|
+
d: "M19 9l-7 7-7-7"
|
|
2178
|
+
}
|
|
2179
|
+
)
|
|
2180
|
+
}
|
|
2181
|
+
)
|
|
2182
|
+
]
|
|
2183
|
+
}
|
|
2184
|
+
),
|
|
2185
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { className: "divide-y divide-slate-100 bg-white", children: fields.map((m) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldListItem, { meta: m, onSelect }, m.id)) })
|
|
2186
|
+
]
|
|
2187
|
+
},
|
|
2188
|
+
sectionName
|
|
2189
|
+
);
|
|
2032
2190
|
})
|
|
2033
2191
|
] });
|
|
2034
2192
|
}
|
|
2035
|
-
function FieldListItem({
|
|
2193
|
+
function FieldListItem({
|
|
2194
|
+
meta,
|
|
2195
|
+
onSelect
|
|
2196
|
+
}) {
|
|
2036
2197
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "p-1 list-none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2037
2198
|
"button",
|
|
2038
2199
|
{
|
|
@@ -2054,9 +2215,15 @@ function FieldListItem({ meta, onSelect }) {
|
|
|
2054
2215
|
}
|
|
2055
2216
|
) });
|
|
2056
2217
|
}
|
|
2057
|
-
function SidebarReferenceSelect({
|
|
2218
|
+
function SidebarReferenceSelect({
|
|
2219
|
+
meta,
|
|
2220
|
+
value,
|
|
2221
|
+
onChange
|
|
2222
|
+
}) {
|
|
2058
2223
|
const ctx = useCmsContext();
|
|
2059
|
-
const collection = ctx.config.collections?.find(
|
|
2224
|
+
const collection = ctx.config.collections?.find(
|
|
2225
|
+
(c) => c.id === meta.collection
|
|
2226
|
+
);
|
|
2060
2227
|
const [items, setItems] = (0, import_react5.useState)([]);
|
|
2061
2228
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
2062
2229
|
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
@@ -2082,7 +2249,9 @@ function SidebarReferenceSelect({ meta, value, onChange }) {
|
|
|
2082
2249
|
}
|
|
2083
2250
|
};
|
|
2084
2251
|
const imgField = collection?.fields.find((f) => f.type === "image");
|
|
2085
|
-
const txtField = collection?.fields.find(
|
|
2252
|
+
const txtField = collection?.fields.find(
|
|
2253
|
+
(f) => f.type === "text" || f.type === "textarea" || f.type === "richtext"
|
|
2254
|
+
);
|
|
2086
2255
|
const filtered = items.filter((it) => {
|
|
2087
2256
|
if (!search) return true;
|
|
2088
2257
|
const q = search.toLowerCase();
|
|
@@ -2110,8 +2279,21 @@ function SidebarReferenceSelect({ meta, value, onChange }) {
|
|
|
2110
2279
|
onClick: () => toggle(it.id),
|
|
2111
2280
|
className: `flex items-center gap-3 p-2 rounded-xl cursor-pointer border ${isSelected ? "border-indigo-500 bg-indigo-50" : "border-slate-100 bg-slate-50 hover:border-slate-300"}`,
|
|
2112
2281
|
children: [
|
|
2113
|
-
!!imgSrc && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2114
|
-
|
|
2282
|
+
!!imgSrc && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2283
|
+
"img",
|
|
2284
|
+
{
|
|
2285
|
+
src: Array.isArray(imgSrc) ? String(imgSrc[0]) : String(imgSrc),
|
|
2286
|
+
alt: "",
|
|
2287
|
+
className: "w-10 h-10 rounded-lg object-cover bg-white border border-slate-200"
|
|
2288
|
+
}
|
|
2289
|
+
),
|
|
2290
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2291
|
+
"span",
|
|
2292
|
+
{
|
|
2293
|
+
className: `text-sm ${isSelected ? "font-semibold text-indigo-900" : "text-slate-700"}`,
|
|
2294
|
+
children: String(label)
|
|
2295
|
+
}
|
|
2296
|
+
),
|
|
2115
2297
|
isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Check, { className: "w-4 h-4 text-indigo-600 ml-auto" })
|
|
2116
2298
|
]
|
|
2117
2299
|
},
|
|
@@ -2130,7 +2312,9 @@ function FieldEditor({
|
|
|
2130
2312
|
onClose
|
|
2131
2313
|
}) {
|
|
2132
2314
|
const ctx = useCmsContext();
|
|
2133
|
-
const [expandedItems, setExpandedItems] = (0, import_react5.useState)(
|
|
2315
|
+
const [expandedItems, setExpandedItems] = (0, import_react5.useState)(
|
|
2316
|
+
{}
|
|
2317
|
+
);
|
|
2134
2318
|
const [searchQuery, setSearchQuery] = (0, import_react5.useState)("");
|
|
2135
2319
|
const [listDragIdx, setListDragIdx] = (0, import_react5.useState)(null);
|
|
2136
2320
|
const [listDragOverIdx, setListDragOverIdx] = (0, import_react5.useState)(null);
|
|
@@ -2152,7 +2336,14 @@ function FieldEditor({
|
|
|
2152
2336
|
className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-600 focus:ring-offset-0"
|
|
2153
2337
|
}
|
|
2154
2338
|
),
|
|
2155
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2340
|
+
"label",
|
|
2341
|
+
{
|
|
2342
|
+
htmlFor: meta.id,
|
|
2343
|
+
className: "text-sm font-medium text-slate-700 cursor-pointer",
|
|
2344
|
+
children: meta.label || "Enabled"
|
|
2345
|
+
}
|
|
2346
|
+
)
|
|
2156
2347
|
] }),
|
|
2157
2348
|
meta.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2158
2349
|
"input",
|
|
@@ -2374,7 +2565,9 @@ function FieldEditor({
|
|
|
2374
2565
|
] }),
|
|
2375
2566
|
(Array.isArray(value) ? value : []).map((item, idx) => {
|
|
2376
2567
|
if (meta.search && searchQuery) {
|
|
2377
|
-
const title = String(
|
|
2568
|
+
const title = String(
|
|
2569
|
+
item?.title || item?.name || ""
|
|
2570
|
+
).toLowerCase();
|
|
2378
2571
|
if (!title.includes(searchQuery.toLowerCase())) return null;
|
|
2379
2572
|
}
|
|
2380
2573
|
const isExpanded = expandedItems[idx] ?? false;
|
|
@@ -2416,7 +2609,10 @@ function FieldEditor({
|
|
|
2416
2609
|
"div",
|
|
2417
2610
|
{
|
|
2418
2611
|
className: "flex items-center justify-between cursor-pointer py-1 select-none gap-2",
|
|
2419
|
-
onClick: () => setExpandedItems((prev) => ({
|
|
2612
|
+
onClick: () => setExpandedItems((prev) => ({
|
|
2613
|
+
...prev,
|
|
2614
|
+
[idx]: !isExpanded
|
|
2615
|
+
})),
|
|
2420
2616
|
children: [
|
|
2421
2617
|
isReorderable && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2422
2618
|
"div",
|
|
@@ -2477,13 +2673,18 @@ function FieldEditor({
|
|
|
2477
2673
|
schemaField.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2478
2674
|
SearchableSelect,
|
|
2479
2675
|
{
|
|
2480
|
-
value: String(
|
|
2676
|
+
value: String(
|
|
2677
|
+
item?.[schemaField.key] ?? (Array.isArray(meta.defaultValue) ? meta.defaultValue[idx]?.[schemaField.key] : "") ?? ""
|
|
2678
|
+
),
|
|
2481
2679
|
options: schemaField.options ?? [],
|
|
2482
2680
|
placeholder: "Search icon...",
|
|
2483
2681
|
iconMap: ctx.iconMap,
|
|
2484
2682
|
onChange: (val) => {
|
|
2485
2683
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2486
|
-
arr[idx] = {
|
|
2684
|
+
arr[idx] = {
|
|
2685
|
+
...arr[idx] || {},
|
|
2686
|
+
[schemaField.key]: val
|
|
2687
|
+
};
|
|
2487
2688
|
onChange(arr);
|
|
2488
2689
|
}
|
|
2489
2690
|
}
|
|
@@ -2491,10 +2692,15 @@ function FieldEditor({
|
|
|
2491
2692
|
"textarea",
|
|
2492
2693
|
{
|
|
2493
2694
|
rows: 3,
|
|
2494
|
-
value: String(
|
|
2695
|
+
value: String(
|
|
2696
|
+
item?.[schemaField.key] ?? ""
|
|
2697
|
+
),
|
|
2495
2698
|
onChange: (e) => {
|
|
2496
2699
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2497
|
-
arr[idx] = {
|
|
2700
|
+
arr[idx] = {
|
|
2701
|
+
...arr[idx] || {},
|
|
2702
|
+
[schemaField.key]: e.target.value
|
|
2703
|
+
};
|
|
2498
2704
|
onChange(arr);
|
|
2499
2705
|
},
|
|
2500
2706
|
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
@@ -2507,7 +2713,10 @@ function FieldEditor({
|
|
|
2507
2713
|
checked: !!item?.[schemaField.key],
|
|
2508
2714
|
onChange: (e) => {
|
|
2509
2715
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2510
|
-
arr[idx] = {
|
|
2716
|
+
arr[idx] = {
|
|
2717
|
+
...arr[idx] || {},
|
|
2718
|
+
[schemaField.key]: e.target.checked
|
|
2719
|
+
};
|
|
2511
2720
|
onChange(arr);
|
|
2512
2721
|
},
|
|
2513
2722
|
className: "w-4 h-4 text-indigo-600 border-slate-300 rounded focus:ring-indigo-500"
|
|
@@ -2520,10 +2729,15 @@ function FieldEditor({
|
|
|
2520
2729
|
"input",
|
|
2521
2730
|
{
|
|
2522
2731
|
type: "url",
|
|
2523
|
-
value: String(
|
|
2732
|
+
value: String(
|
|
2733
|
+
item?.[schemaField.key] ?? ""
|
|
2734
|
+
),
|
|
2524
2735
|
onChange: (e) => {
|
|
2525
2736
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2526
|
-
arr[idx] = {
|
|
2737
|
+
arr[idx] = {
|
|
2738
|
+
...arr[idx] || {},
|
|
2739
|
+
[schemaField.key]: e.target.value
|
|
2740
|
+
};
|
|
2527
2741
|
onChange(arr);
|
|
2528
2742
|
},
|
|
2529
2743
|
placeholder: "https://... or upload",
|
|
@@ -2545,7 +2759,10 @@ function FieldEditor({
|
|
|
2545
2759
|
file,
|
|
2546
2760
|
(url) => {
|
|
2547
2761
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2548
|
-
arr[idx] = {
|
|
2762
|
+
arr[idx] = {
|
|
2763
|
+
...arr[idx] || {},
|
|
2764
|
+
[schemaField.key]: url
|
|
2765
|
+
};
|
|
2549
2766
|
onChange(arr);
|
|
2550
2767
|
},
|
|
2551
2768
|
ctx.uploadImage
|
|
@@ -2556,17 +2773,25 @@ function FieldEditor({
|
|
|
2556
2773
|
)
|
|
2557
2774
|
] })
|
|
2558
2775
|
] }),
|
|
2559
|
-
item?.[schemaField.key] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-lg border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(
|
|
2776
|
+
item?.[schemaField.key] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-lg border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(
|
|
2777
|
+
item?.[schemaField.key]
|
|
2778
|
+
).match(
|
|
2779
|
+
/\.(mp4|webm|ogg|mov)(\?.*)?$/i
|
|
2780
|
+
) || schemaField.type === "video" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2560
2781
|
"video",
|
|
2561
2782
|
{
|
|
2562
|
-
src: String(
|
|
2783
|
+
src: String(
|
|
2784
|
+
item?.[schemaField.key]
|
|
2785
|
+
),
|
|
2563
2786
|
controls: true,
|
|
2564
2787
|
className: "w-full h-auto max-h-32 object-contain rounded-md"
|
|
2565
2788
|
}
|
|
2566
2789
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2567
2790
|
"img",
|
|
2568
2791
|
{
|
|
2569
|
-
src: String(
|
|
2792
|
+
src: String(
|
|
2793
|
+
item?.[schemaField.key]
|
|
2794
|
+
),
|
|
2570
2795
|
alt: "",
|
|
2571
2796
|
className: "w-full h-auto max-h-32 object-contain rounded-md"
|
|
2572
2797
|
}
|
|
@@ -2574,10 +2799,15 @@ function FieldEditor({
|
|
|
2574
2799
|
] }) : schemaField.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2575
2800
|
"select",
|
|
2576
2801
|
{
|
|
2577
|
-
value: String(
|
|
2802
|
+
value: String(
|
|
2803
|
+
item?.[schemaField.key] ?? ""
|
|
2804
|
+
),
|
|
2578
2805
|
onChange: (e) => {
|
|
2579
2806
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2580
|
-
arr[idx] = {
|
|
2807
|
+
arr[idx] = {
|
|
2808
|
+
...arr[idx] || {},
|
|
2809
|
+
[schemaField.key]: e.target.value
|
|
2810
|
+
};
|
|
2581
2811
|
onChange(arr);
|
|
2582
2812
|
},
|
|
2583
2813
|
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 bg-white",
|
|
@@ -2589,7 +2819,10 @@ function FieldEditor({
|
|
|
2589
2819
|
value: item?.[schemaField.key],
|
|
2590
2820
|
onChange: (val) => {
|
|
2591
2821
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2592
|
-
arr[idx] = {
|
|
2822
|
+
arr[idx] = {
|
|
2823
|
+
...arr[idx] || {},
|
|
2824
|
+
[schemaField.key]: val
|
|
2825
|
+
};
|
|
2593
2826
|
onChange(arr);
|
|
2594
2827
|
},
|
|
2595
2828
|
isPrice: schemaField.key.toLowerCase().includes("price") || schemaField.key.toLowerCase().includes("precio"),
|
|
@@ -2599,10 +2832,15 @@ function FieldEditor({
|
|
|
2599
2832
|
"input",
|
|
2600
2833
|
{
|
|
2601
2834
|
type: "text",
|
|
2602
|
-
value: String(
|
|
2835
|
+
value: String(
|
|
2836
|
+
item?.[schemaField.key] ?? ""
|
|
2837
|
+
),
|
|
2603
2838
|
onChange: (e) => {
|
|
2604
2839
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2605
|
-
arr[idx] = {
|
|
2840
|
+
arr[idx] = {
|
|
2841
|
+
...arr[idx] || {},
|
|
2842
|
+
[schemaField.key]: e.target.value
|
|
2843
|
+
};
|
|
2606
2844
|
onChange(arr);
|
|
2607
2845
|
},
|
|
2608
2846
|
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
@@ -2674,7 +2912,14 @@ function FieldEditor({
|
|
|
2674
2912
|
}
|
|
2675
2913
|
)
|
|
2676
2914
|
] }),
|
|
2677
|
-
meta.type === "reference" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2915
|
+
meta.type === "reference" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2916
|
+
SidebarReferenceSelect,
|
|
2917
|
+
{
|
|
2918
|
+
meta,
|
|
2919
|
+
value,
|
|
2920
|
+
onChange
|
|
2921
|
+
}
|
|
2922
|
+
)
|
|
2678
2923
|
] }),
|
|
2679
2924
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pt-6 mt-6 border-t border-slate-100", children: [
|
|
2680
2925
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
@@ -2714,7 +2959,9 @@ function CollectionsSection() {
|
|
|
2714
2959
|
const list = ctx.config.collections ?? [];
|
|
2715
2960
|
list.filter((c) => !c.isSeparator).forEach((c) => {
|
|
2716
2961
|
ctx.adapter.listEntries(c.id).then((entries) => {
|
|
2717
|
-
setCounts(
|
|
2962
|
+
setCounts(
|
|
2963
|
+
(prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length }
|
|
2964
|
+
);
|
|
2718
2965
|
});
|
|
2719
2966
|
});
|
|
2720
2967
|
}, [ctx.adapter, colIds, ctx.collectionChangedAt]);
|
|
@@ -2773,6 +3020,16 @@ function CollectionEditor({ collection }) {
|
|
|
2773
3020
|
const ctx = useCmsContext();
|
|
2774
3021
|
const t = useAdminI18n();
|
|
2775
3022
|
const { message } = import_antd.App.useApp();
|
|
3023
|
+
const currencyCode = ctx.config.currency ?? "USD";
|
|
3024
|
+
const currencyLocale = ctx.config.currencyLocale ?? ctx.config.locale ?? "en-US";
|
|
3025
|
+
const currencyFormatter = (0, import_react5.useMemo)(
|
|
3026
|
+
() => new Intl.NumberFormat(currencyLocale, {
|
|
3027
|
+
style: "currency",
|
|
3028
|
+
currency: currencyCode,
|
|
3029
|
+
maximumFractionDigits: 0
|
|
3030
|
+
}),
|
|
3031
|
+
[currencyCode, currencyLocale]
|
|
3032
|
+
);
|
|
2776
3033
|
const [entries, setEntries] = (0, import_react5.useState)([]);
|
|
2777
3034
|
const [editing, setEditing] = (0, import_react5.useState)(null);
|
|
2778
3035
|
const [originalId, setOriginalId] = (0, import_react5.useState)(null);
|
|
@@ -2833,11 +3090,16 @@ function CollectionEditor({ collection }) {
|
|
|
2833
3090
|
}, [entries, exportMode, exportDateField, exportDateRange]);
|
|
2834
3091
|
const [isImportModalOpen, setIsImportModalOpen] = (0, import_react5.useState)(false);
|
|
2835
3092
|
const [importFile, setImportFile] = (0, import_react5.useState)(null);
|
|
2836
|
-
const [importResult, setImportResult] = (0, import_react5.useState)(
|
|
3093
|
+
const [importResult, setImportResult] = (0, import_react5.useState)(
|
|
3094
|
+
null
|
|
3095
|
+
);
|
|
2837
3096
|
const [isParsingImport, setIsParsingImport] = (0, import_react5.useState)(false);
|
|
2838
3097
|
const [isImporting, setIsImporting] = (0, import_react5.useState)(false);
|
|
2839
3098
|
const [importExistingAction, setImportExistingAction] = (0, import_react5.useState)("omit");
|
|
2840
|
-
const [importProgress, setImportProgress] = (0, import_react5.useState)({
|
|
3099
|
+
const [importProgress, setImportProgress] = (0, import_react5.useState)({
|
|
3100
|
+
current: 0,
|
|
3101
|
+
total: 0
|
|
3102
|
+
});
|
|
2841
3103
|
const fileInputRef = (0, import_react5.useRef)(null);
|
|
2842
3104
|
const load = (0, import_react5.useCallback)(() => {
|
|
2843
3105
|
setLoadingEntries(true);
|
|
@@ -2955,13 +3217,17 @@ function CollectionEditor({ collection }) {
|
|
|
2955
3217
|
`Se crearon ${createdCount} registros y se actualizaron ${updatedCount} existentes.`
|
|
2956
3218
|
);
|
|
2957
3219
|
} else if (createdCount > 0) {
|
|
2958
|
-
message.success(
|
|
3220
|
+
message.success(
|
|
3221
|
+
`Se importaron ${createdCount} registros exitosamente.`
|
|
3222
|
+
);
|
|
2959
3223
|
} else if (omittedCount > 0) {
|
|
2960
3224
|
message.info(
|
|
2961
3225
|
`Los ${omittedCount} registros ya se encontraban creados. No se duplic\xF3 ning\xFAn dato.`
|
|
2962
3226
|
);
|
|
2963
3227
|
} else if (updatedCount > 0) {
|
|
2964
|
-
message.success(
|
|
3228
|
+
message.success(
|
|
3229
|
+
`Se actualizaron ${updatedCount} registros existentes.`
|
|
3230
|
+
);
|
|
2965
3231
|
}
|
|
2966
3232
|
load();
|
|
2967
3233
|
setIsImportModalOpen(false);
|
|
@@ -2991,17 +3257,6 @@ function CollectionEditor({ collection }) {
|
|
|
2991
3257
|
if (f.endField) base[f.endField] = "";
|
|
2992
3258
|
} else if (f.defaultValue !== void 0) {
|
|
2993
3259
|
base[f.id] = f.defaultValue;
|
|
2994
|
-
} else if (f.type === "branch-settings") {
|
|
2995
|
-
base[f.id] = {
|
|
2996
|
-
allBranches: true,
|
|
2997
|
-
branches: [],
|
|
2998
|
-
useBranchPricing: false,
|
|
2999
|
-
priceBranches: [],
|
|
3000
|
-
prices: {},
|
|
3001
|
-
useBranchDiscounts: false,
|
|
3002
|
-
discountBranches: [],
|
|
3003
|
-
discounts: {}
|
|
3004
|
-
};
|
|
3005
3260
|
} else if (f.multiple) {
|
|
3006
3261
|
base[f.id] = [];
|
|
3007
3262
|
} else {
|
|
@@ -3092,7 +3347,9 @@ function CollectionEditor({ collection }) {
|
|
|
3092
3347
|
}
|
|
3093
3348
|
}
|
|
3094
3349
|
await ctx.adapter.putEntry(collection.id, finalEditing);
|
|
3095
|
-
message.success(
|
|
3350
|
+
message.success(
|
|
3351
|
+
originalId ? "Guardado correctamente" : "Creado correctamente"
|
|
3352
|
+
);
|
|
3096
3353
|
ctx.notifyCollectionChanged();
|
|
3097
3354
|
setEntries((prev) => {
|
|
3098
3355
|
const next = [...prev];
|
|
@@ -3120,7 +3377,9 @@ function CollectionEditor({ collection }) {
|
|
|
3120
3377
|
try {
|
|
3121
3378
|
await ctx.adapter.deleteEntry(collection.id, id);
|
|
3122
3379
|
setEntries(
|
|
3123
|
-
(prev) => prev.filter(
|
|
3380
|
+
(prev) => prev.filter(
|
|
3381
|
+
(e) => String(e.id || "").trim().toLowerCase() !== String(id).trim().toLowerCase()
|
|
3382
|
+
)
|
|
3124
3383
|
);
|
|
3125
3384
|
ctx.notifyCollectionChanged();
|
|
3126
3385
|
load();
|
|
@@ -3163,8 +3422,12 @@ function CollectionEditor({ collection }) {
|
|
|
3163
3422
|
setDraggedIdx(null);
|
|
3164
3423
|
setDragOverIdx(null);
|
|
3165
3424
|
};
|
|
3166
|
-
const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter(
|
|
3167
|
-
|
|
3425
|
+
const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter(
|
|
3426
|
+
(f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden
|
|
3427
|
+
).slice(0, 6);
|
|
3428
|
+
const isCreatingEntry = isCreatingManual || (editing ? !entries.some(
|
|
3429
|
+
(entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)
|
|
3430
|
+
) : false);
|
|
3168
3431
|
if (isCustomCreating && collection.customCreateView) {
|
|
3169
3432
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full", children: collection.customCreateView({
|
|
3170
3433
|
onBack: () => setIsCustomCreating(false),
|
|
@@ -3247,7 +3510,9 @@ function CollectionEditor({ collection }) {
|
|
|
3247
3510
|
size: "large",
|
|
3248
3511
|
prefix: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "h-4 w-4 text-slate-400" }),
|
|
3249
3512
|
placeholder: `Buscar por ${collection.searchBy.map((s) => {
|
|
3250
|
-
const f = collection.fields.find(
|
|
3513
|
+
const f = collection.fields.find(
|
|
3514
|
+
(field) => field.id === s
|
|
3515
|
+
);
|
|
3251
3516
|
return f?.label ? f.label.toLowerCase() : s;
|
|
3252
3517
|
}).join(", ")}...`,
|
|
3253
3518
|
value: search,
|
|
@@ -3263,7 +3528,15 @@ function CollectionEditor({ collection }) {
|
|
|
3263
3528
|
const fieldDef = collection.fields.find((cf) => cf.id === f);
|
|
3264
3529
|
if (!fieldDef) return null;
|
|
3265
3530
|
if (fieldDef.type === "date") {
|
|
3266
|
-
const dateVal = filters[f] ? (0, import_dayjs2.default)(filters[f], [
|
|
3531
|
+
const dateVal = filters[f] ? (0, import_dayjs2.default)(filters[f], [
|
|
3532
|
+
"YYYY/MM/DD",
|
|
3533
|
+
"YYYY-MM-DD",
|
|
3534
|
+
"YYYY-M-D"
|
|
3535
|
+
]).isValid() ? (0, import_dayjs2.default)(filters[f], [
|
|
3536
|
+
"YYYY/MM/DD",
|
|
3537
|
+
"YYYY-MM-DD",
|
|
3538
|
+
"YYYY-M-D"
|
|
3539
|
+
]) : null : null;
|
|
3267
3540
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[180px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3268
3541
|
import_antd.DatePicker,
|
|
3269
3542
|
{
|
|
@@ -3284,7 +3557,9 @@ function CollectionEditor({ collection }) {
|
|
|
3284
3557
|
const predefinedOptions = (fieldDef.options || []).map(
|
|
3285
3558
|
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
3286
3559
|
);
|
|
3287
|
-
const entryVals = Array.from(
|
|
3560
|
+
const entryVals = Array.from(
|
|
3561
|
+
new Set(entries.map((e) => String(e[f] || "")))
|
|
3562
|
+
).filter(Boolean);
|
|
3288
3563
|
const combinedOptions = [...predefinedOptions];
|
|
3289
3564
|
for (const ev of entryVals) {
|
|
3290
3565
|
if (!combinedOptions.some((o) => o.value === ev)) {
|
|
@@ -3317,7 +3592,13 @@ function CollectionEditor({ collection }) {
|
|
|
3317
3592
|
isViewingDetail ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Eye, { className: "h-4 w-4 text-indigo-600" }) : isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
|
|
3318
3593
|
isViewingDetail ? `Detalle de ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}${editing?.numero ? ` #${editing.numero}` : ""}` : isCreatingEntry ? collection.createTitle || `Nueva ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}` : `Editar ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}`
|
|
3319
3594
|
] }),
|
|
3320
|
-
isViewingDetail && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3595
|
+
isViewingDetail && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3596
|
+
"span",
|
|
3597
|
+
{
|
|
3598
|
+
className: `px-2.5 py-1 text-xs font-semibold rounded-full ${String(editing.estado).toLowerCase().includes("terminad") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(editing.estado).toLowerCase().includes("proceso") ? "bg-sky-50 text-sky-700 border border-sky-200" : String(editing.estado).toLowerCase().includes("cancelad") ? "bg-rose-50 text-rose-700 border border-rose-200" : String(editing.estado).toLowerCase().includes("vencid") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-amber-50 text-amber-700 border border-amber-200"}`,
|
|
3599
|
+
children: String(editing.estado)
|
|
3600
|
+
}
|
|
3601
|
+
),
|
|
3321
3602
|
!isViewingDetail && !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3322
3603
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
|
|
3323
3604
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -3372,14 +3653,15 @@ function CollectionEditor({ collection }) {
|
|
|
3372
3653
|
if (f.dependsOn) {
|
|
3373
3654
|
const targetVal = editing[f.dependsOn.field];
|
|
3374
3655
|
if (Array.isArray(f.dependsOn.value)) {
|
|
3375
|
-
if (!f.dependsOn.value.includes(targetVal))
|
|
3656
|
+
if (!f.dependsOn.value.includes(targetVal))
|
|
3657
|
+
return false;
|
|
3376
3658
|
} else if (targetVal !== f.dependsOn.value) {
|
|
3377
3659
|
return false;
|
|
3378
3660
|
}
|
|
3379
3661
|
}
|
|
3380
3662
|
return true;
|
|
3381
3663
|
}).map((f) => {
|
|
3382
|
-
const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.multiple || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "
|
|
3664
|
+
const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.multiple || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "time-range";
|
|
3383
3665
|
const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
|
|
3384
3666
|
if (isViewingDetail) {
|
|
3385
3667
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
|
|
@@ -3399,14 +3681,16 @@ function CollectionEditor({ collection }) {
|
|
|
3399
3681
|
alt: f.label,
|
|
3400
3682
|
className: "h-28 w-auto max-w-full object-contain"
|
|
3401
3683
|
}
|
|
3402
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 italic py-1", children: "Sin firma registrada" }) : f.type === "list" || f.multiple ? Array.isArray(editing[f.id]) && editing[f.id].length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-1.5 pt-0.5", children: editing[f.id].map(
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3684
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 italic py-1", children: "Sin firma registrada" }) : f.type === "list" || f.multiple ? Array.isArray(editing[f.id]) && editing[f.id].length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-1.5 pt-0.5", children: editing[f.id].map(
|
|
3685
|
+
(item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3686
|
+
"span",
|
|
3687
|
+
{
|
|
3688
|
+
className: "rounded-xl bg-slate-100 text-slate-700 px-3 py-1 text-xs font-medium border border-slate-200",
|
|
3689
|
+
children: String(item)
|
|
3690
|
+
},
|
|
3691
|
+
idx
|
|
3692
|
+
)
|
|
3693
|
+
) }) : typeof editing[f.id] === "string" && editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2 text-sm text-slate-800 font-medium", children: String(editing[f.id]) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 italic py-1", children: "Ninguno" }) : f.type === "link" ? Boolean(editing[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3410
3694
|
"a",
|
|
3411
3695
|
{
|
|
3412
3696
|
href: String(editing[f.id]),
|
|
@@ -3425,7 +3709,14 @@ function CollectionEditor({ collection }) {
|
|
|
3425
3709
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
|
|
3426
3710
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
3427
3711
|
f.label,
|
|
3428
|
-
(f.required || f.unique) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3712
|
+
(f.required || f.unique) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3713
|
+
"span",
|
|
3714
|
+
{
|
|
3715
|
+
className: "text-rose-500 ml-1 font-bold",
|
|
3716
|
+
title: "Campo obligatorio",
|
|
3717
|
+
children: "*"
|
|
3718
|
+
}
|
|
3719
|
+
)
|
|
3429
3720
|
] }),
|
|
3430
3721
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
|
|
3431
3722
|
] }),
|
|
@@ -3436,16 +3727,7 @@ function CollectionEditor({ collection }) {
|
|
|
3436
3727
|
isCreatingEntry,
|
|
3437
3728
|
isViewingDetail: false,
|
|
3438
3729
|
readOnly: false
|
|
3439
|
-
}) : f.type === "
|
|
3440
|
-
BranchSettingsEditor,
|
|
3441
|
-
{
|
|
3442
|
-
collectionId: f.collection || "",
|
|
3443
|
-
value: editing[f.id],
|
|
3444
|
-
globalPrice: Number(editing.price) || 0,
|
|
3445
|
-
globalDiscount: Number(editing.discountPercent) || 0,
|
|
3446
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
3447
|
-
}
|
|
3448
|
-
) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
|
|
3730
|
+
}) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
|
|
3449
3731
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3450
3732
|
import_antd.Switch,
|
|
3451
3733
|
{
|
|
@@ -3463,6 +3745,14 @@ function CollectionEditor({ collection }) {
|
|
|
3463
3745
|
disabled: f.readOnly,
|
|
3464
3746
|
onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
|
|
3465
3747
|
className: "w-full rounded-xl",
|
|
3748
|
+
formatter: f.formatter ? (value) => {
|
|
3749
|
+
if (value === void 0 || value === null) {
|
|
3750
|
+
return "";
|
|
3751
|
+
}
|
|
3752
|
+
const numericValue = Number(value);
|
|
3753
|
+
return Number.isFinite(numericValue) ? currencyFormatter.format(numericValue) : "";
|
|
3754
|
+
} : void 0,
|
|
3755
|
+
parser: f.formatter ? (value) => parseCurrencyInput(value, currencyLocale) : void 0,
|
|
3466
3756
|
placeholder: "0"
|
|
3467
3757
|
}
|
|
3468
3758
|
) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -3470,7 +3760,10 @@ function CollectionEditor({ collection }) {
|
|
|
3470
3760
|
{
|
|
3471
3761
|
size: "large",
|
|
3472
3762
|
value: editing[f.id] ? (0, import_dayjs2.default)(String(editing[f.id])).isValid() ? (0, import_dayjs2.default)(String(editing[f.id])) : null : null,
|
|
3473
|
-
onChange: (date, dateString) => setEditing({
|
|
3763
|
+
onChange: (date, dateString) => setEditing({
|
|
3764
|
+
...editing,
|
|
3765
|
+
[f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "")
|
|
3766
|
+
}),
|
|
3474
3767
|
format: "YYYY/MM/DD",
|
|
3475
3768
|
placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
|
|
3476
3769
|
className: "w-full rounded-xl"
|
|
@@ -3480,21 +3773,36 @@ function CollectionEditor({ collection }) {
|
|
|
3480
3773
|
AdminTimeRangePicker,
|
|
3481
3774
|
{
|
|
3482
3775
|
value: [
|
|
3483
|
-
toDayjsTime(
|
|
3484
|
-
|
|
3776
|
+
toDayjsTime(
|
|
3777
|
+
f.startField ? editing[f.startField] : ""
|
|
3778
|
+
),
|
|
3779
|
+
toDayjsTime(
|
|
3780
|
+
f.endField ? editing[f.endField] : ""
|
|
3781
|
+
)
|
|
3485
3782
|
],
|
|
3486
3783
|
onChange: (times) => setEditing(
|
|
3487
3784
|
(current) => current ? {
|
|
3488
3785
|
...current,
|
|
3489
|
-
...f.startField ? {
|
|
3490
|
-
|
|
3786
|
+
...f.startField ? {
|
|
3787
|
+
[f.startField]: toStoredTime(
|
|
3788
|
+
times?.[0]
|
|
3789
|
+
)
|
|
3790
|
+
} : {},
|
|
3791
|
+
...f.endField ? {
|
|
3792
|
+
[f.endField]: toStoredTime(
|
|
3793
|
+
times?.[1]
|
|
3794
|
+
)
|
|
3795
|
+
} : {}
|
|
3491
3796
|
} : current
|
|
3492
3797
|
),
|
|
3493
3798
|
allowEmpty: [true, true],
|
|
3494
3799
|
className: "w-full",
|
|
3495
3800
|
format: "h:mm a",
|
|
3496
3801
|
order: false,
|
|
3497
|
-
placeholder: [
|
|
3802
|
+
placeholder: [
|
|
3803
|
+
"Hora de inicio",
|
|
3804
|
+
"Hora de cierre"
|
|
3805
|
+
],
|
|
3498
3806
|
use12Hours: true
|
|
3499
3807
|
}
|
|
3500
3808
|
),
|
|
@@ -3518,7 +3826,10 @@ function CollectionEditor({ collection }) {
|
|
|
3518
3826
|
{
|
|
3519
3827
|
size: "large",
|
|
3520
3828
|
value: String(editing[f.id] ?? ""),
|
|
3521
|
-
onChange: (e) => setEditing({
|
|
3829
|
+
onChange: (e) => setEditing({
|
|
3830
|
+
...editing,
|
|
3831
|
+
[f.id]: e.target.value
|
|
3832
|
+
}),
|
|
3522
3833
|
rows: 4,
|
|
3523
3834
|
placeholder: `Escribe ${f.label.toLowerCase()}...`,
|
|
3524
3835
|
className: "w-full rounded-xl font-sans"
|
|
@@ -3538,7 +3849,10 @@ function CollectionEditor({ collection }) {
|
|
|
3538
3849
|
{
|
|
3539
3850
|
size: "large",
|
|
3540
3851
|
value: String(editing[f.id] ?? ""),
|
|
3541
|
-
onChange: (e) => setEditing({
|
|
3852
|
+
onChange: (e) => setEditing({
|
|
3853
|
+
...editing,
|
|
3854
|
+
[f.id]: e.target.value
|
|
3855
|
+
}),
|
|
3542
3856
|
className: "flex-1 rounded-xl"
|
|
3543
3857
|
}
|
|
3544
3858
|
),
|
|
@@ -3548,7 +3862,9 @@ function CollectionEditor({ collection }) {
|
|
|
3548
3862
|
size: "large",
|
|
3549
3863
|
onClick: () => {
|
|
3550
3864
|
const sourceField = f.source || "title";
|
|
3551
|
-
let val = String(
|
|
3865
|
+
let val = String(
|
|
3866
|
+
editing[sourceField] || editing.id || ""
|
|
3867
|
+
);
|
|
3552
3868
|
val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
3553
3869
|
setEditing({ ...editing, [f.id]: val });
|
|
3554
3870
|
},
|
|
@@ -3570,7 +3886,12 @@ function CollectionEditor({ collection }) {
|
|
|
3570
3886
|
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
3571
3887
|
onSelectRecord: (rec) => {
|
|
3572
3888
|
if (f.onSelectRecord) {
|
|
3573
|
-
setEditing(
|
|
3889
|
+
setEditing(
|
|
3890
|
+
(prev) => prev ? {
|
|
3891
|
+
...prev,
|
|
3892
|
+
...f.onSelectRecord(rec, prev)
|
|
3893
|
+
} : prev
|
|
3894
|
+
);
|
|
3574
3895
|
}
|
|
3575
3896
|
}
|
|
3576
3897
|
}
|
|
@@ -3584,7 +3905,10 @@ function CollectionEditor({ collection }) {
|
|
|
3584
3905
|
placeholder: f.label,
|
|
3585
3906
|
allowClear: true,
|
|
3586
3907
|
onChange: (val) => {
|
|
3587
|
-
const next = {
|
|
3908
|
+
const next = {
|
|
3909
|
+
...editing,
|
|
3910
|
+
[f.id]: val || ""
|
|
3911
|
+
};
|
|
3588
3912
|
collection.fields.forEach((otherField) => {
|
|
3589
3913
|
if (otherField.dependsOnField === f.id && otherField.optionsMap) {
|
|
3590
3914
|
const newOpts = otherField.optionsMap[String(val || "")];
|
|
@@ -3604,25 +3928,56 @@ function CollectionEditor({ collection }) {
|
|
|
3604
3928
|
}
|
|
3605
3929
|
);
|
|
3606
3930
|
})() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3607
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map(
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
"button",
|
|
3931
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map(
|
|
3932
|
+
(url, i) => {
|
|
3933
|
+
const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
|
|
3934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3935
|
+
"div",
|
|
3613
3936
|
{
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3937
|
+
className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32",
|
|
3938
|
+
children: [
|
|
3939
|
+
isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3940
|
+
"video",
|
|
3941
|
+
{
|
|
3942
|
+
src: url,
|
|
3943
|
+
className: "w-full h-full object-cover rounded-lg",
|
|
3944
|
+
autoPlay: true,
|
|
3945
|
+
muted: true,
|
|
3946
|
+
loop: true,
|
|
3947
|
+
playsInline: true
|
|
3948
|
+
}
|
|
3949
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3950
|
+
"img",
|
|
3951
|
+
{
|
|
3952
|
+
src: url,
|
|
3953
|
+
alt: "",
|
|
3954
|
+
className: "w-full h-full object-cover rounded-lg"
|
|
3955
|
+
}
|
|
3956
|
+
),
|
|
3957
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3958
|
+
"button",
|
|
3959
|
+
{
|
|
3960
|
+
type: "button",
|
|
3961
|
+
onClick: () => {
|
|
3962
|
+
const arr = [
|
|
3963
|
+
...editing[f.id] || []
|
|
3964
|
+
];
|
|
3965
|
+
arr.splice(i, 1);
|
|
3966
|
+
setEditing({
|
|
3967
|
+
...editing,
|
|
3968
|
+
[f.id]: arr
|
|
3969
|
+
});
|
|
3970
|
+
},
|
|
3971
|
+
className: "absolute top-2 right-2 bg-red-500/80 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500",
|
|
3972
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
|
|
3973
|
+
}
|
|
3974
|
+
)
|
|
3975
|
+
]
|
|
3976
|
+
},
|
|
3977
|
+
i
|
|
3978
|
+
);
|
|
3979
|
+
}
|
|
3980
|
+
) }),
|
|
3626
3981
|
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
3627
3982
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3628
3983
|
"input",
|
|
@@ -3632,8 +3987,14 @@ function CollectionEditor({ collection }) {
|
|
|
3632
3987
|
onKeyDown: (e) => {
|
|
3633
3988
|
if (e.key === "Enter" && e.currentTarget.value) {
|
|
3634
3989
|
e.preventDefault();
|
|
3635
|
-
const arr = [
|
|
3636
|
-
|
|
3990
|
+
const arr = [
|
|
3991
|
+
...editing[f.id] || [],
|
|
3992
|
+
e.currentTarget.value
|
|
3993
|
+
];
|
|
3994
|
+
setEditing({
|
|
3995
|
+
...editing,
|
|
3996
|
+
[f.id]: arr
|
|
3997
|
+
});
|
|
3637
3998
|
e.currentTarget.value = "";
|
|
3638
3999
|
}
|
|
3639
4000
|
},
|
|
@@ -3657,7 +4018,10 @@ function CollectionEditor({ collection }) {
|
|
|
3657
4018
|
if (f.max && current.length >= f.max) {
|
|
3658
4019
|
return prev;
|
|
3659
4020
|
}
|
|
3660
|
-
return {
|
|
4021
|
+
return {
|
|
4022
|
+
...prev,
|
|
4023
|
+
[f.id]: [...current, url]
|
|
4024
|
+
};
|
|
3661
4025
|
});
|
|
3662
4026
|
},
|
|
3663
4027
|
ctx.uploadImage
|
|
@@ -3675,7 +4039,10 @@ function CollectionEditor({ collection }) {
|
|
|
3675
4039
|
{
|
|
3676
4040
|
type: "url",
|
|
3677
4041
|
value: String(editing[f.id] ?? ""),
|
|
3678
|
-
onChange: (e) => setEditing({
|
|
4042
|
+
onChange: (e) => setEditing({
|
|
4043
|
+
...editing,
|
|
4044
|
+
[f.id]: e.target.value
|
|
4045
|
+
}),
|
|
3679
4046
|
placeholder: "https://...",
|
|
3680
4047
|
className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
3681
4048
|
}
|
|
@@ -3701,7 +4068,9 @@ function CollectionEditor({ collection }) {
|
|
|
3701
4068
|
}
|
|
3702
4069
|
)
|
|
3703
4070
|
] }),
|
|
3704
|
-
editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(editing[f.id]).match(
|
|
4071
|
+
editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(editing[f.id]).match(
|
|
4072
|
+
/\.(mp4|webm|mov|ogg)$/i
|
|
4073
|
+
) || String(editing[f.id]).includes("video") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3705
4074
|
"video",
|
|
3706
4075
|
{
|
|
3707
4076
|
src: String(editing[f.id]),
|
|
@@ -3734,8 +4103,13 @@ function CollectionEditor({ collection }) {
|
|
|
3734
4103
|
"input",
|
|
3735
4104
|
{
|
|
3736
4105
|
type: "color",
|
|
3737
|
-
value: String(editing[f.id] ?? "#000000").startsWith(
|
|
3738
|
-
|
|
4106
|
+
value: String(editing[f.id] ?? "#000000").startsWith(
|
|
4107
|
+
"#"
|
|
4108
|
+
) && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
|
|
4109
|
+
onChange: (e) => setEditing({
|
|
4110
|
+
...editing,
|
|
4111
|
+
[f.id]: e.target.value
|
|
4112
|
+
}),
|
|
3739
4113
|
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
3740
4114
|
}
|
|
3741
4115
|
),
|
|
@@ -3744,7 +4118,10 @@ function CollectionEditor({ collection }) {
|
|
|
3744
4118
|
{
|
|
3745
4119
|
type: "text",
|
|
3746
4120
|
value: String(editing[f.id] ?? ""),
|
|
3747
|
-
onChange: (e) => setEditing({
|
|
4121
|
+
onChange: (e) => setEditing({
|
|
4122
|
+
...editing,
|
|
4123
|
+
[f.id]: e.target.value
|
|
4124
|
+
}),
|
|
3748
4125
|
placeholder: "#000000",
|
|
3749
4126
|
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
3750
4127
|
}
|
|
@@ -3753,62 +4130,75 @@ function CollectionEditor({ collection }) {
|
|
|
3753
4130
|
"div",
|
|
3754
4131
|
{
|
|
3755
4132
|
className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
3756
|
-
style: {
|
|
4133
|
+
style: {
|
|
4134
|
+
backgroundColor: String(
|
|
4135
|
+
editing[f.id] ?? "#000000"
|
|
4136
|
+
)
|
|
4137
|
+
}
|
|
3757
4138
|
}
|
|
3758
4139
|
)
|
|
3759
4140
|
] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3760
4141
|
(Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : []).map((item, idx) => {
|
|
3761
4142
|
const colorVal = String(item ?? "").trim();
|
|
3762
4143
|
const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
|
|
3763
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
4144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4145
|
+
"div",
|
|
4146
|
+
{
|
|
4147
|
+
className: "flex gap-2 items-center",
|
|
4148
|
+
children: [
|
|
4149
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4150
|
+
"input",
|
|
4151
|
+
{
|
|
4152
|
+
type: "color",
|
|
4153
|
+
value: validHex.length === 7 ? validHex : "#000000",
|
|
4154
|
+
onChange: (e) => {
|
|
4155
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
4156
|
+
arr[idx] = e.target.value;
|
|
4157
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
4158
|
+
},
|
|
4159
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
4160
|
+
}
|
|
4161
|
+
),
|
|
4162
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4163
|
+
"input",
|
|
4164
|
+
{
|
|
4165
|
+
type: "text",
|
|
4166
|
+
value: colorVal,
|
|
4167
|
+
onChange: (e) => {
|
|
4168
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
4169
|
+
arr[idx] = e.target.value;
|
|
4170
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
4171
|
+
},
|
|
4172
|
+
placeholder: "#1c2a44",
|
|
4173
|
+
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
4174
|
+
}
|
|
4175
|
+
),
|
|
4176
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4177
|
+
"div",
|
|
4178
|
+
{
|
|
4179
|
+
className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
4180
|
+
style: {
|
|
4181
|
+
backgroundColor: colorVal || "#000000"
|
|
4182
|
+
}
|
|
4183
|
+
}
|
|
4184
|
+
),
|
|
4185
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4186
|
+
"button",
|
|
4187
|
+
{
|
|
4188
|
+
type: "button",
|
|
4189
|
+
onClick: () => {
|
|
4190
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
4191
|
+
arr.splice(idx, 1);
|
|
4192
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
4193
|
+
},
|
|
4194
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
|
|
4195
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
4196
|
+
}
|
|
4197
|
+
)
|
|
4198
|
+
]
|
|
4199
|
+
},
|
|
4200
|
+
idx
|
|
4201
|
+
);
|
|
3812
4202
|
}),
|
|
3813
4203
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3814
4204
|
"button",
|
|
@@ -3831,50 +4221,69 @@ function CollectionEditor({ collection }) {
|
|
|
3831
4221
|
const displayArr = currentArr.length > 0 ? currentArr : [""];
|
|
3832
4222
|
const singularLabel = f.label.endsWith("es") ? f.label.slice(0, -2) : f.label.endsWith("s") ? f.label.slice(0, -1) : f.label;
|
|
3833
4223
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-2.5", children: [
|
|
3834
|
-
displayArr.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
4224
|
+
displayArr.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4225
|
+
"div",
|
|
4226
|
+
{
|
|
4227
|
+
className: "flex gap-2 items-center",
|
|
4228
|
+
children: [
|
|
4229
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-mono font-bold text-slate-400 w-7 text-right shrink-0", children: [
|
|
4230
|
+
"#",
|
|
4231
|
+
idx + 1
|
|
4232
|
+
] }),
|
|
4233
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4234
|
+
"input",
|
|
4235
|
+
{
|
|
4236
|
+
type: "text",
|
|
4237
|
+
value: String(item ?? ""),
|
|
4238
|
+
placeholder: `${singularLabel} #${idx + 1}...`,
|
|
4239
|
+
onChange: (e) => {
|
|
4240
|
+
const arr = [...displayArr];
|
|
4241
|
+
arr[idx] = e.target.value;
|
|
4242
|
+
setEditing({
|
|
4243
|
+
...editing,
|
|
4244
|
+
[f.id]: arr
|
|
4245
|
+
});
|
|
4246
|
+
},
|
|
4247
|
+
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white"
|
|
4248
|
+
}
|
|
4249
|
+
),
|
|
4250
|
+
displayArr.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4251
|
+
"button",
|
|
4252
|
+
{
|
|
4253
|
+
type: "button",
|
|
4254
|
+
onClick: () => {
|
|
4255
|
+
const arr = displayArr.filter(
|
|
4256
|
+
(_, i) => i !== idx
|
|
4257
|
+
);
|
|
4258
|
+
setEditing({
|
|
4259
|
+
...editing,
|
|
4260
|
+
[f.id]: arr.length > 0 ? arr : [""]
|
|
4261
|
+
});
|
|
4262
|
+
},
|
|
4263
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer shrink-0",
|
|
4264
|
+
title: "Eliminar elemento",
|
|
4265
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
4266
|
+
}
|
|
4267
|
+
)
|
|
4268
|
+
]
|
|
4269
|
+
},
|
|
4270
|
+
idx
|
|
4271
|
+
)),
|
|
3867
4272
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3868
4273
|
"button",
|
|
3869
4274
|
{
|
|
3870
4275
|
type: "button",
|
|
3871
4276
|
onClick: () => {
|
|
3872
|
-
setEditing({
|
|
4277
|
+
setEditing({
|
|
4278
|
+
...editing,
|
|
4279
|
+
[f.id]: [...displayArr, ""]
|
|
4280
|
+
});
|
|
3873
4281
|
},
|
|
3874
4282
|
className: "inline-flex items-center gap-1.5 px-3.5 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-bold rounded-xl border border-indigo-100 transition-colors cursor-pointer",
|
|
3875
4283
|
children: [
|
|
3876
4284
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
3877
|
-
" Agregar
|
|
4285
|
+
" Agregar",
|
|
4286
|
+
" ",
|
|
3878
4287
|
singularLabel.toLowerCase()
|
|
3879
4288
|
]
|
|
3880
4289
|
}
|
|
@@ -3888,7 +4297,10 @@ function CollectionEditor({ collection }) {
|
|
|
3888
4297
|
value: String(editing[f.id] ?? ""),
|
|
3889
4298
|
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
3890
4299
|
disabled: f.readOnly,
|
|
3891
|
-
onChange: (e) => setEditing({
|
|
4300
|
+
onChange: (e) => setEditing({
|
|
4301
|
+
...editing,
|
|
4302
|
+
[f.id]: e.target.value
|
|
4303
|
+
}),
|
|
3892
4304
|
placeholder: f.label,
|
|
3893
4305
|
className: "flex-1 rounded-xl"
|
|
3894
4306
|
}
|
|
@@ -3940,8 +4352,13 @@ function CollectionEditor({ collection }) {
|
|
|
3940
4352
|
if (dup) {
|
|
3941
4353
|
const dupName = dup.nombre ? ` (\xAB${dup.nombre} ${dup.apellido || ""}\xBB)` : "";
|
|
3942
4354
|
const errMsg = `Esta identificaci\xF3n ya est\xE1 registrada${dupName}. No puedes usar una c\xE9dula o NIT repetido.`;
|
|
3943
|
-
setDuplicateErrors((prev) => ({
|
|
3944
|
-
|
|
4355
|
+
setDuplicateErrors((prev) => ({
|
|
4356
|
+
...prev,
|
|
4357
|
+
[f.id]: errMsg
|
|
4358
|
+
}));
|
|
4359
|
+
message.warning(
|
|
4360
|
+
`\u26A0\uFE0F Ya existe un registro con esta identificaci\xF3n: ${e.target.value.trim()}.`
|
|
4361
|
+
);
|
|
3945
4362
|
} else {
|
|
3946
4363
|
setDuplicateErrors((prev) => {
|
|
3947
4364
|
const next = { ...prev };
|
|
@@ -4036,7 +4453,10 @@ function CollectionEditor({ collection }) {
|
|
|
4036
4453
|
value: exportMode,
|
|
4037
4454
|
onChange: (val) => setExportMode(val),
|
|
4038
4455
|
options: [
|
|
4039
|
-
{
|
|
4456
|
+
{
|
|
4457
|
+
label: `${t.exportAllRecords} (${entries.length})`,
|
|
4458
|
+
value: "all"
|
|
4459
|
+
},
|
|
4040
4460
|
{ label: t.exportFilterByDate, value: "byDate" }
|
|
4041
4461
|
]
|
|
4042
4462
|
}
|
|
@@ -4055,11 +4475,26 @@ function CollectionEditor({ collection }) {
|
|
|
4055
4475
|
value: exportDateRange,
|
|
4056
4476
|
onChange: (dates) => setExportDateRange(dates),
|
|
4057
4477
|
presets: [
|
|
4058
|
-
{
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
{
|
|
4478
|
+
{
|
|
4479
|
+
label: "Hoy",
|
|
4480
|
+
value: [(0, import_dayjs2.default)().startOf("day"), (0, import_dayjs2.default)().endOf("day")]
|
|
4481
|
+
},
|
|
4482
|
+
{
|
|
4483
|
+
label: "Esta semana",
|
|
4484
|
+
value: [(0, import_dayjs2.default)().startOf("week"), (0, import_dayjs2.default)().endOf("week")]
|
|
4485
|
+
},
|
|
4486
|
+
{
|
|
4487
|
+
label: "Este mes",
|
|
4488
|
+
value: [(0, import_dayjs2.default)().startOf("month"), (0, import_dayjs2.default)().endOf("month")]
|
|
4489
|
+
},
|
|
4490
|
+
{
|
|
4491
|
+
label: "\xDAltimos 30 d\xEDas",
|
|
4492
|
+
value: [(0, import_dayjs2.default)().subtract(30, "day"), (0, import_dayjs2.default)()]
|
|
4493
|
+
},
|
|
4494
|
+
{
|
|
4495
|
+
label: "Este a\xF1o",
|
|
4496
|
+
value: [(0, import_dayjs2.default)().startOf("year"), (0, import_dayjs2.default)().endOf("year")]
|
|
4497
|
+
}
|
|
4063
4498
|
]
|
|
4064
4499
|
}
|
|
4065
4500
|
)
|
|
@@ -4162,7 +4597,15 @@ function CollectionEditor({ collection }) {
|
|
|
4162
4597
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "font-semibold text-sm text-slate-700", children: t.importDropzone }),
|
|
4163
4598
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 mt-1", children: t.importDropzoneSub })
|
|
4164
4599
|
] }),
|
|
4165
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4600
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4601
|
+
import_antd.Button,
|
|
4602
|
+
{
|
|
4603
|
+
size: "middle",
|
|
4604
|
+
loading: isParsingImport,
|
|
4605
|
+
className: "mt-2 rounded-lg font-medium",
|
|
4606
|
+
children: isParsingImport ? "Leyendo archivo..." : "Seleccionar archivo"
|
|
4607
|
+
}
|
|
4608
|
+
)
|
|
4166
4609
|
]
|
|
4167
4610
|
}
|
|
4168
4611
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-4", children: [
|
|
@@ -4250,13 +4693,21 @@ function CollectionEditor({ collection }) {
|
|
|
4250
4693
|
t.importPreviewTitle,
|
|
4251
4694
|
" (",
|
|
4252
4695
|
Math.min(5, importResult.samplePreview.length),
|
|
4253
|
-
" de
|
|
4696
|
+
" de",
|
|
4697
|
+
" ",
|
|
4254
4698
|
importResult.totalRows,
|
|
4255
4699
|
"):"
|
|
4256
4700
|
] }),
|
|
4257
4701
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "overflow-x-auto border border-slate-200 rounded-xl max-h-48 text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { className: "w-full text-left", children: [
|
|
4258
4702
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "bg-slate-100/80 text-slate-700 font-semibold border-b border-slate-200", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: importResult.matchedFields.slice(0, 6).map((m, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "p-2 whitespace-nowrap", children: m.label }, idx)) }) }),
|
|
4259
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: importResult.samplePreview.map((row, rIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { className: "hover:bg-slate-50/60", children: importResult.matchedFields.slice(0, 6).map((m, cIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4703
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: importResult.samplePreview.map((row, rIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { className: "hover:bg-slate-50/60", children: importResult.matchedFields.slice(0, 6).map((m, cIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4704
|
+
"td",
|
|
4705
|
+
{
|
|
4706
|
+
className: "p-2 whitespace-nowrap max-w-[160px] truncate text-slate-600",
|
|
4707
|
+
children: String(row[m.fieldId] ?? "")
|
|
4708
|
+
},
|
|
4709
|
+
cIdx
|
|
4710
|
+
)) }, rIdx)) })
|
|
4260
4711
|
] }) })
|
|
4261
4712
|
] }),
|
|
4262
4713
|
isImporting && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1", children: [
|
|
@@ -4271,7 +4722,9 @@ function CollectionEditor({ collection }) {
|
|
|
4271
4722
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4272
4723
|
import_antd.Progress,
|
|
4273
4724
|
{
|
|
4274
|
-
percent: Math.round(
|
|
4725
|
+
percent: Math.round(
|
|
4726
|
+
importProgress.current / (importProgress.total || 1) * 100
|
|
4727
|
+
),
|
|
4275
4728
|
status: "active"
|
|
4276
4729
|
}
|
|
4277
4730
|
)
|
|
@@ -4309,13 +4762,26 @@ function CollectionEditor({ collection }) {
|
|
|
4309
4762
|
),
|
|
4310
4763
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { className: "w-full text-sm text-left", children: [
|
|
4311
4764
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { children: [
|
|
4312
|
-
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4765
|
+
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4766
|
+
"th",
|
|
4767
|
+
{
|
|
4768
|
+
className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider",
|
|
4769
|
+
children: f.label
|
|
4770
|
+
},
|
|
4771
|
+
f.id
|
|
4772
|
+
)),
|
|
4313
4773
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "px-6 py-4 text-right text-xs font-bold text-slate-500 uppercase tracking-wider sticky right-0 bg-slate-50 border-l border-slate-200 z-10", children: t.actions })
|
|
4314
4774
|
] }) }),
|
|
4315
4775
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
|
|
4316
4776
|
// Loading skeleton rows
|
|
4317
4777
|
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { children: [
|
|
4318
|
-
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4778
|
+
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4779
|
+
"div",
|
|
4780
|
+
{
|
|
4781
|
+
className: "h-4 bg-slate-100 rounded animate-pulse",
|
|
4782
|
+
style: { width: `${60 + i * 13 % 30}%` }
|
|
4783
|
+
}
|
|
4784
|
+
) }, f.id)),
|
|
4319
4785
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 sticky right-0 bg-white border-l border-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-4 w-16 bg-slate-100 rounded animate-pulse ml-auto" }) })
|
|
4320
4786
|
] }, i))
|
|
4321
4787
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
@@ -4349,7 +4815,10 @@ function CollectionEditor({ collection }) {
|
|
|
4349
4815
|
return true;
|
|
4350
4816
|
});
|
|
4351
4817
|
}
|
|
4352
|
-
const paginatedRes = res.slice(
|
|
4818
|
+
const paginatedRes = res.slice(
|
|
4819
|
+
(page - 1) * itemsPerPage,
|
|
4820
|
+
page * itemsPerPage
|
|
4821
|
+
);
|
|
4353
4822
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: paginatedRes.map((e, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4354
4823
|
"tr",
|
|
4355
4824
|
{
|
|
@@ -4360,45 +4829,112 @@ function CollectionEditor({ collection }) {
|
|
|
4360
4829
|
onDragEnd,
|
|
4361
4830
|
className: `hover:bg-slate-50/50 transition-colors group cursor-grab active:cursor-grabbing ${deletingId === e.id ? "opacity-50" : ""} ${dragOverIdx === idx ? "border-t-2 border-t-indigo-500" : ""}`,
|
|
4362
4831
|
children: [
|
|
4363
|
-
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4364
|
-
"
|
|
4365
|
-
{
|
|
4366
|
-
type: "button",
|
|
4367
|
-
onClick: () => f.onCellClick(e[f.id], e),
|
|
4368
|
-
className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block max-w-full",
|
|
4369
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple })
|
|
4370
|
-
}
|
|
4371
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : (f.type === "list" || f.multiple) && e[f.id] ? Array.isArray(e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4372
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: String(e[f.id][0] || "") }),
|
|
4373
|
-
e[f.id].length > 1 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "inline-flex items-center px-1.5 py-0.2 rounded text-[10px] font-bold bg-indigo-50 text-indigo-700 border border-indigo-100 shrink-0", children: [
|
|
4374
|
-
"+",
|
|
4375
|
-
e[f.id].length - 1,
|
|
4376
|
-
" m\xE1s"
|
|
4377
|
-
] })
|
|
4378
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: String(e[f.id]) }) : f.onCellClick ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4379
|
-
"button",
|
|
4380
|
-
{
|
|
4381
|
-
type: "button",
|
|
4382
|
-
onClick: () => f.onCellClick(e[f.id], e),
|
|
4383
|
-
className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block w-full",
|
|
4384
|
-
children: String(e[f.id] ?? "")
|
|
4385
|
-
}
|
|
4386
|
-
) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
|
|
4387
|
-
"$ ",
|
|
4388
|
-
Number(e[f.id]).toLocaleString("es-CO")
|
|
4389
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : f.type === "link" || typeof e[f.id] === "string" && String(e[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4390
|
-
"a",
|
|
4832
|
+
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4833
|
+
"td",
|
|
4391
4834
|
{
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4835
|
+
className: "px-6 py-4 text-slate-700 max-w-[200px] truncate",
|
|
4836
|
+
children: f.renderCell ? f.renderCell(e[f.id], e) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4837
|
+
"img",
|
|
4838
|
+
{
|
|
4839
|
+
src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]),
|
|
4840
|
+
alt: "",
|
|
4841
|
+
className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200"
|
|
4842
|
+
}
|
|
4843
|
+
) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4844
|
+
"svg",
|
|
4845
|
+
{
|
|
4846
|
+
className: "w-4 h-4",
|
|
4847
|
+
fill: "none",
|
|
4848
|
+
stroke: "currentColor",
|
|
4849
|
+
viewBox: "0 0 24 24",
|
|
4850
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4851
|
+
"path",
|
|
4852
|
+
{
|
|
4853
|
+
strokeLinecap: "round",
|
|
4854
|
+
strokeLinejoin: "round",
|
|
4855
|
+
strokeWidth: "2",
|
|
4856
|
+
d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
4857
|
+
}
|
|
4858
|
+
)
|
|
4859
|
+
}
|
|
4860
|
+
) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4861
|
+
"span",
|
|
4862
|
+
{
|
|
4863
|
+
className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes(
|
|
4864
|
+
"Preparaci\xF3n"
|
|
4865
|
+
) ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes(
|
|
4866
|
+
"Cancelado"
|
|
4867
|
+
) ? "bg-slate-100 text-slate-700 border border-slate-200" : String(e[f.id]) === "Vencido" || String(e[f.id]).toLowerCase().includes("vencid") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`,
|
|
4868
|
+
children: String(e[f.id])
|
|
4869
|
+
}
|
|
4870
|
+
) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? f.onCellClick ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4871
|
+
"button",
|
|
4872
|
+
{
|
|
4873
|
+
type: "button",
|
|
4874
|
+
onClick: () => f.onCellClick(e[f.id], e),
|
|
4875
|
+
className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block max-w-full",
|
|
4876
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4877
|
+
ReferenceTableCell,
|
|
4878
|
+
{
|
|
4879
|
+
collectionId: f.collection,
|
|
4880
|
+
entryId: e[f.id],
|
|
4881
|
+
displayField: f.displayField,
|
|
4882
|
+
valueField: f.valueField,
|
|
4883
|
+
multiple: f.multiple
|
|
4884
|
+
}
|
|
4885
|
+
)
|
|
4886
|
+
}
|
|
4887
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4888
|
+
ReferenceTableCell,
|
|
4889
|
+
{
|
|
4890
|
+
collectionId: f.collection,
|
|
4891
|
+
entryId: e[f.id],
|
|
4892
|
+
displayField: f.displayField,
|
|
4893
|
+
valueField: f.valueField,
|
|
4894
|
+
multiple: f.multiple
|
|
4895
|
+
}
|
|
4896
|
+
) : (f.type === "list" || f.multiple) && e[f.id] ? Array.isArray(e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4897
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: String(e[f.id][0] || "") }),
|
|
4898
|
+
e[f.id].length > 1 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "inline-flex items-center px-1.5 py-0.2 rounded text-[10px] font-bold bg-indigo-50 text-indigo-700 border border-indigo-100 shrink-0", children: [
|
|
4899
|
+
"+",
|
|
4900
|
+
e[f.id].length - 1,
|
|
4901
|
+
" m\xE1s"
|
|
4902
|
+
] })
|
|
4903
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: String(e[f.id]) }) : f.onCellClick ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4904
|
+
"button",
|
|
4905
|
+
{
|
|
4906
|
+
type: "button",
|
|
4907
|
+
onClick: () => f.onCellClick(e[f.id], e),
|
|
4908
|
+
className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block w-full",
|
|
4909
|
+
children: String(e[f.id] ?? "")
|
|
4910
|
+
}
|
|
4911
|
+
) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4912
|
+
import_antd.Image,
|
|
4913
|
+
{
|
|
4914
|
+
src: String(e[f.id]),
|
|
4915
|
+
alt: "Firma",
|
|
4916
|
+
className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer",
|
|
4917
|
+
preview: { mask: "Ver" }
|
|
4918
|
+
}
|
|
4919
|
+
) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
|
|
4920
|
+
"$ ",
|
|
4921
|
+
Number(e[f.id]).toLocaleString("es-CO")
|
|
4922
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : f.type === "link" || typeof e[f.id] === "string" && String(e[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4923
|
+
"a",
|
|
4924
|
+
{
|
|
4925
|
+
href: String(e[f.id]),
|
|
4926
|
+
target: "_blank",
|
|
4927
|
+
rel: "noopener noreferrer",
|
|
4928
|
+
className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
|
|
4929
|
+
children: [
|
|
4930
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3 h-3" }),
|
|
4931
|
+
String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
|
|
4932
|
+
]
|
|
4933
|
+
}
|
|
4934
|
+
) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? formatTo12Hour(e[f.id]) || String(e[f.id] ?? "") : String(e[f.id] ?? "")
|
|
4935
|
+
},
|
|
4936
|
+
f.id
|
|
4937
|
+
)),
|
|
4402
4938
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-1.5", children: [
|
|
4403
4939
|
collection.customRowActions && collection.customRowActions({
|
|
4404
4940
|
record: e,
|
|
@@ -4497,10 +5033,36 @@ function CollectionEditor({ collection }) {
|
|
|
4497
5033
|
disabled: deletingId === e.id,
|
|
4498
5034
|
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
4499
5035
|
title: t.delete,
|
|
4500
|
-
children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
5036
|
+
children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5037
|
+
"svg",
|
|
5038
|
+
{
|
|
5039
|
+
className: "animate-spin h-4 w-4",
|
|
5040
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5041
|
+
fill: "none",
|
|
5042
|
+
viewBox: "0 0 24 24",
|
|
5043
|
+
children: [
|
|
5044
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5045
|
+
"circle",
|
|
5046
|
+
{
|
|
5047
|
+
className: "opacity-25",
|
|
5048
|
+
cx: "12",
|
|
5049
|
+
cy: "12",
|
|
5050
|
+
r: "10",
|
|
5051
|
+
stroke: "currentColor",
|
|
5052
|
+
strokeWidth: "4"
|
|
5053
|
+
}
|
|
5054
|
+
),
|
|
5055
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5056
|
+
"path",
|
|
5057
|
+
{
|
|
5058
|
+
className: "opacity-75",
|
|
5059
|
+
fill: "currentColor",
|
|
5060
|
+
d: "M4 12a8 8 0 018-8v8H4z"
|
|
5061
|
+
}
|
|
5062
|
+
)
|
|
5063
|
+
]
|
|
5064
|
+
}
|
|
5065
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "h-4 w-4" })
|
|
4504
5066
|
}
|
|
4505
5067
|
)
|
|
4506
5068
|
] }) })
|
|
@@ -4527,7 +5089,11 @@ function CollectionEditor({ collection }) {
|
|
|
4527
5089
|
let res = entries;
|
|
4528
5090
|
if (search && collection.searchBy?.length) {
|
|
4529
5091
|
const q = search.toLowerCase();
|
|
4530
|
-
res = res.filter(
|
|
5092
|
+
res = res.filter(
|
|
5093
|
+
(e) => collection.searchBy.some(
|
|
5094
|
+
(field) => String(e[field] || "").toLowerCase().includes(q)
|
|
5095
|
+
)
|
|
5096
|
+
);
|
|
4531
5097
|
}
|
|
4532
5098
|
if (Object.keys(filters).length > 0) {
|
|
4533
5099
|
res = res.filter((e) => {
|
|
@@ -4543,7 +5109,11 @@ function CollectionEditor({ collection }) {
|
|
|
4543
5109
|
let res = entries;
|
|
4544
5110
|
if (search && collection.searchBy?.length) {
|
|
4545
5111
|
const q = search.toLowerCase();
|
|
4546
|
-
res = res.filter(
|
|
5112
|
+
res = res.filter(
|
|
5113
|
+
(e) => collection.searchBy.some(
|
|
5114
|
+
(field) => String(e[field] || "").toLowerCase().includes(q)
|
|
5115
|
+
)
|
|
5116
|
+
);
|
|
4547
5117
|
}
|
|
4548
5118
|
if (Object.keys(filters).length > 0) {
|
|
4549
5119
|
res = res.filter((e) => {
|
|
@@ -4553,7 +5123,10 @@ function CollectionEditor({ collection }) {
|
|
|
4553
5123
|
return true;
|
|
4554
5124
|
});
|
|
4555
5125
|
}
|
|
4556
|
-
const totalPages = Math.max(
|
|
5126
|
+
const totalPages = Math.max(
|
|
5127
|
+
1,
|
|
5128
|
+
Math.ceil(res.length / itemsPerPage)
|
|
5129
|
+
);
|
|
4557
5130
|
if (totalPages <= 1) return null;
|
|
4558
5131
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
4559
5132
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -4610,20 +5183,39 @@ function SubmissionsSection() {
|
|
|
4610
5183
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-slate-200 bg-white/50 p-4", children: [
|
|
4611
5184
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Data Collections" }),
|
|
4612
5185
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "flex overflow-x-auto gap-2 pb-2 md:block md:space-x-0 md:space-y-1 md:pb-0 md:overflow-visible", children: [
|
|
4613
|
-
formIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4614
|
-
"
|
|
5186
|
+
formIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5187
|
+
"li",
|
|
4615
5188
|
{
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
5189
|
+
className: "shrink-0 min-w-[140px] md:w-full md:min-w-0",
|
|
5190
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5191
|
+
"button",
|
|
5192
|
+
{
|
|
5193
|
+
onClick: () => setSelectedFormId(id),
|
|
5194
|
+
className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selectedFormId === id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
|
|
5195
|
+
children: [
|
|
5196
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5197
|
+
"div",
|
|
5198
|
+
{
|
|
5199
|
+
className: selectedFormId === id ? "text-slate-900" : "text-slate-700 capitalize",
|
|
5200
|
+
children: id
|
|
5201
|
+
}
|
|
5202
|
+
),
|
|
5203
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5204
|
+
"div",
|
|
5205
|
+
{
|
|
5206
|
+
className: `text-xs mt-0.5 ${selectedFormId === id ? "text-indigo-500" : "text-slate-400"}`,
|
|
5207
|
+
children: [
|
|
5208
|
+
submissions.filter((s) => s.formId === id).length,
|
|
5209
|
+
" items"
|
|
5210
|
+
]
|
|
5211
|
+
}
|
|
5212
|
+
)
|
|
5213
|
+
]
|
|
5214
|
+
}
|
|
5215
|
+
)
|
|
5216
|
+
},
|
|
5217
|
+
id
|
|
5218
|
+
)),
|
|
4627
5219
|
formIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200", children: "No data collected." })
|
|
4628
5220
|
] })
|
|
4629
5221
|
] }),
|
|
@@ -4642,7 +5234,12 @@ function SubmissionsSection() {
|
|
|
4642
5234
|
] })
|
|
4643
5235
|
] });
|
|
4644
5236
|
}
|
|
4645
|
-
function SubmissionsList({
|
|
5237
|
+
function SubmissionsList({
|
|
5238
|
+
formId,
|
|
5239
|
+
submissions,
|
|
5240
|
+
onLoad,
|
|
5241
|
+
loading
|
|
5242
|
+
}) {
|
|
4646
5243
|
const ctx = useCmsContext();
|
|
4647
5244
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
4648
5245
|
const [page, setPage] = (0, import_react5.useState)(1);
|
|
@@ -4670,7 +5267,10 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
4670
5267
|
const unreadCount = submissions.filter((s) => !s.read).length;
|
|
4671
5268
|
const formatDate = (iso) => {
|
|
4672
5269
|
try {
|
|
4673
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
5270
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
5271
|
+
dateStyle: "medium",
|
|
5272
|
+
timeStyle: "short"
|
|
5273
|
+
}).format(new Date(iso));
|
|
4674
5274
|
} catch {
|
|
4675
5275
|
return iso;
|
|
4676
5276
|
}
|
|
@@ -4708,54 +5308,61 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
4708
5308
|
const strVal = String(val ?? "\u2014");
|
|
4709
5309
|
const isImage = typeof val === "string" && (val.startsWith("data:image/") || /\.(jpg|jpeg|png|webp|avif|gif|svg)(\?.*)?$/i.test(val) || val.includes("/images/") && val.includes("sanity.io"));
|
|
4710
5310
|
const isUrl = typeof val === "string" && /^https?:\/\//i.test(val);
|
|
4711
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
{
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
className: "inline-block max-w-sm rounded-lg overflow-hidden border border-slate-200 shadow-sm hover:shadow transition-shadow bg-slate-50 p-1",
|
|
4721
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4722
|
-
"img",
|
|
5311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5312
|
+
"div",
|
|
5313
|
+
{
|
|
5314
|
+
className: "py-4 grid grid-cols-[160px_1fr] gap-4 items-start",
|
|
5315
|
+
children: [
|
|
5316
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { className: "text-xs font-bold uppercase tracking-wide text-slate-400 pt-0.5", children: key }),
|
|
5317
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dd", { className: "text-sm text-slate-800", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-2", children: [
|
|
5318
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5319
|
+
"a",
|
|
4723
5320
|
{
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
5321
|
+
href: strVal,
|
|
5322
|
+
target: "_blank",
|
|
5323
|
+
rel: "noopener noreferrer",
|
|
5324
|
+
className: "inline-block max-w-sm rounded-lg overflow-hidden border border-slate-200 shadow-sm hover:shadow transition-shadow bg-slate-50 p-1",
|
|
5325
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5326
|
+
"img",
|
|
5327
|
+
{
|
|
5328
|
+
src: strVal,
|
|
5329
|
+
alt: key,
|
|
5330
|
+
className: "max-h-64 w-auto object-contain rounded"
|
|
5331
|
+
}
|
|
5332
|
+
)
|
|
4727
5333
|
}
|
|
4728
|
-
)
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
}
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
5334
|
+
),
|
|
5335
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5336
|
+
"a",
|
|
5337
|
+
{
|
|
5338
|
+
href: strVal,
|
|
5339
|
+
target: "_blank",
|
|
5340
|
+
rel: "noopener noreferrer",
|
|
5341
|
+
className: "inline-flex items-center gap-1.5 text-xs text-indigo-600 font-semibold hover:underline",
|
|
5342
|
+
children: [
|
|
5343
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
|
|
5344
|
+
" View / Download file"
|
|
5345
|
+
]
|
|
5346
|
+
}
|
|
5347
|
+
) })
|
|
5348
|
+
] }) : isUrl ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5349
|
+
"a",
|
|
5350
|
+
{
|
|
5351
|
+
href: strVal,
|
|
5352
|
+
target: "_blank",
|
|
5353
|
+
rel: "noopener noreferrer",
|
|
5354
|
+
className: "inline-flex items-center gap-1.5 text-indigo-600 font-medium hover:underline break-all text-sm",
|
|
5355
|
+
children: [
|
|
5356
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5 flex-shrink-0" }),
|
|
5357
|
+
" ",
|
|
5358
|
+
strVal
|
|
5359
|
+
]
|
|
5360
|
+
}
|
|
5361
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "whitespace-pre-wrap", children: strVal }) })
|
|
5362
|
+
]
|
|
5363
|
+
},
|
|
5364
|
+
key
|
|
5365
|
+
);
|
|
4759
5366
|
}) })
|
|
4760
5367
|
] })
|
|
4761
5368
|
] });
|
|
@@ -4777,7 +5384,8 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
4777
5384
|
className: "inline-flex items-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-700 shadow-sm hover:bg-slate-50 transition-colors disabled:opacity-50",
|
|
4778
5385
|
children: [
|
|
4779
5386
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.RefreshCw, { className: `h-4 w-4 ${loading ? "animate-spin" : ""}` }),
|
|
4780
|
-
"
|
|
5387
|
+
" ",
|
|
5388
|
+
"Refresh"
|
|
4781
5389
|
]
|
|
4782
5390
|
}
|
|
4783
5391
|
)
|
|
@@ -4818,31 +5426,38 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
4818
5426
|
!s.read && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "ml-2 inline-block h-2 w-2 rounded-full bg-indigo-500" })
|
|
4819
5427
|
] }),
|
|
4820
5428
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-500 whitespace-nowrap", children: formatDate(s.submittedAt) }),
|
|
4821
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
5429
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5430
|
+
"td",
|
|
5431
|
+
{
|
|
5432
|
+
className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors",
|
|
5433
|
+
onClick: (e) => e.stopPropagation(),
|
|
5434
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-1", children: [
|
|
5435
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5436
|
+
"button",
|
|
5437
|
+
{
|
|
5438
|
+
onClick: () => openDetail(s),
|
|
5439
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
5440
|
+
title: "View detail",
|
|
5441
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Eye, { className: "h-4 w-4" })
|
|
5442
|
+
}
|
|
5443
|
+
),
|
|
5444
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5445
|
+
"button",
|
|
5446
|
+
{
|
|
5447
|
+
onClick: () => deleteOne(s.id),
|
|
5448
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors",
|
|
5449
|
+
title: "Delete",
|
|
5450
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "h-4 w-4" })
|
|
5451
|
+
}
|
|
5452
|
+
)
|
|
5453
|
+
] })
|
|
5454
|
+
}
|
|
5455
|
+
)
|
|
5456
|
+
]
|
|
5457
|
+
},
|
|
5458
|
+
s.id
|
|
5459
|
+
);
|
|
5460
|
+
}),
|
|
4846
5461
|
paginated.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan: 3, className: "px-6 py-16 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col items-center gap-3 text-slate-400", children: [
|
|
4847
5462
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-12 w-12 text-slate-200" }),
|
|
4848
5463
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm font-medium", children: search ? "No matches." : "No data yet." })
|
|
@@ -4895,7 +5510,13 @@ function SettingsSection() {
|
|
|
4895
5510
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "px-6 py-4 border-b border-slate-100 bg-slate-50/50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { className: "font-bold text-slate-800", children: "Configuration Snapshot" }) }),
|
|
4896
5511
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dl", { className: "divide-y divide-slate-100 text-sm", children: [
|
|
4897
5512
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Row, { label: "Site Name", value: ctx.config.siteName ?? "\u2014" }),
|
|
4898
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5513
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5514
|
+
Row,
|
|
5515
|
+
{
|
|
5516
|
+
label: "Registered Pages",
|
|
5517
|
+
value: String(ctx.config.pages.length)
|
|
5518
|
+
}
|
|
5519
|
+
),
|
|
4899
5520
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4900
5521
|
Row,
|
|
4901
5522
|
{
|
|
@@ -4944,7 +5565,13 @@ function ConfigSection() {
|
|
|
4944
5565
|
{
|
|
4945
5566
|
onClick: () => setSelectedGroupId(g.id),
|
|
4946
5567
|
className: `w-full rounded-lg px-3 py-2.5 text-left text-sm transition-all duration-200 ${selectedGroupId === g.id ? "bg-white shadow-sm ring-1 ring-slate-200 font-semibold" : "hover:bg-slate-100"}`,
|
|
4947
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5568
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5569
|
+
"div",
|
|
5570
|
+
{
|
|
5571
|
+
className: `truncate ${selectedGroupId === g.id ? "text-slate-900" : "text-slate-700"}`,
|
|
5572
|
+
children: g.label
|
|
5573
|
+
}
|
|
5574
|
+
)
|
|
4948
5575
|
}
|
|
4949
5576
|
) }, g.id)),
|
|
4950
5577
|
globals.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "px-3 py-6 text-center text-sm text-slate-500 bg-slate-50 rounded-lg border border-dashed border-slate-200 w-full", children: "No global configurations." })
|
|
@@ -5011,10 +5638,22 @@ function Row({
|
|
|
5011
5638
|
}) {
|
|
5012
5639
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between px-6 py-4 hover:bg-slate-50/50 transition-colors", children: [
|
|
5013
5640
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { className: "text-slate-500 font-medium", children: label }),
|
|
5014
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5641
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5642
|
+
"dd",
|
|
5643
|
+
{
|
|
5644
|
+
className: `font-semibold ${highlight ? "text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded" : status === "warning" ? "text-amber-600" : status === "success" ? "text-emerald-600" : "text-slate-900"}`,
|
|
5645
|
+
children: value
|
|
5646
|
+
}
|
|
5647
|
+
)
|
|
5015
5648
|
] });
|
|
5016
5649
|
}
|
|
5017
|
-
function SearchableSelect({
|
|
5650
|
+
function SearchableSelect({
|
|
5651
|
+
value,
|
|
5652
|
+
onChange,
|
|
5653
|
+
options,
|
|
5654
|
+
placeholder,
|
|
5655
|
+
iconMap
|
|
5656
|
+
}) {
|
|
5018
5657
|
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
5019
5658
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
5020
5659
|
const btnRef = (0, import_react5.useRef)(null);
|
|
@@ -5031,7 +5670,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
5031
5670
|
const opensUp = spaceBelow < dropdownHeight && rect.top > dropdownHeight;
|
|
5032
5671
|
setCoords({
|
|
5033
5672
|
top: opensUp ? Math.max(10, rect.top - dropdownHeight - 6) : rect.bottom + 6,
|
|
5034
|
-
left: Math.max(
|
|
5673
|
+
left: Math.max(
|
|
5674
|
+
10,
|
|
5675
|
+
Math.min(rect.left, window.innerWidth - rect.width - 10)
|
|
5676
|
+
),
|
|
5035
5677
|
width: rect.width
|
|
5036
5678
|
});
|
|
5037
5679
|
}
|
|
@@ -5156,7 +5798,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
5156
5798
|
)
|
|
5157
5799
|
] });
|
|
5158
5800
|
}
|
|
5159
|
-
function PasswordField({
|
|
5801
|
+
function PasswordField({
|
|
5802
|
+
value,
|
|
5803
|
+
onChange
|
|
5804
|
+
}) {
|
|
5160
5805
|
const [show, setShow] = (0, import_react5.useState)(false);
|
|
5161
5806
|
const hasExisting = Boolean(value && String(value).trim().length > 0);
|
|
5162
5807
|
const [displayValue, setDisplayValue] = (0, import_react5.useState)("");
|
|
@@ -5342,8 +5987,24 @@ function SignatureInput({
|
|
|
5342
5987
|
centered: true,
|
|
5343
5988
|
width: 560,
|
|
5344
5989
|
footer: [
|
|
5345
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5346
|
-
|
|
5990
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5991
|
+
import_antd.Button,
|
|
5992
|
+
{
|
|
5993
|
+
onClick: clearCanvas,
|
|
5994
|
+
className: "rounded-xl font-medium",
|
|
5995
|
+
children: t.clear
|
|
5996
|
+
},
|
|
5997
|
+
"clear"
|
|
5998
|
+
),
|
|
5999
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6000
|
+
import_antd.Button,
|
|
6001
|
+
{
|
|
6002
|
+
onClick: () => setModalOpen(false),
|
|
6003
|
+
className: "rounded-xl font-medium",
|
|
6004
|
+
children: t.cancel
|
|
6005
|
+
},
|
|
6006
|
+
"cancel"
|
|
6007
|
+
),
|
|
5347
6008
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5348
6009
|
import_antd.Button,
|
|
5349
6010
|
{
|
|
@@ -5394,7 +6055,9 @@ function FormattedNumberInput({
|
|
|
5394
6055
|
if (!cleanDigits) return "";
|
|
5395
6056
|
return cleanDigits.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
5396
6057
|
};
|
|
5397
|
-
const [displayVal, setDisplayVal] = (0, import_react5.useState)(
|
|
6058
|
+
const [displayVal, setDisplayVal] = (0, import_react5.useState)(
|
|
6059
|
+
() => formatWithDots(value)
|
|
6060
|
+
);
|
|
5398
6061
|
(0, import_react5.useEffect)(() => {
|
|
5399
6062
|
setDisplayVal(formatWithDots(value));
|
|
5400
6063
|
}, [value]);
|
|
@@ -5436,440 +6099,6 @@ function FormattedNumberInput({
|
|
|
5436
6099
|
)
|
|
5437
6100
|
] });
|
|
5438
6101
|
}
|
|
5439
|
-
function BranchSettingsEditor({
|
|
5440
|
-
collectionId,
|
|
5441
|
-
value,
|
|
5442
|
-
globalPrice,
|
|
5443
|
-
globalDiscount,
|
|
5444
|
-
onChange
|
|
5445
|
-
}) {
|
|
5446
|
-
const ctx = useCmsContext();
|
|
5447
|
-
const [branches, setBranches] = (0, import_react5.useState)([]);
|
|
5448
|
-
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
5449
|
-
const [loadError, setLoadError] = (0, import_react5.useState)("");
|
|
5450
|
-
const settings = value && typeof value === "object" ? value : {};
|
|
5451
|
-
const selectedBranches = Array.isArray(settings.branches) ? settings.branches.map(String) : [];
|
|
5452
|
-
const prices = settings.prices && typeof settings.prices === "object" ? settings.prices : {};
|
|
5453
|
-
const selectedPriceBranches = [
|
|
5454
|
-
.../* @__PURE__ */ new Set([
|
|
5455
|
-
...Array.isArray(settings.priceBranches) ? settings.priceBranches.map(String) : [],
|
|
5456
|
-
...Object.keys(prices)
|
|
5457
|
-
])
|
|
5458
|
-
];
|
|
5459
|
-
const discounts = settings.discounts && typeof settings.discounts === "object" ? settings.discounts : {};
|
|
5460
|
-
const selectedDiscountBranches = [
|
|
5461
|
-
.../* @__PURE__ */ new Set([
|
|
5462
|
-
...Array.isArray(settings.discountBranches) ? settings.discountBranches.map(String) : [],
|
|
5463
|
-
...Object.keys(discounts)
|
|
5464
|
-
])
|
|
5465
|
-
];
|
|
5466
|
-
const branchAvailability = settings.branchAvailability && typeof settings.branchAvailability === "object" ? settings.branchAvailability : {};
|
|
5467
|
-
const selectedAvailabilityBranches = Object.keys(branchAvailability);
|
|
5468
|
-
const allBranches = settings.allBranches !== false;
|
|
5469
|
-
const useBranchPricing = settings.useBranchPricing === true;
|
|
5470
|
-
const useBranchDiscounts = settings.useBranchDiscounts === true;
|
|
5471
|
-
(0, import_react5.useEffect)(() => {
|
|
5472
|
-
let active = true;
|
|
5473
|
-
setLoading(true);
|
|
5474
|
-
setLoadError("");
|
|
5475
|
-
ctx.adapter.listEntries(collectionId).then((entries) => {
|
|
5476
|
-
if (active) setBranches(entries);
|
|
5477
|
-
}).catch((error) => {
|
|
5478
|
-
console.error("Could not load branches for product settings:", error);
|
|
5479
|
-
if (active) setLoadError("No se pudieron cargar las sedes.");
|
|
5480
|
-
}).finally(() => {
|
|
5481
|
-
if (active) setLoading(false);
|
|
5482
|
-
});
|
|
5483
|
-
return () => {
|
|
5484
|
-
active = false;
|
|
5485
|
-
};
|
|
5486
|
-
}, [collectionId, ctx.adapter]);
|
|
5487
|
-
const getBranchName = (branch) => String(branch.name || branch.id);
|
|
5488
|
-
const updateSettings = (patch) => {
|
|
5489
|
-
onChange({
|
|
5490
|
-
allBranches,
|
|
5491
|
-
branches: selectedBranches,
|
|
5492
|
-
useBranchPricing,
|
|
5493
|
-
priceBranches: selectedPriceBranches,
|
|
5494
|
-
prices: { ...prices },
|
|
5495
|
-
useBranchDiscounts,
|
|
5496
|
-
discountBranches: selectedDiscountBranches,
|
|
5497
|
-
discounts: { ...discounts },
|
|
5498
|
-
branchAvailability: { ...branchAvailability },
|
|
5499
|
-
...patch
|
|
5500
|
-
});
|
|
5501
|
-
};
|
|
5502
|
-
const updateBranchAvailability = (name, start, end) => {
|
|
5503
|
-
updateSettings({
|
|
5504
|
-
branchAvailability: {
|
|
5505
|
-
...branchAvailability,
|
|
5506
|
-
[name]: {
|
|
5507
|
-
start: toStoredTime(start),
|
|
5508
|
-
end: toStoredTime(end)
|
|
5509
|
-
}
|
|
5510
|
-
}
|
|
5511
|
-
});
|
|
5512
|
-
};
|
|
5513
|
-
const updateBranchPrice = (name, value2) => {
|
|
5514
|
-
const nextPrices = { ...prices };
|
|
5515
|
-
if (value2.trim() === "") {
|
|
5516
|
-
delete nextPrices[name];
|
|
5517
|
-
} else {
|
|
5518
|
-
const parsed = Number(value2);
|
|
5519
|
-
if (Number.isFinite(parsed) && parsed >= 0) nextPrices[name] = parsed;
|
|
5520
|
-
}
|
|
5521
|
-
updateSettings({ prices: nextPrices });
|
|
5522
|
-
};
|
|
5523
|
-
const updateBranchDiscount = (name, value2) => {
|
|
5524
|
-
const nextDiscounts = { ...discounts };
|
|
5525
|
-
if (value2.trim() === "") {
|
|
5526
|
-
delete nextDiscounts[name];
|
|
5527
|
-
} else {
|
|
5528
|
-
const parsed = Number(value2);
|
|
5529
|
-
if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 100) {
|
|
5530
|
-
nextDiscounts[name] = parsed;
|
|
5531
|
-
}
|
|
5532
|
-
}
|
|
5533
|
-
updateSettings({ discounts: nextDiscounts });
|
|
5534
|
-
};
|
|
5535
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-4 rounded-xl border border-slate-200 bg-slate-50/50 p-4", children: [
|
|
5536
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
|
|
5537
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5538
|
-
"input",
|
|
5539
|
-
{
|
|
5540
|
-
type: "checkbox",
|
|
5541
|
-
checked: allBranches,
|
|
5542
|
-
onChange: (event) => updateSettings({ allBranches: event.target.checked }),
|
|
5543
|
-
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
5544
|
-
}
|
|
5545
|
-
),
|
|
5546
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
5547
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block font-semibold", children: "Disponible en todas las sedes" }),
|
|
5548
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "mt-0.5 block text-xs text-slate-500", children: "Desactiva esta opci\xF3n para elegir una o varias sedes." })
|
|
5549
|
-
] })
|
|
5550
|
-
] }),
|
|
5551
|
-
!allBranches && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5552
|
-
SearchableMultiSelect,
|
|
5553
|
-
{
|
|
5554
|
-
options: branches.map((branch) => ({
|
|
5555
|
-
value: getBranchName(branch),
|
|
5556
|
-
label: getBranchName(branch)
|
|
5557
|
-
})),
|
|
5558
|
-
value: selectedBranches,
|
|
5559
|
-
onChange: (next) => updateSettings({ branches: next }),
|
|
5560
|
-
loading,
|
|
5561
|
-
error: loadError,
|
|
5562
|
-
placeholder: "Seleccionar sedes...",
|
|
5563
|
-
searchPlaceholder: "Buscar sede...",
|
|
5564
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
5565
|
-
}
|
|
5566
|
-
),
|
|
5567
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "border-t border-slate-200 pt-4", children: [
|
|
5568
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm font-semibold text-slate-700", children: "Horario diferente por sede (opcional)" }),
|
|
5569
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mt-1 text-xs text-slate-500", children: "Deja ambas horas vac\xEDas para heredar el horario general. Si defines una hora, el horario de esa sede reemplaza por completo al general." }),
|
|
5570
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5571
|
-
SearchableMultiSelect,
|
|
5572
|
-
{
|
|
5573
|
-
options: branches.map((branch) => ({
|
|
5574
|
-
value: getBranchName(branch),
|
|
5575
|
-
label: getBranchName(branch)
|
|
5576
|
-
})),
|
|
5577
|
-
value: selectedAvailabilityBranches,
|
|
5578
|
-
onChange: (next) => {
|
|
5579
|
-
const nextSchedules = Object.fromEntries(
|
|
5580
|
-
next.map((name) => [
|
|
5581
|
-
name,
|
|
5582
|
-
branchAvailability[name] ?? { start: "", end: "" }
|
|
5583
|
-
])
|
|
5584
|
-
);
|
|
5585
|
-
updateSettings({ branchAvailability: nextSchedules });
|
|
5586
|
-
},
|
|
5587
|
-
loading,
|
|
5588
|
-
error: loadError,
|
|
5589
|
-
placeholder: "Buscar sedes para configurar su horario...",
|
|
5590
|
-
searchPlaceholder: "Buscar sede...",
|
|
5591
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
5592
|
-
}
|
|
5593
|
-
) }),
|
|
5594
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-3 space-y-2", children: branches.filter(
|
|
5595
|
-
(branch) => selectedAvailabilityBranches.includes(getBranchName(branch))
|
|
5596
|
-
).map((branch) => {
|
|
5597
|
-
const name = getBranchName(branch);
|
|
5598
|
-
const schedule = branchAvailability[name] ?? {};
|
|
5599
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5600
|
-
"div",
|
|
5601
|
-
{
|
|
5602
|
-
className: "space-y-3 rounded-lg border border-slate-200 bg-white p-3",
|
|
5603
|
-
children: [
|
|
5604
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
|
|
5605
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "min-w-0 whitespace-normal break-words text-sm font-semibold leading-5 text-slate-800", children: name }),
|
|
5606
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5607
|
-
"button",
|
|
5608
|
-
{
|
|
5609
|
-
type: "button",
|
|
5610
|
-
onClick: () => {
|
|
5611
|
-
const nextSchedules = { ...branchAvailability };
|
|
5612
|
-
delete nextSchedules[name];
|
|
5613
|
-
updateSettings({ branchAvailability: nextSchedules });
|
|
5614
|
-
},
|
|
5615
|
-
"aria-label": `Quitar horario de ${name}`,
|
|
5616
|
-
title: `Quitar horario de ${name}`,
|
|
5617
|
-
className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-slate-200 text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-700",
|
|
5618
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
5619
|
-
}
|
|
5620
|
-
)
|
|
5621
|
-
] }),
|
|
5622
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5623
|
-
AdminTimeRangePicker,
|
|
5624
|
-
{
|
|
5625
|
-
value: [
|
|
5626
|
-
toDayjsTime(schedule.start),
|
|
5627
|
-
toDayjsTime(schedule.end)
|
|
5628
|
-
],
|
|
5629
|
-
onChange: (times) => updateBranchAvailability(
|
|
5630
|
-
name,
|
|
5631
|
-
times?.[0] ?? null,
|
|
5632
|
-
times?.[1] ?? null
|
|
5633
|
-
),
|
|
5634
|
-
allowEmpty: [true, true],
|
|
5635
|
-
className: "w-full",
|
|
5636
|
-
format: TIME_DISPLAY_FORMAT,
|
|
5637
|
-
order: false,
|
|
5638
|
-
placeholder: ["Hora de inicio", "Hora de cierre"],
|
|
5639
|
-
use12Hours: true
|
|
5640
|
-
}
|
|
5641
|
-
)
|
|
5642
|
-
]
|
|
5643
|
-
},
|
|
5644
|
-
branch.id
|
|
5645
|
-
);
|
|
5646
|
-
}) })
|
|
5647
|
-
] }),
|
|
5648
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "border-t border-slate-200 pt-4", children: [
|
|
5649
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
|
|
5650
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5651
|
-
"input",
|
|
5652
|
-
{
|
|
5653
|
-
type: "checkbox",
|
|
5654
|
-
checked: useBranchPricing,
|
|
5655
|
-
onChange: (event) => updateSettings({ useBranchPricing: event.target.checked }),
|
|
5656
|
-
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
5657
|
-
}
|
|
5658
|
-
),
|
|
5659
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
5660
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block font-semibold", children: "Usar precio diferente por sede" }),
|
|
5661
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "mt-0.5 block text-xs text-slate-500", children: "El precio global se usa como base; deja una sede vac\xEDa para conservarlo." })
|
|
5662
|
-
] })
|
|
5663
|
-
] }),
|
|
5664
|
-
useBranchPricing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-3 space-y-2", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "py-2 text-center text-xs text-slate-400", children: "Cargando sedes..." }) : loadError ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", className: "py-2 text-center text-xs text-red-600", children: loadError }) : branches.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "py-2 text-center text-xs text-slate-400", children: "Agrega sedes a la colecci\xF3n antes de definir precios." }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
5665
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "text-xs text-slate-500", children: [
|
|
5666
|
-
"Precio global actual: $",
|
|
5667
|
-
globalPrice.toLocaleString("es-CO")
|
|
5668
|
-
] }),
|
|
5669
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5670
|
-
SearchableMultiSelect,
|
|
5671
|
-
{
|
|
5672
|
-
options: branches.map((branch) => ({
|
|
5673
|
-
value: getBranchName(branch),
|
|
5674
|
-
label: getBranchName(branch)
|
|
5675
|
-
})),
|
|
5676
|
-
value: selectedPriceBranches,
|
|
5677
|
-
onChange: (next) => {
|
|
5678
|
-
const removed = selectedPriceBranches.filter(
|
|
5679
|
-
(name) => !next.includes(name)
|
|
5680
|
-
);
|
|
5681
|
-
const nextPrices = { ...prices };
|
|
5682
|
-
removed.forEach((name) => delete nextPrices[name]);
|
|
5683
|
-
updateSettings({
|
|
5684
|
-
priceBranches: next,
|
|
5685
|
-
prices: nextPrices
|
|
5686
|
-
});
|
|
5687
|
-
},
|
|
5688
|
-
loading,
|
|
5689
|
-
error: loadError,
|
|
5690
|
-
placeholder: "Buscar y agregar sedes...",
|
|
5691
|
-
searchPlaceholder: "Buscar sede...",
|
|
5692
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
5693
|
-
}
|
|
5694
|
-
),
|
|
5695
|
-
branches.filter(
|
|
5696
|
-
(branch) => selectedPriceBranches.includes(getBranchName(branch))
|
|
5697
|
-
).map((branch) => {
|
|
5698
|
-
const name = getBranchName(branch);
|
|
5699
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5700
|
-
"div",
|
|
5701
|
-
{
|
|
5702
|
-
className: "space-y-2 rounded-lg border border-slate-200 bg-white p-3",
|
|
5703
|
-
children: [
|
|
5704
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
|
|
5705
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "min-w-0 whitespace-normal break-words text-sm font-semibold leading-5 text-slate-800", children: name }),
|
|
5706
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5707
|
-
"button",
|
|
5708
|
-
{
|
|
5709
|
-
type: "button",
|
|
5710
|
-
onClick: () => {
|
|
5711
|
-
const nextPrices = { ...prices };
|
|
5712
|
-
delete nextPrices[name];
|
|
5713
|
-
updateSettings({
|
|
5714
|
-
priceBranches: selectedPriceBranches.filter(
|
|
5715
|
-
(selected) => selected !== name
|
|
5716
|
-
),
|
|
5717
|
-
prices: nextPrices
|
|
5718
|
-
});
|
|
5719
|
-
},
|
|
5720
|
-
"aria-label": `Quitar ${name} de precios por sede`,
|
|
5721
|
-
title: `Quitar ${name}`,
|
|
5722
|
-
className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-slate-200 text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-700",
|
|
5723
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
5724
|
-
}
|
|
5725
|
-
)
|
|
5726
|
-
] }),
|
|
5727
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block w-full", children: [
|
|
5728
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "sr-only", children: [
|
|
5729
|
-
"Precio para ",
|
|
5730
|
-
name
|
|
5731
|
-
] }),
|
|
5732
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5733
|
-
FormattedNumberInput,
|
|
5734
|
-
{
|
|
5735
|
-
value: prices[name] ?? "",
|
|
5736
|
-
onChange: (price) => updateBranchPrice(
|
|
5737
|
-
name,
|
|
5738
|
-
price === null ? "" : String(price)
|
|
5739
|
-
),
|
|
5740
|
-
isPrice: true,
|
|
5741
|
-
allowEmpty: true,
|
|
5742
|
-
placeholder: String(globalPrice),
|
|
5743
|
-
className: "bg-white text-right",
|
|
5744
|
-
containerClassName: "w-full"
|
|
5745
|
-
}
|
|
5746
|
-
)
|
|
5747
|
-
] })
|
|
5748
|
-
]
|
|
5749
|
-
},
|
|
5750
|
-
branch.id
|
|
5751
|
-
);
|
|
5752
|
-
})
|
|
5753
|
-
] }) })
|
|
5754
|
-
] }),
|
|
5755
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "border-t border-slate-200 pt-4", children: [
|
|
5756
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
|
|
5757
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5758
|
-
"input",
|
|
5759
|
-
{
|
|
5760
|
-
type: "checkbox",
|
|
5761
|
-
checked: useBranchDiscounts,
|
|
5762
|
-
onChange: (event) => updateSettings({ useBranchDiscounts: event.target.checked }),
|
|
5763
|
-
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
5764
|
-
}
|
|
5765
|
-
),
|
|
5766
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
5767
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block font-semibold", children: "Usar descuento diferente por sede" }),
|
|
5768
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "mt-0.5 block text-xs text-slate-500", children: "El descuento global aplica como base; una sede vac\xEDa hereda ese porcentaje." })
|
|
5769
|
-
] })
|
|
5770
|
-
] }),
|
|
5771
|
-
useBranchDiscounts && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-3 space-y-2", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "py-2 text-center text-xs text-slate-400", children: "Cargando sedes..." }) : loadError ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", className: "py-2 text-center text-xs text-red-600", children: loadError }) : branches.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "py-2 text-center text-xs text-slate-400", children: "Agrega sedes a la colecci\xF3n antes de definir descuentos." }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
5772
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "text-xs text-slate-500", children: [
|
|
5773
|
-
"Descuento global actual: ",
|
|
5774
|
-
globalDiscount,
|
|
5775
|
-
"%"
|
|
5776
|
-
] }),
|
|
5777
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5778
|
-
SearchableMultiSelect,
|
|
5779
|
-
{
|
|
5780
|
-
options: branches.map((branch) => ({
|
|
5781
|
-
value: getBranchName(branch),
|
|
5782
|
-
label: getBranchName(branch)
|
|
5783
|
-
})),
|
|
5784
|
-
value: selectedDiscountBranches,
|
|
5785
|
-
onChange: (next) => {
|
|
5786
|
-
const removed = selectedDiscountBranches.filter(
|
|
5787
|
-
(name) => !next.includes(name)
|
|
5788
|
-
);
|
|
5789
|
-
const nextDiscounts = { ...discounts };
|
|
5790
|
-
removed.forEach((name) => delete nextDiscounts[name]);
|
|
5791
|
-
updateSettings({
|
|
5792
|
-
discountBranches: next,
|
|
5793
|
-
discounts: nextDiscounts
|
|
5794
|
-
});
|
|
5795
|
-
},
|
|
5796
|
-
loading,
|
|
5797
|
-
error: loadError,
|
|
5798
|
-
placeholder: "Buscar y agregar sedes...",
|
|
5799
|
-
searchPlaceholder: "Buscar sede...",
|
|
5800
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
5801
|
-
}
|
|
5802
|
-
),
|
|
5803
|
-
branches.filter(
|
|
5804
|
-
(branch) => selectedDiscountBranches.includes(getBranchName(branch))
|
|
5805
|
-
).map((branch) => {
|
|
5806
|
-
const name = getBranchName(branch);
|
|
5807
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
5808
|
-
"div",
|
|
5809
|
-
{
|
|
5810
|
-
className: "space-y-2 rounded-lg border border-slate-200 bg-white p-3",
|
|
5811
|
-
children: [
|
|
5812
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
|
|
5813
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "min-w-0 whitespace-normal break-words text-sm font-semibold leading-5 text-slate-800", children: name }),
|
|
5814
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5815
|
-
"button",
|
|
5816
|
-
{
|
|
5817
|
-
type: "button",
|
|
5818
|
-
onClick: () => {
|
|
5819
|
-
const nextDiscounts = { ...discounts };
|
|
5820
|
-
delete nextDiscounts[name];
|
|
5821
|
-
updateSettings({
|
|
5822
|
-
discountBranches: selectedDiscountBranches.filter(
|
|
5823
|
-
(selected) => selected !== name
|
|
5824
|
-
),
|
|
5825
|
-
discounts: nextDiscounts
|
|
5826
|
-
});
|
|
5827
|
-
},
|
|
5828
|
-
"aria-label": `Quitar descuento de ${name}`,
|
|
5829
|
-
title: `Quitar ${name}`,
|
|
5830
|
-
className: "inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-slate-200 text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-700",
|
|
5831
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
5832
|
-
}
|
|
5833
|
-
)
|
|
5834
|
-
] }),
|
|
5835
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block w-full", children: [
|
|
5836
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "sr-only", children: [
|
|
5837
|
-
"Descuento para ",
|
|
5838
|
-
name
|
|
5839
|
-
] }),
|
|
5840
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5841
|
-
FormattedNumberInput,
|
|
5842
|
-
{
|
|
5843
|
-
value: discounts[name] ?? "",
|
|
5844
|
-
onChange: (discount) => updateBranchDiscount(
|
|
5845
|
-
name,
|
|
5846
|
-
discount === null ? "" : String(discount)
|
|
5847
|
-
),
|
|
5848
|
-
isPercent: true,
|
|
5849
|
-
allowEmpty: true,
|
|
5850
|
-
placeholder: String(globalDiscount),
|
|
5851
|
-
className: "bg-white text-right",
|
|
5852
|
-
containerClassName: "w-full"
|
|
5853
|
-
}
|
|
5854
|
-
)
|
|
5855
|
-
] })
|
|
5856
|
-
]
|
|
5857
|
-
},
|
|
5858
|
-
branch.id
|
|
5859
|
-
);
|
|
5860
|
-
})
|
|
5861
|
-
] }) })
|
|
5862
|
-
] })
|
|
5863
|
-
] });
|
|
5864
|
-
}
|
|
5865
|
-
function BranchSettingsSummary({ value }) {
|
|
5866
|
-
if (!value || typeof value !== "object") return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Todas las sedes" });
|
|
5867
|
-
const settings = value;
|
|
5868
|
-
const names = Array.isArray(settings.branches) ? settings.branches : [];
|
|
5869
|
-
const locationSummary = settings.allBranches === false ? names.length > 0 ? names.join(", ") : "Sin sedes" : "Todas las sedes";
|
|
5870
|
-
const pricingSummary = settings.useBranchPricing ? " \xB7 Precio por sede" : " \xB7 Precio global";
|
|
5871
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: locationSummary + pricingSummary });
|
|
5872
|
-
}
|
|
5873
6102
|
function SearchableMultiSelect({
|
|
5874
6103
|
options,
|
|
5875
6104
|
value,
|
|
@@ -6022,32 +6251,40 @@ function SearchableMultiSelect({
|
|
|
6022
6251
|
] })
|
|
6023
6252
|
] })
|
|
6024
6253
|
] }),
|
|
6025
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
"
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
"
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6254
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6255
|
+
"div",
|
|
6256
|
+
{
|
|
6257
|
+
role: "listbox",
|
|
6258
|
+
"aria-multiselectable": "true",
|
|
6259
|
+
className: "max-h-56 overflow-y-auto p-2",
|
|
6260
|
+
children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "py-4 text-center text-xs text-slate-400", children: "Cargando opciones..." }) : error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "alert", className: "py-4 text-center text-xs text-red-600", children: error }) : visibleOptions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "py-4 text-center text-xs text-slate-400", children: options.length === 0 ? emptyMessage : "No hay resultados para la b\xFAsqueda." }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "space-y-1", children: visibleOptions.map((option) => {
|
|
6261
|
+
const isSelected = value.includes(option.value);
|
|
6262
|
+
const isAtMax = !!max && value.length >= max && !isSelected;
|
|
6263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
6264
|
+
"button",
|
|
6265
|
+
{
|
|
6266
|
+
type: "button",
|
|
6267
|
+
role: "option",
|
|
6268
|
+
"aria-selected": isSelected,
|
|
6269
|
+
disabled: isAtMax,
|
|
6270
|
+
onClick: () => toggleOption(option.value),
|
|
6271
|
+
className: `flex w-full items-center gap-2.5 rounded-lg px-3 py-2.5 text-left text-sm transition-colors ${isSelected ? "bg-indigo-50 font-semibold text-indigo-900" : "text-slate-700 hover:bg-slate-50"} disabled:cursor-not-allowed disabled:opacity-50`,
|
|
6272
|
+
children: [
|
|
6273
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6274
|
+
"span",
|
|
6275
|
+
{
|
|
6276
|
+
className: `flex h-4 w-4 shrink-0 items-center justify-center rounded border ${isSelected ? "border-indigo-600 bg-indigo-600 text-white" : "border-slate-300 bg-white"}`,
|
|
6277
|
+
children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Check, { className: "h-3 w-3" })
|
|
6278
|
+
}
|
|
6279
|
+
),
|
|
6280
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: option.label })
|
|
6281
|
+
]
|
|
6282
|
+
},
|
|
6283
|
+
option.value
|
|
6284
|
+
);
|
|
6285
|
+
}) })
|
|
6286
|
+
}
|
|
6287
|
+
)
|
|
6051
6288
|
] })
|
|
6052
6289
|
] });
|
|
6053
6290
|
}
|
|
@@ -6073,19 +6310,29 @@ function ReferenceSelect({
|
|
|
6073
6310
|
const [formError, setFormError] = (0, import_react5.useState)("");
|
|
6074
6311
|
const [newRecord, setNewRecord] = (0, import_react5.useState)({});
|
|
6075
6312
|
const targetCol = ctx.config.collections?.find((c) => c.id === collectionId);
|
|
6313
|
+
const normalizeSearchValue = (field, value2) => {
|
|
6314
|
+
const text = String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim().toLocaleLowerCase();
|
|
6315
|
+
return /phone|telefono|teléfono/i.test(field) ? text.replace(/\D/g, "") : text.replace(/\s+/g, " ");
|
|
6316
|
+
};
|
|
6076
6317
|
const handleSaveRecord = async () => {
|
|
6077
6318
|
setFormError("");
|
|
6078
6319
|
if (!targetCol) return;
|
|
6079
|
-
const uniqueFields = targetCol.fields.filter(
|
|
6320
|
+
const uniqueFields = targetCol.fields.filter(
|
|
6321
|
+
(f) => f.unique || f.id === "id" && !f.hideOnCreate
|
|
6322
|
+
);
|
|
6080
6323
|
for (const uf of uniqueFields) {
|
|
6081
6324
|
const val = String(newRecord[uf.id] || "").trim();
|
|
6082
6325
|
if (!val) {
|
|
6083
6326
|
setFormError(`El campo "${uf.label || uf.id}" es obligatorio.`);
|
|
6084
6327
|
return;
|
|
6085
6328
|
}
|
|
6086
|
-
const isDup = options.some(
|
|
6329
|
+
const isDup = options.some(
|
|
6330
|
+
(opt) => String(opt.value || "").trim().toLowerCase() === val.toLowerCase()
|
|
6331
|
+
);
|
|
6087
6332
|
if (isDup) {
|
|
6088
|
-
setFormError(
|
|
6333
|
+
setFormError(
|
|
6334
|
+
`Ya existe un registro con este ${uf.label.toLowerCase()} (\xAB${val}\xBB).`
|
|
6335
|
+
);
|
|
6089
6336
|
return;
|
|
6090
6337
|
}
|
|
6091
6338
|
}
|
|
@@ -6112,21 +6359,35 @@ function ReferenceSelect({
|
|
|
6112
6359
|
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
6113
6360
|
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
6114
6361
|
const lab = fullName || String(r[displayField] || r.name || r.id);
|
|
6362
|
+
const searchText = [
|
|
6363
|
+
lab,
|
|
6364
|
+
val,
|
|
6365
|
+
...(targetCol.searchBy || []).map((field) => String(r[field] ?? ""))
|
|
6366
|
+
].filter(Boolean).join(" ");
|
|
6115
6367
|
return {
|
|
6116
6368
|
value: val,
|
|
6117
|
-
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
6369
|
+
label: val && val !== lab && val.length < 20 ? `${lab} (${val})` : lab,
|
|
6370
|
+
searchText,
|
|
6118
6371
|
raw: r
|
|
6119
6372
|
};
|
|
6120
6373
|
});
|
|
6121
6374
|
setOptions(fromCollection);
|
|
6122
|
-
const
|
|
6375
|
+
const persistedEntry = (res || []).find((record) => record.id === entryToSave.id) || (res || []).find(
|
|
6376
|
+
(record) => (targetCol.searchBy || []).some((field) => {
|
|
6377
|
+
const requested = normalizeSearchValue(field, entryToSave[field]);
|
|
6378
|
+
return requested && requested === normalizeSearchValue(field, record[field]);
|
|
6379
|
+
})
|
|
6380
|
+
) || entryToSave;
|
|
6381
|
+
const selectedVal = valueField && persistedEntry[valueField] !== void 0 ? String(persistedEntry[valueField]) : persistedEntry.id;
|
|
6123
6382
|
onChange(selectedVal);
|
|
6124
6383
|
if (onSelectRecord) {
|
|
6125
|
-
onSelectRecord(
|
|
6384
|
+
onSelectRecord(persistedEntry);
|
|
6126
6385
|
}
|
|
6127
6386
|
setModalOpen(false);
|
|
6128
6387
|
setNewRecord({});
|
|
6129
|
-
message.success(
|
|
6388
|
+
message.success(
|
|
6389
|
+
t.recordCreatedSuccess || "Registro creado y seleccionado exitosamente."
|
|
6390
|
+
);
|
|
6130
6391
|
} catch (err) {
|
|
6131
6392
|
setFormError(err?.message || "Error al crear registro.");
|
|
6132
6393
|
} finally {
|
|
@@ -6136,7 +6397,11 @@ function ReferenceSelect({
|
|
|
6136
6397
|
(0, import_react5.useEffect)(() => {
|
|
6137
6398
|
if (!collectionId) {
|
|
6138
6399
|
if (fallbackOptions && fallbackOptions.length > 0) {
|
|
6139
|
-
setOptions(
|
|
6400
|
+
setOptions(
|
|
6401
|
+
fallbackOptions.map(
|
|
6402
|
+
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
6403
|
+
)
|
|
6404
|
+
);
|
|
6140
6405
|
}
|
|
6141
6406
|
setLoading(false);
|
|
6142
6407
|
return;
|
|
@@ -6147,18 +6412,31 @@ function ReferenceSelect({
|
|
|
6147
6412
|
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
6148
6413
|
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
6149
6414
|
const lab = fullName || String(r[displayField] || r.name || r.id);
|
|
6415
|
+
const searchText = [
|
|
6416
|
+
lab,
|
|
6417
|
+
val,
|
|
6418
|
+
...(targetCol?.searchBy || []).map((field) => String(r[field] ?? ""))
|
|
6419
|
+
].filter(Boolean).join(" ");
|
|
6150
6420
|
return {
|
|
6151
6421
|
value: val,
|
|
6152
|
-
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
6422
|
+
label: val && val !== lab && val.length < 20 ? `${lab} (${val})` : lab,
|
|
6423
|
+
searchText,
|
|
6153
6424
|
raw: r
|
|
6154
6425
|
};
|
|
6155
6426
|
});
|
|
6156
6427
|
setOptions(fromCollection);
|
|
6157
6428
|
setLoading(false);
|
|
6158
6429
|
}).catch((err) => {
|
|
6159
|
-
console.error(
|
|
6430
|
+
console.error(
|
|
6431
|
+
`Failed to load reference entries for ${collectionId}:`,
|
|
6432
|
+
err
|
|
6433
|
+
);
|
|
6160
6434
|
if (fallbackOptions && fallbackOptions.length > 0) {
|
|
6161
|
-
setOptions(
|
|
6435
|
+
setOptions(
|
|
6436
|
+
fallbackOptions.map(
|
|
6437
|
+
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
6438
|
+
)
|
|
6439
|
+
);
|
|
6162
6440
|
}
|
|
6163
6441
|
setLoading(false);
|
|
6164
6442
|
});
|
|
@@ -6172,85 +6450,67 @@ function ReferenceSelect({
|
|
|
6172
6450
|
}
|
|
6173
6451
|
return list;
|
|
6174
6452
|
}, [options, singleVal]);
|
|
6175
|
-
const canQuickCreate = Boolean(
|
|
6453
|
+
const canQuickCreate = Boolean(
|
|
6454
|
+
targetCol && targetCol.enableQuickCreate !== false
|
|
6455
|
+
);
|
|
6176
6456
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
6177
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
}
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
{
|
|
6235
|
-
type: "primary",
|
|
6236
|
-
size: "large",
|
|
6237
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-4 h-4" }),
|
|
6238
|
-
onClick: () => {
|
|
6239
|
-
setFormError("");
|
|
6240
|
-
const init = {};
|
|
6241
|
-
targetCol.fields.forEach((f) => {
|
|
6242
|
-
if (f.defaultValue !== void 0) init[f.id] = f.defaultValue;
|
|
6243
|
-
else if (f.type === "list" || f.multiple) init[f.id] = [""];
|
|
6244
|
-
else init[f.id] = "";
|
|
6245
|
-
});
|
|
6246
|
-
setNewRecord(init);
|
|
6247
|
-
setModalOpen(true);
|
|
6248
|
-
},
|
|
6249
|
-
className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
|
|
6250
|
-
children: targetCol.submitLabel || t.newBtn
|
|
6251
|
-
}
|
|
6252
|
-
)
|
|
6253
|
-
] }),
|
|
6457
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6458
|
+
import_antd.Select,
|
|
6459
|
+
{
|
|
6460
|
+
size: "large",
|
|
6461
|
+
loading,
|
|
6462
|
+
showSearch: searchable,
|
|
6463
|
+
placeholder: loading ? t.loadingOptions : t.selectOption,
|
|
6464
|
+
allowClear: true,
|
|
6465
|
+
filterOption: (input, option) => {
|
|
6466
|
+
if (!input) return true;
|
|
6467
|
+
const q = input.toLowerCase();
|
|
6468
|
+
const label = String(option?.label ?? "").toLowerCase();
|
|
6469
|
+
const val = String(option?.value ?? "").toLowerCase();
|
|
6470
|
+
const searchText = String(option?.searchText ?? "").toLowerCase();
|
|
6471
|
+
return label.includes(q) || val.includes(q) || searchText.includes(q);
|
|
6472
|
+
},
|
|
6473
|
+
value: singleVal,
|
|
6474
|
+
onChange: (v) => {
|
|
6475
|
+
onChange(v || "");
|
|
6476
|
+
if (onSelectRecord) {
|
|
6477
|
+
const found = options.find((o) => o.value === v);
|
|
6478
|
+
if (found?.raw) onSelectRecord(found.raw);
|
|
6479
|
+
}
|
|
6480
|
+
},
|
|
6481
|
+
options: displayOptions,
|
|
6482
|
+
dropdownRender: (menu) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
6483
|
+
menu,
|
|
6484
|
+
canQuickCreate && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
|
|
6485
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindOption || "\xBFNo encuentras la opci\xF3n?" }),
|
|
6486
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6487
|
+
import_antd.Button,
|
|
6488
|
+
{
|
|
6489
|
+
type: "primary",
|
|
6490
|
+
size: "small",
|
|
6491
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
6492
|
+
onClick: () => {
|
|
6493
|
+
setFormError("");
|
|
6494
|
+
const init = {};
|
|
6495
|
+
targetCol.fields.forEach((f) => {
|
|
6496
|
+
if (f.defaultValue !== void 0)
|
|
6497
|
+
init[f.id] = f.defaultValue;
|
|
6498
|
+
else if (f.type === "list" || f.multiple)
|
|
6499
|
+
init[f.id] = [""];
|
|
6500
|
+
else init[f.id] = "";
|
|
6501
|
+
});
|
|
6502
|
+
setNewRecord(init);
|
|
6503
|
+
setModalOpen(true);
|
|
6504
|
+
},
|
|
6505
|
+
className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
|
|
6506
|
+
children: t.createNewOption || `Crear ${targetCol.name}`
|
|
6507
|
+
}
|
|
6508
|
+
)
|
|
6509
|
+
] })
|
|
6510
|
+
] }),
|
|
6511
|
+
className: "w-full"
|
|
6512
|
+
}
|
|
6513
|
+
) }),
|
|
6254
6514
|
canQuickCreate && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6255
6515
|
import_antd.Modal,
|
|
6256
6516
|
{
|
|
@@ -6261,7 +6521,9 @@ function ReferenceSelect({
|
|
|
6261
6521
|
width: 650,
|
|
6262
6522
|
footer: null,
|
|
6263
6523
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pt-2 space-y-4", children: [
|
|
6264
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: targetCol.fields.filter(
|
|
6524
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: targetCol.fields.filter(
|
|
6525
|
+
(f) => !f.hideOnCreate && !f.readOnly && f.type !== "signature"
|
|
6526
|
+
).map((f) => {
|
|
6265
6527
|
if (f.dependsOn && newRecord[f.dependsOn.field] !== void 0) {
|
|
6266
6528
|
const targetVal = f.dependsOn.value;
|
|
6267
6529
|
const currentVal = newRecord[f.dependsOn.field];
|
|
@@ -6290,7 +6552,10 @@ function ReferenceSelect({
|
|
|
6290
6552
|
onChange: (e) => {
|
|
6291
6553
|
const updated = [...currentList];
|
|
6292
6554
|
updated[idx] = e.target.value;
|
|
6293
|
-
setNewRecord((prev) => ({
|
|
6555
|
+
setNewRecord((prev) => ({
|
|
6556
|
+
...prev,
|
|
6557
|
+
[f.id]: updated
|
|
6558
|
+
}));
|
|
6294
6559
|
}
|
|
6295
6560
|
}
|
|
6296
6561
|
),
|
|
@@ -6299,7 +6564,9 @@ function ReferenceSelect({
|
|
|
6299
6564
|
{
|
|
6300
6565
|
type: "button",
|
|
6301
6566
|
onClick: () => {
|
|
6302
|
-
const updated = currentList.filter(
|
|
6567
|
+
const updated = currentList.filter(
|
|
6568
|
+
(_, i) => i !== idx
|
|
6569
|
+
);
|
|
6303
6570
|
setNewRecord((prev) => ({
|
|
6304
6571
|
...prev,
|
|
6305
6572
|
[f.id]: updated.length > 0 ? updated : [""]
|
|
@@ -6332,7 +6599,9 @@ function ReferenceSelect({
|
|
|
6332
6599
|
}
|
|
6333
6600
|
if (f.type === "select") {
|
|
6334
6601
|
const opts = f.optionsMap && f.dependsOnField ? f.optionsMap[String(newRecord[f.dependsOnField] || "")] || f.options || [] : f.options || [];
|
|
6335
|
-
const formattedOpts = opts.map(
|
|
6602
|
+
const formattedOpts = opts.map(
|
|
6603
|
+
(o) => typeof o === "string" ? { label: o, value: o } : o
|
|
6604
|
+
);
|
|
6336
6605
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: colSpanClass, children: [
|
|
6337
6606
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: f.label }),
|
|
6338
6607
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -6367,7 +6636,10 @@ function ReferenceSelect({
|
|
|
6367
6636
|
{
|
|
6368
6637
|
rows: 3,
|
|
6369
6638
|
value: newRecord[f.id] || "",
|
|
6370
|
-
onChange: (e) => setNewRecord((prev) => ({
|
|
6639
|
+
onChange: (e) => setNewRecord((prev) => ({
|
|
6640
|
+
...prev,
|
|
6641
|
+
[f.id]: e.target.value
|
|
6642
|
+
}))
|
|
6371
6643
|
}
|
|
6372
6644
|
)
|
|
6373
6645
|
] }, f.id);
|
|
@@ -6385,17 +6657,26 @@ function ReferenceSelect({
|
|
|
6385
6657
|
value: newRecord[f.id] || "",
|
|
6386
6658
|
placeholder: f.label,
|
|
6387
6659
|
onChange: (e) => {
|
|
6388
|
-
setNewRecord((prev) => ({
|
|
6660
|
+
setNewRecord((prev) => ({
|
|
6661
|
+
...prev,
|
|
6662
|
+
[f.id]: e.target.value
|
|
6663
|
+
}));
|
|
6389
6664
|
if (formError) setFormError("");
|
|
6390
6665
|
},
|
|
6391
6666
|
onBlur: (e) => {
|
|
6392
6667
|
if (f.unique) {
|
|
6393
6668
|
const clean = (e.target.value || "").trim().toLowerCase();
|
|
6394
6669
|
if (clean) {
|
|
6395
|
-
const dup = options.find(
|
|
6670
|
+
const dup = options.find(
|
|
6671
|
+
(opt) => String(opt.value || "").trim().toLowerCase() === clean
|
|
6672
|
+
);
|
|
6396
6673
|
if (dup) {
|
|
6397
|
-
setFormError(
|
|
6398
|
-
|
|
6674
|
+
setFormError(
|
|
6675
|
+
`Ya existe un registro con este ${f.label.toLowerCase()} (\xAB${dup.label || clean}\xBB).`
|
|
6676
|
+
);
|
|
6677
|
+
message.warning(
|
|
6678
|
+
`\u26A0\uFE0F Ya existe un registro con este ${f.label.toLowerCase()}: ${clean}.`
|
|
6679
|
+
);
|
|
6399
6680
|
}
|
|
6400
6681
|
}
|
|
6401
6682
|
}
|
|
@@ -6447,11 +6728,24 @@ function ReferenceTableCell({
|
|
|
6447
6728
|
}).catch(() => {
|
|
6448
6729
|
setLabels(ids);
|
|
6449
6730
|
});
|
|
6450
|
-
}, [
|
|
6731
|
+
}, [
|
|
6732
|
+
collectionId,
|
|
6733
|
+
displayField,
|
|
6734
|
+
valueField,
|
|
6735
|
+
JSON.stringify(ids),
|
|
6736
|
+
ctx.adapter
|
|
6737
|
+
]);
|
|
6451
6738
|
if (labels.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "-" });
|
|
6452
6739
|
if (multiple || labels.length > 1) {
|
|
6453
6740
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-wrap gap-1 max-w-[260px]", children: [
|
|
6454
|
-
labels.slice(0, 3).map((lbl, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6741
|
+
labels.slice(0, 3).map((lbl, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6742
|
+
"span",
|
|
6743
|
+
{
|
|
6744
|
+
className: "inline-flex px-1.5 py-0.5 rounded bg-slate-100 text-slate-700 text-[11px] font-medium truncate max-w-[120px]",
|
|
6745
|
+
children: lbl
|
|
6746
|
+
},
|
|
6747
|
+
idx
|
|
6748
|
+
)),
|
|
6455
6749
|
labels.length > 3 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "inline-flex px-1.5 py-0.5 rounded bg-slate-200 text-slate-600 text-[10px] font-bold", children: [
|
|
6456
6750
|
"+",
|
|
6457
6751
|
labels.length - 3
|
|
@@ -6720,6 +7014,7 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
6720
7014
|
0 && (module.exports = {
|
|
6721
7015
|
AdminApp,
|
|
6722
7016
|
AdminLogin,
|
|
7017
|
+
AdminTimeRangePicker,
|
|
6723
7018
|
CmsProvider,
|
|
6724
7019
|
EditableFile,
|
|
6725
7020
|
EditableImage,
|
|
@@ -6727,6 +7022,8 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
6727
7022
|
EditableList,
|
|
6728
7023
|
EditableReference,
|
|
6729
7024
|
EditableText,
|
|
7025
|
+
FormattedNumberInput,
|
|
7026
|
+
SearchableMultiSelect,
|
|
6730
7027
|
SubscriptionPage,
|
|
6731
7028
|
SubscriptionProvider,
|
|
6732
7029
|
generateDefaultTemplate,
|