admin-lib-cms 1.2.17 → 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 +2206 -1091
- package/dist/index.mjs +2224 -1099
- package/dist/storage.js +70 -26
- package/dist/storage.mjs +70 -26
- package/dist/types.d.mts +36 -1
- package/dist/types.d.ts +36 -1
- package/package.json +3 -2
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,
|
|
@@ -829,9 +832,232 @@ function EditableReference({
|
|
|
829
832
|
var import_react5 = __toESM(require("react"));
|
|
830
833
|
var import_react_dom = require("react-dom");
|
|
831
834
|
var import_antd = require("antd");
|
|
832
|
-
var
|
|
835
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
833
836
|
var import_lucide_react2 = require("lucide-react");
|
|
834
837
|
|
|
838
|
+
// src/admin/excel.ts
|
|
839
|
+
var XLSX = __toESM(require("xlsx"));
|
|
840
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
841
|
+
function filterEntriesByDateRange(entries, fieldId, startDate, endDate) {
|
|
842
|
+
if (!startDate && !endDate) return entries;
|
|
843
|
+
const startDayjs = startDate ? (0, import_dayjs.default)(startDate).startOf("day") : null;
|
|
844
|
+
const endDayjs = endDate ? (0, import_dayjs.default)(endDate).endOf("day") : null;
|
|
845
|
+
return entries.filter((e) => {
|
|
846
|
+
const val = e[fieldId];
|
|
847
|
+
if (!val) return false;
|
|
848
|
+
const d = (0, import_dayjs.default)(String(val));
|
|
849
|
+
if (!d.isValid()) return false;
|
|
850
|
+
if (startDayjs && d.isBefore(startDayjs)) return false;
|
|
851
|
+
if (endDayjs && d.isAfter(endDayjs)) return false;
|
|
852
|
+
return true;
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
function findExistingEntry(item, existingEntries, collection) {
|
|
856
|
+
if (item.id && !item.id.startsWith("item_")) {
|
|
857
|
+
const cleanId = String(item.id).trim().toLowerCase();
|
|
858
|
+
const matchById = existingEntries.find(
|
|
859
|
+
(e) => e.id && String(e.id).trim().toLowerCase() === cleanId || e._id && String(e._id).trim().toLowerCase() === cleanId
|
|
860
|
+
);
|
|
861
|
+
if (matchById) return matchById;
|
|
862
|
+
}
|
|
863
|
+
const uniqueFieldIds = [];
|
|
864
|
+
(collection.fields || []).forEach((f) => {
|
|
865
|
+
if (f.unique && !uniqueFieldIds.includes(f.id)) {
|
|
866
|
+
uniqueFieldIds.push(f.id);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
(collection.uniqueFields || []).forEach((uf) => {
|
|
870
|
+
if (!uniqueFieldIds.includes(uf)) {
|
|
871
|
+
uniqueFieldIds.push(uf);
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
for (const ufId of uniqueFieldIds) {
|
|
875
|
+
const itemVal = item[ufId];
|
|
876
|
+
if (itemVal !== void 0 && itemVal !== null && String(itemVal).trim() !== "") {
|
|
877
|
+
const cleanVal = String(itemVal).trim().toLowerCase();
|
|
878
|
+
const match = existingEntries.find((e) => {
|
|
879
|
+
const eVal = e[ufId];
|
|
880
|
+
return eVal !== void 0 && eVal !== null && String(eVal).trim().toLowerCase() === cleanVal;
|
|
881
|
+
});
|
|
882
|
+
if (match) return match;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return null;
|
|
886
|
+
}
|
|
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
|
+
}
|
|
896
|
+
if (val === void 0 || val === null) return "";
|
|
897
|
+
if (typeof val === "number" || typeof val === "boolean") return val;
|
|
898
|
+
if (Array.isArray(val)) {
|
|
899
|
+
return val.map((item) => typeof item === "object" && item !== null ? JSON.stringify(item) : String(item)).join(", ");
|
|
900
|
+
}
|
|
901
|
+
if (typeof val === "object") {
|
|
902
|
+
try {
|
|
903
|
+
return JSON.stringify(val);
|
|
904
|
+
} catch {
|
|
905
|
+
return String(val);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return String(val);
|
|
909
|
+
}
|
|
910
|
+
function exportCollectionToExcel(collection, entries, fileNamePrefix) {
|
|
911
|
+
const columns = [
|
|
912
|
+
{ key: "id", label: "ID" }
|
|
913
|
+
];
|
|
914
|
+
(collection.fields || []).forEach((f) => {
|
|
915
|
+
columns.push({
|
|
916
|
+
key: f.id,
|
|
917
|
+
label: f.label || f.id,
|
|
918
|
+
field: f
|
|
919
|
+
});
|
|
920
|
+
});
|
|
921
|
+
const rows = entries.map((entry) => {
|
|
922
|
+
const rowObj = {};
|
|
923
|
+
columns.forEach((col) => {
|
|
924
|
+
const rawVal = entry[col.key];
|
|
925
|
+
rowObj[col.label] = formatValueForExport(rawVal, col.field, entry);
|
|
926
|
+
});
|
|
927
|
+
return rowObj;
|
|
928
|
+
});
|
|
929
|
+
const worksheet = XLSX.utils.json_to_sheet(rows);
|
|
930
|
+
const colWidths = columns.map((col) => {
|
|
931
|
+
let maxLen = col.label.length;
|
|
932
|
+
for (let i = 0; i < Math.min(rows.length, 100); i++) {
|
|
933
|
+
const cellVal = String(rows[i]?.[col.label] ?? "");
|
|
934
|
+
if (cellVal.length > maxLen) {
|
|
935
|
+
maxLen = Math.min(cellVal.length, 45);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return { wch: Math.max(maxLen + 3, 12) };
|
|
939
|
+
});
|
|
940
|
+
worksheet["!cols"] = colWidths;
|
|
941
|
+
const workbook = XLSX.utils.book_new();
|
|
942
|
+
const safeSheetName = (collection.name || collection.id).replace(/[\\/?*[\]:]/g, "").slice(0, 31) || "Datos";
|
|
943
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, safeSheetName);
|
|
944
|
+
const dateStr = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
945
|
+
const baseName = fileNamePrefix || (collection.name || collection.id).toLowerCase().replace(/[^a-z0-9_-]+/g, "_");
|
|
946
|
+
const fileName = `${baseName}_${dateStr}.xlsx`;
|
|
947
|
+
XLSX.writeFile(workbook, fileName);
|
|
948
|
+
}
|
|
949
|
+
async function parseExcelForCollection(file, collection, existingEntries = []) {
|
|
950
|
+
const data = await file.arrayBuffer();
|
|
951
|
+
const workbook = XLSX.read(data, { type: "array" });
|
|
952
|
+
const firstSheetName = workbook.SheetNames[0];
|
|
953
|
+
if (!firstSheetName) {
|
|
954
|
+
throw new Error("El archivo no contiene ninguna hoja de c\xE1lculo.");
|
|
955
|
+
}
|
|
956
|
+
const worksheet = workbook.Sheets[firstSheetName];
|
|
957
|
+
const rawRows = XLSX.utils.sheet_to_json(worksheet, { defval: "" });
|
|
958
|
+
if (!rawRows.length) {
|
|
959
|
+
return {
|
|
960
|
+
records: [],
|
|
961
|
+
totalRows: 0,
|
|
962
|
+
matchedFields: [],
|
|
963
|
+
unmatchedHeaders: [],
|
|
964
|
+
samplePreview: [],
|
|
965
|
+
errors: ["El archivo no contiene filas con datos."]
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
const headers = Object.keys(rawRows[0] || {});
|
|
969
|
+
const matchedFields = [];
|
|
970
|
+
const unmatchedHeaders = [];
|
|
971
|
+
const headerToFieldMap = /* @__PURE__ */ new Map();
|
|
972
|
+
headers.forEach((header) => {
|
|
973
|
+
const cleanHeader = header.trim().toLowerCase();
|
|
974
|
+
if (cleanHeader === "id" || cleanHeader === "_id" || cleanHeader === "identificador") {
|
|
975
|
+
headerToFieldMap.set(header, "id");
|
|
976
|
+
matchedFields.push({ label: header, fieldId: "id" });
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
const matched = (collection.fields || []).find((f) => {
|
|
980
|
+
const fieldLabel = (f.label || "").trim().toLowerCase();
|
|
981
|
+
const fieldId = f.id.trim().toLowerCase();
|
|
982
|
+
return fieldLabel === cleanHeader || fieldId === cleanHeader;
|
|
983
|
+
});
|
|
984
|
+
if (matched) {
|
|
985
|
+
headerToFieldMap.set(header, matched);
|
|
986
|
+
matchedFields.push({ label: header, fieldId: matched.id });
|
|
987
|
+
} else {
|
|
988
|
+
unmatchedHeaders.push(header);
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
const records = [];
|
|
992
|
+
const errors = [];
|
|
993
|
+
rawRows.forEach((row, idx) => {
|
|
994
|
+
const entry = { id: "" };
|
|
995
|
+
(collection.fields || []).forEach((f) => {
|
|
996
|
+
if (f.defaultValue !== void 0) {
|
|
997
|
+
entry[f.id] = f.defaultValue;
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
headers.forEach((header) => {
|
|
1001
|
+
const mapping = headerToFieldMap.get(header);
|
|
1002
|
+
const rawVal = row[header];
|
|
1003
|
+
if (rawVal === void 0 || rawVal === "") return;
|
|
1004
|
+
if (mapping === "id") {
|
|
1005
|
+
entry.id = String(rawVal).trim();
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
if (!mapping) return;
|
|
1009
|
+
const field = mapping;
|
|
1010
|
+
if (field.type === "number") {
|
|
1011
|
+
const num = Number(String(rawVal).replace(/[^0-9.-]/g, ""));
|
|
1012
|
+
entry[field.id] = isNaN(num) ? rawVal : num;
|
|
1013
|
+
} else if (field.type === "boolean") {
|
|
1014
|
+
const str = String(rawVal).trim().toLowerCase();
|
|
1015
|
+
entry[field.id] = str === "true" || str === "si" || str === "s\xED" || str === "yes" || str === "1" || str === "verdadero";
|
|
1016
|
+
} else if (field.multiple || field.type === "list") {
|
|
1017
|
+
if (typeof rawVal === "string") {
|
|
1018
|
+
entry[field.id] = rawVal.split(/[,;\n]/).map((s) => s.trim()).filter(Boolean);
|
|
1019
|
+
} else if (Array.isArray(rawVal)) {
|
|
1020
|
+
entry[field.id] = rawVal;
|
|
1021
|
+
} else {
|
|
1022
|
+
entry[field.id] = [String(rawVal)];
|
|
1023
|
+
}
|
|
1024
|
+
} else if (typeof rawVal === "string" && (rawVal.startsWith("{") || rawVal.startsWith("["))) {
|
|
1025
|
+
try {
|
|
1026
|
+
entry[field.id] = JSON.parse(rawVal);
|
|
1027
|
+
} catch {
|
|
1028
|
+
entry[field.id] = rawVal;
|
|
1029
|
+
}
|
|
1030
|
+
} else {
|
|
1031
|
+
entry[field.id] = rawVal;
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
if (!entry.id) {
|
|
1035
|
+
entry.id = typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `item_${Date.now()}_${idx}`;
|
|
1036
|
+
}
|
|
1037
|
+
records.push(entry);
|
|
1038
|
+
});
|
|
1039
|
+
let existingCount = 0;
|
|
1040
|
+
let newCount = 0;
|
|
1041
|
+
records.forEach((rec) => {
|
|
1042
|
+
const existing = findExistingEntry(rec, existingEntries, collection);
|
|
1043
|
+
if (existing) {
|
|
1044
|
+
existingCount++;
|
|
1045
|
+
} else {
|
|
1046
|
+
newCount++;
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
return {
|
|
1050
|
+
records,
|
|
1051
|
+
totalRows: records.length,
|
|
1052
|
+
matchedFields,
|
|
1053
|
+
unmatchedHeaders,
|
|
1054
|
+
samplePreview: records.slice(0, 5),
|
|
1055
|
+
existingRecordsCount: existingCount,
|
|
1056
|
+
newRecordsCount: newCount,
|
|
1057
|
+
errors
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
|
|
835
1061
|
// src/admin/i18n.ts
|
|
836
1062
|
var translations = {
|
|
837
1063
|
es: {
|
|
@@ -916,6 +1142,29 @@ var translations = {
|
|
|
916
1142
|
submissions: "Mensajes y Formularios",
|
|
917
1143
|
noSubmissions: "No hay env\xEDos registrados",
|
|
918
1144
|
exportCsv: "Exportar CSV",
|
|
1145
|
+
exportExcel: "Exportar Excel",
|
|
1146
|
+
importExcel: "Importar Excel",
|
|
1147
|
+
exportSuccess: "Archivo Excel exportado con \xE9xito.",
|
|
1148
|
+
importSuccess: "registros procesados exitosamente.",
|
|
1149
|
+
exportModalTitle: "Exportar a Excel",
|
|
1150
|
+
exportAllRecords: "Todos los registros",
|
|
1151
|
+
exportFilterByDate: "Filtrar por rango de fechas",
|
|
1152
|
+
exportDateFieldLabel: "Campo de fecha",
|
|
1153
|
+
exportDateRangeLabel: "Rango de fechas",
|
|
1154
|
+
exportDownloadBtn: "Descargar Excel",
|
|
1155
|
+
exportNoRecordsInRange: "No se encontraron registros en el rango seleccionado.",
|
|
1156
|
+
importModalTitle: "Importar datos desde Excel / CSV",
|
|
1157
|
+
importModalDesc: "Carga un archivo .xlsx, .xls o .csv para agregar o actualizar registros autom\xE1ticamente.",
|
|
1158
|
+
importDropzone: "Haz clic o arrastra un archivo Excel aqu\xED",
|
|
1159
|
+
importDropzoneSub: "Formatos compatibles: .xlsx, .xls, .csv. La primera fila debe contener los encabezados.",
|
|
1160
|
+
importPreviewTitle: "Vista previa de importaci\xF3n",
|
|
1161
|
+
importConfirmBtn: "Importar registros",
|
|
1162
|
+
importOverwritesWarning: "Tratamiento de registros ya existentes:",
|
|
1163
|
+
importingProgress: "Importando registros...",
|
|
1164
|
+
importExistingOmit: "Omitir existentes (no volver a crear ni duplicar)",
|
|
1165
|
+
importExistingUpdate: "Actualizar existentes con datos del archivo",
|
|
1166
|
+
importExistingDetected: "ya existentes",
|
|
1167
|
+
importNewDetected: "nuevos a crear",
|
|
919
1168
|
markRead: "Marcar como le\xEDdo",
|
|
920
1169
|
settingsTitle: "Ajustes del sitio",
|
|
921
1170
|
entries: "registros"
|
|
@@ -1002,6 +1251,29 @@ var translations = {
|
|
|
1002
1251
|
submissions: "Form Submissions",
|
|
1003
1252
|
noSubmissions: "No submissions yet",
|
|
1004
1253
|
exportCsv: "Export CSV",
|
|
1254
|
+
exportExcel: "Export Excel",
|
|
1255
|
+
importExcel: "Import Excel",
|
|
1256
|
+
exportSuccess: "Excel file exported successfully.",
|
|
1257
|
+
importSuccess: "records processed successfully.",
|
|
1258
|
+
exportModalTitle: "Export to Excel",
|
|
1259
|
+
exportAllRecords: "All records",
|
|
1260
|
+
exportFilterByDate: "Filter by date range",
|
|
1261
|
+
exportDateFieldLabel: "Date field",
|
|
1262
|
+
exportDateRangeLabel: "Date range",
|
|
1263
|
+
exportDownloadBtn: "Download Excel",
|
|
1264
|
+
exportNoRecordsInRange: "No records found in the selected date range.",
|
|
1265
|
+
importModalTitle: "Import data from Excel / CSV",
|
|
1266
|
+
importModalDesc: "Upload a .xlsx, .xls or .csv file to automatically create or update records.",
|
|
1267
|
+
importDropzone: "Click or drag an Excel file here",
|
|
1268
|
+
importDropzoneSub: "Supported formats: .xlsx, .xls, .csv. The first row must contain column headers.",
|
|
1269
|
+
importPreviewTitle: "Import Preview",
|
|
1270
|
+
importConfirmBtn: "Import records",
|
|
1271
|
+
importOverwritesWarning: "Handling of existing records:",
|
|
1272
|
+
importingProgress: "Importing records...",
|
|
1273
|
+
importExistingOmit: "Skip existing (do not recreate or duplicate)",
|
|
1274
|
+
importExistingUpdate: "Update existing with file data",
|
|
1275
|
+
importExistingDetected: "existing records",
|
|
1276
|
+
importNewDetected: "new to create",
|
|
1005
1277
|
markRead: "Mark as read",
|
|
1006
1278
|
settingsTitle: "Site Settings",
|
|
1007
1279
|
entries: "entries"
|
|
@@ -1018,12 +1290,13 @@ function getAdminTranslations(locale) {
|
|
|
1018
1290
|
// src/admin/AdminApp.tsx
|
|
1019
1291
|
var import_lucide_react3 = require("lucide-react");
|
|
1020
1292
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1021
|
-
var AdminI18nContext = import_react5.default.createContext(
|
|
1293
|
+
var AdminI18nContext = import_react5.default.createContext(
|
|
1294
|
+
getAdminTranslations("en")
|
|
1295
|
+
);
|
|
1022
1296
|
function useAdminI18n() {
|
|
1023
1297
|
return import_react5.default.useContext(AdminI18nContext);
|
|
1024
1298
|
}
|
|
1025
1299
|
var TIME_STORAGE_FORMAT = "h:mm a";
|
|
1026
|
-
var TIME_DISPLAY_FORMAT = "h:mm a";
|
|
1027
1300
|
var TIME_PICKER_THEME = {
|
|
1028
1301
|
token: {
|
|
1029
1302
|
borderRadius: 12,
|
|
@@ -1049,6 +1322,21 @@ var TIME_PICKER_THEME = {
|
|
|
1049
1322
|
}
|
|
1050
1323
|
}
|
|
1051
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
|
+
}
|
|
1052
1340
|
function AdminTimeRangePicker(props) {
|
|
1053
1341
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1054
1342
|
import_antd.TimePicker.RangePicker,
|
|
@@ -1072,13 +1360,19 @@ function toDayjsTime(value) {
|
|
|
1072
1360
|
const isPm = match12[3].toLowerCase().startsWith("p");
|
|
1073
1361
|
if (isPm && h < 12) h += 12;
|
|
1074
1362
|
if (!isPm && h === 12) h = 0;
|
|
1075
|
-
return (0,
|
|
1363
|
+
return (0, import_dayjs2.default)().hour(h).minute(m).second(0).millisecond(0);
|
|
1076
1364
|
}
|
|
1077
1365
|
const match24 = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(str);
|
|
1078
1366
|
if (match24) {
|
|
1079
|
-
return (0,
|
|
1367
|
+
return (0, import_dayjs2.default)().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
|
|
1080
1368
|
}
|
|
1081
|
-
const parsed = (0,
|
|
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
|
+
]);
|
|
1082
1376
|
return parsed.isValid() ? parsed : null;
|
|
1083
1377
|
}
|
|
1084
1378
|
function toStoredTime(value) {
|
|
@@ -1145,7 +1439,15 @@ function FilePickerButton({
|
|
|
1145
1439
|
function AdminApp(props) {
|
|
1146
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 }) });
|
|
1147
1441
|
if (props.projectId) {
|
|
1148
|
-
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
|
+
);
|
|
1149
1451
|
}
|
|
1150
1452
|
return content;
|
|
1151
1453
|
}
|
|
@@ -1154,7 +1456,9 @@ function AdminAppContent(props) {
|
|
|
1154
1456
|
const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
|
|
1155
1457
|
const t = (0, import_react5.useMemo)(() => getAdminTranslations(rawLocale), [rawLocale]);
|
|
1156
1458
|
const hasDashboard = Boolean(props.dashboard);
|
|
1157
|
-
const [section, setSection] = (0, import_react5.useState)(
|
|
1459
|
+
const [section, setSection] = (0, import_react5.useState)(
|
|
1460
|
+
hasDashboard ? "dashboard" : "pages"
|
|
1461
|
+
);
|
|
1158
1462
|
const [authChecking, setAuthChecking] = (0, import_react5.useState)(true);
|
|
1159
1463
|
const [authenticated, setAuthenticated] = (0, import_react5.useState)(false);
|
|
1160
1464
|
const hideSettings = props.hideSettings ?? ctx.config.hideSettings ?? false;
|
|
@@ -1209,13 +1513,27 @@ function AdminAppContent(props) {
|
|
|
1209
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." }),
|
|
1210
1514
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
|
|
1211
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: [
|
|
1212
|
-
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)]" }),
|
|
1213
1524
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-bold text-slate-900 tracking-tight", children: "Admin CMS" })
|
|
1214
1525
|
] }) }),
|
|
1215
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: [
|
|
1216
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: [
|
|
1217
1528
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
|
|
1218
|
-
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)]" }),
|
|
1219
1537
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: "Admin CMS" })
|
|
1220
1538
|
] }),
|
|
1221
1539
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
|
|
@@ -1352,7 +1670,9 @@ function AdminAppContent(props) {
|
|
|
1352
1670
|
});
|
|
1353
1671
|
} else {
|
|
1354
1672
|
const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
|
|
1355
|
-
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);
|
|
1356
1676
|
const otherCustom = (props.customSections || []).filter(
|
|
1357
1677
|
(cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
|
|
1358
1678
|
).map((cs) => cs.id);
|
|
@@ -1373,7 +1693,9 @@ function AdminAppContent(props) {
|
|
|
1373
1693
|
"button",
|
|
1374
1694
|
{
|
|
1375
1695
|
onClick: async () => {
|
|
1376
|
-
await fetch("/api/admin/auth?action=logout", {
|
|
1696
|
+
await fetch("/api/admin/auth?action=logout", {
|
|
1697
|
+
method: "POST"
|
|
1698
|
+
});
|
|
1377
1699
|
window.location.href = "/admin/login";
|
|
1378
1700
|
},
|
|
1379
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",
|
|
@@ -1460,16 +1782,22 @@ function PageListItem({
|
|
|
1460
1782
|
] })
|
|
1461
1783
|
}
|
|
1462
1784
|
) }),
|
|
1463
|
-
hasChildren && expanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1464
|
-
|
|
1785
|
+
hasChildren && expanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1786
|
+
"ul",
|
|
1465
1787
|
{
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
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
|
+
)
|
|
1473
1801
|
] });
|
|
1474
1802
|
}
|
|
1475
1803
|
function PagesSection() {
|
|
@@ -1504,14 +1832,20 @@ function PagesSection() {
|
|
|
1504
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." }) })
|
|
1505
1833
|
] });
|
|
1506
1834
|
}
|
|
1507
|
-
function PageEditor({
|
|
1835
|
+
function PageEditor({
|
|
1836
|
+
page,
|
|
1837
|
+
showList,
|
|
1838
|
+
onToggleList
|
|
1839
|
+
}) {
|
|
1508
1840
|
const ctx = useCmsContext();
|
|
1509
1841
|
const t = useAdminI18n();
|
|
1510
1842
|
const iframeRef = (0, import_react5.useRef)(null);
|
|
1511
1843
|
const [registered, setRegistered] = (0, import_react5.useState)([]);
|
|
1512
1844
|
const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
|
|
1513
1845
|
const [preview, setPreview] = (0, import_react5.useState)(false);
|
|
1514
|
-
const [drawerState, setDrawerState] = (0, import_react5.useState)(
|
|
1846
|
+
const [drawerState, setDrawerState] = (0, import_react5.useState)(
|
|
1847
|
+
"half"
|
|
1848
|
+
);
|
|
1515
1849
|
const src = (0, import_react5.useMemo)(
|
|
1516
1850
|
() => `${page.path}${preview ? "" : "?__cms=edit"}`,
|
|
1517
1851
|
[page.path, preview]
|
|
@@ -1530,7 +1864,11 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1530
1864
|
}
|
|
1531
1865
|
} else if (d.type === "cms:ready") {
|
|
1532
1866
|
iframeRef.current?.contentWindow?.postMessage(
|
|
1533
|
-
{
|
|
1867
|
+
{
|
|
1868
|
+
__cms: true,
|
|
1869
|
+
type: "cms:set-all-overrides",
|
|
1870
|
+
overrides: ctx.overrides
|
|
1871
|
+
},
|
|
1534
1872
|
"*"
|
|
1535
1873
|
);
|
|
1536
1874
|
}
|
|
@@ -1553,20 +1891,54 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1553
1891
|
[ctx]
|
|
1554
1892
|
);
|
|
1555
1893
|
const selectedMeta = registered.find((r) => r.id === selectedId) ?? null;
|
|
1556
|
-
const [viewMode, setViewMode] = (0, import_react5.useState)(
|
|
1894
|
+
const [viewMode, setViewMode] = (0, import_react5.useState)(
|
|
1895
|
+
"desktop"
|
|
1896
|
+
);
|
|
1557
1897
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex h-full flex-col", children: [
|
|
1558
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: [
|
|
1559
1899
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 text-sm shrink-0", children: [
|
|
1560
|
-
/* @__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
|
+
),
|
|
1561
1909
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-bold text-slate-800 text-sm md:text-base", children: page.name }),
|
|
1562
1910
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-slate-300 hidden sm:inline", children: "|" }),
|
|
1563
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 })
|
|
1564
1912
|
] }),
|
|
1565
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: [
|
|
1566
1914
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex bg-slate-100/80 p-0.5 rounded-lg mr-2 shrink-0", children: [
|
|
1567
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1568
|
-
|
|
1569
|
-
|
|
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
|
+
)
|
|
1570
1942
|
] }),
|
|
1571
1943
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1572
1944
|
"button",
|
|
@@ -1619,100 +1991,133 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1619
1991
|
] })
|
|
1620
1992
|
] }),
|
|
1621
1993
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col sm:flex-row flex-1 overflow-hidden", children: [
|
|
1622
|
-
/* @__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)(
|
|
1623
|
-
"
|
|
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",
|
|
1624
1996
|
{
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
className: "h-full w-full bg-white",
|
|
1629
|
-
allow: "autoplay; encrypted-media; fullscreen"
|
|
1630
|
-
},
|
|
1631
|
-
src
|
|
1632
|
-
) }) }),
|
|
1633
|
-
/* @__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: [
|
|
1634
|
-
/* @__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: [
|
|
1635
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "text-xs font-bold uppercase tracking-widest text-slate-500", children: selectedMeta ? "Edit Field" : "Editable Elements" }),
|
|
1636
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1637
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1 sm:hidden", children: [
|
|
1638
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1639
|
-
"button",
|
|
1640
|
-
{
|
|
1641
|
-
onClick: () => setDrawerState((prev) => prev === "full" ? "half" : prev === "half" ? "min" : "half"),
|
|
1642
|
-
className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
|
|
1643
|
-
title: "Shrink",
|
|
1644
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-4 h-4" })
|
|
1645
|
-
}
|
|
1646
|
-
),
|
|
1647
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1648
|
-
"button",
|
|
1649
|
-
{
|
|
1650
|
-
onClick: () => setDrawerState((prev) => prev === "min" ? "half" : prev === "half" ? "full" : "half"),
|
|
1651
|
-
className: "p-1 text-slate-400 hover:text-slate-700 hover:bg-slate-100 rounded",
|
|
1652
|
-
title: "Expand",
|
|
1653
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-4 h-4" })
|
|
1654
|
-
}
|
|
1655
|
-
)
|
|
1656
|
-
] }),
|
|
1657
|
-
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" })
|
|
1658
|
-
] })
|
|
1659
|
-
] }),
|
|
1660
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: drawerState === "min" ? "hidden sm:block" : "block", children: [
|
|
1661
|
-
!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." }) }),
|
|
1662
|
-
selectedMeta ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1663
|
-
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",
|
|
1664
2000
|
{
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
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",
|
|
1671
2045
|
{
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
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
|
+
);
|
|
1676
2072
|
},
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
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
|
+
] }),
|
|
1685
2102
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1686
|
-
|
|
2103
|
+
SectionAccordion,
|
|
1687
2104
|
{
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
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
|
+
}
|
|
1693
2114
|
}
|
|
1694
|
-
)
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
SectionAccordion,
|
|
1701
|
-
{
|
|
1702
|
-
registered,
|
|
1703
|
-
onSelect: (id) => {
|
|
1704
|
-
setSelectedId(id);
|
|
1705
|
-
setDrawerState((prev) => prev === "min" ? "half" : prev);
|
|
1706
|
-
iframeRef.current?.contentWindow?.postMessage(
|
|
1707
|
-
{ __cms: true, type: "cms:select", id },
|
|
1708
|
-
"*"
|
|
1709
|
-
);
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
)
|
|
1713
|
-
] })
|
|
1714
|
-
] })
|
|
1715
|
-
] })
|
|
2115
|
+
)
|
|
2116
|
+
] })
|
|
2117
|
+
] })
|
|
2118
|
+
]
|
|
2119
|
+
}
|
|
2120
|
+
)
|
|
1716
2121
|
] })
|
|
1717
2122
|
] });
|
|
1718
2123
|
}
|
|
@@ -1741,37 +2146,54 @@ function SectionAccordion({
|
|
|
1741
2146
|
sectionNames.map((sectionName) => {
|
|
1742
2147
|
const isOpen = expanded[sectionName] ?? false;
|
|
1743
2148
|
const fields = groups[sectionName];
|
|
1744
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
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
|
+
);
|
|
1771
2190
|
})
|
|
1772
2191
|
] });
|
|
1773
2192
|
}
|
|
1774
|
-
function FieldListItem({
|
|
2193
|
+
function FieldListItem({
|
|
2194
|
+
meta,
|
|
2195
|
+
onSelect
|
|
2196
|
+
}) {
|
|
1775
2197
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "p-1 list-none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1776
2198
|
"button",
|
|
1777
2199
|
{
|
|
@@ -1793,9 +2215,15 @@ function FieldListItem({ meta, onSelect }) {
|
|
|
1793
2215
|
}
|
|
1794
2216
|
) });
|
|
1795
2217
|
}
|
|
1796
|
-
function SidebarReferenceSelect({
|
|
2218
|
+
function SidebarReferenceSelect({
|
|
2219
|
+
meta,
|
|
2220
|
+
value,
|
|
2221
|
+
onChange
|
|
2222
|
+
}) {
|
|
1797
2223
|
const ctx = useCmsContext();
|
|
1798
|
-
const collection = ctx.config.collections?.find(
|
|
2224
|
+
const collection = ctx.config.collections?.find(
|
|
2225
|
+
(c) => c.id === meta.collection
|
|
2226
|
+
);
|
|
1799
2227
|
const [items, setItems] = (0, import_react5.useState)([]);
|
|
1800
2228
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
1801
2229
|
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
@@ -1821,7 +2249,9 @@ function SidebarReferenceSelect({ meta, value, onChange }) {
|
|
|
1821
2249
|
}
|
|
1822
2250
|
};
|
|
1823
2251
|
const imgField = collection?.fields.find((f) => f.type === "image");
|
|
1824
|
-
const txtField = collection?.fields.find(
|
|
2252
|
+
const txtField = collection?.fields.find(
|
|
2253
|
+
(f) => f.type === "text" || f.type === "textarea" || f.type === "richtext"
|
|
2254
|
+
);
|
|
1825
2255
|
const filtered = items.filter((it) => {
|
|
1826
2256
|
if (!search) return true;
|
|
1827
2257
|
const q = search.toLowerCase();
|
|
@@ -1849,8 +2279,21 @@ function SidebarReferenceSelect({ meta, value, onChange }) {
|
|
|
1849
2279
|
onClick: () => toggle(it.id),
|
|
1850
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"}`,
|
|
1851
2281
|
children: [
|
|
1852
|
-
!!imgSrc && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1853
|
-
|
|
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
|
+
),
|
|
1854
2297
|
isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Check, { className: "w-4 h-4 text-indigo-600 ml-auto" })
|
|
1855
2298
|
]
|
|
1856
2299
|
},
|
|
@@ -1869,7 +2312,9 @@ function FieldEditor({
|
|
|
1869
2312
|
onClose
|
|
1870
2313
|
}) {
|
|
1871
2314
|
const ctx = useCmsContext();
|
|
1872
|
-
const [expandedItems, setExpandedItems] = (0, import_react5.useState)(
|
|
2315
|
+
const [expandedItems, setExpandedItems] = (0, import_react5.useState)(
|
|
2316
|
+
{}
|
|
2317
|
+
);
|
|
1873
2318
|
const [searchQuery, setSearchQuery] = (0, import_react5.useState)("");
|
|
1874
2319
|
const [listDragIdx, setListDragIdx] = (0, import_react5.useState)(null);
|
|
1875
2320
|
const [listDragOverIdx, setListDragOverIdx] = (0, import_react5.useState)(null);
|
|
@@ -1891,7 +2336,14 @@ function FieldEditor({
|
|
|
1891
2336
|
className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-600 focus:ring-offset-0"
|
|
1892
2337
|
}
|
|
1893
2338
|
),
|
|
1894
|
-
/* @__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
|
+
)
|
|
1895
2347
|
] }),
|
|
1896
2348
|
meta.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1897
2349
|
"input",
|
|
@@ -2113,7 +2565,9 @@ function FieldEditor({
|
|
|
2113
2565
|
] }),
|
|
2114
2566
|
(Array.isArray(value) ? value : []).map((item, idx) => {
|
|
2115
2567
|
if (meta.search && searchQuery) {
|
|
2116
|
-
const title = String(
|
|
2568
|
+
const title = String(
|
|
2569
|
+
item?.title || item?.name || ""
|
|
2570
|
+
).toLowerCase();
|
|
2117
2571
|
if (!title.includes(searchQuery.toLowerCase())) return null;
|
|
2118
2572
|
}
|
|
2119
2573
|
const isExpanded = expandedItems[idx] ?? false;
|
|
@@ -2155,7 +2609,10 @@ function FieldEditor({
|
|
|
2155
2609
|
"div",
|
|
2156
2610
|
{
|
|
2157
2611
|
className: "flex items-center justify-between cursor-pointer py-1 select-none gap-2",
|
|
2158
|
-
onClick: () => setExpandedItems((prev) => ({
|
|
2612
|
+
onClick: () => setExpandedItems((prev) => ({
|
|
2613
|
+
...prev,
|
|
2614
|
+
[idx]: !isExpanded
|
|
2615
|
+
})),
|
|
2159
2616
|
children: [
|
|
2160
2617
|
isReorderable && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2161
2618
|
"div",
|
|
@@ -2216,13 +2673,18 @@ function FieldEditor({
|
|
|
2216
2673
|
schemaField.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2217
2674
|
SearchableSelect,
|
|
2218
2675
|
{
|
|
2219
|
-
value: String(
|
|
2676
|
+
value: String(
|
|
2677
|
+
item?.[schemaField.key] ?? (Array.isArray(meta.defaultValue) ? meta.defaultValue[idx]?.[schemaField.key] : "") ?? ""
|
|
2678
|
+
),
|
|
2220
2679
|
options: schemaField.options ?? [],
|
|
2221
2680
|
placeholder: "Search icon...",
|
|
2222
2681
|
iconMap: ctx.iconMap,
|
|
2223
2682
|
onChange: (val) => {
|
|
2224
2683
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2225
|
-
arr[idx] = {
|
|
2684
|
+
arr[idx] = {
|
|
2685
|
+
...arr[idx] || {},
|
|
2686
|
+
[schemaField.key]: val
|
|
2687
|
+
};
|
|
2226
2688
|
onChange(arr);
|
|
2227
2689
|
}
|
|
2228
2690
|
}
|
|
@@ -2230,10 +2692,15 @@ function FieldEditor({
|
|
|
2230
2692
|
"textarea",
|
|
2231
2693
|
{
|
|
2232
2694
|
rows: 3,
|
|
2233
|
-
value: String(
|
|
2695
|
+
value: String(
|
|
2696
|
+
item?.[schemaField.key] ?? ""
|
|
2697
|
+
),
|
|
2234
2698
|
onChange: (e) => {
|
|
2235
2699
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2236
|
-
arr[idx] = {
|
|
2700
|
+
arr[idx] = {
|
|
2701
|
+
...arr[idx] || {},
|
|
2702
|
+
[schemaField.key]: e.target.value
|
|
2703
|
+
};
|
|
2237
2704
|
onChange(arr);
|
|
2238
2705
|
},
|
|
2239
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"
|
|
@@ -2246,7 +2713,10 @@ function FieldEditor({
|
|
|
2246
2713
|
checked: !!item?.[schemaField.key],
|
|
2247
2714
|
onChange: (e) => {
|
|
2248
2715
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2249
|
-
arr[idx] = {
|
|
2716
|
+
arr[idx] = {
|
|
2717
|
+
...arr[idx] || {},
|
|
2718
|
+
[schemaField.key]: e.target.checked
|
|
2719
|
+
};
|
|
2250
2720
|
onChange(arr);
|
|
2251
2721
|
},
|
|
2252
2722
|
className: "w-4 h-4 text-indigo-600 border-slate-300 rounded focus:ring-indigo-500"
|
|
@@ -2259,10 +2729,15 @@ function FieldEditor({
|
|
|
2259
2729
|
"input",
|
|
2260
2730
|
{
|
|
2261
2731
|
type: "url",
|
|
2262
|
-
value: String(
|
|
2732
|
+
value: String(
|
|
2733
|
+
item?.[schemaField.key] ?? ""
|
|
2734
|
+
),
|
|
2263
2735
|
onChange: (e) => {
|
|
2264
2736
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2265
|
-
arr[idx] = {
|
|
2737
|
+
arr[idx] = {
|
|
2738
|
+
...arr[idx] || {},
|
|
2739
|
+
[schemaField.key]: e.target.value
|
|
2740
|
+
};
|
|
2266
2741
|
onChange(arr);
|
|
2267
2742
|
},
|
|
2268
2743
|
placeholder: "https://... or upload",
|
|
@@ -2284,7 +2759,10 @@ function FieldEditor({
|
|
|
2284
2759
|
file,
|
|
2285
2760
|
(url) => {
|
|
2286
2761
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2287
|
-
arr[idx] = {
|
|
2762
|
+
arr[idx] = {
|
|
2763
|
+
...arr[idx] || {},
|
|
2764
|
+
[schemaField.key]: url
|
|
2765
|
+
};
|
|
2288
2766
|
onChange(arr);
|
|
2289
2767
|
},
|
|
2290
2768
|
ctx.uploadImage
|
|
@@ -2295,17 +2773,25 @@ function FieldEditor({
|
|
|
2295
2773
|
)
|
|
2296
2774
|
] })
|
|
2297
2775
|
] }),
|
|
2298
|
-
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)(
|
|
2299
2781
|
"video",
|
|
2300
2782
|
{
|
|
2301
|
-
src: String(
|
|
2783
|
+
src: String(
|
|
2784
|
+
item?.[schemaField.key]
|
|
2785
|
+
),
|
|
2302
2786
|
controls: true,
|
|
2303
2787
|
className: "w-full h-auto max-h-32 object-contain rounded-md"
|
|
2304
2788
|
}
|
|
2305
2789
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2306
2790
|
"img",
|
|
2307
2791
|
{
|
|
2308
|
-
src: String(
|
|
2792
|
+
src: String(
|
|
2793
|
+
item?.[schemaField.key]
|
|
2794
|
+
),
|
|
2309
2795
|
alt: "",
|
|
2310
2796
|
className: "w-full h-auto max-h-32 object-contain rounded-md"
|
|
2311
2797
|
}
|
|
@@ -2313,10 +2799,15 @@ function FieldEditor({
|
|
|
2313
2799
|
] }) : schemaField.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2314
2800
|
"select",
|
|
2315
2801
|
{
|
|
2316
|
-
value: String(
|
|
2802
|
+
value: String(
|
|
2803
|
+
item?.[schemaField.key] ?? ""
|
|
2804
|
+
),
|
|
2317
2805
|
onChange: (e) => {
|
|
2318
2806
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2319
|
-
arr[idx] = {
|
|
2807
|
+
arr[idx] = {
|
|
2808
|
+
...arr[idx] || {},
|
|
2809
|
+
[schemaField.key]: e.target.value
|
|
2810
|
+
};
|
|
2320
2811
|
onChange(arr);
|
|
2321
2812
|
},
|
|
2322
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",
|
|
@@ -2328,7 +2819,10 @@ function FieldEditor({
|
|
|
2328
2819
|
value: item?.[schemaField.key],
|
|
2329
2820
|
onChange: (val) => {
|
|
2330
2821
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2331
|
-
arr[idx] = {
|
|
2822
|
+
arr[idx] = {
|
|
2823
|
+
...arr[idx] || {},
|
|
2824
|
+
[schemaField.key]: val
|
|
2825
|
+
};
|
|
2332
2826
|
onChange(arr);
|
|
2333
2827
|
},
|
|
2334
2828
|
isPrice: schemaField.key.toLowerCase().includes("price") || schemaField.key.toLowerCase().includes("precio"),
|
|
@@ -2338,10 +2832,15 @@ function FieldEditor({
|
|
|
2338
2832
|
"input",
|
|
2339
2833
|
{
|
|
2340
2834
|
type: "text",
|
|
2341
|
-
value: String(
|
|
2835
|
+
value: String(
|
|
2836
|
+
item?.[schemaField.key] ?? ""
|
|
2837
|
+
),
|
|
2342
2838
|
onChange: (e) => {
|
|
2343
2839
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
2344
|
-
arr[idx] = {
|
|
2840
|
+
arr[idx] = {
|
|
2841
|
+
...arr[idx] || {},
|
|
2842
|
+
[schemaField.key]: e.target.value
|
|
2843
|
+
};
|
|
2345
2844
|
onChange(arr);
|
|
2346
2845
|
},
|
|
2347
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"
|
|
@@ -2413,7 +2912,14 @@ function FieldEditor({
|
|
|
2413
2912
|
}
|
|
2414
2913
|
)
|
|
2415
2914
|
] }),
|
|
2416
|
-
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
|
+
)
|
|
2417
2923
|
] }),
|
|
2418
2924
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pt-6 mt-6 border-t border-slate-100", children: [
|
|
2419
2925
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
@@ -2453,42 +2959,44 @@ function CollectionsSection() {
|
|
|
2453
2959
|
const list = ctx.config.collections ?? [];
|
|
2454
2960
|
list.filter((c) => !c.isSeparator).forEach((c) => {
|
|
2455
2961
|
ctx.adapter.listEntries(c.id).then((entries) => {
|
|
2456
|
-
setCounts(
|
|
2962
|
+
setCounts(
|
|
2963
|
+
(prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length }
|
|
2964
|
+
);
|
|
2457
2965
|
});
|
|
2458
2966
|
});
|
|
2459
2967
|
}, [ctx.adapter, colIds, ctx.collectionChangedAt]);
|
|
2460
2968
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
|
|
2461
|
-
/* @__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: [
|
|
2462
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
|
|
2463
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "flex overflow-x-auto gap-
|
|
2969
|
+
/* @__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-2 sm:p-3 md:p-4", children: [
|
|
2970
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "hidden md:block mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
|
|
2971
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ul", { className: "flex items-center md:items-stretch overflow-x-auto gap-1.5 p-1 md:p-0 md:block md:space-x-0 md:space-y-1 md:overflow-visible", children: [
|
|
2464
2972
|
collections.map((c, idx) => {
|
|
2465
2973
|
if (c.isSeparator) {
|
|
2466
2974
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2467
2975
|
"li",
|
|
2468
2976
|
{
|
|
2469
|
-
className: "my-3 border-t border-slate-200/80 pt-2 px-1 list-none",
|
|
2470
|
-
children: c.name && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400", children: c.name })
|
|
2977
|
+
className: "self-center shrink-0 h-6 w-px bg-slate-200 mx-1 md:h-auto md:w-auto md:mx-0 md:my-3 md:border-t md:border-slate-200/80 md:pt-2 md:px-1 list-none",
|
|
2978
|
+
children: c.name && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "hidden md:block text-[10px] font-bold uppercase tracking-wider text-slate-400", children: c.name })
|
|
2471
2979
|
},
|
|
2472
2980
|
c.id || `sep-${idx}`
|
|
2473
2981
|
);
|
|
2474
2982
|
}
|
|
2475
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "shrink-0
|
|
2983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: "shrink-0 md:w-full md:min-w-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2476
2984
|
"button",
|
|
2477
2985
|
{
|
|
2478
2986
|
onClick: () => setSelected(c),
|
|
2479
|
-
className: `w-full
|
|
2987
|
+
className: `rounded-xl px-3.5 py-2 md:w-full md:px-3 md:py-2.5 text-left text-xs md:text-sm transition-all duration-200 ${selected?.id === c.id ? "bg-white border border-slate-200/90 shadow-2xs font-semibold" : "text-slate-600 hover:text-slate-900 hover:bg-slate-100/70 border border-transparent"}`,
|
|
2480
2988
|
children: [
|
|
2481
2989
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2482
2990
|
"div",
|
|
2483
2991
|
{
|
|
2484
|
-
className: selected?.id === c.id ? "text-slate-900" : "text-slate-700",
|
|
2992
|
+
className: selected?.id === c.id ? "text-slate-900 font-bold" : "text-slate-700 font-medium",
|
|
2485
2993
|
children: c.name
|
|
2486
2994
|
}
|
|
2487
2995
|
),
|
|
2488
2996
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2489
2997
|
"div",
|
|
2490
2998
|
{
|
|
2491
|
-
className: `text-xs mt-0.5 ${selected?.id === c.id ? "text-indigo-
|
|
2999
|
+
className: `text-[10px] md:text-xs mt-0.5 ${selected?.id === c.id ? "text-indigo-600 font-medium" : "text-slate-400"}`,
|
|
2492
3000
|
children: [
|
|
2493
3001
|
counts[c.id] ?? 0,
|
|
2494
3002
|
" items"
|
|
@@ -2502,7 +3010,7 @@ function CollectionsSection() {
|
|
|
2502
3010
|
collections.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 collections registered." })
|
|
2503
3011
|
] })
|
|
2504
3012
|
] }),
|
|
2505
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex-1 overflow-auto p-4 md:p-8 relative", children: [
|
|
3013
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex-1 overflow-auto p-2 sm:p-4 md:p-8 relative", children: [
|
|
2506
3014
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "absolute inset-0 bg-grid-slate-100 [mask-image:linear-gradient(0deg,white,rgba(255,255,255,0.6))] -z-10 pointer-events-none" }),
|
|
2507
3015
|
selected ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollectionEditor, { collection: selected }, selected.id) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid h-full place-items-center text-sm text-slate-500", children: "Select a collection to manage its entries." })
|
|
2508
3016
|
] })
|
|
@@ -2512,12 +3020,32 @@ function CollectionEditor({ collection }) {
|
|
|
2512
3020
|
const ctx = useCmsContext();
|
|
2513
3021
|
const t = useAdminI18n();
|
|
2514
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
|
+
);
|
|
2515
3033
|
const [entries, setEntries] = (0, import_react5.useState)([]);
|
|
2516
3034
|
const [editing, setEditing] = (0, import_react5.useState)(null);
|
|
2517
3035
|
const [originalId, setOriginalId] = (0, import_react5.useState)(null);
|
|
2518
3036
|
const [duplicateErrors, setDuplicateErrors] = (0, import_react5.useState)({});
|
|
2519
3037
|
const [isCreatingManual, setIsCreatingManual] = (0, import_react5.useState)(false);
|
|
2520
3038
|
const [isViewingDetail, setIsViewingDetail] = (0, import_react5.useState)(false);
|
|
3039
|
+
const [customViewingRecord, setCustomViewingRecord] = (0, import_react5.useState)(null);
|
|
3040
|
+
const [isCustomEditing, setIsCustomEditing] = (0, import_react5.useState)(false);
|
|
3041
|
+
const [customActiveView, setCustomActiveView] = (0, import_react5.useState)(null);
|
|
3042
|
+
const [isCustomCreating, setIsCustomCreating] = (0, import_react5.useState)(false);
|
|
3043
|
+
(0, import_react5.useEffect)(() => {
|
|
3044
|
+
setCustomViewingRecord(null);
|
|
3045
|
+
setIsCustomEditing(false);
|
|
3046
|
+
setCustomActiveView(null);
|
|
3047
|
+
setIsCustomCreating(false);
|
|
3048
|
+
}, [collection.id]);
|
|
2521
3049
|
const [saving, setSaving] = (0, import_react5.useState)(false);
|
|
2522
3050
|
const [deletingId, setDeletingId] = (0, import_react5.useState)(null);
|
|
2523
3051
|
const [loadingEntries, setLoadingEntries] = (0, import_react5.useState)(true);
|
|
@@ -2527,6 +3055,52 @@ function CollectionEditor({ collection }) {
|
|
|
2527
3055
|
const [filters, setFilters] = (0, import_react5.useState)({});
|
|
2528
3056
|
const [page, setPage] = (0, import_react5.useState)(1);
|
|
2529
3057
|
const itemsPerPage = 10;
|
|
3058
|
+
const dateFields = (0, import_react5.useMemo)(() => {
|
|
3059
|
+
const list = [];
|
|
3060
|
+
(collection.fields || []).forEach((f) => {
|
|
3061
|
+
if (f.type === "date" || f.type === "datetime" || f.id === "fecha" || f.id.toLowerCase().includes("fecha") || f.id.toLowerCase().includes("date")) {
|
|
3062
|
+
list.push({ id: f.id, label: f.label || f.id });
|
|
3063
|
+
}
|
|
3064
|
+
});
|
|
3065
|
+
const hasCreatedAt = entries.some((e) => e._createdAt);
|
|
3066
|
+
if (hasCreatedAt && !list.some((f) => f.id === "_createdAt")) {
|
|
3067
|
+
list.push({ id: "_createdAt", label: "Fecha de creaci\xF3n (_createdAt)" });
|
|
3068
|
+
}
|
|
3069
|
+
return list;
|
|
3070
|
+
}, [collection.fields, entries]);
|
|
3071
|
+
const [isExportModalOpen, setIsExportModalOpen] = (0, import_react5.useState)(false);
|
|
3072
|
+
const [exportMode, setExportMode] = (0, import_react5.useState)("all");
|
|
3073
|
+
const [exportDateField, setExportDateField] = (0, import_react5.useState)("");
|
|
3074
|
+
const [exportDateRange, setExportDateRange] = (0, import_react5.useState)(null);
|
|
3075
|
+
(0, import_react5.useEffect)(() => {
|
|
3076
|
+
if (dateFields.length > 0 && !exportDateField) {
|
|
3077
|
+
setExportDateField(dateFields[0].id);
|
|
3078
|
+
}
|
|
3079
|
+
}, [dateFields, exportDateField]);
|
|
3080
|
+
const exportTargetEntries = (0, import_react5.useMemo)(() => {
|
|
3081
|
+
if (exportMode === "all" || !exportDateField || !exportDateRange || !exportDateRange[0] || !exportDateRange[1]) {
|
|
3082
|
+
return entries;
|
|
3083
|
+
}
|
|
3084
|
+
return filterEntriesByDateRange(
|
|
3085
|
+
entries,
|
|
3086
|
+
exportDateField,
|
|
3087
|
+
exportDateRange[0].format("YYYY-MM-DD"),
|
|
3088
|
+
exportDateRange[1].format("YYYY-MM-DD")
|
|
3089
|
+
);
|
|
3090
|
+
}, [entries, exportMode, exportDateField, exportDateRange]);
|
|
3091
|
+
const [isImportModalOpen, setIsImportModalOpen] = (0, import_react5.useState)(false);
|
|
3092
|
+
const [importFile, setImportFile] = (0, import_react5.useState)(null);
|
|
3093
|
+
const [importResult, setImportResult] = (0, import_react5.useState)(
|
|
3094
|
+
null
|
|
3095
|
+
);
|
|
3096
|
+
const [isParsingImport, setIsParsingImport] = (0, import_react5.useState)(false);
|
|
3097
|
+
const [isImporting, setIsImporting] = (0, import_react5.useState)(false);
|
|
3098
|
+
const [importExistingAction, setImportExistingAction] = (0, import_react5.useState)("omit");
|
|
3099
|
+
const [importProgress, setImportProgress] = (0, import_react5.useState)({
|
|
3100
|
+
current: 0,
|
|
3101
|
+
total: 0
|
|
3102
|
+
});
|
|
3103
|
+
const fileInputRef = (0, import_react5.useRef)(null);
|
|
2530
3104
|
const load = (0, import_react5.useCallback)(() => {
|
|
2531
3105
|
setLoadingEntries(true);
|
|
2532
3106
|
ctx.adapter.listEntries(collection.id).then((res) => {
|
|
@@ -2562,7 +3136,115 @@ function CollectionEditor({ collection }) {
|
|
|
2562
3136
|
(0, import_react5.useEffect)(() => {
|
|
2563
3137
|
load();
|
|
2564
3138
|
}, [load]);
|
|
3139
|
+
const handleOpenExportModal = () => {
|
|
3140
|
+
if (dateFields.length === 0) {
|
|
3141
|
+
try {
|
|
3142
|
+
exportCollectionToExcel(collection, entries);
|
|
3143
|
+
message.success(t.exportSuccess);
|
|
3144
|
+
} catch (err) {
|
|
3145
|
+
console.error("Error exportando a Excel:", err);
|
|
3146
|
+
message.error("No se pudo exportar a Excel.");
|
|
3147
|
+
}
|
|
3148
|
+
return;
|
|
3149
|
+
}
|
|
3150
|
+
setIsExportModalOpen(true);
|
|
3151
|
+
};
|
|
3152
|
+
const handleConfirmExport = () => {
|
|
3153
|
+
try {
|
|
3154
|
+
let suffix = "";
|
|
3155
|
+
if (exportMode === "byDate" && exportDateRange?.[0] && exportDateRange?.[1]) {
|
|
3156
|
+
suffix = `${(collection.name || collection.id).toLowerCase()}_${exportDateRange[0].format("YYYYMMDD")}_al_${exportDateRange[1].format("YYYYMMDD")}`;
|
|
3157
|
+
}
|
|
3158
|
+
exportCollectionToExcel(collection, exportTargetEntries, suffix);
|
|
3159
|
+
message.success(t.exportSuccess);
|
|
3160
|
+
setIsExportModalOpen(false);
|
|
3161
|
+
} catch (err) {
|
|
3162
|
+
console.error("Error exportando a Excel:", err);
|
|
3163
|
+
message.error("No se pudo exportar a Excel.");
|
|
3164
|
+
}
|
|
3165
|
+
};
|
|
3166
|
+
const handleProcessImportFile = async (file) => {
|
|
3167
|
+
setIsParsingImport(true);
|
|
3168
|
+
setImportFile(file);
|
|
3169
|
+
try {
|
|
3170
|
+
const res = await parseExcelForCollection(file, collection, entries);
|
|
3171
|
+
setImportResult(res);
|
|
3172
|
+
if (res.errors.length > 0) {
|
|
3173
|
+
message.warning(res.errors[0]);
|
|
3174
|
+
}
|
|
3175
|
+
} catch (err) {
|
|
3176
|
+
console.error("Error parseando archivo Excel:", err);
|
|
3177
|
+
message.error(err?.message || "Error al leer el archivo Excel.");
|
|
3178
|
+
setImportResult(null);
|
|
3179
|
+
setImportFile(null);
|
|
3180
|
+
} finally {
|
|
3181
|
+
setIsParsingImport(false);
|
|
3182
|
+
}
|
|
3183
|
+
};
|
|
3184
|
+
const handleExecuteImport = async () => {
|
|
3185
|
+
if (!importResult || !importResult.records.length) return;
|
|
3186
|
+
setIsImporting(true);
|
|
3187
|
+
const total = importResult.records.length;
|
|
3188
|
+
setImportProgress({ current: 0, total });
|
|
3189
|
+
try {
|
|
3190
|
+
let createdCount = 0;
|
|
3191
|
+
let updatedCount = 0;
|
|
3192
|
+
let omittedCount = 0;
|
|
3193
|
+
for (let i = 0; i < total; i++) {
|
|
3194
|
+
const item = { ...importResult.records[i] };
|
|
3195
|
+
const existing = findExistingEntry(item, entries, collection);
|
|
3196
|
+
if (existing) {
|
|
3197
|
+
if (importExistingAction === "omit") {
|
|
3198
|
+
omittedCount++;
|
|
3199
|
+
} else {
|
|
3200
|
+
const merged = { ...existing, ...item, id: existing.id };
|
|
3201
|
+
if (existing._id) merged._id = existing._id;
|
|
3202
|
+
await ctx.adapter.putEntry(collection.id, merged);
|
|
3203
|
+
updatedCount++;
|
|
3204
|
+
}
|
|
3205
|
+
} else {
|
|
3206
|
+
await ctx.adapter.putEntry(collection.id, item);
|
|
3207
|
+
createdCount++;
|
|
3208
|
+
}
|
|
3209
|
+
setImportProgress({ current: i + 1, total });
|
|
3210
|
+
}
|
|
3211
|
+
if (createdCount > 0 && omittedCount > 0) {
|
|
3212
|
+
message.success(
|
|
3213
|
+
`Se importaron ${createdCount} registros nuevos. Se omitieron ${omittedCount} registros ya existentes.`
|
|
3214
|
+
);
|
|
3215
|
+
} else if (createdCount > 0 && updatedCount > 0) {
|
|
3216
|
+
message.success(
|
|
3217
|
+
`Se crearon ${createdCount} registros y se actualizaron ${updatedCount} existentes.`
|
|
3218
|
+
);
|
|
3219
|
+
} else if (createdCount > 0) {
|
|
3220
|
+
message.success(
|
|
3221
|
+
`Se importaron ${createdCount} registros exitosamente.`
|
|
3222
|
+
);
|
|
3223
|
+
} else if (omittedCount > 0) {
|
|
3224
|
+
message.info(
|
|
3225
|
+
`Los ${omittedCount} registros ya se encontraban creados. No se duplic\xF3 ning\xFAn dato.`
|
|
3226
|
+
);
|
|
3227
|
+
} else if (updatedCount > 0) {
|
|
3228
|
+
message.success(
|
|
3229
|
+
`Se actualizaron ${updatedCount} registros existentes.`
|
|
3230
|
+
);
|
|
3231
|
+
}
|
|
3232
|
+
load();
|
|
3233
|
+
setIsImportModalOpen(false);
|
|
3234
|
+
setImportResult(null);
|
|
3235
|
+
setImportFile(null);
|
|
3236
|
+
} catch (err) {
|
|
3237
|
+
console.error("Error importando registros:", err);
|
|
3238
|
+
message.error("Ocurri\xF3 un error al guardar los registros importados.");
|
|
3239
|
+
} finally {
|
|
3240
|
+
setIsImporting(false);
|
|
3241
|
+
}
|
|
3242
|
+
};
|
|
2565
3243
|
const startNew = () => {
|
|
3244
|
+
if (collection.customCreateView) {
|
|
3245
|
+
setIsCustomCreating(true);
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
2566
3248
|
setIsCreatingManual(true);
|
|
2567
3249
|
setOriginalId(null);
|
|
2568
3250
|
setDuplicateErrors({});
|
|
@@ -2575,17 +3257,6 @@ function CollectionEditor({ collection }) {
|
|
|
2575
3257
|
if (f.endField) base[f.endField] = "";
|
|
2576
3258
|
} else if (f.defaultValue !== void 0) {
|
|
2577
3259
|
base[f.id] = f.defaultValue;
|
|
2578
|
-
} else if (f.type === "branch-settings") {
|
|
2579
|
-
base[f.id] = {
|
|
2580
|
-
allBranches: true,
|
|
2581
|
-
branches: [],
|
|
2582
|
-
useBranchPricing: false,
|
|
2583
|
-
priceBranches: [],
|
|
2584
|
-
prices: {},
|
|
2585
|
-
useBranchDiscounts: false,
|
|
2586
|
-
discountBranches: [],
|
|
2587
|
-
discounts: {}
|
|
2588
|
-
};
|
|
2589
3260
|
} else if (f.multiple) {
|
|
2590
3261
|
base[f.id] = [];
|
|
2591
3262
|
} else {
|
|
@@ -2676,7 +3347,9 @@ function CollectionEditor({ collection }) {
|
|
|
2676
3347
|
}
|
|
2677
3348
|
}
|
|
2678
3349
|
await ctx.adapter.putEntry(collection.id, finalEditing);
|
|
2679
|
-
message.success(
|
|
3350
|
+
message.success(
|
|
3351
|
+
originalId ? "Guardado correctamente" : "Creado correctamente"
|
|
3352
|
+
);
|
|
2680
3353
|
ctx.notifyCollectionChanged();
|
|
2681
3354
|
setEntries((prev) => {
|
|
2682
3355
|
const next = [...prev];
|
|
@@ -2704,7 +3377,9 @@ function CollectionEditor({ collection }) {
|
|
|
2704
3377
|
try {
|
|
2705
3378
|
await ctx.adapter.deleteEntry(collection.id, id);
|
|
2706
3379
|
setEntries(
|
|
2707
|
-
(prev) => prev.filter(
|
|
3380
|
+
(prev) => prev.filter(
|
|
3381
|
+
(e) => String(e.id || "").trim().toLowerCase() !== String(id).trim().toLowerCase()
|
|
3382
|
+
)
|
|
2708
3383
|
);
|
|
2709
3384
|
ctx.notifyCollectionChanged();
|
|
2710
3385
|
load();
|
|
@@ -2747,25 +3422,86 @@ function CollectionEditor({ collection }) {
|
|
|
2747
3422
|
setDraggedIdx(null);
|
|
2748
3423
|
setDragOverIdx(null);
|
|
2749
3424
|
};
|
|
2750
|
-
const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter(
|
|
2751
|
-
|
|
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);
|
|
3431
|
+
if (isCustomCreating && collection.customCreateView) {
|
|
3432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full", children: collection.customCreateView({
|
|
3433
|
+
onBack: () => setIsCustomCreating(false),
|
|
3434
|
+
reload: () => {
|
|
3435
|
+
load();
|
|
3436
|
+
}
|
|
3437
|
+
}) });
|
|
3438
|
+
}
|
|
3439
|
+
if (customActiveView) {
|
|
3440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full", children: customActiveView({
|
|
3441
|
+
onBack: () => setCustomActiveView(null),
|
|
3442
|
+
reload: () => {
|
|
3443
|
+
load();
|
|
3444
|
+
}
|
|
3445
|
+
}) });
|
|
3446
|
+
}
|
|
3447
|
+
if (customViewingRecord && (collection.customDetailView || collection.renderCustomDetail || collection.customEditView)) {
|
|
3448
|
+
const renderFn = isCustomEditing && collection.customEditView ? collection.customEditView : collection.customDetailView || collection.renderCustomDetail;
|
|
3449
|
+
if (renderFn) {
|
|
3450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-full", children: renderFn({
|
|
3451
|
+
record: customViewingRecord,
|
|
3452
|
+
isEditing: isCustomEditing,
|
|
3453
|
+
onBack: () => {
|
|
3454
|
+
setCustomViewingRecord(null);
|
|
3455
|
+
setIsCustomEditing(false);
|
|
3456
|
+
},
|
|
3457
|
+
reload: () => {
|
|
3458
|
+
load();
|
|
3459
|
+
}
|
|
3460
|
+
}) });
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
2752
3463
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mx-auto max-w-5xl", children: [
|
|
2753
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex flex-col sm:flex-row sm:items-center justify-between gap-4", children: [
|
|
2754
3465
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
2755
3466
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
|
|
2756
3467
|
collection.description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
|
|
2757
3468
|
] }),
|
|
2758
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
3469
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3470
|
+
!collection.disableExport && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3471
|
+
import_antd.Button,
|
|
3472
|
+
{
|
|
3473
|
+
size: "large",
|
|
3474
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "h-4 w-4 text-emerald-600" }),
|
|
3475
|
+
onClick: handleOpenExportModal,
|
|
3476
|
+
disabled: loadingEntries || entries.length === 0,
|
|
3477
|
+
className: "rounded-xl font-medium border-slate-200 hover:border-emerald-500 hover:text-emerald-600 shadow-sm",
|
|
3478
|
+
title: "Descargar registros en formato Excel (soporta filtro por fechas)",
|
|
3479
|
+
children: t.exportExcel
|
|
3480
|
+
}
|
|
3481
|
+
),
|
|
3482
|
+
!collection.disableImport && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3483
|
+
import_antd.Button,
|
|
3484
|
+
{
|
|
3485
|
+
size: "large",
|
|
3486
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileUp, { className: "h-4 w-4 text-sky-600" }),
|
|
3487
|
+
onClick: () => setIsImportModalOpen(true),
|
|
3488
|
+
className: "rounded-xl font-medium border-slate-200 hover:border-sky-500 hover:text-sky-600 shadow-sm",
|
|
3489
|
+
title: "Cargar registros desde un archivo Excel o CSV",
|
|
3490
|
+
children: t.importExcel
|
|
3491
|
+
}
|
|
3492
|
+
),
|
|
3493
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3494
|
+
import_antd.Button,
|
|
3495
|
+
{
|
|
3496
|
+
type: "primary",
|
|
3497
|
+
size: "large",
|
|
3498
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
|
|
3499
|
+
onClick: startNew,
|
|
3500
|
+
className: "rounded-xl font-bold shadow-sm",
|
|
3501
|
+
children: t.newEntry
|
|
3502
|
+
}
|
|
3503
|
+
)
|
|
3504
|
+
] })
|
|
2769
3505
|
] }),
|
|
2770
3506
|
!editing && (collection.searchBy?.length || collection.filterBy?.length) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-6 flex flex-wrap gap-4 items-center p-4 bg-white rounded-2xl border border-slate-200 shadow-sm animate-in fade-in slide-in-from-top-2", children: [
|
|
2771
3507
|
collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "relative flex-1 min-w-[220px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -2774,7 +3510,9 @@ function CollectionEditor({ collection }) {
|
|
|
2774
3510
|
size: "large",
|
|
2775
3511
|
prefix: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "h-4 w-4 text-slate-400" }),
|
|
2776
3512
|
placeholder: `Buscar por ${collection.searchBy.map((s) => {
|
|
2777
|
-
const f = collection.fields.find(
|
|
3513
|
+
const f = collection.fields.find(
|
|
3514
|
+
(field) => field.id === s
|
|
3515
|
+
);
|
|
2778
3516
|
return f?.label ? f.label.toLowerCase() : s;
|
|
2779
3517
|
}).join(", ")}...`,
|
|
2780
3518
|
value: search,
|
|
@@ -2790,7 +3528,15 @@ function CollectionEditor({ collection }) {
|
|
|
2790
3528
|
const fieldDef = collection.fields.find((cf) => cf.id === f);
|
|
2791
3529
|
if (!fieldDef) return null;
|
|
2792
3530
|
if (fieldDef.type === "date") {
|
|
2793
|
-
const dateVal = filters[f] ? (0,
|
|
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;
|
|
2794
3540
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[180px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2795
3541
|
import_antd.DatePicker,
|
|
2796
3542
|
{
|
|
@@ -2811,7 +3557,9 @@ function CollectionEditor({ collection }) {
|
|
|
2811
3557
|
const predefinedOptions = (fieldDef.options || []).map(
|
|
2812
3558
|
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
2813
3559
|
);
|
|
2814
|
-
const entryVals = Array.from(
|
|
3560
|
+
const entryVals = Array.from(
|
|
3561
|
+
new Set(entries.map((e) => String(e[f] || "")))
|
|
3562
|
+
).filter(Boolean);
|
|
2815
3563
|
const combinedOptions = [...predefinedOptions];
|
|
2816
3564
|
for (const ev of entryVals) {
|
|
2817
3565
|
if (!combinedOptions.some((o) => o.value === ev)) {
|
|
@@ -2844,7 +3592,13 @@ function CollectionEditor({ collection }) {
|
|
|
2844
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" }),
|
|
2845
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}`
|
|
2846
3594
|
] }),
|
|
2847
|
-
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
|
+
),
|
|
2848
3602
|
!isViewingDetail && !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2849
3603
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
|
|
2850
3604
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -2899,14 +3653,15 @@ function CollectionEditor({ collection }) {
|
|
|
2899
3653
|
if (f.dependsOn) {
|
|
2900
3654
|
const targetVal = editing[f.dependsOn.field];
|
|
2901
3655
|
if (Array.isArray(f.dependsOn.value)) {
|
|
2902
|
-
if (!f.dependsOn.value.includes(targetVal))
|
|
3656
|
+
if (!f.dependsOn.value.includes(targetVal))
|
|
3657
|
+
return false;
|
|
2903
3658
|
} else if (targetVal !== f.dependsOn.value) {
|
|
2904
3659
|
return false;
|
|
2905
3660
|
}
|
|
2906
3661
|
}
|
|
2907
3662
|
return true;
|
|
2908
3663
|
}).map((f) => {
|
|
2909
|
-
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";
|
|
2910
3665
|
const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
|
|
2911
3666
|
if (isViewingDetail) {
|
|
2912
3667
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
|
|
@@ -2926,14 +3681,16 @@ function CollectionEditor({ collection }) {
|
|
|
2926
3681
|
alt: f.label,
|
|
2927
3682
|
className: "h-28 w-auto max-w-full object-contain"
|
|
2928
3683
|
}
|
|
2929
|
-
) }) : /* @__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(
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
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)(
|
|
2937
3694
|
"a",
|
|
2938
3695
|
{
|
|
2939
3696
|
href: String(editing[f.id]),
|
|
@@ -2945,14 +3702,21 @@ function CollectionEditor({ collection }) {
|
|
|
2945
3702
|
String(editing[f.id]).includes("maps") ? "Ver en Google Maps" : String(editing[f.id])
|
|
2946
3703
|
]
|
|
2947
3704
|
}
|
|
2948
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 py-1 block", children: "\u2014" }) : f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 whitespace-pre-line leading-relaxed", children: String(editing[f.id] || "\u2014") }) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? /* @__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: formatTo12Hour(editing[f.id]) || String(editing[f.id] ?? "\u2014") }) : /* @__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] ?? "\u2014") })
|
|
3705
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 py-1 block", children: "\u2014" }) : f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl bg-slate-50 border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 whitespace-pre-line leading-relaxed", children: String(editing[f.id] || "\u2014") }) : f.type === "time" || f.id.toLowerCase().includes("hora") || f.id === "inicioServicio" || f.id === "finServicio" ? /* @__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: formatTo12Hour(editing[f.id]) || String(editing[f.id] ?? "\u2014") }) : f.renderCell ? /* @__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: f.renderCell(editing[f.id], editing) }) : /* @__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] ?? "\u2014") })
|
|
2949
3706
|
] }, f.id);
|
|
2950
3707
|
}
|
|
2951
3708
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
|
|
2952
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: [
|
|
2953
3710
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
2954
3711
|
f.label,
|
|
2955
|
-
(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
|
+
)
|
|
2956
3720
|
] }),
|
|
2957
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 })
|
|
2958
3722
|
] }),
|
|
@@ -2963,16 +3727,7 @@ function CollectionEditor({ collection }) {
|
|
|
2963
3727
|
isCreatingEntry,
|
|
2964
3728
|
isViewingDetail: false,
|
|
2965
3729
|
readOnly: false
|
|
2966
|
-
}) : f.type === "
|
|
2967
|
-
BranchSettingsEditor,
|
|
2968
|
-
{
|
|
2969
|
-
collectionId: f.collection || "",
|
|
2970
|
-
value: editing[f.id],
|
|
2971
|
-
globalPrice: Number(editing.price) || 0,
|
|
2972
|
-
globalDiscount: Number(editing.discountPercent) || 0,
|
|
2973
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2974
|
-
}
|
|
2975
|
-
) : 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: [
|
|
2976
3731
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2977
3732
|
import_antd.Switch,
|
|
2978
3733
|
{
|
|
@@ -2990,14 +3745,25 @@ function CollectionEditor({ collection }) {
|
|
|
2990
3745
|
disabled: f.readOnly,
|
|
2991
3746
|
onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
|
|
2992
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,
|
|
2993
3756
|
placeholder: "0"
|
|
2994
3757
|
}
|
|
2995
3758
|
) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2996
3759
|
import_antd.DatePicker,
|
|
2997
3760
|
{
|
|
2998
3761
|
size: "large",
|
|
2999
|
-
value: editing[f.id] ? (0,
|
|
3000
|
-
onChange: (date, dateString) => setEditing({
|
|
3762
|
+
value: editing[f.id] ? (0, import_dayjs2.default)(String(editing[f.id])).isValid() ? (0, import_dayjs2.default)(String(editing[f.id])) : null : null,
|
|
3763
|
+
onChange: (date, dateString) => setEditing({
|
|
3764
|
+
...editing,
|
|
3765
|
+
[f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "")
|
|
3766
|
+
}),
|
|
3001
3767
|
format: "YYYY/MM/DD",
|
|
3002
3768
|
placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
|
|
3003
3769
|
className: "w-full rounded-xl"
|
|
@@ -3007,21 +3773,36 @@ function CollectionEditor({ collection }) {
|
|
|
3007
3773
|
AdminTimeRangePicker,
|
|
3008
3774
|
{
|
|
3009
3775
|
value: [
|
|
3010
|
-
toDayjsTime(
|
|
3011
|
-
|
|
3776
|
+
toDayjsTime(
|
|
3777
|
+
f.startField ? editing[f.startField] : ""
|
|
3778
|
+
),
|
|
3779
|
+
toDayjsTime(
|
|
3780
|
+
f.endField ? editing[f.endField] : ""
|
|
3781
|
+
)
|
|
3012
3782
|
],
|
|
3013
3783
|
onChange: (times) => setEditing(
|
|
3014
3784
|
(current) => current ? {
|
|
3015
3785
|
...current,
|
|
3016
|
-
...f.startField ? {
|
|
3017
|
-
|
|
3786
|
+
...f.startField ? {
|
|
3787
|
+
[f.startField]: toStoredTime(
|
|
3788
|
+
times?.[0]
|
|
3789
|
+
)
|
|
3790
|
+
} : {},
|
|
3791
|
+
...f.endField ? {
|
|
3792
|
+
[f.endField]: toStoredTime(
|
|
3793
|
+
times?.[1]
|
|
3794
|
+
)
|
|
3795
|
+
} : {}
|
|
3018
3796
|
} : current
|
|
3019
3797
|
),
|
|
3020
3798
|
allowEmpty: [true, true],
|
|
3021
3799
|
className: "w-full",
|
|
3022
3800
|
format: "h:mm a",
|
|
3023
3801
|
order: false,
|
|
3024
|
-
placeholder: [
|
|
3802
|
+
placeholder: [
|
|
3803
|
+
"Hora de inicio",
|
|
3804
|
+
"Hora de cierre"
|
|
3805
|
+
],
|
|
3025
3806
|
use12Hours: true
|
|
3026
3807
|
}
|
|
3027
3808
|
),
|
|
@@ -3045,7 +3826,10 @@ function CollectionEditor({ collection }) {
|
|
|
3045
3826
|
{
|
|
3046
3827
|
size: "large",
|
|
3047
3828
|
value: String(editing[f.id] ?? ""),
|
|
3048
|
-
onChange: (e) => setEditing({
|
|
3829
|
+
onChange: (e) => setEditing({
|
|
3830
|
+
...editing,
|
|
3831
|
+
[f.id]: e.target.value
|
|
3832
|
+
}),
|
|
3049
3833
|
rows: 4,
|
|
3050
3834
|
placeholder: `Escribe ${f.label.toLowerCase()}...`,
|
|
3051
3835
|
className: "w-full rounded-xl font-sans"
|
|
@@ -3065,7 +3849,10 @@ function CollectionEditor({ collection }) {
|
|
|
3065
3849
|
{
|
|
3066
3850
|
size: "large",
|
|
3067
3851
|
value: String(editing[f.id] ?? ""),
|
|
3068
|
-
onChange: (e) => setEditing({
|
|
3852
|
+
onChange: (e) => setEditing({
|
|
3853
|
+
...editing,
|
|
3854
|
+
[f.id]: e.target.value
|
|
3855
|
+
}),
|
|
3069
3856
|
className: "flex-1 rounded-xl"
|
|
3070
3857
|
}
|
|
3071
3858
|
),
|
|
@@ -3075,7 +3862,9 @@ function CollectionEditor({ collection }) {
|
|
|
3075
3862
|
size: "large",
|
|
3076
3863
|
onClick: () => {
|
|
3077
3864
|
const sourceField = f.source || "title";
|
|
3078
|
-
let val = String(
|
|
3865
|
+
let val = String(
|
|
3866
|
+
editing[sourceField] || editing.id || ""
|
|
3867
|
+
);
|
|
3079
3868
|
val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
3080
3869
|
setEditing({ ...editing, [f.id]: val });
|
|
3081
3870
|
},
|
|
@@ -3097,7 +3886,12 @@ function CollectionEditor({ collection }) {
|
|
|
3097
3886
|
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
3098
3887
|
onSelectRecord: (rec) => {
|
|
3099
3888
|
if (f.onSelectRecord) {
|
|
3100
|
-
setEditing(
|
|
3889
|
+
setEditing(
|
|
3890
|
+
(prev) => prev ? {
|
|
3891
|
+
...prev,
|
|
3892
|
+
...f.onSelectRecord(rec, prev)
|
|
3893
|
+
} : prev
|
|
3894
|
+
);
|
|
3101
3895
|
}
|
|
3102
3896
|
}
|
|
3103
3897
|
}
|
|
@@ -3111,7 +3905,10 @@ function CollectionEditor({ collection }) {
|
|
|
3111
3905
|
placeholder: f.label,
|
|
3112
3906
|
allowClear: true,
|
|
3113
3907
|
onChange: (val) => {
|
|
3114
|
-
const next = {
|
|
3908
|
+
const next = {
|
|
3909
|
+
...editing,
|
|
3910
|
+
[f.id]: val || ""
|
|
3911
|
+
};
|
|
3115
3912
|
collection.fields.forEach((otherField) => {
|
|
3116
3913
|
if (otherField.dependsOnField === f.id && otherField.optionsMap) {
|
|
3117
3914
|
const newOpts = otherField.optionsMap[String(val || "")];
|
|
@@ -3131,25 +3928,56 @@ function CollectionEditor({ collection }) {
|
|
|
3131
3928
|
}
|
|
3132
3929
|
);
|
|
3133
3930
|
})() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3134
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map(
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
"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",
|
|
3140
3936
|
{
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
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
|
+
) }),
|
|
3153
3981
|
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
3154
3982
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3155
3983
|
"input",
|
|
@@ -3159,8 +3987,14 @@ function CollectionEditor({ collection }) {
|
|
|
3159
3987
|
onKeyDown: (e) => {
|
|
3160
3988
|
if (e.key === "Enter" && e.currentTarget.value) {
|
|
3161
3989
|
e.preventDefault();
|
|
3162
|
-
const arr = [
|
|
3163
|
-
|
|
3990
|
+
const arr = [
|
|
3991
|
+
...editing[f.id] || [],
|
|
3992
|
+
e.currentTarget.value
|
|
3993
|
+
];
|
|
3994
|
+
setEditing({
|
|
3995
|
+
...editing,
|
|
3996
|
+
[f.id]: arr
|
|
3997
|
+
});
|
|
3164
3998
|
e.currentTarget.value = "";
|
|
3165
3999
|
}
|
|
3166
4000
|
},
|
|
@@ -3184,7 +4018,10 @@ function CollectionEditor({ collection }) {
|
|
|
3184
4018
|
if (f.max && current.length >= f.max) {
|
|
3185
4019
|
return prev;
|
|
3186
4020
|
}
|
|
3187
|
-
return {
|
|
4021
|
+
return {
|
|
4022
|
+
...prev,
|
|
4023
|
+
[f.id]: [...current, url]
|
|
4024
|
+
};
|
|
3188
4025
|
});
|
|
3189
4026
|
},
|
|
3190
4027
|
ctx.uploadImage
|
|
@@ -3202,7 +4039,10 @@ function CollectionEditor({ collection }) {
|
|
|
3202
4039
|
{
|
|
3203
4040
|
type: "url",
|
|
3204
4041
|
value: String(editing[f.id] ?? ""),
|
|
3205
|
-
onChange: (e) => setEditing({
|
|
4042
|
+
onChange: (e) => setEditing({
|
|
4043
|
+
...editing,
|
|
4044
|
+
[f.id]: e.target.value
|
|
4045
|
+
}),
|
|
3206
4046
|
placeholder: "https://...",
|
|
3207
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"
|
|
3208
4048
|
}
|
|
@@ -3228,7 +4068,9 @@ function CollectionEditor({ collection }) {
|
|
|
3228
4068
|
}
|
|
3229
4069
|
)
|
|
3230
4070
|
] }),
|
|
3231
|
-
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)(
|
|
3232
4074
|
"video",
|
|
3233
4075
|
{
|
|
3234
4076
|
src: String(editing[f.id]),
|
|
@@ -3261,8 +4103,13 @@ function CollectionEditor({ collection }) {
|
|
|
3261
4103
|
"input",
|
|
3262
4104
|
{
|
|
3263
4105
|
type: "color",
|
|
3264
|
-
value: String(editing[f.id] ?? "#000000").startsWith(
|
|
3265
|
-
|
|
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
|
+
}),
|
|
3266
4113
|
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
3267
4114
|
}
|
|
3268
4115
|
),
|
|
@@ -3271,7 +4118,10 @@ function CollectionEditor({ collection }) {
|
|
|
3271
4118
|
{
|
|
3272
4119
|
type: "text",
|
|
3273
4120
|
value: String(editing[f.id] ?? ""),
|
|
3274
|
-
onChange: (e) => setEditing({
|
|
4121
|
+
onChange: (e) => setEditing({
|
|
4122
|
+
...editing,
|
|
4123
|
+
[f.id]: e.target.value
|
|
4124
|
+
}),
|
|
3275
4125
|
placeholder: "#000000",
|
|
3276
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"
|
|
3277
4127
|
}
|
|
@@ -3280,62 +4130,75 @@ function CollectionEditor({ collection }) {
|
|
|
3280
4130
|
"div",
|
|
3281
4131
|
{
|
|
3282
4132
|
className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
3283
|
-
style: {
|
|
4133
|
+
style: {
|
|
4134
|
+
backgroundColor: String(
|
|
4135
|
+
editing[f.id] ?? "#000000"
|
|
4136
|
+
)
|
|
4137
|
+
}
|
|
3284
4138
|
}
|
|
3285
4139
|
)
|
|
3286
4140
|
] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3287
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) => {
|
|
3288
4142
|
const colorVal = String(item ?? "").trim();
|
|
3289
4143
|
const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
|
|
3290
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
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
|
+
);
|
|
3339
4202
|
}),
|
|
3340
4203
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3341
4204
|
"button",
|
|
@@ -3358,50 +4221,69 @@ function CollectionEditor({ collection }) {
|
|
|
3358
4221
|
const displayArr = currentArr.length > 0 ? currentArr : [""];
|
|
3359
4222
|
const singularLabel = f.label.endsWith("es") ? f.label.slice(0, -2) : f.label.endsWith("s") ? f.label.slice(0, -1) : f.label;
|
|
3360
4223
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-2.5", children: [
|
|
3361
|
-
displayArr.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
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
|
+
)),
|
|
3394
4272
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3395
4273
|
"button",
|
|
3396
4274
|
{
|
|
3397
4275
|
type: "button",
|
|
3398
4276
|
onClick: () => {
|
|
3399
|
-
setEditing({
|
|
4277
|
+
setEditing({
|
|
4278
|
+
...editing,
|
|
4279
|
+
[f.id]: [...displayArr, ""]
|
|
4280
|
+
});
|
|
3400
4281
|
},
|
|
3401
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",
|
|
3402
4283
|
children: [
|
|
3403
4284
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
3404
|
-
" Agregar
|
|
4285
|
+
" Agregar",
|
|
4286
|
+
" ",
|
|
3405
4287
|
singularLabel.toLowerCase()
|
|
3406
4288
|
]
|
|
3407
4289
|
}
|
|
@@ -3415,7 +4297,10 @@ function CollectionEditor({ collection }) {
|
|
|
3415
4297
|
value: String(editing[f.id] ?? ""),
|
|
3416
4298
|
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
3417
4299
|
disabled: f.readOnly,
|
|
3418
|
-
onChange: (e) => setEditing({
|
|
4300
|
+
onChange: (e) => setEditing({
|
|
4301
|
+
...editing,
|
|
4302
|
+
[f.id]: e.target.value
|
|
4303
|
+
}),
|
|
3419
4304
|
placeholder: f.label,
|
|
3420
4305
|
className: "flex-1 rounded-xl"
|
|
3421
4306
|
}
|
|
@@ -3467,8 +4352,13 @@ function CollectionEditor({ collection }) {
|
|
|
3467
4352
|
if (dup) {
|
|
3468
4353
|
const dupName = dup.nombre ? ` (\xAB${dup.nombre} ${dup.apellido || ""}\xBB)` : "";
|
|
3469
4354
|
const errMsg = `Esta identificaci\xF3n ya est\xE1 registrada${dupName}. No puedes usar una c\xE9dula o NIT repetido.`;
|
|
3470
|
-
setDuplicateErrors((prev) => ({
|
|
3471
|
-
|
|
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
|
+
);
|
|
3472
4362
|
} else {
|
|
3473
4363
|
setDuplicateErrors((prev) => {
|
|
3474
4364
|
const next = { ...prev };
|
|
@@ -3536,38 +4426,385 @@ function CollectionEditor({ collection }) {
|
|
|
3536
4426
|
] }) })
|
|
3537
4427
|
}
|
|
3538
4428
|
),
|
|
3539
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
(
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
4429
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4430
|
+
import_antd.Modal,
|
|
4431
|
+
{
|
|
4432
|
+
open: isExportModalOpen,
|
|
4433
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 text-slate-900 font-bold text-lg", children: [
|
|
4434
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "h-5 w-5 text-emerald-600" }),
|
|
4435
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
4436
|
+
t.exportModalTitle,
|
|
4437
|
+
" - ",
|
|
4438
|
+
collection.name
|
|
4439
|
+
] })
|
|
4440
|
+
] }),
|
|
4441
|
+
onCancel: () => setIsExportModalOpen(false),
|
|
4442
|
+
footer: null,
|
|
4443
|
+
centered: true,
|
|
4444
|
+
width: "min(560px, calc(100vw - 32px))",
|
|
4445
|
+
mask: { blur: true },
|
|
4446
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "py-2 space-y-4", children: [
|
|
4447
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Descarga los registros en formato Excel estructurado (.xlsx)." }),
|
|
4448
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4449
|
+
import_antd.Segmented,
|
|
4450
|
+
{
|
|
4451
|
+
size: "large",
|
|
4452
|
+
block: true,
|
|
4453
|
+
value: exportMode,
|
|
4454
|
+
onChange: (val) => setExportMode(val),
|
|
4455
|
+
options: [
|
|
4456
|
+
{
|
|
4457
|
+
label: `${t.exportAllRecords} (${entries.length})`,
|
|
4458
|
+
value: "all"
|
|
4459
|
+
},
|
|
4460
|
+
{ label: t.exportFilterByDate, value: "byDate" }
|
|
4461
|
+
]
|
|
4462
|
+
}
|
|
4463
|
+
),
|
|
4464
|
+
exportMode === "byDate" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-4 bg-slate-50 border border-slate-200 rounded-xl space-y-3 animate-in fade-in", children: [
|
|
4465
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1", children: [
|
|
4466
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "text-xs font-semibold text-slate-600", children: [
|
|
4467
|
+
t.exportDateRangeLabel,
|
|
4468
|
+
":"
|
|
4469
|
+
] }),
|
|
4470
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4471
|
+
import_antd.DatePicker.RangePicker,
|
|
4472
|
+
{
|
|
4473
|
+
size: "large",
|
|
4474
|
+
className: "w-full rounded-xl",
|
|
4475
|
+
value: exportDateRange,
|
|
4476
|
+
onChange: (dates) => setExportDateRange(dates),
|
|
4477
|
+
presets: [
|
|
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
|
+
}
|
|
4498
|
+
]
|
|
4499
|
+
}
|
|
4500
|
+
)
|
|
4501
|
+
] }),
|
|
4502
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pt-1 flex items-center justify-between text-xs", children: [
|
|
4503
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-slate-500 font-medium", children: "Registros coincidentes:" }),
|
|
4504
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4505
|
+
"span",
|
|
4506
|
+
{
|
|
4507
|
+
className: `font-bold ${exportTargetEntries.length > 0 ? "text-emerald-600" : "text-amber-600"}`,
|
|
4508
|
+
children: [
|
|
4509
|
+
exportTargetEntries.length,
|
|
4510
|
+
" de ",
|
|
4511
|
+
entries.length,
|
|
4512
|
+
" registros"
|
|
4513
|
+
]
|
|
4514
|
+
}
|
|
4515
|
+
)
|
|
4516
|
+
] })
|
|
4517
|
+
] }),
|
|
4518
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
4519
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { size: "large", onClick: () => setIsExportModalOpen(false), children: t.cancel }),
|
|
4520
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4521
|
+
import_antd.Button,
|
|
4522
|
+
{
|
|
4523
|
+
type: "primary",
|
|
4524
|
+
size: "large",
|
|
4525
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileDown, { className: "h-4 w-4" }),
|
|
4526
|
+
onClick: handleConfirmExport,
|
|
4527
|
+
disabled: exportTargetEntries.length === 0,
|
|
4528
|
+
className: "rounded-xl font-bold bg-emerald-600 hover:bg-emerald-500",
|
|
4529
|
+
children: [
|
|
4530
|
+
t.exportDownloadBtn,
|
|
4531
|
+
" (",
|
|
4532
|
+
exportTargetEntries.length,
|
|
4533
|
+
")"
|
|
4534
|
+
]
|
|
4535
|
+
}
|
|
4536
|
+
)
|
|
4537
|
+
] })
|
|
4538
|
+
] })
|
|
4539
|
+
}
|
|
4540
|
+
),
|
|
4541
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4542
|
+
import_antd.Modal,
|
|
4543
|
+
{
|
|
4544
|
+
open: isImportModalOpen,
|
|
4545
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 text-slate-900 font-bold text-lg", children: [
|
|
4546
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileSpreadsheet, { className: "h-5 w-5 text-emerald-600" }),
|
|
4547
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
4548
|
+
t.importModalTitle,
|
|
4549
|
+
" - ",
|
|
4550
|
+
collection.name
|
|
4551
|
+
] })
|
|
4552
|
+
] }),
|
|
4553
|
+
onCancel: () => {
|
|
4554
|
+
if (!isImporting) {
|
|
4555
|
+
setIsImportModalOpen(false);
|
|
4556
|
+
setImportResult(null);
|
|
4557
|
+
setImportFile(null);
|
|
4558
|
+
}
|
|
4559
|
+
},
|
|
4560
|
+
footer: null,
|
|
4561
|
+
centered: true,
|
|
4562
|
+
width: "min(800px, calc(100vw - 32px))",
|
|
4563
|
+
mask: { blur: true },
|
|
4564
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "py-2 space-y-4", children: [
|
|
4565
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: t.importModalDesc }),
|
|
4566
|
+
!importResult ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4567
|
+
"div",
|
|
4568
|
+
{
|
|
4569
|
+
onDragOver: (e) => {
|
|
4570
|
+
e.preventDefault();
|
|
4571
|
+
e.stopPropagation();
|
|
4572
|
+
},
|
|
4573
|
+
onDrop: (e) => {
|
|
4574
|
+
e.preventDefault();
|
|
4575
|
+
e.stopPropagation();
|
|
4576
|
+
const file = e.dataTransfer.files?.[0];
|
|
4577
|
+
if (file) handleProcessImportFile(file);
|
|
4578
|
+
},
|
|
4579
|
+
onClick: () => fileInputRef.current?.click(),
|
|
4580
|
+
className: "border-2 border-dashed border-slate-300 hover:border-emerald-500 rounded-2xl p-8 text-center cursor-pointer bg-slate-50 hover:bg-emerald-50/30 transition-all flex flex-col items-center justify-center gap-3",
|
|
4581
|
+
children: [
|
|
4582
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4583
|
+
"input",
|
|
4584
|
+
{
|
|
4585
|
+
ref: fileInputRef,
|
|
4586
|
+
type: "file",
|
|
4587
|
+
accept: ".xlsx,.xls,.csv",
|
|
4588
|
+
className: "hidden",
|
|
4589
|
+
onChange: (e) => {
|
|
4590
|
+
const file = e.target.files?.[0];
|
|
4591
|
+
if (file) handleProcessImportFile(file);
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
),
|
|
4595
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "size-14 rounded-full bg-emerald-100 flex items-center justify-center text-emerald-600 shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileSpreadsheet, { className: "size-7" }) }),
|
|
4596
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
4597
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "font-semibold text-sm text-slate-700", children: t.importDropzone }),
|
|
4598
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-400 mt-1", children: t.importDropzoneSub })
|
|
4599
|
+
] }),
|
|
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
|
+
)
|
|
4609
|
+
]
|
|
4610
|
+
}
|
|
4611
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-4", children: [
|
|
4612
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between p-3.5 bg-emerald-50/60 border border-emerald-200 rounded-xl", children: [
|
|
4613
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
4614
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "size-9 rounded-lg bg-emerald-100 text-emerald-700 flex items-center justify-center font-bold", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileSpreadsheet, { className: "size-5" }) }),
|
|
4615
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
4616
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm font-bold text-slate-900", children: importFile?.name }),
|
|
4617
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "text-xs text-emerald-700 font-medium", children: [
|
|
4618
|
+
importResult.totalRows,
|
|
4619
|
+
" registros encontrados en el archivo"
|
|
4620
|
+
] })
|
|
4621
|
+
] })
|
|
4622
|
+
] }),
|
|
4623
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4624
|
+
import_antd.Button,
|
|
4625
|
+
{
|
|
4626
|
+
size: "small",
|
|
4627
|
+
onClick: () => {
|
|
4628
|
+
setImportResult(null);
|
|
4629
|
+
setImportFile(null);
|
|
4630
|
+
},
|
|
4631
|
+
disabled: isImporting,
|
|
4632
|
+
children: "Cambiar archivo"
|
|
4633
|
+
}
|
|
4634
|
+
)
|
|
4635
|
+
] }),
|
|
4636
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-wrap items-center gap-2 p-3 bg-slate-50 border border-slate-200 rounded-xl", children: [
|
|
4637
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold text-slate-700", children: "Estado de los registros:" }),
|
|
4638
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_antd.Tag, { color: "green", className: "text-xs font-medium", children: [
|
|
4639
|
+
"\u2713 ",
|
|
4640
|
+
importResult.newRecordsCount,
|
|
4641
|
+
" ",
|
|
4642
|
+
t.importNewDetected
|
|
4643
|
+
] }),
|
|
4644
|
+
importResult.existingRecordsCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_antd.Tag, { color: "gold", className: "text-xs font-medium", children: [
|
|
4645
|
+
"\u2139\uFE0F ",
|
|
4646
|
+
importResult.existingRecordsCount,
|
|
4647
|
+
" ",
|
|
4648
|
+
t.importExistingDetected
|
|
4649
|
+
] })
|
|
4650
|
+
] }),
|
|
4651
|
+
importResult.existingRecordsCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-3.5 bg-slate-50/90 rounded-xl border border-slate-200 space-y-2", children: [
|
|
4652
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-bold text-slate-700 block", children: t.importOverwritesWarning }),
|
|
4653
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4654
|
+
import_antd.Radio.Group,
|
|
4655
|
+
{
|
|
4656
|
+
value: importExistingAction,
|
|
4657
|
+
onChange: (e) => setImportExistingAction(e.target.value),
|
|
4658
|
+
disabled: isImporting,
|
|
4659
|
+
className: "flex flex-col gap-2.5",
|
|
4660
|
+
children: [
|
|
4661
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_antd.Radio, { value: "omit", className: "text-xs text-slate-700", children: [
|
|
4662
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold text-emerald-700 block", children: t.importExistingOmit }),
|
|
4663
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[11px] text-slate-500 block", children: "Si ya existe por ID o campo \xFAnico, no se vuelve a crear ni duplicar en la base de datos." })
|
|
4664
|
+
] }),
|
|
4665
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_antd.Radio, { value: "update", className: "text-xs text-slate-700", children: [
|
|
4666
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-semibold text-sky-700 block", children: t.importExistingUpdate }),
|
|
4667
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[11px] text-slate-500 block", children: "Actualiza los campos de los registros ya existentes con los datos del archivo." })
|
|
4668
|
+
] })
|
|
4669
|
+
]
|
|
4670
|
+
}
|
|
4671
|
+
)
|
|
4672
|
+
] }),
|
|
4673
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
4674
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-600 uppercase tracking-wider block mb-1.5", children: [
|
|
4675
|
+
"Campos reconocidos (",
|
|
4676
|
+
importResult.matchedFields.length,
|
|
4677
|
+
"):"
|
|
4678
|
+
] }),
|
|
4679
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-wrap gap-1.5", children: [
|
|
4680
|
+
importResult.matchedFields.map((m, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_antd.Tag, { color: "green", className: "text-xs py-0.5", children: [
|
|
4681
|
+
"\u2713 ",
|
|
4682
|
+
m.label
|
|
4683
|
+
] }, idx)),
|
|
4684
|
+
importResult.unmatchedHeaders.map((u, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_antd.Tag, { color: "orange", className: "text-xs py-0.5", children: [
|
|
4685
|
+
"\u26A0\uFE0F ",
|
|
4686
|
+
u,
|
|
4687
|
+
" (omitido)"
|
|
4688
|
+
] }, idx))
|
|
4689
|
+
] })
|
|
4690
|
+
] }),
|
|
4691
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
4692
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-600 uppercase tracking-wider block mb-1.5", children: [
|
|
4693
|
+
t.importPreviewTitle,
|
|
4694
|
+
" (",
|
|
4695
|
+
Math.min(5, importResult.samplePreview.length),
|
|
4696
|
+
" de",
|
|
4697
|
+
" ",
|
|
4698
|
+
importResult.totalRows,
|
|
4699
|
+
"):"
|
|
4700
|
+
] }),
|
|
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: [
|
|
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)) }) }),
|
|
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)) })
|
|
4711
|
+
] }) })
|
|
4712
|
+
] }),
|
|
4713
|
+
isImporting && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1", children: [
|
|
4714
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex justify-between text-xs text-slate-600 font-medium", children: [
|
|
4715
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: t.importingProgress }),
|
|
4716
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
4717
|
+
importProgress.current,
|
|
4718
|
+
" / ",
|
|
4719
|
+
importProgress.total
|
|
4720
|
+
] })
|
|
4721
|
+
] }),
|
|
4722
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4723
|
+
import_antd.Progress,
|
|
4724
|
+
{
|
|
4725
|
+
percent: Math.round(
|
|
4726
|
+
importProgress.current / (importProgress.total || 1) * 100
|
|
4727
|
+
),
|
|
4728
|
+
status: "active"
|
|
4729
|
+
}
|
|
4730
|
+
)
|
|
4731
|
+
] }),
|
|
4732
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex justify-end gap-2 pt-2", children: [
|
|
4733
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4734
|
+
import_antd.Button,
|
|
4735
|
+
{
|
|
4736
|
+
size: "large",
|
|
4737
|
+
onClick: () => setIsImportModalOpen(false),
|
|
4738
|
+
disabled: isImporting,
|
|
4739
|
+
children: t.cancel
|
|
4740
|
+
}
|
|
4741
|
+
),
|
|
4742
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4743
|
+
import_antd.Button,
|
|
4744
|
+
{
|
|
4745
|
+
type: "primary",
|
|
4746
|
+
size: "large",
|
|
4747
|
+
loading: isImporting,
|
|
4748
|
+
onClick: handleExecuteImport,
|
|
4749
|
+
className: "rounded-xl font-bold bg-emerald-600 hover:bg-emerald-500",
|
|
4750
|
+
children: [
|
|
4751
|
+
t.importConfirmBtn,
|
|
4752
|
+
" (",
|
|
4753
|
+
importExistingAction === "omit" && importResult.existingRecordsCount > 0 ? importResult.newRecordsCount : importResult.totalRows,
|
|
4754
|
+
")"
|
|
4755
|
+
]
|
|
4756
|
+
}
|
|
4757
|
+
)
|
|
4758
|
+
] })
|
|
4759
|
+
] })
|
|
4760
|
+
] })
|
|
4761
|
+
}
|
|
4762
|
+
),
|
|
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: [
|
|
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: [
|
|
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
|
+
)),
|
|
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 })
|
|
4774
|
+
] }) }),
|
|
4775
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
|
|
4776
|
+
// Loading skeleton rows
|
|
4777
|
+
Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { children: [
|
|
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)),
|
|
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" }) })
|
|
4786
|
+
] }, i))
|
|
4787
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
4788
|
+
(() => {
|
|
4789
|
+
let res = entries;
|
|
4790
|
+
if (search && collection.searchBy?.length) {
|
|
4791
|
+
const q = search.toLowerCase().trim();
|
|
4792
|
+
res = res.filter((e) => {
|
|
4793
|
+
return collection.searchBy.some((field) => {
|
|
4794
|
+
const val = String(e[field] ?? "").toLowerCase();
|
|
4795
|
+
if (!val) return false;
|
|
4796
|
+
if (val.includes(q)) return true;
|
|
4797
|
+
const normVal = val.replace(/-/g, "/");
|
|
4798
|
+
const normQ = q.replace(/-/g, "/");
|
|
4799
|
+
return normVal.includes(normQ);
|
|
4800
|
+
});
|
|
4801
|
+
});
|
|
4802
|
+
}
|
|
4803
|
+
if (Object.keys(filters).length > 0) {
|
|
4804
|
+
res = res.filter((e) => {
|
|
4805
|
+
for (const [k, v] of Object.entries(filters)) {
|
|
4806
|
+
if (!v) continue;
|
|
4807
|
+
const entryVal = String(e[k] ?? "").trim();
|
|
3571
4808
|
const filterVal = String(v).trim();
|
|
3572
4809
|
const normEntry = entryVal.replace(/-/g, "/");
|
|
3573
4810
|
const normFilter = filterVal.replace(/-/g, "/");
|
|
@@ -3578,7 +4815,10 @@ function CollectionEditor({ collection }) {
|
|
|
3578
4815
|
return true;
|
|
3579
4816
|
});
|
|
3580
4817
|
}
|
|
3581
|
-
const paginatedRes = res.slice(
|
|
4818
|
+
const paginatedRes = res.slice(
|
|
4819
|
+
(page - 1) * itemsPerPage,
|
|
4820
|
+
page * itemsPerPage
|
|
4821
|
+
);
|
|
3582
4822
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: paginatedRes.map((e, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3583
4823
|
"tr",
|
|
3584
4824
|
{
|
|
@@ -3589,50 +4829,159 @@ function CollectionEditor({ collection }) {
|
|
|
3589
4829
|
onDragEnd,
|
|
3590
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" : ""}`,
|
|
3591
4831
|
children: [
|
|
3592
|
-
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3593
|
-
"
|
|
3594
|
-
{
|
|
3595
|
-
type: "button",
|
|
3596
|
-
onClick: () => f.onCellClick(e[f.id], e),
|
|
3597
|
-
className: "font-medium text-indigo-600 hover:text-indigo-800 hover:underline cursor-pointer text-left truncate block max-w-full",
|
|
3598
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple })
|
|
3599
|
-
}
|
|
3600
|
-
) : /* @__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: [
|
|
3601
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: String(e[f.id][0] || "") }),
|
|
3602
|
-
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: [
|
|
3603
|
-
"+",
|
|
3604
|
-
e[f.id].length - 1,
|
|
3605
|
-
" m\xE1s"
|
|
3606
|
-
] })
|
|
3607
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: String(e[f.id]) }) : f.onCellClick ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3608
|
-
"button",
|
|
4832
|
+
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4833
|
+
"td",
|
|
3609
4834
|
{
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
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
|
+
)),
|
|
3631
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: [
|
|
3632
|
-
|
|
4939
|
+
collection.customRowActions && collection.customRowActions({
|
|
4940
|
+
record: e,
|
|
4941
|
+
openDetail: () => {
|
|
4942
|
+
if (collection.customDetailView || collection.renderCustomDetail) {
|
|
4943
|
+
setCustomViewingRecord(e);
|
|
4944
|
+
setIsCustomEditing(false);
|
|
4945
|
+
return;
|
|
4946
|
+
}
|
|
4947
|
+
if (collection.onViewRecord) {
|
|
4948
|
+
collection.onViewRecord(e);
|
|
4949
|
+
return;
|
|
4950
|
+
}
|
|
4951
|
+
setIsCreatingManual(false);
|
|
4952
|
+
setIsViewingDetail(true);
|
|
4953
|
+
setOriginalId(String(e.id || ""));
|
|
4954
|
+
setDuplicateErrors({});
|
|
4955
|
+
setEditing({ ...e });
|
|
4956
|
+
},
|
|
4957
|
+
openEdit: () => {
|
|
4958
|
+
if (collection.customEditView) {
|
|
4959
|
+
setCustomViewingRecord(e);
|
|
4960
|
+
setIsCustomEditing(true);
|
|
4961
|
+
return;
|
|
4962
|
+
}
|
|
4963
|
+
setIsCreatingManual(false);
|
|
4964
|
+
setIsViewingDetail(false);
|
|
4965
|
+
setOriginalId(String(e.id || ""));
|
|
4966
|
+
setDuplicateErrors({});
|
|
4967
|
+
setEditing({ ...e });
|
|
4968
|
+
},
|
|
4969
|
+
openCustomView: (renderFn) => {
|
|
4970
|
+
setCustomActiveView(() => renderFn);
|
|
4971
|
+
},
|
|
4972
|
+
reload: () => {
|
|
4973
|
+
load();
|
|
4974
|
+
}
|
|
4975
|
+
}),
|
|
4976
|
+
(collection.enableDetailView || collection.onViewRecord || collection.customDetailView || collection.renderCustomDetail) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3633
4977
|
"button",
|
|
3634
4978
|
{
|
|
3635
4979
|
onClick: () => {
|
|
4980
|
+
if (collection.customDetailView || collection.renderCustomDetail) {
|
|
4981
|
+
setCustomViewingRecord(e);
|
|
4982
|
+
setIsCustomEditing(false);
|
|
4983
|
+
return;
|
|
4984
|
+
}
|
|
3636
4985
|
if (collection.onViewRecord) {
|
|
3637
4986
|
collection.onViewRecord(e);
|
|
3638
4987
|
return;
|
|
@@ -3661,6 +5010,11 @@ function CollectionEditor({ collection }) {
|
|
|
3661
5010
|
"button",
|
|
3662
5011
|
{
|
|
3663
5012
|
onClick: () => {
|
|
5013
|
+
if (collection.customEditView) {
|
|
5014
|
+
setCustomViewingRecord(e);
|
|
5015
|
+
setIsCustomEditing(true);
|
|
5016
|
+
return;
|
|
5017
|
+
}
|
|
3664
5018
|
setIsCreatingManual(false);
|
|
3665
5019
|
setIsViewingDetail(false);
|
|
3666
5020
|
setOriginalId(String(e.id || ""));
|
|
@@ -3672,17 +5026,43 @@ function CollectionEditor({ collection }) {
|
|
|
3672
5026
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
|
|
3673
5027
|
}
|
|
3674
5028
|
),
|
|
3675
|
-
!collection.disableDelete && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5029
|
+
!collection.disableDelete && !collection.hideDelete && (!collection.canDelete || collection.canDelete(e)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3676
5030
|
"button",
|
|
3677
5031
|
{
|
|
3678
5032
|
onClick: () => remove(e.id),
|
|
3679
5033
|
disabled: deletingId === e.id,
|
|
3680
5034
|
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
3681
5035
|
title: t.delete,
|
|
3682
|
-
children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
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" })
|
|
3686
5066
|
}
|
|
3687
5067
|
)
|
|
3688
5068
|
] }) })
|
|
@@ -3709,7 +5089,11 @@ function CollectionEditor({ collection }) {
|
|
|
3709
5089
|
let res = entries;
|
|
3710
5090
|
if (search && collection.searchBy?.length) {
|
|
3711
5091
|
const q = search.toLowerCase();
|
|
3712
|
-
res = res.filter(
|
|
5092
|
+
res = res.filter(
|
|
5093
|
+
(e) => collection.searchBy.some(
|
|
5094
|
+
(field) => String(e[field] || "").toLowerCase().includes(q)
|
|
5095
|
+
)
|
|
5096
|
+
);
|
|
3713
5097
|
}
|
|
3714
5098
|
if (Object.keys(filters).length > 0) {
|
|
3715
5099
|
res = res.filter((e) => {
|
|
@@ -3725,7 +5109,11 @@ function CollectionEditor({ collection }) {
|
|
|
3725
5109
|
let res = entries;
|
|
3726
5110
|
if (search && collection.searchBy?.length) {
|
|
3727
5111
|
const q = search.toLowerCase();
|
|
3728
|
-
res = res.filter(
|
|
5112
|
+
res = res.filter(
|
|
5113
|
+
(e) => collection.searchBy.some(
|
|
5114
|
+
(field) => String(e[field] || "").toLowerCase().includes(q)
|
|
5115
|
+
)
|
|
5116
|
+
);
|
|
3729
5117
|
}
|
|
3730
5118
|
if (Object.keys(filters).length > 0) {
|
|
3731
5119
|
res = res.filter((e) => {
|
|
@@ -3735,7 +5123,10 @@ function CollectionEditor({ collection }) {
|
|
|
3735
5123
|
return true;
|
|
3736
5124
|
});
|
|
3737
5125
|
}
|
|
3738
|
-
const totalPages = Math.max(
|
|
5126
|
+
const totalPages = Math.max(
|
|
5127
|
+
1,
|
|
5128
|
+
Math.ceil(res.length / itemsPerPage)
|
|
5129
|
+
);
|
|
3739
5130
|
if (totalPages <= 1) return null;
|
|
3740
5131
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3741
5132
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -3792,20 +5183,39 @@ function SubmissionsSection() {
|
|
|
3792
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: [
|
|
3793
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" }),
|
|
3794
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: [
|
|
3795
|
-
formIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3796
|
-
"
|
|
5186
|
+
formIds.map((id) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5187
|
+
"li",
|
|
3797
5188
|
{
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
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
|
+
)),
|
|
3809
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." })
|
|
3810
5220
|
] })
|
|
3811
5221
|
] }),
|
|
@@ -3824,7 +5234,12 @@ function SubmissionsSection() {
|
|
|
3824
5234
|
] })
|
|
3825
5235
|
] });
|
|
3826
5236
|
}
|
|
3827
|
-
function SubmissionsList({
|
|
5237
|
+
function SubmissionsList({
|
|
5238
|
+
formId,
|
|
5239
|
+
submissions,
|
|
5240
|
+
onLoad,
|
|
5241
|
+
loading
|
|
5242
|
+
}) {
|
|
3828
5243
|
const ctx = useCmsContext();
|
|
3829
5244
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
3830
5245
|
const [page, setPage] = (0, import_react5.useState)(1);
|
|
@@ -3852,7 +5267,10 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
3852
5267
|
const unreadCount = submissions.filter((s) => !s.read).length;
|
|
3853
5268
|
const formatDate = (iso) => {
|
|
3854
5269
|
try {
|
|
3855
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
5270
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
5271
|
+
dateStyle: "medium",
|
|
5272
|
+
timeStyle: "short"
|
|
5273
|
+
}).format(new Date(iso));
|
|
3856
5274
|
} catch {
|
|
3857
5275
|
return iso;
|
|
3858
5276
|
}
|
|
@@ -3890,54 +5308,61 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
3890
5308
|
const strVal = String(val ?? "\u2014");
|
|
3891
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"));
|
|
3892
5310
|
const isUrl = typeof val === "string" && /^https?:\/\//i.test(val);
|
|
3893
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
{
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
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",
|
|
3903
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3904
|
-
"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",
|
|
3905
5320
|
{
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
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
|
+
)
|
|
3909
5333
|
}
|
|
3910
|
-
)
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
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
|
+
);
|
|
3941
5366
|
}) })
|
|
3942
5367
|
] })
|
|
3943
5368
|
] });
|
|
@@ -3959,7 +5384,8 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
3959
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",
|
|
3960
5385
|
children: [
|
|
3961
5386
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.RefreshCw, { className: `h-4 w-4 ${loading ? "animate-spin" : ""}` }),
|
|
3962
|
-
"
|
|
5387
|
+
" ",
|
|
5388
|
+
"Refresh"
|
|
3963
5389
|
]
|
|
3964
5390
|
}
|
|
3965
5391
|
)
|
|
@@ -4000,26 +5426,33 @@ function SubmissionsList({ formId, submissions, onLoad, loading }) {
|
|
|
4000
5426
|
!s.read && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "ml-2 inline-block h-2 w-2 rounded-full bg-indigo-500" })
|
|
4001
5427
|
] }),
|
|
4002
5428
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-500 whitespace-nowrap", children: formatDate(s.submittedAt) }),
|
|
4003
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
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
|
+
)
|
|
4023
5456
|
]
|
|
4024
5457
|
},
|
|
4025
5458
|
s.id
|
|
@@ -4077,7 +5510,13 @@ function SettingsSection() {
|
|
|
4077
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" }) }),
|
|
4078
5511
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("dl", { className: "divide-y divide-slate-100 text-sm", children: [
|
|
4079
5512
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Row, { label: "Site Name", value: ctx.config.siteName ?? "\u2014" }),
|
|
4080
|
-
/* @__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
|
+
),
|
|
4081
5520
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4082
5521
|
Row,
|
|
4083
5522
|
{
|
|
@@ -4126,7 +5565,13 @@ function ConfigSection() {
|
|
|
4126
5565
|
{
|
|
4127
5566
|
onClick: () => setSelectedGroupId(g.id),
|
|
4128
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"}`,
|
|
4129
|
-
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
|
+
)
|
|
4130
5575
|
}
|
|
4131
5576
|
) }, g.id)),
|
|
4132
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." })
|
|
@@ -4193,10 +5638,22 @@ function Row({
|
|
|
4193
5638
|
}) {
|
|
4194
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: [
|
|
4195
5640
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("dt", { className: "text-slate-500 font-medium", children: label }),
|
|
4196
|
-
/* @__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
|
+
)
|
|
4197
5648
|
] });
|
|
4198
5649
|
}
|
|
4199
|
-
function SearchableSelect({
|
|
5650
|
+
function SearchableSelect({
|
|
5651
|
+
value,
|
|
5652
|
+
onChange,
|
|
5653
|
+
options,
|
|
5654
|
+
placeholder,
|
|
5655
|
+
iconMap
|
|
5656
|
+
}) {
|
|
4200
5657
|
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
4201
5658
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
4202
5659
|
const btnRef = (0, import_react5.useRef)(null);
|
|
@@ -4213,7 +5670,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
4213
5670
|
const opensUp = spaceBelow < dropdownHeight && rect.top > dropdownHeight;
|
|
4214
5671
|
setCoords({
|
|
4215
5672
|
top: opensUp ? Math.max(10, rect.top - dropdownHeight - 6) : rect.bottom + 6,
|
|
4216
|
-
left: Math.max(
|
|
5673
|
+
left: Math.max(
|
|
5674
|
+
10,
|
|
5675
|
+
Math.min(rect.left, window.innerWidth - rect.width - 10)
|
|
5676
|
+
),
|
|
4217
5677
|
width: rect.width
|
|
4218
5678
|
});
|
|
4219
5679
|
}
|
|
@@ -4338,7 +5798,10 @@ function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
|
4338
5798
|
)
|
|
4339
5799
|
] });
|
|
4340
5800
|
}
|
|
4341
|
-
function PasswordField({
|
|
5801
|
+
function PasswordField({
|
|
5802
|
+
value,
|
|
5803
|
+
onChange
|
|
5804
|
+
}) {
|
|
4342
5805
|
const [show, setShow] = (0, import_react5.useState)(false);
|
|
4343
5806
|
const hasExisting = Boolean(value && String(value).trim().length > 0);
|
|
4344
5807
|
const [displayValue, setDisplayValue] = (0, import_react5.useState)("");
|
|
@@ -4524,8 +5987,24 @@ function SignatureInput({
|
|
|
4524
5987
|
centered: true,
|
|
4525
5988
|
width: 560,
|
|
4526
5989
|
footer: [
|
|
4527
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4528
|
-
|
|
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
|
+
),
|
|
4529
6008
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4530
6009
|
import_antd.Button,
|
|
4531
6010
|
{
|
|
@@ -4576,7 +6055,9 @@ function FormattedNumberInput({
|
|
|
4576
6055
|
if (!cleanDigits) return "";
|
|
4577
6056
|
return cleanDigits.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
4578
6057
|
};
|
|
4579
|
-
const [displayVal, setDisplayVal] = (0, import_react5.useState)(
|
|
6058
|
+
const [displayVal, setDisplayVal] = (0, import_react5.useState)(
|
|
6059
|
+
() => formatWithDots(value)
|
|
6060
|
+
);
|
|
4580
6061
|
(0, import_react5.useEffect)(() => {
|
|
4581
6062
|
setDisplayVal(formatWithDots(value));
|
|
4582
6063
|
}, [value]);
|
|
@@ -4618,440 +6099,6 @@ function FormattedNumberInput({
|
|
|
4618
6099
|
)
|
|
4619
6100
|
] });
|
|
4620
6101
|
}
|
|
4621
|
-
function BranchSettingsEditor({
|
|
4622
|
-
collectionId,
|
|
4623
|
-
value,
|
|
4624
|
-
globalPrice,
|
|
4625
|
-
globalDiscount,
|
|
4626
|
-
onChange
|
|
4627
|
-
}) {
|
|
4628
|
-
const ctx = useCmsContext();
|
|
4629
|
-
const [branches, setBranches] = (0, import_react5.useState)([]);
|
|
4630
|
-
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
4631
|
-
const [loadError, setLoadError] = (0, import_react5.useState)("");
|
|
4632
|
-
const settings = value && typeof value === "object" ? value : {};
|
|
4633
|
-
const selectedBranches = Array.isArray(settings.branches) ? settings.branches.map(String) : [];
|
|
4634
|
-
const prices = settings.prices && typeof settings.prices === "object" ? settings.prices : {};
|
|
4635
|
-
const selectedPriceBranches = [
|
|
4636
|
-
.../* @__PURE__ */ new Set([
|
|
4637
|
-
...Array.isArray(settings.priceBranches) ? settings.priceBranches.map(String) : [],
|
|
4638
|
-
...Object.keys(prices)
|
|
4639
|
-
])
|
|
4640
|
-
];
|
|
4641
|
-
const discounts = settings.discounts && typeof settings.discounts === "object" ? settings.discounts : {};
|
|
4642
|
-
const selectedDiscountBranches = [
|
|
4643
|
-
.../* @__PURE__ */ new Set([
|
|
4644
|
-
...Array.isArray(settings.discountBranches) ? settings.discountBranches.map(String) : [],
|
|
4645
|
-
...Object.keys(discounts)
|
|
4646
|
-
])
|
|
4647
|
-
];
|
|
4648
|
-
const branchAvailability = settings.branchAvailability && typeof settings.branchAvailability === "object" ? settings.branchAvailability : {};
|
|
4649
|
-
const selectedAvailabilityBranches = Object.keys(branchAvailability);
|
|
4650
|
-
const allBranches = settings.allBranches !== false;
|
|
4651
|
-
const useBranchPricing = settings.useBranchPricing === true;
|
|
4652
|
-
const useBranchDiscounts = settings.useBranchDiscounts === true;
|
|
4653
|
-
(0, import_react5.useEffect)(() => {
|
|
4654
|
-
let active = true;
|
|
4655
|
-
setLoading(true);
|
|
4656
|
-
setLoadError("");
|
|
4657
|
-
ctx.adapter.listEntries(collectionId).then((entries) => {
|
|
4658
|
-
if (active) setBranches(entries);
|
|
4659
|
-
}).catch((error) => {
|
|
4660
|
-
console.error("Could not load branches for product settings:", error);
|
|
4661
|
-
if (active) setLoadError("No se pudieron cargar las sedes.");
|
|
4662
|
-
}).finally(() => {
|
|
4663
|
-
if (active) setLoading(false);
|
|
4664
|
-
});
|
|
4665
|
-
return () => {
|
|
4666
|
-
active = false;
|
|
4667
|
-
};
|
|
4668
|
-
}, [collectionId, ctx.adapter]);
|
|
4669
|
-
const getBranchName = (branch) => String(branch.name || branch.id);
|
|
4670
|
-
const updateSettings = (patch) => {
|
|
4671
|
-
onChange({
|
|
4672
|
-
allBranches,
|
|
4673
|
-
branches: selectedBranches,
|
|
4674
|
-
useBranchPricing,
|
|
4675
|
-
priceBranches: selectedPriceBranches,
|
|
4676
|
-
prices: { ...prices },
|
|
4677
|
-
useBranchDiscounts,
|
|
4678
|
-
discountBranches: selectedDiscountBranches,
|
|
4679
|
-
discounts: { ...discounts },
|
|
4680
|
-
branchAvailability: { ...branchAvailability },
|
|
4681
|
-
...patch
|
|
4682
|
-
});
|
|
4683
|
-
};
|
|
4684
|
-
const updateBranchAvailability = (name, start, end) => {
|
|
4685
|
-
updateSettings({
|
|
4686
|
-
branchAvailability: {
|
|
4687
|
-
...branchAvailability,
|
|
4688
|
-
[name]: {
|
|
4689
|
-
start: toStoredTime(start),
|
|
4690
|
-
end: toStoredTime(end)
|
|
4691
|
-
}
|
|
4692
|
-
}
|
|
4693
|
-
});
|
|
4694
|
-
};
|
|
4695
|
-
const updateBranchPrice = (name, value2) => {
|
|
4696
|
-
const nextPrices = { ...prices };
|
|
4697
|
-
if (value2.trim() === "") {
|
|
4698
|
-
delete nextPrices[name];
|
|
4699
|
-
} else {
|
|
4700
|
-
const parsed = Number(value2);
|
|
4701
|
-
if (Number.isFinite(parsed) && parsed >= 0) nextPrices[name] = parsed;
|
|
4702
|
-
}
|
|
4703
|
-
updateSettings({ prices: nextPrices });
|
|
4704
|
-
};
|
|
4705
|
-
const updateBranchDiscount = (name, value2) => {
|
|
4706
|
-
const nextDiscounts = { ...discounts };
|
|
4707
|
-
if (value2.trim() === "") {
|
|
4708
|
-
delete nextDiscounts[name];
|
|
4709
|
-
} else {
|
|
4710
|
-
const parsed = Number(value2);
|
|
4711
|
-
if (Number.isFinite(parsed) && parsed >= 0 && parsed <= 100) {
|
|
4712
|
-
nextDiscounts[name] = parsed;
|
|
4713
|
-
}
|
|
4714
|
-
}
|
|
4715
|
-
updateSettings({ discounts: nextDiscounts });
|
|
4716
|
-
};
|
|
4717
|
-
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: [
|
|
4718
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
|
|
4719
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4720
|
-
"input",
|
|
4721
|
-
{
|
|
4722
|
-
type: "checkbox",
|
|
4723
|
-
checked: allBranches,
|
|
4724
|
-
onChange: (event) => updateSettings({ allBranches: event.target.checked }),
|
|
4725
|
-
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
4726
|
-
}
|
|
4727
|
-
),
|
|
4728
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
4729
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block font-semibold", children: "Disponible en todas las sedes" }),
|
|
4730
|
-
/* @__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." })
|
|
4731
|
-
] })
|
|
4732
|
-
] }),
|
|
4733
|
-
!allBranches && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4734
|
-
SearchableMultiSelect,
|
|
4735
|
-
{
|
|
4736
|
-
options: branches.map((branch) => ({
|
|
4737
|
-
value: getBranchName(branch),
|
|
4738
|
-
label: getBranchName(branch)
|
|
4739
|
-
})),
|
|
4740
|
-
value: selectedBranches,
|
|
4741
|
-
onChange: (next) => updateSettings({ branches: next }),
|
|
4742
|
-
loading,
|
|
4743
|
-
error: loadError,
|
|
4744
|
-
placeholder: "Seleccionar sedes...",
|
|
4745
|
-
searchPlaceholder: "Buscar sede...",
|
|
4746
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
4747
|
-
}
|
|
4748
|
-
),
|
|
4749
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "border-t border-slate-200 pt-4", children: [
|
|
4750
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm font-semibold text-slate-700", children: "Horario diferente por sede (opcional)" }),
|
|
4751
|
-
/* @__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." }),
|
|
4752
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-3", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4753
|
-
SearchableMultiSelect,
|
|
4754
|
-
{
|
|
4755
|
-
options: branches.map((branch) => ({
|
|
4756
|
-
value: getBranchName(branch),
|
|
4757
|
-
label: getBranchName(branch)
|
|
4758
|
-
})),
|
|
4759
|
-
value: selectedAvailabilityBranches,
|
|
4760
|
-
onChange: (next) => {
|
|
4761
|
-
const nextSchedules = Object.fromEntries(
|
|
4762
|
-
next.map((name) => [
|
|
4763
|
-
name,
|
|
4764
|
-
branchAvailability[name] ?? { start: "", end: "" }
|
|
4765
|
-
])
|
|
4766
|
-
);
|
|
4767
|
-
updateSettings({ branchAvailability: nextSchedules });
|
|
4768
|
-
},
|
|
4769
|
-
loading,
|
|
4770
|
-
error: loadError,
|
|
4771
|
-
placeholder: "Buscar sedes para configurar su horario...",
|
|
4772
|
-
searchPlaceholder: "Buscar sede...",
|
|
4773
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
4774
|
-
}
|
|
4775
|
-
) }),
|
|
4776
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-3 space-y-2", children: branches.filter(
|
|
4777
|
-
(branch) => selectedAvailabilityBranches.includes(getBranchName(branch))
|
|
4778
|
-
).map((branch) => {
|
|
4779
|
-
const name = getBranchName(branch);
|
|
4780
|
-
const schedule = branchAvailability[name] ?? {};
|
|
4781
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4782
|
-
"div",
|
|
4783
|
-
{
|
|
4784
|
-
className: "space-y-3 rounded-lg border border-slate-200 bg-white p-3",
|
|
4785
|
-
children: [
|
|
4786
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
|
|
4787
|
-
/* @__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 }),
|
|
4788
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4789
|
-
"button",
|
|
4790
|
-
{
|
|
4791
|
-
type: "button",
|
|
4792
|
-
onClick: () => {
|
|
4793
|
-
const nextSchedules = { ...branchAvailability };
|
|
4794
|
-
delete nextSchedules[name];
|
|
4795
|
-
updateSettings({ branchAvailability: nextSchedules });
|
|
4796
|
-
},
|
|
4797
|
-
"aria-label": `Quitar horario de ${name}`,
|
|
4798
|
-
title: `Quitar horario de ${name}`,
|
|
4799
|
-
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",
|
|
4800
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
4801
|
-
}
|
|
4802
|
-
)
|
|
4803
|
-
] }),
|
|
4804
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4805
|
-
AdminTimeRangePicker,
|
|
4806
|
-
{
|
|
4807
|
-
value: [
|
|
4808
|
-
toDayjsTime(schedule.start),
|
|
4809
|
-
toDayjsTime(schedule.end)
|
|
4810
|
-
],
|
|
4811
|
-
onChange: (times) => updateBranchAvailability(
|
|
4812
|
-
name,
|
|
4813
|
-
times?.[0] ?? null,
|
|
4814
|
-
times?.[1] ?? null
|
|
4815
|
-
),
|
|
4816
|
-
allowEmpty: [true, true],
|
|
4817
|
-
className: "w-full",
|
|
4818
|
-
format: TIME_DISPLAY_FORMAT,
|
|
4819
|
-
order: false,
|
|
4820
|
-
placeholder: ["Hora de inicio", "Hora de cierre"],
|
|
4821
|
-
use12Hours: true
|
|
4822
|
-
}
|
|
4823
|
-
)
|
|
4824
|
-
]
|
|
4825
|
-
},
|
|
4826
|
-
branch.id
|
|
4827
|
-
);
|
|
4828
|
-
}) })
|
|
4829
|
-
] }),
|
|
4830
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "border-t border-slate-200 pt-4", children: [
|
|
4831
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
|
|
4832
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4833
|
-
"input",
|
|
4834
|
-
{
|
|
4835
|
-
type: "checkbox",
|
|
4836
|
-
checked: useBranchPricing,
|
|
4837
|
-
onChange: (event) => updateSettings({ useBranchPricing: event.target.checked }),
|
|
4838
|
-
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
4839
|
-
}
|
|
4840
|
-
),
|
|
4841
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
4842
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block font-semibold", children: "Usar precio diferente por sede" }),
|
|
4843
|
-
/* @__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." })
|
|
4844
|
-
] })
|
|
4845
|
-
] }),
|
|
4846
|
-
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: [
|
|
4847
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "text-xs text-slate-500", children: [
|
|
4848
|
-
"Precio global actual: $",
|
|
4849
|
-
globalPrice.toLocaleString("es-CO")
|
|
4850
|
-
] }),
|
|
4851
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4852
|
-
SearchableMultiSelect,
|
|
4853
|
-
{
|
|
4854
|
-
options: branches.map((branch) => ({
|
|
4855
|
-
value: getBranchName(branch),
|
|
4856
|
-
label: getBranchName(branch)
|
|
4857
|
-
})),
|
|
4858
|
-
value: selectedPriceBranches,
|
|
4859
|
-
onChange: (next) => {
|
|
4860
|
-
const removed = selectedPriceBranches.filter(
|
|
4861
|
-
(name) => !next.includes(name)
|
|
4862
|
-
);
|
|
4863
|
-
const nextPrices = { ...prices };
|
|
4864
|
-
removed.forEach((name) => delete nextPrices[name]);
|
|
4865
|
-
updateSettings({
|
|
4866
|
-
priceBranches: next,
|
|
4867
|
-
prices: nextPrices
|
|
4868
|
-
});
|
|
4869
|
-
},
|
|
4870
|
-
loading,
|
|
4871
|
-
error: loadError,
|
|
4872
|
-
placeholder: "Buscar y agregar sedes...",
|
|
4873
|
-
searchPlaceholder: "Buscar sede...",
|
|
4874
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
4875
|
-
}
|
|
4876
|
-
),
|
|
4877
|
-
branches.filter(
|
|
4878
|
-
(branch) => selectedPriceBranches.includes(getBranchName(branch))
|
|
4879
|
-
).map((branch) => {
|
|
4880
|
-
const name = getBranchName(branch);
|
|
4881
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4882
|
-
"div",
|
|
4883
|
-
{
|
|
4884
|
-
className: "space-y-2 rounded-lg border border-slate-200 bg-white p-3",
|
|
4885
|
-
children: [
|
|
4886
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
|
|
4887
|
-
/* @__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 }),
|
|
4888
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4889
|
-
"button",
|
|
4890
|
-
{
|
|
4891
|
-
type: "button",
|
|
4892
|
-
onClick: () => {
|
|
4893
|
-
const nextPrices = { ...prices };
|
|
4894
|
-
delete nextPrices[name];
|
|
4895
|
-
updateSettings({
|
|
4896
|
-
priceBranches: selectedPriceBranches.filter(
|
|
4897
|
-
(selected) => selected !== name
|
|
4898
|
-
),
|
|
4899
|
-
prices: nextPrices
|
|
4900
|
-
});
|
|
4901
|
-
},
|
|
4902
|
-
"aria-label": `Quitar ${name} de precios por sede`,
|
|
4903
|
-
title: `Quitar ${name}`,
|
|
4904
|
-
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",
|
|
4905
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
4906
|
-
}
|
|
4907
|
-
)
|
|
4908
|
-
] }),
|
|
4909
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block w-full", children: [
|
|
4910
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "sr-only", children: [
|
|
4911
|
-
"Precio para ",
|
|
4912
|
-
name
|
|
4913
|
-
] }),
|
|
4914
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4915
|
-
FormattedNumberInput,
|
|
4916
|
-
{
|
|
4917
|
-
value: prices[name] ?? "",
|
|
4918
|
-
onChange: (price) => updateBranchPrice(
|
|
4919
|
-
name,
|
|
4920
|
-
price === null ? "" : String(price)
|
|
4921
|
-
),
|
|
4922
|
-
isPrice: true,
|
|
4923
|
-
allowEmpty: true,
|
|
4924
|
-
placeholder: String(globalPrice),
|
|
4925
|
-
className: "bg-white text-right",
|
|
4926
|
-
containerClassName: "w-full"
|
|
4927
|
-
}
|
|
4928
|
-
)
|
|
4929
|
-
] })
|
|
4930
|
-
]
|
|
4931
|
-
},
|
|
4932
|
-
branch.id
|
|
4933
|
-
);
|
|
4934
|
-
})
|
|
4935
|
-
] }) })
|
|
4936
|
-
] }),
|
|
4937
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "border-t border-slate-200 pt-4", children: [
|
|
4938
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-start gap-3 text-sm text-slate-700", children: [
|
|
4939
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4940
|
-
"input",
|
|
4941
|
-
{
|
|
4942
|
-
type: "checkbox",
|
|
4943
|
-
checked: useBranchDiscounts,
|
|
4944
|
-
onChange: (event) => updateSettings({ useBranchDiscounts: event.target.checked }),
|
|
4945
|
-
className: "mt-0.5 h-4 w-4 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
4946
|
-
}
|
|
4947
|
-
),
|
|
4948
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
|
|
4949
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "block font-semibold", children: "Usar descuento diferente por sede" }),
|
|
4950
|
-
/* @__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." })
|
|
4951
|
-
] })
|
|
4952
|
-
] }),
|
|
4953
|
-
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: [
|
|
4954
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "text-xs text-slate-500", children: [
|
|
4955
|
-
"Descuento global actual: ",
|
|
4956
|
-
globalDiscount,
|
|
4957
|
-
"%"
|
|
4958
|
-
] }),
|
|
4959
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4960
|
-
SearchableMultiSelect,
|
|
4961
|
-
{
|
|
4962
|
-
options: branches.map((branch) => ({
|
|
4963
|
-
value: getBranchName(branch),
|
|
4964
|
-
label: getBranchName(branch)
|
|
4965
|
-
})),
|
|
4966
|
-
value: selectedDiscountBranches,
|
|
4967
|
-
onChange: (next) => {
|
|
4968
|
-
const removed = selectedDiscountBranches.filter(
|
|
4969
|
-
(name) => !next.includes(name)
|
|
4970
|
-
);
|
|
4971
|
-
const nextDiscounts = { ...discounts };
|
|
4972
|
-
removed.forEach((name) => delete nextDiscounts[name]);
|
|
4973
|
-
updateSettings({
|
|
4974
|
-
discountBranches: next,
|
|
4975
|
-
discounts: nextDiscounts
|
|
4976
|
-
});
|
|
4977
|
-
},
|
|
4978
|
-
loading,
|
|
4979
|
-
error: loadError,
|
|
4980
|
-
placeholder: "Buscar y agregar sedes...",
|
|
4981
|
-
searchPlaceholder: "Buscar sede...",
|
|
4982
|
-
emptyMessage: "No hay sedes registradas todav\xEDa."
|
|
4983
|
-
}
|
|
4984
|
-
),
|
|
4985
|
-
branches.filter(
|
|
4986
|
-
(branch) => selectedDiscountBranches.includes(getBranchName(branch))
|
|
4987
|
-
).map((branch) => {
|
|
4988
|
-
const name = getBranchName(branch);
|
|
4989
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4990
|
-
"div",
|
|
4991
|
-
{
|
|
4992
|
-
className: "space-y-2 rounded-lg border border-slate-200 bg-white p-3",
|
|
4993
|
-
children: [
|
|
4994
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex min-w-0 items-center justify-between gap-3", children: [
|
|
4995
|
-
/* @__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 }),
|
|
4996
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4997
|
-
"button",
|
|
4998
|
-
{
|
|
4999
|
-
type: "button",
|
|
5000
|
-
onClick: () => {
|
|
5001
|
-
const nextDiscounts = { ...discounts };
|
|
5002
|
-
delete nextDiscounts[name];
|
|
5003
|
-
updateSettings({
|
|
5004
|
-
discountBranches: selectedDiscountBranches.filter(
|
|
5005
|
-
(selected) => selected !== name
|
|
5006
|
-
),
|
|
5007
|
-
discounts: nextDiscounts
|
|
5008
|
-
});
|
|
5009
|
-
},
|
|
5010
|
-
"aria-label": `Quitar descuento de ${name}`,
|
|
5011
|
-
title: `Quitar ${name}`,
|
|
5012
|
-
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",
|
|
5013
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-4 w-4" })
|
|
5014
|
-
}
|
|
5015
|
-
)
|
|
5016
|
-
] }),
|
|
5017
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block w-full", children: [
|
|
5018
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "sr-only", children: [
|
|
5019
|
-
"Descuento para ",
|
|
5020
|
-
name
|
|
5021
|
-
] }),
|
|
5022
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5023
|
-
FormattedNumberInput,
|
|
5024
|
-
{
|
|
5025
|
-
value: discounts[name] ?? "",
|
|
5026
|
-
onChange: (discount) => updateBranchDiscount(
|
|
5027
|
-
name,
|
|
5028
|
-
discount === null ? "" : String(discount)
|
|
5029
|
-
),
|
|
5030
|
-
isPercent: true,
|
|
5031
|
-
allowEmpty: true,
|
|
5032
|
-
placeholder: String(globalDiscount),
|
|
5033
|
-
className: "bg-white text-right",
|
|
5034
|
-
containerClassName: "w-full"
|
|
5035
|
-
}
|
|
5036
|
-
)
|
|
5037
|
-
] })
|
|
5038
|
-
]
|
|
5039
|
-
},
|
|
5040
|
-
branch.id
|
|
5041
|
-
);
|
|
5042
|
-
})
|
|
5043
|
-
] }) })
|
|
5044
|
-
] })
|
|
5045
|
-
] });
|
|
5046
|
-
}
|
|
5047
|
-
function BranchSettingsSummary({ value }) {
|
|
5048
|
-
if (!value || typeof value !== "object") return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "Todas las sedes" });
|
|
5049
|
-
const settings = value;
|
|
5050
|
-
const names = Array.isArray(settings.branches) ? settings.branches : [];
|
|
5051
|
-
const locationSummary = settings.allBranches === false ? names.length > 0 ? names.join(", ") : "Sin sedes" : "Todas las sedes";
|
|
5052
|
-
const pricingSummary = settings.useBranchPricing ? " \xB7 Precio por sede" : " \xB7 Precio global";
|
|
5053
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: locationSummary + pricingSummary });
|
|
5054
|
-
}
|
|
5055
6102
|
function SearchableMultiSelect({
|
|
5056
6103
|
options,
|
|
5057
6104
|
value,
|
|
@@ -5204,32 +6251,40 @@ function SearchableMultiSelect({
|
|
|
5204
6251
|
] })
|
|
5205
6252
|
] })
|
|
5206
6253
|
] }),
|
|
5207
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
"
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
"
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
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
|
+
)
|
|
5233
6288
|
] })
|
|
5234
6289
|
] });
|
|
5235
6290
|
}
|
|
@@ -5255,19 +6310,29 @@ function ReferenceSelect({
|
|
|
5255
6310
|
const [formError, setFormError] = (0, import_react5.useState)("");
|
|
5256
6311
|
const [newRecord, setNewRecord] = (0, import_react5.useState)({});
|
|
5257
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
|
+
};
|
|
5258
6317
|
const handleSaveRecord = async () => {
|
|
5259
6318
|
setFormError("");
|
|
5260
6319
|
if (!targetCol) return;
|
|
5261
|
-
const uniqueFields = targetCol.fields.filter(
|
|
6320
|
+
const uniqueFields = targetCol.fields.filter(
|
|
6321
|
+
(f) => f.unique || f.id === "id" && !f.hideOnCreate
|
|
6322
|
+
);
|
|
5262
6323
|
for (const uf of uniqueFields) {
|
|
5263
6324
|
const val = String(newRecord[uf.id] || "").trim();
|
|
5264
6325
|
if (!val) {
|
|
5265
6326
|
setFormError(`El campo "${uf.label || uf.id}" es obligatorio.`);
|
|
5266
6327
|
return;
|
|
5267
6328
|
}
|
|
5268
|
-
const isDup = options.some(
|
|
6329
|
+
const isDup = options.some(
|
|
6330
|
+
(opt) => String(opt.value || "").trim().toLowerCase() === val.toLowerCase()
|
|
6331
|
+
);
|
|
5269
6332
|
if (isDup) {
|
|
5270
|
-
setFormError(
|
|
6333
|
+
setFormError(
|
|
6334
|
+
`Ya existe un registro con este ${uf.label.toLowerCase()} (\xAB${val}\xBB).`
|
|
6335
|
+
);
|
|
5271
6336
|
return;
|
|
5272
6337
|
}
|
|
5273
6338
|
}
|
|
@@ -5294,21 +6359,35 @@ function ReferenceSelect({
|
|
|
5294
6359
|
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
5295
6360
|
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
5296
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(" ");
|
|
5297
6367
|
return {
|
|
5298
6368
|
value: val,
|
|
5299
|
-
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
6369
|
+
label: val && val !== lab && val.length < 20 ? `${lab} (${val})` : lab,
|
|
6370
|
+
searchText,
|
|
5300
6371
|
raw: r
|
|
5301
6372
|
};
|
|
5302
6373
|
});
|
|
5303
6374
|
setOptions(fromCollection);
|
|
5304
|
-
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;
|
|
5305
6382
|
onChange(selectedVal);
|
|
5306
6383
|
if (onSelectRecord) {
|
|
5307
|
-
onSelectRecord(
|
|
6384
|
+
onSelectRecord(persistedEntry);
|
|
5308
6385
|
}
|
|
5309
6386
|
setModalOpen(false);
|
|
5310
6387
|
setNewRecord({});
|
|
5311
|
-
message.success(
|
|
6388
|
+
message.success(
|
|
6389
|
+
t.recordCreatedSuccess || "Registro creado y seleccionado exitosamente."
|
|
6390
|
+
);
|
|
5312
6391
|
} catch (err) {
|
|
5313
6392
|
setFormError(err?.message || "Error al crear registro.");
|
|
5314
6393
|
} finally {
|
|
@@ -5318,7 +6397,11 @@ function ReferenceSelect({
|
|
|
5318
6397
|
(0, import_react5.useEffect)(() => {
|
|
5319
6398
|
if (!collectionId) {
|
|
5320
6399
|
if (fallbackOptions && fallbackOptions.length > 0) {
|
|
5321
|
-
setOptions(
|
|
6400
|
+
setOptions(
|
|
6401
|
+
fallbackOptions.map(
|
|
6402
|
+
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
6403
|
+
)
|
|
6404
|
+
);
|
|
5322
6405
|
}
|
|
5323
6406
|
setLoading(false);
|
|
5324
6407
|
return;
|
|
@@ -5329,18 +6412,31 @@ function ReferenceSelect({
|
|
|
5329
6412
|
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
5330
6413
|
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
5331
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(" ");
|
|
5332
6420
|
return {
|
|
5333
6421
|
value: val,
|
|
5334
|
-
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
6422
|
+
label: val && val !== lab && val.length < 20 ? `${lab} (${val})` : lab,
|
|
6423
|
+
searchText,
|
|
5335
6424
|
raw: r
|
|
5336
6425
|
};
|
|
5337
6426
|
});
|
|
5338
6427
|
setOptions(fromCollection);
|
|
5339
6428
|
setLoading(false);
|
|
5340
6429
|
}).catch((err) => {
|
|
5341
|
-
console.error(
|
|
6430
|
+
console.error(
|
|
6431
|
+
`Failed to load reference entries for ${collectionId}:`,
|
|
6432
|
+
err
|
|
6433
|
+
);
|
|
5342
6434
|
if (fallbackOptions && fallbackOptions.length > 0) {
|
|
5343
|
-
setOptions(
|
|
6435
|
+
setOptions(
|
|
6436
|
+
fallbackOptions.map(
|
|
6437
|
+
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
6438
|
+
)
|
|
6439
|
+
);
|
|
5344
6440
|
}
|
|
5345
6441
|
setLoading(false);
|
|
5346
6442
|
});
|
|
@@ -5354,85 +6450,67 @@ function ReferenceSelect({
|
|
|
5354
6450
|
}
|
|
5355
6451
|
return list;
|
|
5356
6452
|
}, [options, singleVal]);
|
|
5357
|
-
const canQuickCreate = Boolean(
|
|
6453
|
+
const canQuickCreate = Boolean(
|
|
6454
|
+
targetCol && targetCol.enableQuickCreate !== false
|
|
6455
|
+
);
|
|
5358
6456
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
5359
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
}
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
{
|
|
5417
|
-
type: "primary",
|
|
5418
|
-
size: "large",
|
|
5419
|
-
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-4 h-4" }),
|
|
5420
|
-
onClick: () => {
|
|
5421
|
-
setFormError("");
|
|
5422
|
-
const init = {};
|
|
5423
|
-
targetCol.fields.forEach((f) => {
|
|
5424
|
-
if (f.defaultValue !== void 0) init[f.id] = f.defaultValue;
|
|
5425
|
-
else if (f.type === "list" || f.multiple) init[f.id] = [""];
|
|
5426
|
-
else init[f.id] = "";
|
|
5427
|
-
});
|
|
5428
|
-
setNewRecord(init);
|
|
5429
|
-
setModalOpen(true);
|
|
5430
|
-
},
|
|
5431
|
-
className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
|
|
5432
|
-
children: targetCol.submitLabel || t.newBtn
|
|
5433
|
-
}
|
|
5434
|
-
)
|
|
5435
|
-
] }),
|
|
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
|
+
) }),
|
|
5436
6514
|
canQuickCreate && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5437
6515
|
import_antd.Modal,
|
|
5438
6516
|
{
|
|
@@ -5443,7 +6521,9 @@ function ReferenceSelect({
|
|
|
5443
6521
|
width: 650,
|
|
5444
6522
|
footer: null,
|
|
5445
6523
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pt-2 space-y-4", children: [
|
|
5446
|
-
/* @__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) => {
|
|
5447
6527
|
if (f.dependsOn && newRecord[f.dependsOn.field] !== void 0) {
|
|
5448
6528
|
const targetVal = f.dependsOn.value;
|
|
5449
6529
|
const currentVal = newRecord[f.dependsOn.field];
|
|
@@ -5472,7 +6552,10 @@ function ReferenceSelect({
|
|
|
5472
6552
|
onChange: (e) => {
|
|
5473
6553
|
const updated = [...currentList];
|
|
5474
6554
|
updated[idx] = e.target.value;
|
|
5475
|
-
setNewRecord((prev) => ({
|
|
6555
|
+
setNewRecord((prev) => ({
|
|
6556
|
+
...prev,
|
|
6557
|
+
[f.id]: updated
|
|
6558
|
+
}));
|
|
5476
6559
|
}
|
|
5477
6560
|
}
|
|
5478
6561
|
),
|
|
@@ -5481,7 +6564,9 @@ function ReferenceSelect({
|
|
|
5481
6564
|
{
|
|
5482
6565
|
type: "button",
|
|
5483
6566
|
onClick: () => {
|
|
5484
|
-
const updated = currentList.filter(
|
|
6567
|
+
const updated = currentList.filter(
|
|
6568
|
+
(_, i) => i !== idx
|
|
6569
|
+
);
|
|
5485
6570
|
setNewRecord((prev) => ({
|
|
5486
6571
|
...prev,
|
|
5487
6572
|
[f.id]: updated.length > 0 ? updated : [""]
|
|
@@ -5514,7 +6599,9 @@ function ReferenceSelect({
|
|
|
5514
6599
|
}
|
|
5515
6600
|
if (f.type === "select") {
|
|
5516
6601
|
const opts = f.optionsMap && f.dependsOnField ? f.optionsMap[String(newRecord[f.dependsOnField] || "")] || f.options || [] : f.options || [];
|
|
5517
|
-
const formattedOpts = opts.map(
|
|
6602
|
+
const formattedOpts = opts.map(
|
|
6603
|
+
(o) => typeof o === "string" ? { label: o, value: o } : o
|
|
6604
|
+
);
|
|
5518
6605
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: colSpanClass, children: [
|
|
5519
6606
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: f.label }),
|
|
5520
6607
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -5549,7 +6636,10 @@ function ReferenceSelect({
|
|
|
5549
6636
|
{
|
|
5550
6637
|
rows: 3,
|
|
5551
6638
|
value: newRecord[f.id] || "",
|
|
5552
|
-
onChange: (e) => setNewRecord((prev) => ({
|
|
6639
|
+
onChange: (e) => setNewRecord((prev) => ({
|
|
6640
|
+
...prev,
|
|
6641
|
+
[f.id]: e.target.value
|
|
6642
|
+
}))
|
|
5553
6643
|
}
|
|
5554
6644
|
)
|
|
5555
6645
|
] }, f.id);
|
|
@@ -5567,17 +6657,26 @@ function ReferenceSelect({
|
|
|
5567
6657
|
value: newRecord[f.id] || "",
|
|
5568
6658
|
placeholder: f.label,
|
|
5569
6659
|
onChange: (e) => {
|
|
5570
|
-
setNewRecord((prev) => ({
|
|
6660
|
+
setNewRecord((prev) => ({
|
|
6661
|
+
...prev,
|
|
6662
|
+
[f.id]: e.target.value
|
|
6663
|
+
}));
|
|
5571
6664
|
if (formError) setFormError("");
|
|
5572
6665
|
},
|
|
5573
6666
|
onBlur: (e) => {
|
|
5574
6667
|
if (f.unique) {
|
|
5575
6668
|
const clean = (e.target.value || "").trim().toLowerCase();
|
|
5576
6669
|
if (clean) {
|
|
5577
|
-
const dup = options.find(
|
|
6670
|
+
const dup = options.find(
|
|
6671
|
+
(opt) => String(opt.value || "").trim().toLowerCase() === clean
|
|
6672
|
+
);
|
|
5578
6673
|
if (dup) {
|
|
5579
|
-
setFormError(
|
|
5580
|
-
|
|
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
|
+
);
|
|
5581
6680
|
}
|
|
5582
6681
|
}
|
|
5583
6682
|
}
|
|
@@ -5629,11 +6728,24 @@ function ReferenceTableCell({
|
|
|
5629
6728
|
}).catch(() => {
|
|
5630
6729
|
setLabels(ids);
|
|
5631
6730
|
});
|
|
5632
|
-
}, [
|
|
6731
|
+
}, [
|
|
6732
|
+
collectionId,
|
|
6733
|
+
displayField,
|
|
6734
|
+
valueField,
|
|
6735
|
+
JSON.stringify(ids),
|
|
6736
|
+
ctx.adapter
|
|
6737
|
+
]);
|
|
5633
6738
|
if (labels.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "-" });
|
|
5634
6739
|
if (multiple || labels.length > 1) {
|
|
5635
6740
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-wrap gap-1 max-w-[260px]", children: [
|
|
5636
|
-
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
|
+
)),
|
|
5637
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: [
|
|
5638
6750
|
"+",
|
|
5639
6751
|
labels.length - 3
|
|
@@ -5902,6 +7014,7 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
5902
7014
|
0 && (module.exports = {
|
|
5903
7015
|
AdminApp,
|
|
5904
7016
|
AdminLogin,
|
|
7017
|
+
AdminTimeRangePicker,
|
|
5905
7018
|
CmsProvider,
|
|
5906
7019
|
EditableFile,
|
|
5907
7020
|
EditableImage,
|
|
@@ -5909,6 +7022,8 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
5909
7022
|
EditableList,
|
|
5910
7023
|
EditableReference,
|
|
5911
7024
|
EditableText,
|
|
7025
|
+
FormattedNumberInput,
|
|
7026
|
+
SearchableMultiSelect,
|
|
5912
7027
|
SubscriptionPage,
|
|
5913
7028
|
SubscriptionProvider,
|
|
5914
7029
|
generateDefaultTemplate,
|