admin-lib-cms 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1627 -616
- package/dist/index.mjs +1639 -616
- package/dist/types.d.mts +20 -2
- package/dist/types.d.ts +20 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -826,12 +826,196 @@ function EditableReference({
|
|
|
826
826
|
}
|
|
827
827
|
|
|
828
828
|
// src/admin/AdminApp.tsx
|
|
829
|
-
var import_react5 = require("react");
|
|
829
|
+
var import_react5 = __toESM(require("react"));
|
|
830
|
+
var import_react_dom = require("react-dom");
|
|
830
831
|
var import_antd = require("antd");
|
|
831
832
|
var import_dayjs = __toESM(require("dayjs"));
|
|
832
833
|
var import_lucide_react2 = require("lucide-react");
|
|
834
|
+
|
|
835
|
+
// src/admin/i18n.ts
|
|
836
|
+
var translations = {
|
|
837
|
+
es: {
|
|
838
|
+
menuDashboard: "Dashboard",
|
|
839
|
+
menuPages: "P\xE1ginas",
|
|
840
|
+
menuCollections: "Colecciones",
|
|
841
|
+
menuData: "Datos",
|
|
842
|
+
menuConfig: "Configuraci\xF3n",
|
|
843
|
+
menuSettings: "Ajustes",
|
|
844
|
+
menuSubscription: "Suscripci\xF3n",
|
|
845
|
+
liveEditor: "Editor en vivo",
|
|
846
|
+
viewSite: "Ver sitio",
|
|
847
|
+
signOut: "Cerrar sesi\xF3n",
|
|
848
|
+
signedInAs: "Conectado como",
|
|
849
|
+
saving: "Guardando...",
|
|
850
|
+
saved: "Guardado",
|
|
851
|
+
saveChanges: "Guardar cambios",
|
|
852
|
+
discardChanges: "Descartar",
|
|
853
|
+
unsavedChanges: "Cambios sin guardar",
|
|
854
|
+
desktop: "Escritorio",
|
|
855
|
+
tablet: "Tableta",
|
|
856
|
+
mobile: "M\xF3vil",
|
|
857
|
+
search: "Buscar...",
|
|
858
|
+
filterBy: "Filtrar por...",
|
|
859
|
+
all: "Todos",
|
|
860
|
+
actions: "Acciones",
|
|
861
|
+
edit: "Editar",
|
|
862
|
+
delete: "Eliminar",
|
|
863
|
+
cancel: "Cancelar",
|
|
864
|
+
save: "Guardar",
|
|
865
|
+
create: "Crear",
|
|
866
|
+
newEntry: "Nuevo",
|
|
867
|
+
createNew: "Crear nuevo",
|
|
868
|
+
confirmDeleteTitle: "\xBFEliminar este registro?",
|
|
869
|
+
confirmDeleteText: "Esta acci\xF3n no se puede deshacer.",
|
|
870
|
+
deleteSuccess: "Registro eliminado exitosamente.",
|
|
871
|
+
saveSuccess: "Registro guardado exitosamente.",
|
|
872
|
+
noRecords: "No hay registros disponibles.",
|
|
873
|
+
recordsFound: "registros encontrados",
|
|
874
|
+
back: "Volver",
|
|
875
|
+
apply: "Aplicar",
|
|
876
|
+
close: "Cerrar",
|
|
877
|
+
signatureRegistered: "Firma registrada",
|
|
878
|
+
viewLarger: "Click en la firma para verla en pantalla grande",
|
|
879
|
+
previewMask: "Ver m\xE1s grande",
|
|
880
|
+
addSignature: "AGREGAR FIRMA",
|
|
881
|
+
replaceSignature: "REEMPLAZAR FIRMA",
|
|
882
|
+
uploadImage: "SUBIR IMAGEN",
|
|
883
|
+
uploadNewImage: "SUBIR NUEVA IMAGEN",
|
|
884
|
+
signOnScreen: "Firmar en pantalla",
|
|
885
|
+
signInstructions: "Dibuja la firma en el recuadro usando el dedo o el mouse:",
|
|
886
|
+
clear: "Limpiar",
|
|
887
|
+
saveSignature: "Guardar Firma",
|
|
888
|
+
selectOption: "-- Selecciona una opci\xF3n --",
|
|
889
|
+
loadingOptions: "Cargando opciones...",
|
|
890
|
+
cantFindClient: "\xBFNo encuentras el cliente?",
|
|
891
|
+
createClient: "Crear cliente",
|
|
892
|
+
newBtn: "Nuevo",
|
|
893
|
+
basicDetails: "Datos b\xE1sicos",
|
|
894
|
+
clientType: "Tipo",
|
|
895
|
+
clientDocType: "Tipo de documento",
|
|
896
|
+
clientIdentification: "Identificaci\xF3n",
|
|
897
|
+
clientBranch: "Sucursal o sede",
|
|
898
|
+
clientName: "Nombre",
|
|
899
|
+
clientEmail: "Email",
|
|
900
|
+
clientPhone: "Tel\xE9fono",
|
|
901
|
+
clientCity: "Ciudad",
|
|
902
|
+
clientAddress: "direcci\xF3n",
|
|
903
|
+
clientCreatedSuccess: "Cliente creado y seleccionado exitosamente.",
|
|
904
|
+
idRequired: "La identificaci\xF3n es obligatoria.",
|
|
905
|
+
nameRequired: "El nombre es obligatorio.",
|
|
906
|
+
signInTitle: "Iniciar sesi\xF3n",
|
|
907
|
+
signInSubtitle: "Ingresa tus credenciales para acceder al panel",
|
|
908
|
+
emailLabel: "Correo electr\xF3nico",
|
|
909
|
+
passwordLabel: "Contrase\xF1a",
|
|
910
|
+
signInButton: "Iniciar sesi\xF3n",
|
|
911
|
+
invalidCredentials: "Credenciales inv\xE1lidas",
|
|
912
|
+
loggingIn: "Iniciando sesi\xF3n...",
|
|
913
|
+
submissions: "Mensajes y Formularios",
|
|
914
|
+
noSubmissions: "No hay env\xEDos registrados",
|
|
915
|
+
exportCsv: "Exportar CSV",
|
|
916
|
+
markRead: "Marcar como le\xEDdo",
|
|
917
|
+
settingsTitle: "Ajustes del sitio",
|
|
918
|
+
entries: "registros"
|
|
919
|
+
},
|
|
920
|
+
en: {
|
|
921
|
+
menuDashboard: "Dashboard",
|
|
922
|
+
menuPages: "Pages",
|
|
923
|
+
menuCollections: "Collections",
|
|
924
|
+
menuData: "Data",
|
|
925
|
+
menuConfig: "Settings",
|
|
926
|
+
menuSettings: "Preferences",
|
|
927
|
+
menuSubscription: "Subscription",
|
|
928
|
+
liveEditor: "Live Editor",
|
|
929
|
+
viewSite: "View site",
|
|
930
|
+
signOut: "Sign out",
|
|
931
|
+
signedInAs: "Signed in as",
|
|
932
|
+
saving: "Saving...",
|
|
933
|
+
saved: "Saved",
|
|
934
|
+
saveChanges: "Save changes",
|
|
935
|
+
discardChanges: "Discard",
|
|
936
|
+
unsavedChanges: "Unsaved changes",
|
|
937
|
+
desktop: "Desktop",
|
|
938
|
+
tablet: "Tablet",
|
|
939
|
+
mobile: "Mobile",
|
|
940
|
+
search: "Search...",
|
|
941
|
+
filterBy: "Filter by...",
|
|
942
|
+
all: "All",
|
|
943
|
+
actions: "Actions",
|
|
944
|
+
edit: "Edit",
|
|
945
|
+
delete: "Delete",
|
|
946
|
+
cancel: "Cancel",
|
|
947
|
+
save: "Save",
|
|
948
|
+
create: "Create",
|
|
949
|
+
newEntry: "New",
|
|
950
|
+
createNew: "Create new",
|
|
951
|
+
confirmDeleteTitle: "Delete this record?",
|
|
952
|
+
confirmDeleteText: "This action cannot be undone.",
|
|
953
|
+
deleteSuccess: "Record deleted successfully.",
|
|
954
|
+
saveSuccess: "Record saved successfully.",
|
|
955
|
+
noRecords: "No records found.",
|
|
956
|
+
recordsFound: "records found",
|
|
957
|
+
back: "Back",
|
|
958
|
+
apply: "Apply",
|
|
959
|
+
close: "Close",
|
|
960
|
+
signatureRegistered: "Signature registered",
|
|
961
|
+
viewLarger: "Click signature to view full size",
|
|
962
|
+
previewMask: "View larger",
|
|
963
|
+
addSignature: "ADD SIGNATURE",
|
|
964
|
+
replaceSignature: "REPLACE SIGNATURE",
|
|
965
|
+
uploadImage: "UPLOAD IMAGE",
|
|
966
|
+
uploadNewImage: "UPLOAD NEW IMAGE",
|
|
967
|
+
signOnScreen: "Sign on screen",
|
|
968
|
+
signInstructions: "Draw signature in the box using finger or mouse:",
|
|
969
|
+
clear: "Clear",
|
|
970
|
+
saveSignature: "Save Signature",
|
|
971
|
+
selectOption: "-- Select an option --",
|
|
972
|
+
loadingOptions: "Loading options...",
|
|
973
|
+
cantFindClient: "Can't find the client?",
|
|
974
|
+
createClient: "Create client",
|
|
975
|
+
newBtn: "New",
|
|
976
|
+
basicDetails: "Basic details",
|
|
977
|
+
clientType: "Type",
|
|
978
|
+
clientDocType: "Document type",
|
|
979
|
+
clientIdentification: "Identification",
|
|
980
|
+
clientBranch: "Branch or site",
|
|
981
|
+
clientName: "Name",
|
|
982
|
+
clientEmail: "Email",
|
|
983
|
+
clientPhone: "Phone",
|
|
984
|
+
clientCity: "City",
|
|
985
|
+
clientAddress: "Address",
|
|
986
|
+
clientCreatedSuccess: "Client created and selected successfully.",
|
|
987
|
+
idRequired: "Identification is required.",
|
|
988
|
+
nameRequired: "Name is required.",
|
|
989
|
+
signInTitle: "Sign In",
|
|
990
|
+
signInSubtitle: "Enter your credentials to access the panel",
|
|
991
|
+
emailLabel: "Email address",
|
|
992
|
+
passwordLabel: "Password",
|
|
993
|
+
signInButton: "Sign In",
|
|
994
|
+
invalidCredentials: "Invalid credentials",
|
|
995
|
+
loggingIn: "Signing in...",
|
|
996
|
+
submissions: "Form Submissions",
|
|
997
|
+
noSubmissions: "No submissions yet",
|
|
998
|
+
exportCsv: "Export CSV",
|
|
999
|
+
markRead: "Mark as read",
|
|
1000
|
+
settingsTitle: "Site Settings",
|
|
1001
|
+
entries: "entries"
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
function getAdminTranslations(locale) {
|
|
1005
|
+
const norm = String(locale || "").trim().toLowerCase();
|
|
1006
|
+
if (norm === "es" || norm.startsWith("es-")) {
|
|
1007
|
+
return translations.es;
|
|
1008
|
+
}
|
|
1009
|
+
return translations.en;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// src/admin/AdminApp.tsx
|
|
833
1013
|
var import_lucide_react3 = require("lucide-react");
|
|
834
1014
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1015
|
+
var AdminI18nContext = import_react5.default.createContext(getAdminTranslations("en"));
|
|
1016
|
+
function useAdminI18n() {
|
|
1017
|
+
return import_react5.default.useContext(AdminI18nContext);
|
|
1018
|
+
}
|
|
835
1019
|
var TIME_STORAGE_FORMAT = "HH:mm";
|
|
836
1020
|
var TIME_DISPLAY_FORMAT = "h:mm A";
|
|
837
1021
|
var TIME_PICKER_THEME = {
|
|
@@ -872,23 +1056,24 @@ function AdminTimeRangePicker(props) {
|
|
|
872
1056
|
}
|
|
873
1057
|
) });
|
|
874
1058
|
}
|
|
875
|
-
function AdminTimePicker(props) {
|
|
876
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
877
|
-
import_antd.TimePicker,
|
|
878
|
-
{
|
|
879
|
-
...props,
|
|
880
|
-
className: `w-full min-w-0 ${props.className ?? ""}`,
|
|
881
|
-
style: {
|
|
882
|
-
boxShadow: "0 1px 2px rgba(15, 23, 42, 0.08)",
|
|
883
|
-
...props.style
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
) });
|
|
887
|
-
}
|
|
888
1059
|
function toDayjsTime(value) {
|
|
889
|
-
const
|
|
890
|
-
if (!
|
|
891
|
-
|
|
1060
|
+
const str = String(value ?? "").trim();
|
|
1061
|
+
if (!str) return null;
|
|
1062
|
+
const match12 = /^(\d{1,2}):(\d{2})\s*([ap]\.?m\.?)$/i.exec(str);
|
|
1063
|
+
if (match12) {
|
|
1064
|
+
let h = Number(match12[1]);
|
|
1065
|
+
const m = Number(match12[2]);
|
|
1066
|
+
const isPm = match12[3].toLowerCase().startsWith("p");
|
|
1067
|
+
if (isPm && h < 12) h += 12;
|
|
1068
|
+
if (!isPm && h === 12) h = 0;
|
|
1069
|
+
return (0, import_dayjs.default)().hour(h).minute(m).second(0).millisecond(0);
|
|
1070
|
+
}
|
|
1071
|
+
const match24 = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(str);
|
|
1072
|
+
if (match24) {
|
|
1073
|
+
return (0, import_dayjs.default)().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
|
|
1074
|
+
}
|
|
1075
|
+
const parsed = (0, import_dayjs.default)(str, ["h:mm a", "h:mm A", "hh:mm a", "hh:mm A", "HH:mm"]);
|
|
1076
|
+
return parsed.isValid() ? parsed : null;
|
|
892
1077
|
}
|
|
893
1078
|
function toStoredTime(value) {
|
|
894
1079
|
return value?.format(TIME_STORAGE_FORMAT) ?? "";
|
|
@@ -949,6 +1134,8 @@ function AdminApp(props) {
|
|
|
949
1134
|
}
|
|
950
1135
|
function AdminAppContent(props) {
|
|
951
1136
|
const ctx = useCmsContext();
|
|
1137
|
+
const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
|
|
1138
|
+
const t = (0, import_react5.useMemo)(() => getAdminTranslations(rawLocale), [rawLocale]);
|
|
952
1139
|
const hasDashboard = Boolean(props.dashboard);
|
|
953
1140
|
const [section, setSection] = (0, import_react5.useState)(hasDashboard ? "dashboard" : "pages");
|
|
954
1141
|
const [authChecking, setAuthChecking] = (0, import_react5.useState)(true);
|
|
@@ -958,13 +1145,13 @@ function AdminAppContent(props) {
|
|
|
958
1145
|
const hideGlobals = props.hideGlobals ?? ctx.config.hideGlobals ?? false;
|
|
959
1146
|
const hideConfig = props.hideConfig ?? ctx.config.hideConfig ?? false;
|
|
960
1147
|
const menuLabels = {
|
|
961
|
-
dashboard:
|
|
962
|
-
pages:
|
|
963
|
-
collections:
|
|
964
|
-
data:
|
|
965
|
-
config:
|
|
966
|
-
settings:
|
|
967
|
-
subscription:
|
|
1148
|
+
dashboard: t.menuDashboard,
|
|
1149
|
+
pages: t.menuPages,
|
|
1150
|
+
collections: t.menuCollections,
|
|
1151
|
+
data: t.menuData,
|
|
1152
|
+
config: t.menuConfig,
|
|
1153
|
+
settings: t.menuSettings,
|
|
1154
|
+
subscription: t.menuSubscription,
|
|
968
1155
|
...ctx.config.menuLabels,
|
|
969
1156
|
...props.menuLabels
|
|
970
1157
|
};
|
|
@@ -1000,7 +1187,7 @@ function AdminAppContent(props) {
|
|
|
1000
1187
|
if (!isSubscriptionActive) {
|
|
1001
1188
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-col lg:flex-row h-screen w-full overflow-hidden bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}) });
|
|
1002
1189
|
}
|
|
1003
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
|
|
1190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminI18nContext.Provider, { value: t, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
|
|
1004
1191
|
daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-amber-400 text-amber-950 px-4 py-2.5 text-center text-sm font-semibold shadow-sm z-50", children: "Your account has an overdue balance. Please update your payment." }),
|
|
1005
1192
|
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." }),
|
|
1006
1193
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
|
|
@@ -1016,71 +1203,155 @@ function AdminAppContent(props) {
|
|
|
1016
1203
|
] }),
|
|
1017
1204
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
|
|
1018
1205
|
] }),
|
|
1019
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: (() => {
|
|
1207
|
+
const navItemsMap = /* @__PURE__ */ new Map();
|
|
1208
|
+
if (hasDashboard) {
|
|
1209
|
+
navItemsMap.set(
|
|
1210
|
+
"dashboard",
|
|
1211
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1212
|
+
SideItem,
|
|
1213
|
+
{
|
|
1214
|
+
active: section === "dashboard",
|
|
1215
|
+
onClick: () => setSection("dashboard"),
|
|
1216
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.BarChart3, { className: "h-4 w-4 shrink-0" }),
|
|
1217
|
+
children: menuLabels.dashboard
|
|
1218
|
+
},
|
|
1219
|
+
"dashboard"
|
|
1220
|
+
)
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
navItemsMap.set(
|
|
1224
|
+
"pages",
|
|
1225
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1226
|
+
SideItem,
|
|
1227
|
+
{
|
|
1228
|
+
active: section === "pages",
|
|
1229
|
+
onClick: () => setSection("pages"),
|
|
1230
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
|
|
1231
|
+
children: menuLabels.pages
|
|
1232
|
+
},
|
|
1233
|
+
"pages"
|
|
1234
|
+
)
|
|
1235
|
+
);
|
|
1236
|
+
navItemsMap.set(
|
|
1237
|
+
"collections",
|
|
1238
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1239
|
+
SideItem,
|
|
1240
|
+
{
|
|
1241
|
+
active: section === "collections",
|
|
1242
|
+
onClick: () => setSection("collections"),
|
|
1243
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
|
|
1244
|
+
children: menuLabels.collections
|
|
1245
|
+
},
|
|
1246
|
+
"collections"
|
|
1247
|
+
)
|
|
1248
|
+
);
|
|
1249
|
+
props.customSections?.forEach((cs) => {
|
|
1250
|
+
navItemsMap.set(
|
|
1251
|
+
cs.id,
|
|
1252
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1253
|
+
SideItem,
|
|
1254
|
+
{
|
|
1255
|
+
active: section === cs.id,
|
|
1256
|
+
onClick: () => setSection(cs.id),
|
|
1257
|
+
icon: cs.icon || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
|
|
1258
|
+
children: cs.label
|
|
1259
|
+
},
|
|
1260
|
+
cs.id
|
|
1261
|
+
)
|
|
1262
|
+
);
|
|
1263
|
+
});
|
|
1264
|
+
if (!hideData) {
|
|
1265
|
+
navItemsMap.set(
|
|
1266
|
+
"submissions",
|
|
1267
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1268
|
+
SideItem,
|
|
1269
|
+
{
|
|
1270
|
+
active: section === "submissions",
|
|
1271
|
+
onClick: () => setSection("submissions"),
|
|
1272
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
|
|
1273
|
+
children: menuLabels.data
|
|
1274
|
+
},
|
|
1275
|
+
"submissions"
|
|
1276
|
+
)
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
if (!hideConfig && !hideGlobals) {
|
|
1280
|
+
navItemsMap.set(
|
|
1281
|
+
"config",
|
|
1282
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1283
|
+
SideItem,
|
|
1284
|
+
{
|
|
1285
|
+
active: section === "config",
|
|
1286
|
+
onClick: () => setSection("config"),
|
|
1287
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
|
|
1288
|
+
children: menuLabels.config
|
|
1289
|
+
},
|
|
1290
|
+
"config"
|
|
1291
|
+
)
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
if (!hideSettings) {
|
|
1295
|
+
navItemsMap.set(
|
|
1296
|
+
"settings",
|
|
1297
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1298
|
+
SideItem,
|
|
1299
|
+
{
|
|
1300
|
+
active: section === "settings",
|
|
1301
|
+
onClick: () => setSection("settings"),
|
|
1302
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
|
|
1303
|
+
children: menuLabels.settings
|
|
1304
|
+
},
|
|
1305
|
+
"settings"
|
|
1306
|
+
)
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
if (subscriptionCtx) {
|
|
1310
|
+
navItemsMap.set(
|
|
1311
|
+
"subscription",
|
|
1312
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1313
|
+
SideItem,
|
|
1314
|
+
{
|
|
1315
|
+
active: section === "subscription",
|
|
1316
|
+
onClick: () => setSection("subscription"),
|
|
1317
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
|
|
1318
|
+
children: menuLabels.subscription
|
|
1319
|
+
},
|
|
1320
|
+
"subscription"
|
|
1321
|
+
)
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
const orderedKeys = [];
|
|
1325
|
+
if (props.menuOrder && Array.isArray(props.menuOrder) && props.menuOrder.length > 0) {
|
|
1326
|
+
props.menuOrder.forEach((k) => {
|
|
1327
|
+
if (navItemsMap.has(k) && !orderedKeys.includes(k)) {
|
|
1328
|
+
orderedKeys.push(k);
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
navItemsMap.forEach((_, k) => {
|
|
1332
|
+
if (!orderedKeys.includes(k)) {
|
|
1333
|
+
orderedKeys.push(k);
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
} else {
|
|
1337
|
+
const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
|
|
1338
|
+
const bottomCustom = (props.customSections || []).filter((cs) => cs.position === "bottom" || cs.position === "after-collections").map((cs) => cs.id);
|
|
1339
|
+
const otherCustom = (props.customSections || []).filter(
|
|
1340
|
+
(cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
|
|
1341
|
+
).map((cs) => cs.id);
|
|
1342
|
+
if (hasDashboard) orderedKeys.push("dashboard");
|
|
1343
|
+
topCustom.forEach((k) => orderedKeys.push(k));
|
|
1344
|
+
orderedKeys.push("pages");
|
|
1345
|
+
orderedKeys.push("collections");
|
|
1346
|
+
otherCustom.forEach((k) => orderedKeys.push(k));
|
|
1347
|
+
bottomCustom.forEach((k) => orderedKeys.push(k));
|
|
1348
|
+
if (!hideData) orderedKeys.push("submissions");
|
|
1349
|
+
if (!hideConfig && !hideGlobals) orderedKeys.push("config");
|
|
1350
|
+
if (!hideSettings) orderedKeys.push("settings");
|
|
1351
|
+
if (subscriptionCtx) orderedKeys.push("subscription");
|
|
1352
|
+
}
|
|
1353
|
+
return orderedKeys.map((k) => navItemsMap.get(k));
|
|
1354
|
+
})() }),
|
|
1084
1355
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1085
1356
|
"button",
|
|
1086
1357
|
{
|
|
@@ -1091,7 +1362,7 @@ function AdminAppContent(props) {
|
|
|
1091
1362
|
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",
|
|
1092
1363
|
children: [
|
|
1093
1364
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.LogOut, { className: "w-4 h-4" }),
|
|
1094
|
-
|
|
1365
|
+
t.signOut
|
|
1095
1366
|
]
|
|
1096
1367
|
}
|
|
1097
1368
|
) })
|
|
@@ -1103,10 +1374,13 @@ function AdminAppContent(props) {
|
|
|
1103
1374
|
!hideData && section === "submissions" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubmissionsSection, {}),
|
|
1104
1375
|
!hideConfig && !hideGlobals && section === "config" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ConfigSection, {}),
|
|
1105
1376
|
!hideSettings && section === "settings" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsSection, {}),
|
|
1106
|
-
section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {})
|
|
1377
|
+
section === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}),
|
|
1378
|
+
props.customSections?.map(
|
|
1379
|
+
(cs) => section === cs.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1 overflow-y-auto", children: typeof cs.component === "function" ? (0, import_react5.createElement)(cs.component) : cs.component }, cs.id) : null
|
|
1380
|
+
)
|
|
1107
1381
|
] })
|
|
1108
1382
|
] })
|
|
1109
|
-
] });
|
|
1383
|
+
] }) });
|
|
1110
1384
|
}
|
|
1111
1385
|
function SideItem({
|
|
1112
1386
|
active,
|
|
@@ -1215,6 +1489,7 @@ function PagesSection() {
|
|
|
1215
1489
|
}
|
|
1216
1490
|
function PageEditor({ page, showList, onToggleList }) {
|
|
1217
1491
|
const ctx = useCmsContext();
|
|
1492
|
+
const t = useAdminI18n();
|
|
1218
1493
|
const iframeRef = (0, import_react5.useRef)(null);
|
|
1219
1494
|
const [registered, setRegistered] = (0, import_react5.useState)([]);
|
|
1220
1495
|
const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
|
|
@@ -1308,7 +1583,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1308
1583
|
className: "inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 hover:text-slate-900 disabled:opacity-50 transition-colors bg-white shadow-sm shrink-0",
|
|
1309
1584
|
children: [
|
|
1310
1585
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-3.5 w-3.5" }),
|
|
1311
|
-
|
|
1586
|
+
t.discardChanges
|
|
1312
1587
|
]
|
|
1313
1588
|
}
|
|
1314
1589
|
),
|
|
@@ -1320,7 +1595,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
1320
1595
|
className: "inline-flex items-center gap-1.5 rounded-lg bg-indigo-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-indigo-700 disabled:opacity-50 transition-colors shadow-sm shrink-0",
|
|
1321
1596
|
children: [
|
|
1322
1597
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-3.5 w-3.5" }),
|
|
1323
|
-
|
|
1598
|
+
t.save
|
|
1324
1599
|
]
|
|
1325
1600
|
}
|
|
1326
1601
|
)
|
|
@@ -2153,13 +2428,18 @@ function CollectionsSection() {
|
|
|
2153
2428
|
collections.find((c) => !c.isSeparator) ?? null
|
|
2154
2429
|
);
|
|
2155
2430
|
const [counts, setCounts] = (0, import_react5.useState)({});
|
|
2431
|
+
const colIds = (0, import_react5.useMemo)(
|
|
2432
|
+
() => (ctx.config.collections ?? []).filter((c) => !c.isSeparator).map((c) => c.id).join(","),
|
|
2433
|
+
[ctx.config.collections]
|
|
2434
|
+
);
|
|
2156
2435
|
(0, import_react5.useEffect)(() => {
|
|
2157
|
-
|
|
2436
|
+
const list = ctx.config.collections ?? [];
|
|
2437
|
+
list.filter((c) => !c.isSeparator).forEach((c) => {
|
|
2158
2438
|
ctx.adapter.listEntries(c.id).then((entries) => {
|
|
2159
|
-
setCounts((prev) =>
|
|
2439
|
+
setCounts((prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length });
|
|
2160
2440
|
});
|
|
2161
2441
|
});
|
|
2162
|
-
}, [ctx.adapter,
|
|
2442
|
+
}, [ctx.adapter, colIds, ctx.collectionChangedAt]);
|
|
2163
2443
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
|
|
2164
2444
|
/* @__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: [
|
|
2165
2445
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
|
|
@@ -2169,7 +2449,8 @@ function CollectionsSection() {
|
|
|
2169
2449
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2170
2450
|
"li",
|
|
2171
2451
|
{
|
|
2172
|
-
className: "my-
|
|
2452
|
+
className: "my-3 border-t border-slate-200/80 pt-2 px-1 list-none",
|
|
2453
|
+
children: c.name && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400", children: c.name })
|
|
2173
2454
|
},
|
|
2174
2455
|
c.id || `sep-${idx}`
|
|
2175
2456
|
);
|
|
@@ -2212,6 +2493,7 @@ function CollectionsSection() {
|
|
|
2212
2493
|
}
|
|
2213
2494
|
function CollectionEditor({ collection }) {
|
|
2214
2495
|
const ctx = useCmsContext();
|
|
2496
|
+
const t = useAdminI18n();
|
|
2215
2497
|
const [entries, setEntries] = (0, import_react5.useState)([]);
|
|
2216
2498
|
const [editing, setEditing] = (0, import_react5.useState)(null);
|
|
2217
2499
|
const [saving, setSaving] = (0, import_react5.useState)(false);
|
|
@@ -2273,6 +2555,16 @@ function CollectionEditor({ collection }) {
|
|
|
2273
2555
|
try {
|
|
2274
2556
|
const finalEditing = { ...editing };
|
|
2275
2557
|
collection.fields.forEach((f) => {
|
|
2558
|
+
if (f.autoIncrement && isCreatingEntry && (!finalEditing[f.id] || Number(finalEditing[f.id]) === 0)) {
|
|
2559
|
+
const maxVal = entries.reduce(
|
|
2560
|
+
(max, e) => Math.max(max, Number(e[f.id]) || 0),
|
|
2561
|
+
0
|
|
2562
|
+
);
|
|
2563
|
+
finalEditing[f.id] = maxVal > 0 ? maxVal + 1 : 1;
|
|
2564
|
+
}
|
|
2565
|
+
if (f.id === "estado" && !finalEditing[f.id]) {
|
|
2566
|
+
finalEditing[f.id] = "Nueva";
|
|
2567
|
+
}
|
|
2276
2568
|
if (f.type === "time-range") {
|
|
2277
2569
|
delete finalEditing[f.id];
|
|
2278
2570
|
} else if (f.type === "slug" && !finalEditing[f.id]) {
|
|
@@ -2328,6 +2620,7 @@ function CollectionEditor({ collection }) {
|
|
|
2328
2620
|
newEntries[i].order = i;
|
|
2329
2621
|
await ctx.adapter.putEntry(collection.id, newEntries[i]);
|
|
2330
2622
|
}
|
|
2623
|
+
ctx.notifyCollectionChanged();
|
|
2331
2624
|
};
|
|
2332
2625
|
const onDragEnd = (e) => {
|
|
2333
2626
|
const target = e.target;
|
|
@@ -2335,7 +2628,7 @@ function CollectionEditor({ collection }) {
|
|
|
2335
2628
|
setDraggedIdx(null);
|
|
2336
2629
|
setDragOverIdx(null);
|
|
2337
2630
|
};
|
|
2338
|
-
const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0,
|
|
2631
|
+
const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 6);
|
|
2339
2632
|
const isCreatingEntry = editing ? !entries.some((entry) => entry.id === editing.id) : false;
|
|
2340
2633
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mx-auto max-w-5xl", children: [
|
|
2341
2634
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
@@ -2343,69 +2636,110 @@ function CollectionEditor({ collection }) {
|
|
|
2343
2636
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
|
|
2344
2637
|
collection.description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
|
|
2345
2638
|
] }),
|
|
2346
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
2347
|
-
|
|
2639
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2640
|
+
import_antd.Button,
|
|
2348
2641
|
{
|
|
2642
|
+
type: "primary",
|
|
2643
|
+
size: "large",
|
|
2644
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
|
|
2349
2645
|
onClick: startNew,
|
|
2350
|
-
className: "
|
|
2351
|
-
children:
|
|
2352
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
|
|
2353
|
-
" New Entry"
|
|
2354
|
-
]
|
|
2646
|
+
className: "rounded-xl font-bold shadow-sm",
|
|
2647
|
+
children: t.newEntry
|
|
2355
2648
|
}
|
|
2356
2649
|
)
|
|
2357
2650
|
] }),
|
|
2358
2651
|
!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: [
|
|
2359
|
-
collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
"
|
|
2363
|
-
{
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
] }) : null,
|
|
2652
|
+
collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "relative flex-1 min-w-[220px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2653
|
+
import_antd.Input,
|
|
2654
|
+
{
|
|
2655
|
+
size: "large",
|
|
2656
|
+
prefix: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "h-4 w-4 text-slate-400" }),
|
|
2657
|
+
placeholder: `Buscar por ${collection.searchBy.map((s) => s === "numero" ? "n\xFAmero" : s === "clienteNombre" ? "cliente" : s === "clienteId" ? "identificaci\xF3n" : s === "fecha" ? "fecha" : s).join(", ")}...`,
|
|
2658
|
+
value: search,
|
|
2659
|
+
allowClear: true,
|
|
2660
|
+
onChange: (e) => {
|
|
2661
|
+
setSearch(e.target.value);
|
|
2662
|
+
setPage(1);
|
|
2663
|
+
},
|
|
2664
|
+
className: "rounded-xl"
|
|
2665
|
+
}
|
|
2666
|
+
) }) : null,
|
|
2375
2667
|
collection.filterBy?.map((f) => {
|
|
2376
2668
|
const fieldDef = collection.fields.find((cf) => cf.id === f);
|
|
2377
|
-
|
|
2378
|
-
if (
|
|
2379
|
-
|
|
2380
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
2381
|
-
|
|
2669
|
+
if (!fieldDef) return null;
|
|
2670
|
+
if (fieldDef.type === "date") {
|
|
2671
|
+
const dateVal = filters[f] ? (0, import_dayjs.default)(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]).isValid() ? (0, import_dayjs.default)(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]) : null : null;
|
|
2672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[180px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2673
|
+
import_antd.DatePicker,
|
|
2382
2674
|
{
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2675
|
+
size: "large",
|
|
2676
|
+
format: "YYYY/MM/DD",
|
|
2677
|
+
placeholder: `Filtrar por ${fieldDef.label}`,
|
|
2678
|
+
allowClear: true,
|
|
2679
|
+
value: dateVal,
|
|
2680
|
+
onChange: (_, dateStr) => {
|
|
2681
|
+
const val = Array.isArray(dateStr) ? dateStr[0] : dateStr;
|
|
2682
|
+
setFilters((prev) => ({ ...prev, [f]: val || "" }));
|
|
2386
2683
|
setPage(1);
|
|
2387
2684
|
},
|
|
2388
|
-
className: "w-full rounded-xl
|
|
2389
|
-
children: [
|
|
2390
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
|
|
2391
|
-
"All ",
|
|
2392
|
-
fieldDef.label
|
|
2393
|
-
] }),
|
|
2394
|
-
uniqueVals.map((v) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: v, children: v }, v))
|
|
2395
|
-
]
|
|
2685
|
+
className: "w-full rounded-xl"
|
|
2396
2686
|
}
|
|
2397
|
-
),
|
|
2398
|
-
|
|
2399
|
-
|
|
2687
|
+
) }, f);
|
|
2688
|
+
}
|
|
2689
|
+
const predefinedOptions = (fieldDef.options || []).map(
|
|
2690
|
+
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
2691
|
+
);
|
|
2692
|
+
const entryVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
|
|
2693
|
+
const combinedOptions = [...predefinedOptions];
|
|
2694
|
+
for (const ev of entryVals) {
|
|
2695
|
+
if (!combinedOptions.some((o) => o.value === ev)) {
|
|
2696
|
+
combinedOptions.push({ value: ev, label: ev });
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[170px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2700
|
+
import_antd.Select,
|
|
2701
|
+
{
|
|
2702
|
+
size: "large",
|
|
2703
|
+
value: filters[f] || void 0,
|
|
2704
|
+
placeholder: `Filtrar por ${fieldDef.label}`,
|
|
2705
|
+
allowClear: true,
|
|
2706
|
+
onChange: (v) => {
|
|
2707
|
+
setFilters((prev) => ({ ...prev, [f]: v || "" }));
|
|
2708
|
+
setPage(1);
|
|
2709
|
+
},
|
|
2710
|
+
options: combinedOptions,
|
|
2711
|
+
className: "w-full"
|
|
2712
|
+
}
|
|
2713
|
+
) }, f);
|
|
2400
2714
|
})
|
|
2401
2715
|
] }),
|
|
2402
2716
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2403
2717
|
import_antd.Modal,
|
|
2404
2718
|
{
|
|
2405
2719
|
open: Boolean(editing),
|
|
2406
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("
|
|
2407
|
-
|
|
2408
|
-
|
|
2720
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pr-8", children: [
|
|
2721
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 text-slate-900 font-bold", children: [
|
|
2722
|
+
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" }),
|
|
2723
|
+
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}`
|
|
2724
|
+
] }),
|
|
2725
|
+
!isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2726
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
|
|
2727
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2728
|
+
import_antd.Select,
|
|
2729
|
+
{
|
|
2730
|
+
size: "middle",
|
|
2731
|
+
value: String(editing.estado || "Nueva"),
|
|
2732
|
+
onChange: (val) => setEditing({ ...editing, estado: val }),
|
|
2733
|
+
options: [
|
|
2734
|
+
{ value: "Nueva", label: "Nueva" },
|
|
2735
|
+
{ value: "Proceso", label: "Proceso" },
|
|
2736
|
+
{ value: "Terminado", label: "Terminado" },
|
|
2737
|
+
{ value: "Cancelado", label: "Cancelado" }
|
|
2738
|
+
],
|
|
2739
|
+
className: "w-32"
|
|
2740
|
+
}
|
|
2741
|
+
)
|
|
2742
|
+
] })
|
|
2409
2743
|
] }),
|
|
2410
2744
|
onCancel: () => {
|
|
2411
2745
|
if (!saving) setEditing(null);
|
|
@@ -2429,445 +2763,556 @@ function CollectionEditor({ collection }) {
|
|
|
2429
2763
|
backdropFilter: "blur(8px)"
|
|
2430
2764
|
}
|
|
2431
2765
|
},
|
|
2432
|
-
children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
|
|
2433
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
{
|
|
2441
|
-
|
|
2442
|
-
value: editing[f.id],
|
|
2443
|
-
globalPrice: Number(editing.price) || 0,
|
|
2444
|
-
globalDiscount: Number(editing.discountPercent) || 0,
|
|
2445
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2446
|
-
}
|
|
2447
|
-
) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mt-1 h-10 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2448
|
-
"input",
|
|
2449
|
-
{
|
|
2450
|
-
type: "checkbox",
|
|
2451
|
-
checked: !!editing[f.id],
|
|
2452
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
|
|
2453
|
-
className: "w-5 h-5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500"
|
|
2454
|
-
}
|
|
2455
|
-
) }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2456
|
-
FormattedNumberInput,
|
|
2457
|
-
{
|
|
2458
|
-
value: editing[f.id],
|
|
2459
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2460
|
-
isPrice: f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.toLowerCase().includes("valor") || f.label.includes("$"),
|
|
2461
|
-
isPercent: f.id.toLowerCase().includes("discount") || f.id.toLowerCase().includes("descuento") || f.label.toLowerCase().includes("descuento")
|
|
2462
|
-
}
|
|
2463
|
-
) : f.type === "time-range" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2464
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2465
|
-
AdminTimeRangePicker,
|
|
2466
|
-
{
|
|
2467
|
-
value: [
|
|
2468
|
-
toDayjsTime(f.startField ? editing[f.startField] : ""),
|
|
2469
|
-
toDayjsTime(f.endField ? editing[f.endField] : "")
|
|
2470
|
-
],
|
|
2471
|
-
onChange: (times) => setEditing(
|
|
2472
|
-
(current) => current ? {
|
|
2473
|
-
...current,
|
|
2474
|
-
...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
|
|
2475
|
-
...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
|
|
2476
|
-
} : current
|
|
2477
|
-
),
|
|
2478
|
-
allowEmpty: [true, true],
|
|
2479
|
-
className: "w-full",
|
|
2480
|
-
format: TIME_DISPLAY_FORMAT,
|
|
2481
|
-
order: false,
|
|
2482
|
-
placeholder: ["Hora de inicio", "Hora de cierre"],
|
|
2483
|
-
use12Hours: true
|
|
2484
|
-
}
|
|
2485
|
-
),
|
|
2486
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Selecciona inicio y cierre en un mismo control. Usa AM/PM; si el cierre es anterior al inicio, el horario cruza medianoche. Deja ambos vac\xEDos para mantenerlo siempre disponible." })
|
|
2487
|
-
] }) : f.type === "time" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2488
|
-
AdminTimePicker,
|
|
2489
|
-
{
|
|
2490
|
-
value: toDayjsTime(editing[f.id]),
|
|
2491
|
-
onChange: (time) => setEditing({ ...editing, [f.id]: toStoredTime(time) }),
|
|
2492
|
-
className: "w-full",
|
|
2493
|
-
format: TIME_DISPLAY_FORMAT,
|
|
2494
|
-
use12Hours: true
|
|
2495
|
-
}
|
|
2496
|
-
) : f.type === "richtext" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2497
|
-
"textarea",
|
|
2498
|
-
{
|
|
2499
|
-
value: String(editing[f.id] ?? ""),
|
|
2500
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2501
|
-
rows: 4,
|
|
2502
|
-
className: "w-full rounded-xl border border-slate-200 px-4 py-3 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all font-mono text-xs"
|
|
2766
|
+
children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
|
|
2767
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).filter((f) => {
|
|
2768
|
+
if (f.id === "estado" && !isCreatingEntry) return false;
|
|
2769
|
+
if (isCreatingEntry && f.hideOnCreate) return false;
|
|
2770
|
+
if (f.dependsOn) {
|
|
2771
|
+
const targetVal = editing[f.dependsOn.field];
|
|
2772
|
+
if (Array.isArray(f.dependsOn.value)) {
|
|
2773
|
+
if (!f.dependsOn.value.includes(targetVal)) return false;
|
|
2774
|
+
} else if (targetVal !== f.dependsOn.value) {
|
|
2775
|
+
return false;
|
|
2503
2776
|
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2515
|
-
|
|
2777
|
+
}
|
|
2778
|
+
return true;
|
|
2779
|
+
}).map((f) => {
|
|
2780
|
+
const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range";
|
|
2781
|
+
const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
|
|
2782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
|
|
2783
|
+
/* @__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: [
|
|
2784
|
+
f.label,
|
|
2785
|
+
/* @__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 })
|
|
2786
|
+
] }),
|
|
2787
|
+
f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2788
|
+
BranchSettingsEditor,
|
|
2516
2789
|
{
|
|
2517
|
-
|
|
2518
|
-
value:
|
|
2519
|
-
|
|
2520
|
-
|
|
2790
|
+
collectionId: f.collection || "",
|
|
2791
|
+
value: editing[f.id],
|
|
2792
|
+
globalPrice: Number(editing.price) || 0,
|
|
2793
|
+
globalDiscount: Number(editing.discountPercent) || 0,
|
|
2794
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2521
2795
|
}
|
|
2522
|
-
),
|
|
2523
|
-
|
|
2524
|
-
|
|
2796
|
+
) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
|
|
2797
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2798
|
+
import_antd.Switch,
|
|
2799
|
+
{
|
|
2800
|
+
checked: !!editing[f.id],
|
|
2801
|
+
onChange: (checked) => setEditing({ ...editing, [f.id]: checked })
|
|
2802
|
+
}
|
|
2803
|
+
),
|
|
2804
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
|
|
2805
|
+
] }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2806
|
+
import_antd.InputNumber,
|
|
2525
2807
|
{
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
className: "px-4 py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-700 text-sm font-semibold rounded-xl border border-slate-200 transition-colors",
|
|
2534
|
-
children: "Generate"
|
|
2808
|
+
size: "large",
|
|
2809
|
+
value: editing[f.id] !== void 0 && editing[f.id] !== null && editing[f.id] !== "" ? Number(editing[f.id]) : void 0,
|
|
2810
|
+
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
2811
|
+
disabled: f.readOnly,
|
|
2812
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
|
|
2813
|
+
className: "w-full rounded-xl",
|
|
2814
|
+
placeholder: "0"
|
|
2535
2815
|
}
|
|
2536
|
-
)
|
|
2537
|
-
|
|
2538
|
-
ReferenceSelect,
|
|
2539
|
-
{
|
|
2540
|
-
collectionId: f.collection,
|
|
2541
|
-
displayField: f.displayField,
|
|
2542
|
-
valueField: f.valueField,
|
|
2543
|
-
fallbackOptions: f.options,
|
|
2544
|
-
multiple: f.multiple,
|
|
2545
|
-
searchable: f.searchable,
|
|
2546
|
-
max: f.max,
|
|
2547
|
-
value: editing[f.id],
|
|
2548
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2549
|
-
}
|
|
2550
|
-
) : f.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
|
|
2551
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2552
|
-
"select",
|
|
2816
|
+
) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2817
|
+
import_antd.DatePicker,
|
|
2553
2818
|
{
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
const val = typeof opt === "string" ? opt : opt.value;
|
|
2561
|
-
const lab = typeof opt === "string" ? opt : opt.label;
|
|
2562
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: val, children: lab }, val);
|
|
2563
|
-
})
|
|
2564
|
-
]
|
|
2819
|
+
size: "large",
|
|
2820
|
+
value: editing[f.id] ? (0, import_dayjs.default)(String(editing[f.id])).isValid() ? (0, import_dayjs.default)(String(editing[f.id])) : null : null,
|
|
2821
|
+
onChange: (date, dateString) => setEditing({ ...editing, [f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "") }),
|
|
2822
|
+
format: "YYYY/MM/DD",
|
|
2823
|
+
placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
|
|
2824
|
+
className: "w-full rounded-xl"
|
|
2565
2825
|
}
|
|
2566
|
-
),
|
|
2567
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
|
|
2568
|
-
] }) : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
2569
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
|
|
2570
|
-
const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
|
|
2571
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
|
|
2572
|
-
isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
|
|
2573
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2574
|
-
"button",
|
|
2575
|
-
{
|
|
2576
|
-
type: "button",
|
|
2577
|
-
onClick: () => {
|
|
2578
|
-
const arr = [...editing[f.id] || []];
|
|
2579
|
-
arr.splice(i, 1);
|
|
2580
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
2581
|
-
},
|
|
2582
|
-
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",
|
|
2583
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
|
|
2584
|
-
}
|
|
2585
|
-
)
|
|
2586
|
-
] }, i);
|
|
2587
|
-
}) }),
|
|
2588
|
-
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
2826
|
+
) : f.type === "time-range" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
|
|
2589
2827
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2590
|
-
|
|
2828
|
+
AdminTimeRangePicker,
|
|
2591
2829
|
{
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2830
|
+
value: [
|
|
2831
|
+
toDayjsTime(f.startField ? editing[f.startField] : ""),
|
|
2832
|
+
toDayjsTime(f.endField ? editing[f.endField] : "")
|
|
2833
|
+
],
|
|
2834
|
+
onChange: (times) => setEditing(
|
|
2835
|
+
(current) => current ? {
|
|
2836
|
+
...current,
|
|
2837
|
+
...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
|
|
2838
|
+
...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
|
|
2839
|
+
} : current
|
|
2840
|
+
),
|
|
2841
|
+
allowEmpty: [true, true],
|
|
2842
|
+
className: "w-full",
|
|
2843
|
+
format: "h:mm a",
|
|
2844
|
+
order: false,
|
|
2845
|
+
placeholder: ["Hora de inicio", "Hora de cierre"],
|
|
2846
|
+
use12Hours: true
|
|
2603
2847
|
}
|
|
2604
2848
|
),
|
|
2849
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Selecciona inicio y cierre en un mismo control. Usa AM/PM. Deja ambos vac\xEDos para mantenerlo siempre disponible." })
|
|
2850
|
+
] }) : f.type === "time" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2851
|
+
import_antd.TimePicker,
|
|
2852
|
+
{
|
|
2853
|
+
size: "large",
|
|
2854
|
+
use12Hours: true,
|
|
2855
|
+
format: "h:mm a",
|
|
2856
|
+
value: toDayjsTime(editing[f.id]),
|
|
2857
|
+
onChange: (time, timeString) => setEditing({
|
|
2858
|
+
...editing,
|
|
2859
|
+
[f.id]: (Array.isArray(timeString) ? timeString[0] : timeString) || (time ? time.format("h:mm a") : "")
|
|
2860
|
+
}),
|
|
2861
|
+
placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
|
|
2862
|
+
className: "w-full rounded-xl"
|
|
2863
|
+
}
|
|
2864
|
+
) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2865
|
+
import_antd.Input.TextArea,
|
|
2866
|
+
{
|
|
2867
|
+
size: "large",
|
|
2868
|
+
value: String(editing[f.id] ?? ""),
|
|
2869
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2870
|
+
rows: 4,
|
|
2871
|
+
placeholder: `Escribe ${f.label.toLowerCase()}...`,
|
|
2872
|
+
className: "w-full rounded-xl font-sans"
|
|
2873
|
+
}
|
|
2874
|
+
) : f.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2875
|
+
SearchableSelect,
|
|
2876
|
+
{
|
|
2877
|
+
value: String(editing[f.id] ?? ""),
|
|
2878
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2879
|
+
options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
|
|
2880
|
+
placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
|
|
2881
|
+
iconMap: ctx.iconMap
|
|
2882
|
+
}
|
|
2883
|
+
) : f.type === "slug" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
2605
2884
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2606
|
-
|
|
2607
|
-
{
|
|
2608
|
-
accept: "image/*,video/*",
|
|
2609
|
-
multiple: true,
|
|
2610
|
-
className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
|
|
2611
|
-
onFiles: (files) => {
|
|
2612
|
-
files.forEach((file) => {
|
|
2613
|
-
void handleImageFile(
|
|
2614
|
-
file,
|
|
2615
|
-
(url) => {
|
|
2616
|
-
setEditing((prev) => {
|
|
2617
|
-
if (!prev) return prev;
|
|
2618
|
-
const current = prev[f.id] || [];
|
|
2619
|
-
if (f.max && current.length >= f.max) {
|
|
2620
|
-
return prev;
|
|
2621
|
-
}
|
|
2622
|
-
return { ...prev, [f.id]: [...current, url] };
|
|
2623
|
-
});
|
|
2624
|
-
},
|
|
2625
|
-
ctx.uploadImage
|
|
2626
|
-
);
|
|
2627
|
-
});
|
|
2628
|
-
},
|
|
2629
|
-
children: "Upload"
|
|
2630
|
-
}
|
|
2631
|
-
)
|
|
2632
|
-
] })
|
|
2633
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
2634
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
2635
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2636
|
-
"input",
|
|
2885
|
+
import_antd.Input,
|
|
2637
2886
|
{
|
|
2638
|
-
|
|
2887
|
+
size: "large",
|
|
2639
2888
|
value: String(editing[f.id] ?? ""),
|
|
2640
2889
|
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2641
|
-
|
|
2642
|
-
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"
|
|
2890
|
+
className: "flex-1 rounded-xl"
|
|
2643
2891
|
}
|
|
2644
2892
|
),
|
|
2645
2893
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2646
|
-
|
|
2894
|
+
import_antd.Button,
|
|
2647
2895
|
{
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
file,
|
|
2655
|
-
(url) => setEditing(
|
|
2656
|
-
(current) => current ? { ...current, [f.id]: url } : current
|
|
2657
|
-
),
|
|
2658
|
-
ctx.uploadImage
|
|
2659
|
-
);
|
|
2660
|
-
}
|
|
2896
|
+
size: "large",
|
|
2897
|
+
onClick: () => {
|
|
2898
|
+
const sourceField = f.source || "title";
|
|
2899
|
+
let val = String(editing[sourceField] || editing.id || "");
|
|
2900
|
+
val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
2901
|
+
setEditing({ ...editing, [f.id]: val });
|
|
2661
2902
|
},
|
|
2662
|
-
|
|
2903
|
+
className: "rounded-xl font-semibold",
|
|
2904
|
+
children: "Generate"
|
|
2663
2905
|
}
|
|
2664
2906
|
)
|
|
2665
|
-
] }),
|
|
2666
|
-
|
|
2667
|
-
"video",
|
|
2668
|
-
{
|
|
2669
|
-
src: String(editing[f.id]),
|
|
2670
|
-
controls: true,
|
|
2671
|
-
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
2672
|
-
}
|
|
2673
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2674
|
-
"img",
|
|
2675
|
-
{
|
|
2676
|
-
src: String(editing[f.id]),
|
|
2677
|
-
alt: "",
|
|
2678
|
-
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
2679
|
-
}
|
|
2680
|
-
) }) : null
|
|
2681
|
-
] }) : f.type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2682
|
-
PasswordField,
|
|
2683
|
-
{
|
|
2684
|
-
value: String(editing[f.id] ?? ""),
|
|
2685
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2686
|
-
}
|
|
2687
|
-
) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
2688
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2689
|
-
"input",
|
|
2690
|
-
{
|
|
2691
|
-
type: "color",
|
|
2692
|
-
value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
|
|
2693
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2694
|
-
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
2695
|
-
}
|
|
2696
|
-
),
|
|
2697
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2698
|
-
"input",
|
|
2699
|
-
{
|
|
2700
|
-
type: "text",
|
|
2701
|
-
value: String(editing[f.id] ?? ""),
|
|
2702
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2703
|
-
placeholder: "#000000",
|
|
2704
|
-
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"
|
|
2705
|
-
}
|
|
2706
|
-
),
|
|
2707
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2708
|
-
"div",
|
|
2907
|
+
] }) : f.type === "reference" || f.type === "select" && f.collection ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2908
|
+
ReferenceSelect,
|
|
2709
2909
|
{
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
"
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2910
|
+
collectionId: f.collection,
|
|
2911
|
+
displayField: f.displayField,
|
|
2912
|
+
valueField: f.valueField,
|
|
2913
|
+
fallbackOptions: f.options,
|
|
2914
|
+
multiple: f.multiple,
|
|
2915
|
+
searchable: f.searchable,
|
|
2916
|
+
max: f.max,
|
|
2917
|
+
value: editing[f.id],
|
|
2918
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2919
|
+
onSelectRecord: (rec) => {
|
|
2920
|
+
if (f.id === "clienteId" && rec) {
|
|
2921
|
+
setEditing((prev) => prev ? {
|
|
2922
|
+
...prev,
|
|
2923
|
+
clienteId: rec.id || prev.clienteId,
|
|
2924
|
+
clienteNombre: rec.nombre || rec.name || prev.clienteNombre,
|
|
2925
|
+
ciudad: rec.ciudad || prev.ciudad,
|
|
2926
|
+
direccion: rec.direccion || prev.direccion,
|
|
2927
|
+
telefono: rec.telefono || prev.telefono
|
|
2928
|
+
} : prev);
|
|
2929
|
+
} else if (f.id === "empleadoId" && rec) {
|
|
2930
|
+
setEditing((prev) => prev ? {
|
|
2931
|
+
...prev,
|
|
2932
|
+
empleadoId: rec.id || prev.empleadoId,
|
|
2933
|
+
empleadoNombre: rec.apellido ? `${rec.nombre || rec.name || ""} ${rec.apellido}`.trim() : rec.nombre || rec.name || prev.empleadoNombre
|
|
2934
|
+
} : prev);
|
|
2730
2935
|
}
|
|
2731
|
-
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
) : f.type === "select" ? (() => {
|
|
2939
|
+
const dynamicOptions = f.optionsMap && f.dependsOnField ? f.optionsMap[String(editing[f.dependsOnField] || "")] || f.options || [] : f.options || [];
|
|
2940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2941
|
+
import_antd.Select,
|
|
2942
|
+
{
|
|
2943
|
+
size: "large",
|
|
2944
|
+
value: editing[f.id] ? String(editing[f.id]) : void 0,
|
|
2945
|
+
placeholder: f.label,
|
|
2946
|
+
allowClear: true,
|
|
2947
|
+
onChange: (val) => {
|
|
2948
|
+
const next = { ...editing, [f.id]: val || "" };
|
|
2949
|
+
collection.fields.forEach((otherField) => {
|
|
2950
|
+
if (otherField.dependsOnField === f.id && otherField.optionsMap) {
|
|
2951
|
+
const newOpts = otherField.optionsMap[String(val || "")];
|
|
2952
|
+
if (newOpts && newOpts.length > 0) {
|
|
2953
|
+
const firstVal = typeof newOpts[0] === "string" ? newOpts[0] : newOpts[0].value;
|
|
2954
|
+
next[otherField.id] = firstVal;
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
});
|
|
2958
|
+
setEditing(next);
|
|
2959
|
+
},
|
|
2960
|
+
options: dynamicOptions.map((opt) => ({
|
|
2961
|
+
label: typeof opt === "string" ? opt : opt.label,
|
|
2962
|
+
value: typeof opt === "string" ? opt : opt.value
|
|
2963
|
+
})),
|
|
2964
|
+
className: "w-full"
|
|
2965
|
+
}
|
|
2966
|
+
);
|
|
2967
|
+
})() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
2968
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
|
|
2969
|
+
const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
|
|
2970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
|
|
2971
|
+
isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
|
|
2972
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2973
|
+
"button",
|
|
2974
|
+
{
|
|
2975
|
+
type: "button",
|
|
2976
|
+
onClick: () => {
|
|
2977
|
+
const arr = [...editing[f.id] || []];
|
|
2978
|
+
arr.splice(i, 1);
|
|
2979
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2980
|
+
},
|
|
2981
|
+
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",
|
|
2982
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
|
|
2983
|
+
}
|
|
2984
|
+
)
|
|
2985
|
+
] }, i);
|
|
2986
|
+
}) }),
|
|
2987
|
+
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
2732
2988
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2733
2989
|
"input",
|
|
2734
2990
|
{
|
|
2735
|
-
type: "
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2991
|
+
type: "url",
|
|
2992
|
+
placeholder: "Add media URL and press Enter...",
|
|
2993
|
+
onKeyDown: (e) => {
|
|
2994
|
+
if (e.key === "Enter" && e.currentTarget.value) {
|
|
2995
|
+
e.preventDefault();
|
|
2996
|
+
const arr = [...editing[f.id] || [], e.currentTarget.value];
|
|
2997
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2998
|
+
e.currentTarget.value = "";
|
|
2999
|
+
}
|
|
2741
3000
|
},
|
|
2742
|
-
|
|
2743
|
-
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"
|
|
3001
|
+
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"
|
|
2744
3002
|
}
|
|
2745
3003
|
),
|
|
2746
3004
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2747
|
-
|
|
3005
|
+
FilePickerButton,
|
|
3006
|
+
{
|
|
3007
|
+
accept: "image/*,video/*",
|
|
3008
|
+
multiple: true,
|
|
3009
|
+
className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
|
|
3010
|
+
onFiles: (files) => {
|
|
3011
|
+
files.forEach((file) => {
|
|
3012
|
+
void handleImageFile(
|
|
3013
|
+
file,
|
|
3014
|
+
(url) => {
|
|
3015
|
+
setEditing((prev) => {
|
|
3016
|
+
if (!prev) return prev;
|
|
3017
|
+
const current = prev[f.id] || [];
|
|
3018
|
+
if (f.max && current.length >= f.max) {
|
|
3019
|
+
return prev;
|
|
3020
|
+
}
|
|
3021
|
+
return { ...prev, [f.id]: [...current, url] };
|
|
3022
|
+
});
|
|
3023
|
+
},
|
|
3024
|
+
ctx.uploadImage
|
|
3025
|
+
);
|
|
3026
|
+
});
|
|
3027
|
+
},
|
|
3028
|
+
children: "Upload"
|
|
3029
|
+
}
|
|
3030
|
+
)
|
|
3031
|
+
] })
|
|
3032
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3033
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
3034
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3035
|
+
"input",
|
|
2748
3036
|
{
|
|
2749
|
-
|
|
2750
|
-
|
|
3037
|
+
type: "url",
|
|
3038
|
+
value: String(editing[f.id] ?? ""),
|
|
3039
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
3040
|
+
placeholder: "https://...",
|
|
3041
|
+
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"
|
|
2751
3042
|
}
|
|
2752
3043
|
),
|
|
2753
3044
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2754
|
-
|
|
3045
|
+
FilePickerButton,
|
|
2755
3046
|
{
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
3047
|
+
accept: "image/*,video/*",
|
|
3048
|
+
className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
|
|
3049
|
+
onFiles: (files) => {
|
|
3050
|
+
const file = files[0];
|
|
3051
|
+
if (file) {
|
|
3052
|
+
void handleImageFile(
|
|
3053
|
+
file,
|
|
3054
|
+
(url) => setEditing(
|
|
3055
|
+
(current) => current ? { ...current, [f.id]: url } : current
|
|
3056
|
+
),
|
|
3057
|
+
ctx.uploadImage
|
|
3058
|
+
);
|
|
3059
|
+
}
|
|
2761
3060
|
},
|
|
2762
|
-
|
|
2763
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
3061
|
+
children: "Upload"
|
|
2764
3062
|
}
|
|
2765
3063
|
)
|
|
2766
|
-
] },
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
3064
|
+
] }),
|
|
3065
|
+
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(/\.(mp4|webm|mov|ogg)$/i) || String(editing[f.id]).includes("video") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3066
|
+
"video",
|
|
3067
|
+
{
|
|
3068
|
+
src: String(editing[f.id]),
|
|
3069
|
+
controls: true,
|
|
3070
|
+
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
3071
|
+
}
|
|
3072
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3073
|
+
"img",
|
|
3074
|
+
{
|
|
3075
|
+
src: String(editing[f.id]),
|
|
3076
|
+
alt: "",
|
|
3077
|
+
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
3078
|
+
}
|
|
3079
|
+
) }) : null
|
|
3080
|
+
] }) : f.type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3081
|
+
PasswordField,
|
|
2770
3082
|
{
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
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) : [];
|
|
2774
|
-
arr.push("#000000");
|
|
2775
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
2776
|
-
},
|
|
2777
|
-
className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
|
|
2778
|
-
children: [
|
|
2779
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
2780
|
-
" Add Color"
|
|
2781
|
-
]
|
|
3083
|
+
value: String(editing[f.id] ?? ""),
|
|
3084
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2782
3085
|
}
|
|
2783
|
-
)
|
|
2784
|
-
|
|
2785
|
-
|
|
3086
|
+
) : f.type === "signature" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3087
|
+
SignatureInput,
|
|
3088
|
+
{
|
|
3089
|
+
value: editing[f.id],
|
|
3090
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
3091
|
+
label: f.label
|
|
3092
|
+
}
|
|
3093
|
+
) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
3094
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3095
|
+
"input",
|
|
3096
|
+
{
|
|
3097
|
+
type: "color",
|
|
3098
|
+
value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
|
|
3099
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
3100
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
3101
|
+
}
|
|
3102
|
+
),
|
|
2786
3103
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2787
3104
|
"input",
|
|
2788
3105
|
{
|
|
2789
3106
|
type: "text",
|
|
2790
|
-
value: String(
|
|
2791
|
-
onChange: (e) => {
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
2795
|
-
},
|
|
2796
|
-
className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
3107
|
+
value: String(editing[f.id] ?? ""),
|
|
3108
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
3109
|
+
placeholder: "#000000",
|
|
3110
|
+
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"
|
|
2797
3111
|
}
|
|
2798
3112
|
),
|
|
2799
3113
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3114
|
+
"div",
|
|
3115
|
+
{
|
|
3116
|
+
className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
3117
|
+
style: { backgroundColor: String(editing[f.id] ?? "#000000") }
|
|
3118
|
+
}
|
|
3119
|
+
)
|
|
3120
|
+
] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3121
|
+
(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) => {
|
|
3122
|
+
const colorVal = String(item ?? "").trim();
|
|
3123
|
+
const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
|
|
3124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
3125
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3126
|
+
"input",
|
|
3127
|
+
{
|
|
3128
|
+
type: "color",
|
|
3129
|
+
value: validHex.length === 7 ? validHex : "#000000",
|
|
3130
|
+
onChange: (e) => {
|
|
3131
|
+
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) : [];
|
|
3132
|
+
arr[idx] = e.target.value;
|
|
3133
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
3134
|
+
},
|
|
3135
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
3136
|
+
}
|
|
3137
|
+
),
|
|
3138
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3139
|
+
"input",
|
|
3140
|
+
{
|
|
3141
|
+
type: "text",
|
|
3142
|
+
value: colorVal,
|
|
3143
|
+
onChange: (e) => {
|
|
3144
|
+
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) : [];
|
|
3145
|
+
arr[idx] = e.target.value;
|
|
3146
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
3147
|
+
},
|
|
3148
|
+
placeholder: "#1c2a44",
|
|
3149
|
+
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"
|
|
3150
|
+
}
|
|
3151
|
+
),
|
|
3152
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3153
|
+
"div",
|
|
3154
|
+
{
|
|
3155
|
+
className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
3156
|
+
style: { backgroundColor: colorVal || "#000000" }
|
|
3157
|
+
}
|
|
3158
|
+
),
|
|
3159
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3160
|
+
"button",
|
|
3161
|
+
{
|
|
3162
|
+
type: "button",
|
|
3163
|
+
onClick: () => {
|
|
3164
|
+
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) : [];
|
|
3165
|
+
arr.splice(idx, 1);
|
|
3166
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
3167
|
+
},
|
|
3168
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
|
|
3169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
3170
|
+
}
|
|
3171
|
+
)
|
|
3172
|
+
] }, idx);
|
|
3173
|
+
}),
|
|
3174
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3175
|
+
"button",
|
|
3176
|
+
{
|
|
3177
|
+
type: "button",
|
|
3178
|
+
onClick: () => {
|
|
3179
|
+
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) : [];
|
|
3180
|
+
arr.push("#000000");
|
|
3181
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
3182
|
+
},
|
|
3183
|
+
className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
|
|
3184
|
+
children: [
|
|
3185
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
3186
|
+
" Add Color"
|
|
3187
|
+
]
|
|
3188
|
+
}
|
|
3189
|
+
)
|
|
3190
|
+
] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
3191
|
+
(Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
|
|
3192
|
+
const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
|
|
3193
|
+
const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
|
|
3194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
3195
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
|
|
3196
|
+
idx + 1,
|
|
3197
|
+
"."
|
|
3198
|
+
] }),
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3200
|
+
"input",
|
|
3201
|
+
{
|
|
3202
|
+
type: "text",
|
|
3203
|
+
value: String(item ?? ""),
|
|
3204
|
+
placeholder,
|
|
3205
|
+
onChange: (e) => {
|
|
3206
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
3207
|
+
arr[idx] = e.target.value;
|
|
3208
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
3209
|
+
},
|
|
3210
|
+
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"
|
|
3211
|
+
}
|
|
3212
|
+
),
|
|
3213
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3214
|
+
"button",
|
|
3215
|
+
{
|
|
3216
|
+
type: "button",
|
|
3217
|
+
onClick: () => {
|
|
3218
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
3219
|
+
arr.splice(idx, 1);
|
|
3220
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
3221
|
+
},
|
|
3222
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
|
|
3223
|
+
title: "Eliminar elemento",
|
|
3224
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
3225
|
+
}
|
|
3226
|
+
)
|
|
3227
|
+
] }, idx);
|
|
3228
|
+
}),
|
|
3229
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2800
3230
|
"button",
|
|
2801
3231
|
{
|
|
2802
3232
|
type: "button",
|
|
2803
3233
|
onClick: () => {
|
|
2804
3234
|
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
2805
|
-
arr.
|
|
3235
|
+
arr.push("");
|
|
2806
3236
|
setEditing({ ...editing, [f.id]: arr });
|
|
2807
3237
|
},
|
|
2808
|
-
className: "
|
|
2809
|
-
children:
|
|
3238
|
+
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",
|
|
3239
|
+
children: [
|
|
3240
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
3241
|
+
" ",
|
|
3242
|
+
f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
|
|
3243
|
+
]
|
|
2810
3244
|
}
|
|
2811
3245
|
)
|
|
2812
|
-
] },
|
|
2813
|
-
|
|
2814
|
-
|
|
3246
|
+
] }) : f.type === "link" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
|
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3248
|
+
import_antd.Input,
|
|
3249
|
+
{
|
|
3250
|
+
size: "large",
|
|
3251
|
+
value: String(editing[f.id] ?? ""),
|
|
3252
|
+
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
3253
|
+
disabled: f.readOnly,
|
|
3254
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
3255
|
+
placeholder: f.label,
|
|
3256
|
+
className: "flex-1 rounded-xl"
|
|
3257
|
+
}
|
|
3258
|
+
),
|
|
3259
|
+
Boolean(editing[f.id]) && String(editing[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3260
|
+
"a",
|
|
3261
|
+
{
|
|
3262
|
+
href: String(editing[f.id]),
|
|
3263
|
+
target: "_blank",
|
|
3264
|
+
rel: "noopener noreferrer",
|
|
3265
|
+
className: "inline-flex items-center gap-1.5 px-3 py-2 bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-xl text-xs font-bold border border-blue-200 transition-colors shrink-0",
|
|
3266
|
+
children: [
|
|
3267
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
|
|
3268
|
+
String(editing[f.id]).includes("maps") ? "Ver en Mapa" : "Abrir"
|
|
3269
|
+
]
|
|
3270
|
+
}
|
|
3271
|
+
) : null
|
|
3272
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3273
|
+
import_antd.Input,
|
|
2815
3274
|
{
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
className: "
|
|
2823
|
-
children: [
|
|
2824
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
2825
|
-
" Add Item"
|
|
2826
|
-
]
|
|
3275
|
+
size: "large",
|
|
3276
|
+
value: String(editing[f.id] ?? ""),
|
|
3277
|
+
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
3278
|
+
disabled: f.readOnly,
|
|
3279
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
3280
|
+
placeholder: f.label,
|
|
3281
|
+
className: "w-full rounded-xl"
|
|
2827
3282
|
}
|
|
2828
3283
|
)
|
|
2829
|
-
] }
|
|
2830
|
-
|
|
2831
|
-
{
|
|
2832
|
-
value: String(editing[f.id] ?? ""),
|
|
2833
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2834
|
-
className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
2835
|
-
}
|
|
2836
|
-
)
|
|
2837
|
-
] }, f.id)) }) }),
|
|
3284
|
+
] }, f.id);
|
|
3285
|
+
}) }) }),
|
|
2838
3286
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex shrink-0 justify-end gap-3 border-t border-slate-200 bg-white px-6 py-4", children: [
|
|
2839
3287
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2840
|
-
|
|
3288
|
+
import_antd.Button,
|
|
2841
3289
|
{
|
|
3290
|
+
size: "large",
|
|
2842
3291
|
onClick: () => setEditing(null),
|
|
2843
3292
|
disabled: saving,
|
|
2844
|
-
className: "rounded-xl
|
|
2845
|
-
children:
|
|
3293
|
+
className: "rounded-xl font-medium",
|
|
3294
|
+
children: t.cancel
|
|
2846
3295
|
}
|
|
2847
3296
|
),
|
|
2848
3297
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2849
|
-
|
|
3298
|
+
import_antd.Button,
|
|
2850
3299
|
{
|
|
3300
|
+
size: "large",
|
|
3301
|
+
type: "primary",
|
|
2851
3302
|
onClick: save,
|
|
2852
|
-
|
|
2853
|
-
className: "
|
|
2854
|
-
children:
|
|
2855
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2856
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2857
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
2858
|
-
] }),
|
|
2859
|
-
"Saving..."
|
|
2860
|
-
] }) : "Save Entry"
|
|
3303
|
+
loading: saving,
|
|
3304
|
+
className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700",
|
|
3305
|
+
children: collection.submitLabel || (isCreatingEntry ? t.create.toUpperCase() : t.save.toUpperCase())
|
|
2861
3306
|
}
|
|
2862
3307
|
)
|
|
2863
3308
|
] })
|
|
2864
|
-
] })
|
|
3309
|
+
] }) })
|
|
2865
3310
|
}
|
|
2866
3311
|
),
|
|
2867
3312
|
/* @__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: [
|
|
2868
3313
|
/* @__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: [
|
|
2869
3314
|
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: f.label }, f.id)),
|
|
2870
|
-
/* @__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:
|
|
3315
|
+
/* @__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 })
|
|
2871
3316
|
] }) }),
|
|
2872
3317
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
|
|
2873
3318
|
// Loading skeleton rows
|
|
@@ -2879,13 +3324,29 @@ function CollectionEditor({ collection }) {
|
|
|
2879
3324
|
(() => {
|
|
2880
3325
|
let res = entries;
|
|
2881
3326
|
if (search && collection.searchBy?.length) {
|
|
2882
|
-
const q = search.toLowerCase();
|
|
2883
|
-
res = res.filter((e) =>
|
|
3327
|
+
const q = search.toLowerCase().trim();
|
|
3328
|
+
res = res.filter((e) => {
|
|
3329
|
+
return collection.searchBy.some((field) => {
|
|
3330
|
+
const val = String(e[field] ?? "").toLowerCase();
|
|
3331
|
+
if (!val) return false;
|
|
3332
|
+
if (val.includes(q)) return true;
|
|
3333
|
+
const normVal = val.replace(/-/g, "/");
|
|
3334
|
+
const normQ = q.replace(/-/g, "/");
|
|
3335
|
+
return normVal.includes(normQ);
|
|
3336
|
+
});
|
|
3337
|
+
});
|
|
2884
3338
|
}
|
|
2885
3339
|
if (Object.keys(filters).length > 0) {
|
|
2886
3340
|
res = res.filter((e) => {
|
|
2887
3341
|
for (const [k, v] of Object.entries(filters)) {
|
|
2888
|
-
if (v
|
|
3342
|
+
if (!v) continue;
|
|
3343
|
+
const entryVal = String(e[k] ?? "").trim();
|
|
3344
|
+
const filterVal = String(v).trim();
|
|
3345
|
+
const normEntry = entryVal.replace(/-/g, "/");
|
|
3346
|
+
const normFilter = filterVal.replace(/-/g, "/");
|
|
3347
|
+
if (normEntry !== normFilter && !normEntry.includes(normFilter)) {
|
|
3348
|
+
return false;
|
|
3349
|
+
}
|
|
2889
3350
|
}
|
|
2890
3351
|
return true;
|
|
2891
3352
|
});
|
|
@@ -2901,10 +3362,22 @@ function CollectionEditor({ collection }) {
|
|
|
2901
3362
|
onDragEnd,
|
|
2902
3363
|
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" : ""}`,
|
|
2903
3364
|
children: [
|
|
2904
|
-
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : 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)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : 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)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", 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" }) }) }) : (f.
|
|
3365
|
+
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : 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)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : 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)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", 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" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { 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("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__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 === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
|
|
2905
3366
|
"$ ",
|
|
2906
3367
|
Number(e[f.id]).toLocaleString("es-CO")
|
|
2907
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) :
|
|
3368
|
+
] }) : /* @__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)(
|
|
3369
|
+
"a",
|
|
3370
|
+
{
|
|
3371
|
+
href: String(e[f.id]),
|
|
3372
|
+
target: "_blank",
|
|
3373
|
+
rel: "noopener noreferrer",
|
|
3374
|
+
className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
|
|
3375
|
+
children: [
|
|
3376
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3 h-3" }),
|
|
3377
|
+
String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
|
|
3378
|
+
]
|
|
3379
|
+
}
|
|
3380
|
+
) : String(e[f.id] ?? "") }, f.id)),
|
|
2908
3381
|
/* @__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-2", children: [
|
|
2909
3382
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
|
|
2910
3383
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -2912,7 +3385,7 @@ function CollectionEditor({ collection }) {
|
|
|
2912
3385
|
{
|
|
2913
3386
|
onClick: () => setEditing(e),
|
|
2914
3387
|
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
2915
|
-
title:
|
|
3388
|
+
title: t.edit,
|
|
2916
3389
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
|
|
2917
3390
|
}
|
|
2918
3391
|
),
|
|
@@ -2922,7 +3395,7 @@ function CollectionEditor({ collection }) {
|
|
|
2922
3395
|
onClick: () => remove(e.id),
|
|
2923
3396
|
disabled: deletingId === e.id,
|
|
2924
3397
|
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
2925
|
-
title:
|
|
3398
|
+
title: t.delete,
|
|
2926
3399
|
children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2927
3400
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2928
3401
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
@@ -2942,7 +3415,7 @@ function CollectionEditor({ collection }) {
|
|
|
2942
3415
|
className: "px-6 py-12 text-center text-slate-500",
|
|
2943
3416
|
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col items-center justify-center", children: [
|
|
2944
3417
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-10 w-10 text-slate-300 mb-3" }),
|
|
2945
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children:
|
|
3418
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t.noRecords })
|
|
2946
3419
|
] })
|
|
2947
3420
|
}
|
|
2948
3421
|
) })
|
|
@@ -2963,7 +3436,7 @@ function CollectionEditor({ collection }) {
|
|
|
2963
3436
|
return true;
|
|
2964
3437
|
});
|
|
2965
3438
|
}
|
|
2966
|
-
return `${res.length}
|
|
3439
|
+
return `${res.length} ${t.entries}`;
|
|
2967
3440
|
})() }),
|
|
2968
3441
|
(() => {
|
|
2969
3442
|
let res = entries;
|
|
@@ -3443,79 +3916,143 @@ function Row({
|
|
|
3443
3916
|
function SearchableSelect({ value, onChange, options, placeholder, iconMap }) {
|
|
3444
3917
|
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
3445
3918
|
const [search, setSearch] = (0, import_react5.useState)("");
|
|
3446
|
-
const
|
|
3447
|
-
const
|
|
3919
|
+
const btnRef = (0, import_react5.useRef)(null);
|
|
3920
|
+
const [coords, setCoords] = (0, import_react5.useState)({
|
|
3921
|
+
top: 0,
|
|
3922
|
+
left: 0,
|
|
3923
|
+
width: 250
|
|
3924
|
+
});
|
|
3925
|
+
const updateCoords = (0, import_react5.useCallback)(() => {
|
|
3926
|
+
if (btnRef.current) {
|
|
3927
|
+
const rect = btnRef.current.getBoundingClientRect();
|
|
3928
|
+
const dropdownHeight = 280;
|
|
3929
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
3930
|
+
const opensUp = spaceBelow < dropdownHeight && rect.top > dropdownHeight;
|
|
3931
|
+
setCoords({
|
|
3932
|
+
top: opensUp ? Math.max(10, rect.top - dropdownHeight - 6) : rect.bottom + 6,
|
|
3933
|
+
left: Math.max(10, Math.min(rect.left, window.innerWidth - rect.width - 10)),
|
|
3934
|
+
width: rect.width
|
|
3935
|
+
});
|
|
3936
|
+
}
|
|
3937
|
+
}, []);
|
|
3938
|
+
const handleToggle = () => {
|
|
3939
|
+
if (!open) {
|
|
3940
|
+
updateCoords();
|
|
3941
|
+
}
|
|
3942
|
+
setOpen((prev) => !prev);
|
|
3943
|
+
setSearch("");
|
|
3944
|
+
};
|
|
3945
|
+
(0, import_react5.useEffect)(() => {
|
|
3946
|
+
if (!open) return;
|
|
3947
|
+
const handleScrollOrResize = () => {
|
|
3948
|
+
updateCoords();
|
|
3949
|
+
};
|
|
3950
|
+
window.addEventListener("scroll", handleScrollOrResize, true);
|
|
3951
|
+
window.addEventListener("resize", handleScrollOrResize);
|
|
3952
|
+
return () => {
|
|
3953
|
+
window.removeEventListener("scroll", handleScrollOrResize, true);
|
|
3954
|
+
window.removeEventListener("resize", handleScrollOrResize);
|
|
3955
|
+
};
|
|
3956
|
+
}, [open, updateCoords]);
|
|
3957
|
+
const filtered = options.filter(
|
|
3958
|
+
(o) => o.toLowerCase().includes(search.toLowerCase())
|
|
3959
|
+
);
|
|
3960
|
+
const capped = filtered.slice(0, 100);
|
|
3448
3961
|
const SelectedIcon = iconMap && value ? iconMap[value] : null;
|
|
3449
3962
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
|
|
3450
3963
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3451
3964
|
"button",
|
|
3452
3965
|
{
|
|
3966
|
+
ref: btnRef,
|
|
3453
3967
|
type: "button",
|
|
3454
|
-
onClick:
|
|
3455
|
-
|
|
3456
|
-
setSearch("");
|
|
3457
|
-
},
|
|
3458
|
-
className: "w-full flex items-center justify-between rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors",
|
|
3968
|
+
onClick: handleToggle,
|
|
3969
|
+
className: "w-full flex items-center justify-between rounded-xl border border-slate-200 px-3.5 py-2.5 text-sm text-slate-800 shadow-sm hover:border-slate-300 focus:border-indigo-500 bg-white transition-colors cursor-pointer",
|
|
3459
3970
|
children: [
|
|
3460
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 truncate", children: [
|
|
3461
|
-
SelectedIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3462
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: value || placeholder || "
|
|
3971
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2.5 truncate", children: [
|
|
3972
|
+
SelectedIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-5 h-5 flex items-center justify-center rounded bg-slate-100 text-indigo-600 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SelectedIcon, { className: "w-3.5 h-3.5" }) }),
|
|
3973
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate font-medium", children: value || placeholder || "Seleccionar icono..." })
|
|
3463
3974
|
] }),
|
|
3464
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: `w-4 h-4 text-slate-400 transition-transform shrink-0 ${open ? "rotate-180" : ""}` })
|
|
3465
|
-
]
|
|
3466
|
-
}
|
|
3467
|
-
),
|
|
3468
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
3469
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "fixed inset-0 z-[100]", onClick: () => setOpen(false) }),
|
|
3470
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "absolute z-[101] mt-1 w-full rounded-xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in slide-in-from-top-1 duration-150", children: [
|
|
3471
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2 border-b border-slate-100 flex items-center gap-2", children: [
|
|
3472
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
|
|
3473
3975
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3474
|
-
|
|
3976
|
+
import_lucide_react2.ChevronDown,
|
|
3475
3977
|
{
|
|
3476
|
-
|
|
3477
|
-
type: "text",
|
|
3478
|
-
className: "w-full text-sm outline-none bg-transparent text-slate-800 placeholder:text-slate-400",
|
|
3479
|
-
placeholder: "Type to search\u2026",
|
|
3480
|
-
value: search,
|
|
3481
|
-
onChange: (e) => setSearch(e.target.value)
|
|
3978
|
+
className: `w-4 h-4 text-slate-400 transition-transform shrink-0 ${open ? "rotate-180" : ""}`
|
|
3482
3979
|
}
|
|
3483
|
-
)
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3980
|
+
)
|
|
3981
|
+
]
|
|
3982
|
+
}
|
|
3983
|
+
),
|
|
3984
|
+
open && typeof document !== "undefined" && (0, import_react_dom.createPortal)(
|
|
3985
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
3986
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3987
|
+
"div",
|
|
3988
|
+
{
|
|
3989
|
+
className: "fixed inset-0 z-[99998] cursor-default",
|
|
3990
|
+
onClick: () => setOpen(false)
|
|
3991
|
+
}
|
|
3992
|
+
),
|
|
3993
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3994
|
+
"div",
|
|
3995
|
+
{
|
|
3996
|
+
style: {
|
|
3997
|
+
position: "fixed",
|
|
3998
|
+
top: `${coords.top}px`,
|
|
3999
|
+
left: `${coords.left}px`,
|
|
4000
|
+
width: `${coords.width}px`
|
|
4001
|
+
},
|
|
4002
|
+
className: "z-[99999] rounded-2xl border border-slate-200 bg-white shadow-2xl max-h-72 flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-150",
|
|
4003
|
+
children: [
|
|
4004
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2.5 border-b border-slate-100 flex items-center gap-2 bg-slate-50/50", children: [
|
|
4005
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "w-4 h-4 text-slate-400 shrink-0" }),
|
|
4006
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4007
|
+
"input",
|
|
4008
|
+
{
|
|
4009
|
+
autoFocus: true,
|
|
4010
|
+
type: "text",
|
|
4011
|
+
className: "w-full text-sm outline-none bg-transparent text-slate-800 placeholder:text-slate-400",
|
|
4012
|
+
placeholder: "Buscar icono por nombre (ej: LuCode, LuServer)...",
|
|
4013
|
+
value: search,
|
|
4014
|
+
onChange: (e) => setSearch(e.target.value)
|
|
4015
|
+
}
|
|
4016
|
+
),
|
|
4017
|
+
search && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold text-slate-400 bg-slate-200 px-1.5 py-0.5 rounded-full shrink-0 tabular-nums", children: filtered.length })
|
|
4018
|
+
] }),
|
|
4019
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "overflow-y-auto flex-1 p-1.5", children: [
|
|
4020
|
+
filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-4 text-xs text-slate-500 text-center", children: [
|
|
4021
|
+
'No se encontraron iconos para "',
|
|
4022
|
+
search,
|
|
4023
|
+
'"'
|
|
4024
|
+
] }),
|
|
4025
|
+
capped.map((opt) => {
|
|
4026
|
+
const OptIcon = iconMap ? iconMap[opt] : null;
|
|
4027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4028
|
+
"button",
|
|
4029
|
+
{
|
|
4030
|
+
type: "button",
|
|
4031
|
+
className: `w-full flex items-center gap-2.5 text-left px-2.5 py-2 text-sm rounded-xl transition-colors cursor-pointer ${value === opt ? "bg-indigo-50 text-indigo-700 font-semibold" : "text-slate-700 hover:bg-slate-50"}`,
|
|
4032
|
+
onClick: () => {
|
|
4033
|
+
onChange(opt);
|
|
4034
|
+
setOpen(false);
|
|
4035
|
+
},
|
|
4036
|
+
children: [
|
|
4037
|
+
OptIcon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-6 h-6 flex items-center justify-center rounded-lg bg-slate-100 text-indigo-600 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OptIcon, { className: "w-4 h-4" }) }),
|
|
4038
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "truncate", children: opt })
|
|
4039
|
+
]
|
|
4040
|
+
},
|
|
4041
|
+
opt
|
|
4042
|
+
);
|
|
4043
|
+
}),
|
|
4044
|
+
filtered.length > 100 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "px-3 py-2 text-[10px] text-slate-400 text-center border-t border-slate-100 mt-1", children: [
|
|
4045
|
+
"Mostrando 100 de ",
|
|
4046
|
+
filtered.length,
|
|
4047
|
+
" \u2014 escribe en el buscador para filtrar"
|
|
4048
|
+
] })
|
|
4049
|
+
] })
|
|
4050
|
+
]
|
|
4051
|
+
}
|
|
4052
|
+
)
|
|
4053
|
+
] }),
|
|
4054
|
+
document.body
|
|
4055
|
+
)
|
|
3519
4056
|
] });
|
|
3520
4057
|
}
|
|
3521
4058
|
function PasswordField({ value, onChange }) {
|
|
@@ -3549,6 +4086,197 @@ function PasswordField({ value, onChange }) {
|
|
|
3549
4086
|
)
|
|
3550
4087
|
] });
|
|
3551
4088
|
}
|
|
4089
|
+
function SignatureInput({
|
|
4090
|
+
value,
|
|
4091
|
+
onChange,
|
|
4092
|
+
label
|
|
4093
|
+
}) {
|
|
4094
|
+
const t = useAdminI18n();
|
|
4095
|
+
const [modalOpen, setModalOpen] = (0, import_react5.useState)(false);
|
|
4096
|
+
const canvasRef = (0, import_react5.useRef)(null);
|
|
4097
|
+
const isDrawingRef = (0, import_react5.useRef)(false);
|
|
4098
|
+
const fileInputRef = (0, import_react5.useRef)(null);
|
|
4099
|
+
const sigVal = typeof value === "string" ? value : "";
|
|
4100
|
+
const displayLabel = label || t.signatureRegistered;
|
|
4101
|
+
const startDrawing = (e) => {
|
|
4102
|
+
const canvas = canvasRef.current;
|
|
4103
|
+
if (!canvas) return;
|
|
4104
|
+
const ctx = canvas.getContext("2d");
|
|
4105
|
+
if (!ctx) return;
|
|
4106
|
+
isDrawingRef.current = true;
|
|
4107
|
+
const rect = canvas.getBoundingClientRect();
|
|
4108
|
+
const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
|
|
4109
|
+
const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
|
|
4110
|
+
ctx.beginPath();
|
|
4111
|
+
ctx.moveTo(x, y);
|
|
4112
|
+
};
|
|
4113
|
+
const draw = (e) => {
|
|
4114
|
+
if (!isDrawingRef.current) return;
|
|
4115
|
+
const canvas = canvasRef.current;
|
|
4116
|
+
if (!canvas) return;
|
|
4117
|
+
const ctx = canvas.getContext("2d");
|
|
4118
|
+
if (!ctx) return;
|
|
4119
|
+
const rect = canvas.getBoundingClientRect();
|
|
4120
|
+
const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
|
|
4121
|
+
const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
|
|
4122
|
+
ctx.lineTo(x, y);
|
|
4123
|
+
ctx.stroke();
|
|
4124
|
+
};
|
|
4125
|
+
const stopDrawing = () => {
|
|
4126
|
+
isDrawingRef.current = false;
|
|
4127
|
+
};
|
|
4128
|
+
const clearCanvas = () => {
|
|
4129
|
+
const canvas = canvasRef.current;
|
|
4130
|
+
if (!canvas) return;
|
|
4131
|
+
const ctx = canvas.getContext("2d");
|
|
4132
|
+
if (!ctx) return;
|
|
4133
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
4134
|
+
};
|
|
4135
|
+
const saveDrawnSignature = () => {
|
|
4136
|
+
const canvas = canvasRef.current;
|
|
4137
|
+
if (!canvas) return;
|
|
4138
|
+
const dataUrl = canvas.toDataURL("image/png");
|
|
4139
|
+
onChange(dataUrl);
|
|
4140
|
+
setModalOpen(false);
|
|
4141
|
+
};
|
|
4142
|
+
const handleFileUpload = (e) => {
|
|
4143
|
+
const file = e.target.files?.[0];
|
|
4144
|
+
if (!file) return;
|
|
4145
|
+
const reader = new FileReader();
|
|
4146
|
+
reader.onload = (evt) => {
|
|
4147
|
+
if (typeof evt.target?.result === "string") {
|
|
4148
|
+
onChange(evt.target.result);
|
|
4149
|
+
}
|
|
4150
|
+
};
|
|
4151
|
+
reader.readAsDataURL(file);
|
|
4152
|
+
e.target.value = "";
|
|
4153
|
+
};
|
|
4154
|
+
(0, import_react5.useEffect)(() => {
|
|
4155
|
+
if (modalOpen) {
|
|
4156
|
+
setTimeout(() => {
|
|
4157
|
+
const canvas = canvasRef.current;
|
|
4158
|
+
if (!canvas) return;
|
|
4159
|
+
const ctx = canvas.getContext("2d");
|
|
4160
|
+
if (ctx) {
|
|
4161
|
+
ctx.strokeStyle = "#0f172a";
|
|
4162
|
+
ctx.lineWidth = 2.5;
|
|
4163
|
+
ctx.lineCap = "round";
|
|
4164
|
+
ctx.lineJoin = "round";
|
|
4165
|
+
}
|
|
4166
|
+
}, 50);
|
|
4167
|
+
}
|
|
4168
|
+
}, [modalOpen]);
|
|
4169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
4170
|
+
sigVal ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between p-3 rounded-xl border border-slate-200 bg-slate-50/70", children: [
|
|
4171
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
4172
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4173
|
+
import_antd.Image,
|
|
4174
|
+
{
|
|
4175
|
+
src: sigVal,
|
|
4176
|
+
alt: displayLabel,
|
|
4177
|
+
className: "h-16 max-w-[220px] object-contain rounded bg-white p-1 border border-slate-200 shadow-sm cursor-pointer hover:border-blue-500",
|
|
4178
|
+
preview: {
|
|
4179
|
+
mask: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold", children: t.previewMask })
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
),
|
|
4183
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
|
|
4184
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold text-emerald-700 bg-emerald-50 border border-emerald-200 px-2.5 py-0.5 rounded-full w-fit", children: t.signatureRegistered }),
|
|
4185
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[11px] text-slate-500", children: t.viewLarger })
|
|
4186
|
+
] })
|
|
4187
|
+
] }),
|
|
4188
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4189
|
+
import_antd.Button,
|
|
4190
|
+
{
|
|
4191
|
+
danger: true,
|
|
4192
|
+
type: "text",
|
|
4193
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" }),
|
|
4194
|
+
onClick: () => onChange(""),
|
|
4195
|
+
className: "hover:bg-red-50 text-red-600 font-medium",
|
|
4196
|
+
children: t.delete
|
|
4197
|
+
}
|
|
4198
|
+
)
|
|
4199
|
+
] }) : null,
|
|
4200
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
4201
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4202
|
+
import_antd.Button,
|
|
4203
|
+
{
|
|
4204
|
+
type: "primary",
|
|
4205
|
+
size: "large",
|
|
4206
|
+
onClick: () => {
|
|
4207
|
+
clearCanvas();
|
|
4208
|
+
setModalOpen(true);
|
|
4209
|
+
},
|
|
4210
|
+
className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
|
|
4211
|
+
children: sigVal ? t.replaceSignature : t.addSignature
|
|
4212
|
+
}
|
|
4213
|
+
),
|
|
4214
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4215
|
+
import_antd.Button,
|
|
4216
|
+
{
|
|
4217
|
+
type: "primary",
|
|
4218
|
+
size: "large",
|
|
4219
|
+
onClick: () => fileInputRef.current?.click(),
|
|
4220
|
+
className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
|
|
4221
|
+
children: sigVal ? t.uploadNewImage : t.uploadImage
|
|
4222
|
+
}
|
|
4223
|
+
),
|
|
4224
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4225
|
+
"input",
|
|
4226
|
+
{
|
|
4227
|
+
type: "file",
|
|
4228
|
+
ref: fileInputRef,
|
|
4229
|
+
accept: "image/*",
|
|
4230
|
+
onChange: handleFileUpload,
|
|
4231
|
+
className: "hidden"
|
|
4232
|
+
}
|
|
4233
|
+
)
|
|
4234
|
+
] }),
|
|
4235
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4236
|
+
import_antd.Modal,
|
|
4237
|
+
{
|
|
4238
|
+
open: modalOpen,
|
|
4239
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-bold text-slate-800", children: t.signOnScreen }),
|
|
4240
|
+
onCancel: () => setModalOpen(false),
|
|
4241
|
+
centered: true,
|
|
4242
|
+
width: 560,
|
|
4243
|
+
footer: [
|
|
4244
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { onClick: clearCanvas, className: "rounded-xl font-medium", children: t.clear }, "clear"),
|
|
4245
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { onClick: () => setModalOpen(false), className: "rounded-xl font-medium", children: t.cancel }, "cancel"),
|
|
4246
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4247
|
+
import_antd.Button,
|
|
4248
|
+
{
|
|
4249
|
+
type: "primary",
|
|
4250
|
+
onClick: saveDrawnSignature,
|
|
4251
|
+
className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl",
|
|
4252
|
+
children: t.saveSignature
|
|
4253
|
+
},
|
|
4254
|
+
"save"
|
|
4255
|
+
)
|
|
4256
|
+
],
|
|
4257
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "py-2 space-y-2", children: [
|
|
4258
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: t.signInstructions }),
|
|
4259
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "border-2 border-dashed border-slate-300 rounded-2xl bg-white overflow-hidden touch-none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4260
|
+
"canvas",
|
|
4261
|
+
{
|
|
4262
|
+
ref: canvasRef,
|
|
4263
|
+
width: 500,
|
|
4264
|
+
height: 220,
|
|
4265
|
+
onMouseDown: startDrawing,
|
|
4266
|
+
onMouseMove: draw,
|
|
4267
|
+
onMouseUp: stopDrawing,
|
|
4268
|
+
onMouseLeave: stopDrawing,
|
|
4269
|
+
onTouchStart: startDrawing,
|
|
4270
|
+
onTouchMove: draw,
|
|
4271
|
+
onTouchEnd: stopDrawing,
|
|
4272
|
+
className: "w-full h-[220px] cursor-crosshair block"
|
|
4273
|
+
}
|
|
4274
|
+
) })
|
|
4275
|
+
] })
|
|
4276
|
+
}
|
|
4277
|
+
)
|
|
4278
|
+
] });
|
|
4279
|
+
}
|
|
3552
4280
|
function FormattedNumberInput({
|
|
3553
4281
|
value,
|
|
3554
4282
|
onChange,
|
|
@@ -4231,11 +4959,80 @@ function ReferenceSelect({
|
|
|
4231
4959
|
searchable = false,
|
|
4232
4960
|
max,
|
|
4233
4961
|
value,
|
|
4234
|
-
onChange
|
|
4962
|
+
onChange,
|
|
4963
|
+
onSelectRecord
|
|
4235
4964
|
}) {
|
|
4236
4965
|
const ctx = useCmsContext();
|
|
4966
|
+
const t = useAdminI18n();
|
|
4237
4967
|
const [options, setOptions] = (0, import_react5.useState)([]);
|
|
4238
4968
|
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
4969
|
+
const [clientModalOpen, setClientModalOpen] = (0, import_react5.useState)(false);
|
|
4970
|
+
const [creatingClient, setCreatingClient] = (0, import_react5.useState)(false);
|
|
4971
|
+
const [clientError, setClientError] = (0, import_react5.useState)("");
|
|
4972
|
+
const [newClient, setNewClient] = (0, import_react5.useState)({
|
|
4973
|
+
tipo: "Persona",
|
|
4974
|
+
tipoDocumento: "C\xE9dula de ciudadan\xEDa",
|
|
4975
|
+
id: "",
|
|
4976
|
+
sucursal: "",
|
|
4977
|
+
nombre: "",
|
|
4978
|
+
email: "",
|
|
4979
|
+
telefono: "",
|
|
4980
|
+
ciudad: "",
|
|
4981
|
+
direccion: ""
|
|
4982
|
+
});
|
|
4983
|
+
const handleSaveClient = async () => {
|
|
4984
|
+
setClientError("");
|
|
4985
|
+
if (!newClient.id.trim()) {
|
|
4986
|
+
setClientError(t.idRequired);
|
|
4987
|
+
return;
|
|
4988
|
+
}
|
|
4989
|
+
if (!newClient.nombre.trim()) {
|
|
4990
|
+
setClientError(t.nameRequired);
|
|
4991
|
+
return;
|
|
4992
|
+
}
|
|
4993
|
+
setCreatingClient(true);
|
|
4994
|
+
try {
|
|
4995
|
+
const entry = {
|
|
4996
|
+
...newClient,
|
|
4997
|
+
id: newClient.id.trim(),
|
|
4998
|
+
nombre: newClient.nombre.trim()
|
|
4999
|
+
};
|
|
5000
|
+
await ctx.adapter.putEntry("clients", entry);
|
|
5001
|
+
const res = await ctx.adapter.listEntries("clients");
|
|
5002
|
+
const fromCollection = (res || []).map((r) => {
|
|
5003
|
+
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
5004
|
+
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
5005
|
+
const lab = fullName || String(r[displayField] || r.name || r.id);
|
|
5006
|
+
return {
|
|
5007
|
+
value: val,
|
|
5008
|
+
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
5009
|
+
raw: r
|
|
5010
|
+
};
|
|
5011
|
+
});
|
|
5012
|
+
setOptions(fromCollection);
|
|
5013
|
+
onChange(entry.id);
|
|
5014
|
+
if (onSelectRecord) {
|
|
5015
|
+
onSelectRecord(entry);
|
|
5016
|
+
}
|
|
5017
|
+
setClientModalOpen(false);
|
|
5018
|
+
setNewClient({
|
|
5019
|
+
tipo: "Persona",
|
|
5020
|
+
tipoDocumento: "C\xE9dula de ciudadan\xEDa",
|
|
5021
|
+
id: "",
|
|
5022
|
+
sucursal: "",
|
|
5023
|
+
nombre: "",
|
|
5024
|
+
email: "",
|
|
5025
|
+
telefono: "",
|
|
5026
|
+
ciudad: "",
|
|
5027
|
+
direccion: ""
|
|
5028
|
+
});
|
|
5029
|
+
import_antd.message.success(t.clientCreatedSuccess);
|
|
5030
|
+
} catch (err) {
|
|
5031
|
+
setClientError(err?.message || "Error al crear cliente.");
|
|
5032
|
+
} finally {
|
|
5033
|
+
setCreatingClient(false);
|
|
5034
|
+
}
|
|
5035
|
+
};
|
|
4239
5036
|
(0, import_react5.useEffect)(() => {
|
|
4240
5037
|
if (!collectionId) {
|
|
4241
5038
|
if (fallbackOptions && fallbackOptions.length > 0) {
|
|
@@ -4246,65 +5043,279 @@ function ReferenceSelect({
|
|
|
4246
5043
|
}
|
|
4247
5044
|
setLoading(true);
|
|
4248
5045
|
ctx.adapter.listEntries(collectionId).then((res) => {
|
|
4249
|
-
const fromCollection = res.map((r) => {
|
|
5046
|
+
const fromCollection = (res || []).map((r) => {
|
|
4250
5047
|
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
4251
|
-
const
|
|
4252
|
-
|
|
5048
|
+
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
5049
|
+
const lab = fullName || String(r[displayField] || r.name || r.id);
|
|
5050
|
+
return {
|
|
5051
|
+
value: val,
|
|
5052
|
+
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
5053
|
+
raw: r
|
|
5054
|
+
};
|
|
4253
5055
|
});
|
|
4254
|
-
|
|
4255
|
-
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
4256
|
-
);
|
|
4257
|
-
const combined = [...fromCollection];
|
|
4258
|
-
for (const fb of fallbackList) {
|
|
4259
|
-
if (!combined.some((c) => c.value === fb.value || c.label === fb.label)) {
|
|
4260
|
-
combined.push(fb);
|
|
4261
|
-
}
|
|
4262
|
-
}
|
|
4263
|
-
setOptions(combined);
|
|
5056
|
+
setOptions(fromCollection);
|
|
4264
5057
|
setLoading(false);
|
|
4265
5058
|
}).catch(() => {
|
|
4266
|
-
|
|
4267
|
-
setOptions(fallbackOptions.map((opt) => typeof opt === "string" ? { value: opt, label: opt } : opt));
|
|
4268
|
-
}
|
|
5059
|
+
setOptions([]);
|
|
4269
5060
|
setLoading(false);
|
|
4270
5061
|
});
|
|
4271
|
-
}, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter]);
|
|
5062
|
+
}, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter, ctx.collectionChangedAt]);
|
|
4272
5063
|
if (multiple) {
|
|
4273
5064
|
const selectedList = Array.isArray(value) ? value.map(String) : typeof value === "string" && value.trim() ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
4274
5065
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4275
|
-
|
|
5066
|
+
import_antd.Select,
|
|
4276
5067
|
{
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
onChange,
|
|
5068
|
+
size: "large",
|
|
5069
|
+
mode: "multiple",
|
|
4280
5070
|
loading,
|
|
4281
|
-
searchable,
|
|
5071
|
+
showSearch: searchable,
|
|
4282
5072
|
placeholder: "Seleccionar opciones...",
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
5073
|
+
filterOption: (input, option) => {
|
|
5074
|
+
if (!input) return true;
|
|
5075
|
+
const q = input.toLowerCase();
|
|
5076
|
+
const label = String(option?.label ?? "").toLowerCase();
|
|
5077
|
+
const val = String(option?.value ?? "").toLowerCase();
|
|
5078
|
+
return label.includes(q) || val.includes(q);
|
|
5079
|
+
},
|
|
5080
|
+
maxCount: max,
|
|
5081
|
+
value: selectedList,
|
|
5082
|
+
onChange,
|
|
5083
|
+
options,
|
|
5084
|
+
className: "w-full"
|
|
4286
5085
|
}
|
|
4287
5086
|
);
|
|
4288
5087
|
}
|
|
4289
|
-
const singleVal =
|
|
5088
|
+
const singleVal = value !== void 0 && value !== null && value !== "" ? String(value) : void 0;
|
|
4290
5089
|
const displayOptions = [...options];
|
|
4291
5090
|
if (singleVal && !displayOptions.some((o) => o.value === singleVal)) {
|
|
4292
5091
|
displayOptions.unshift({ value: singleVal, label: singleVal });
|
|
4293
5092
|
}
|
|
4294
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4295
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
4296
|
-
"
|
|
5093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
5094
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
5095
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5096
|
+
import_antd.Select,
|
|
5097
|
+
{
|
|
5098
|
+
size: "large",
|
|
5099
|
+
loading,
|
|
5100
|
+
showSearch: searchable,
|
|
5101
|
+
placeholder: loading ? t.loadingOptions : t.selectOption,
|
|
5102
|
+
allowClear: true,
|
|
5103
|
+
filterOption: (input, option) => {
|
|
5104
|
+
if (!input) return true;
|
|
5105
|
+
const q = input.toLowerCase();
|
|
5106
|
+
const label = String(option?.label ?? "").toLowerCase();
|
|
5107
|
+
const val = String(option?.value ?? "").toLowerCase();
|
|
5108
|
+
return label.includes(q) || val.includes(q);
|
|
5109
|
+
},
|
|
5110
|
+
value: singleVal,
|
|
5111
|
+
onChange: (v) => {
|
|
5112
|
+
onChange(v || "");
|
|
5113
|
+
if (onSelectRecord) {
|
|
5114
|
+
const found = options.find((o) => o.value === v);
|
|
5115
|
+
if (found?.raw) onSelectRecord(found.raw);
|
|
5116
|
+
}
|
|
5117
|
+
},
|
|
5118
|
+
options: displayOptions,
|
|
5119
|
+
dropdownRender: (menu) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5120
|
+
menu,
|
|
5121
|
+
collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
|
|
5122
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindClient }),
|
|
5123
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5124
|
+
import_antd.Button,
|
|
5125
|
+
{
|
|
5126
|
+
type: "primary",
|
|
5127
|
+
size: "small",
|
|
5128
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
|
|
5129
|
+
onClick: () => {
|
|
5130
|
+
setClientError("");
|
|
5131
|
+
setClientModalOpen(true);
|
|
5132
|
+
},
|
|
5133
|
+
className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
|
|
5134
|
+
children: t.createClient
|
|
5135
|
+
}
|
|
5136
|
+
)
|
|
5137
|
+
] })
|
|
5138
|
+
] }),
|
|
5139
|
+
className: "w-full"
|
|
5140
|
+
}
|
|
5141
|
+
) }),
|
|
5142
|
+
collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5143
|
+
import_antd.Button,
|
|
5144
|
+
{
|
|
5145
|
+
type: "primary",
|
|
5146
|
+
size: "large",
|
|
5147
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-4 h-4" }),
|
|
5148
|
+
onClick: () => {
|
|
5149
|
+
setClientError("");
|
|
5150
|
+
setClientModalOpen(true);
|
|
5151
|
+
},
|
|
5152
|
+
className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
|
|
5153
|
+
children: t.newBtn
|
|
5154
|
+
}
|
|
5155
|
+
)
|
|
5156
|
+
] }),
|
|
5157
|
+
collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5158
|
+
import_antd.Modal,
|
|
4297
5159
|
{
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
5160
|
+
open: clientModalOpen,
|
|
5161
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xl font-bold text-slate-900 font-display", children: t.basicDetails }),
|
|
5162
|
+
onCancel: () => setClientModalOpen(false),
|
|
5163
|
+
centered: true,
|
|
5164
|
+
width: 650,
|
|
5165
|
+
footer: null,
|
|
5166
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pt-2 space-y-4", children: [
|
|
5167
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
5168
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5169
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientType }),
|
|
5170
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5171
|
+
import_antd.Select,
|
|
5172
|
+
{
|
|
5173
|
+
size: "large",
|
|
5174
|
+
value: newClient.tipo,
|
|
5175
|
+
onChange: (val) => {
|
|
5176
|
+
setNewClient((prev) => ({
|
|
5177
|
+
...prev,
|
|
5178
|
+
tipo: val,
|
|
5179
|
+
tipoDocumento: val === "Empresa" ? "Nit" : "C\xE9dula de ciudadan\xEDa"
|
|
5180
|
+
}));
|
|
5181
|
+
},
|
|
5182
|
+
options: [
|
|
5183
|
+
{ label: "Persona", value: "Persona" },
|
|
5184
|
+
{ label: "Empresa", value: "Empresa" }
|
|
5185
|
+
],
|
|
5186
|
+
className: "w-full"
|
|
5187
|
+
}
|
|
5188
|
+
)
|
|
5189
|
+
] }),
|
|
5190
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5191
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientDocType }),
|
|
5192
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5193
|
+
import_antd.Select,
|
|
5194
|
+
{
|
|
5195
|
+
size: "large",
|
|
5196
|
+
value: newClient.tipoDocumento,
|
|
5197
|
+
onChange: (val) => setNewClient((prev) => ({ ...prev, tipoDocumento: val })),
|
|
5198
|
+
options: newClient.tipo === "Persona" ? [
|
|
5199
|
+
{ label: "C\xE9dula de ciudadan\xEDa", value: "C\xE9dula de ciudadan\xEDa" },
|
|
5200
|
+
{ label: "C\xE9dula de extranjer\xEDa", value: "C\xE9dula de extranjer\xEDa" },
|
|
5201
|
+
{ label: "Pasaporte", value: "Pasaporte" }
|
|
5202
|
+
] : [{ label: "Nit", value: "Nit" }],
|
|
5203
|
+
className: "w-full"
|
|
5204
|
+
}
|
|
5205
|
+
)
|
|
5206
|
+
] })
|
|
5207
|
+
] }),
|
|
5208
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
5209
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5210
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
|
|
5211
|
+
t.clientIdentification,
|
|
5212
|
+
" *"
|
|
5213
|
+
] }),
|
|
5214
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5215
|
+
import_antd.Input,
|
|
5216
|
+
{
|
|
5217
|
+
size: "large",
|
|
5218
|
+
placeholder: t.clientIdentification,
|
|
5219
|
+
value: newClient.id,
|
|
5220
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, id: e.target.value }))
|
|
5221
|
+
}
|
|
5222
|
+
)
|
|
5223
|
+
] }),
|
|
5224
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5225
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientBranch }),
|
|
5226
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5227
|
+
import_antd.Input,
|
|
5228
|
+
{
|
|
5229
|
+
size: "large",
|
|
5230
|
+
placeholder: t.clientBranch,
|
|
5231
|
+
value: newClient.sucursal,
|
|
5232
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, sucursal: e.target.value }))
|
|
5233
|
+
}
|
|
5234
|
+
)
|
|
5235
|
+
] })
|
|
5236
|
+
] }),
|
|
5237
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
5238
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5239
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
|
|
5240
|
+
t.clientName,
|
|
5241
|
+
" *"
|
|
5242
|
+
] }),
|
|
5243
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5244
|
+
import_antd.Input,
|
|
5245
|
+
{
|
|
5246
|
+
size: "large",
|
|
5247
|
+
placeholder: t.clientName,
|
|
5248
|
+
value: newClient.nombre,
|
|
5249
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, nombre: e.target.value }))
|
|
5250
|
+
}
|
|
5251
|
+
)
|
|
5252
|
+
] }),
|
|
5253
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5254
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientEmail }),
|
|
5255
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5256
|
+
import_antd.Input,
|
|
5257
|
+
{
|
|
5258
|
+
size: "large",
|
|
5259
|
+
placeholder: t.clientEmail,
|
|
5260
|
+
value: newClient.email,
|
|
5261
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, email: e.target.value }))
|
|
5262
|
+
}
|
|
5263
|
+
)
|
|
5264
|
+
] })
|
|
5265
|
+
] }),
|
|
5266
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
5267
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5268
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientPhone }),
|
|
5269
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5270
|
+
import_antd.Input,
|
|
5271
|
+
{
|
|
5272
|
+
size: "large",
|
|
5273
|
+
placeholder: t.clientPhone,
|
|
5274
|
+
value: newClient.telefono,
|
|
5275
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, telefono: e.target.value }))
|
|
5276
|
+
}
|
|
5277
|
+
)
|
|
5278
|
+
] }),
|
|
5279
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5280
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientCity }),
|
|
5281
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5282
|
+
import_antd.Input,
|
|
5283
|
+
{
|
|
5284
|
+
size: "large",
|
|
5285
|
+
placeholder: t.clientCity,
|
|
5286
|
+
value: newClient.ciudad,
|
|
5287
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, ciudad: e.target.value }))
|
|
5288
|
+
}
|
|
5289
|
+
)
|
|
5290
|
+
] })
|
|
5291
|
+
] }),
|
|
5292
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
5293
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientAddress }),
|
|
5294
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5295
|
+
import_antd.Input,
|
|
5296
|
+
{
|
|
5297
|
+
size: "large",
|
|
5298
|
+
placeholder: t.clientAddress,
|
|
5299
|
+
value: newClient.direccion,
|
|
5300
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, direccion: e.target.value }))
|
|
5301
|
+
}
|
|
5302
|
+
)
|
|
5303
|
+
] }),
|
|
5304
|
+
clientError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs font-semibold text-red-600 bg-red-50 p-2.5 rounded-lg border border-red-200", children: clientError }),
|
|
5305
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
5306
|
+
import_antd.Button,
|
|
5307
|
+
{
|
|
5308
|
+
type: "primary",
|
|
5309
|
+
size: "large",
|
|
5310
|
+
loading: creatingClient,
|
|
5311
|
+
onClick: handleSaveClient,
|
|
5312
|
+
className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm mt-2",
|
|
5313
|
+
children: t.create.toUpperCase()
|
|
5314
|
+
}
|
|
5315
|
+
)
|
|
5316
|
+
] })
|
|
4305
5317
|
}
|
|
4306
|
-
)
|
|
4307
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
|
|
5318
|
+
)
|
|
4308
5319
|
] });
|
|
4309
5320
|
}
|
|
4310
5321
|
function ReferenceTableCell({
|