admin-lib-cms 1.2.10 → 1.2.12
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 +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1518 -592
- package/dist/index.mjs +1531 -593
- package/dist/types.d.mts +21 -2
- package/dist/types.d.ts +21 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -22,9 +22,21 @@ import {
|
|
|
22
22
|
} from "./chunk-4KJKAYIC.mjs";
|
|
23
23
|
|
|
24
24
|
// src/admin/AdminApp.tsx
|
|
25
|
-
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
25
|
+
import React, { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
26
26
|
import { createPortal } from "react-dom";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
ConfigProvider,
|
|
29
|
+
Modal,
|
|
30
|
+
TimePicker,
|
|
31
|
+
DatePicker,
|
|
32
|
+
Input,
|
|
33
|
+
InputNumber,
|
|
34
|
+
Select,
|
|
35
|
+
Switch,
|
|
36
|
+
Button,
|
|
37
|
+
Image,
|
|
38
|
+
message
|
|
39
|
+
} from "antd";
|
|
28
40
|
import dayjs from "dayjs";
|
|
29
41
|
import {
|
|
30
42
|
FileText,
|
|
@@ -56,8 +68,191 @@ import {
|
|
|
56
68
|
Check,
|
|
57
69
|
GripVertical
|
|
58
70
|
} from "lucide-react";
|
|
71
|
+
|
|
72
|
+
// src/admin/i18n.ts
|
|
73
|
+
var translations = {
|
|
74
|
+
es: {
|
|
75
|
+
menuDashboard: "Dashboard",
|
|
76
|
+
menuPages: "P\xE1ginas",
|
|
77
|
+
menuCollections: "Colecciones",
|
|
78
|
+
menuData: "Datos",
|
|
79
|
+
menuConfig: "Configuraci\xF3n",
|
|
80
|
+
menuSettings: "Ajustes",
|
|
81
|
+
menuSubscription: "Suscripci\xF3n",
|
|
82
|
+
liveEditor: "Editor en vivo",
|
|
83
|
+
viewSite: "Ver sitio",
|
|
84
|
+
signOut: "Cerrar sesi\xF3n",
|
|
85
|
+
signedInAs: "Conectado como",
|
|
86
|
+
saving: "Guardando...",
|
|
87
|
+
saved: "Guardado",
|
|
88
|
+
saveChanges: "Guardar cambios",
|
|
89
|
+
discardChanges: "Descartar",
|
|
90
|
+
unsavedChanges: "Cambios sin guardar",
|
|
91
|
+
desktop: "Escritorio",
|
|
92
|
+
tablet: "Tableta",
|
|
93
|
+
mobile: "M\xF3vil",
|
|
94
|
+
search: "Buscar...",
|
|
95
|
+
filterBy: "Filtrar por...",
|
|
96
|
+
all: "Todos",
|
|
97
|
+
actions: "Acciones",
|
|
98
|
+
edit: "Editar",
|
|
99
|
+
delete: "Eliminar",
|
|
100
|
+
cancel: "Cancelar",
|
|
101
|
+
save: "Guardar",
|
|
102
|
+
create: "Crear",
|
|
103
|
+
newEntry: "Nuevo",
|
|
104
|
+
createNew: "Crear nuevo",
|
|
105
|
+
confirmDeleteTitle: "\xBFEliminar este registro?",
|
|
106
|
+
confirmDeleteText: "Esta acci\xF3n no se puede deshacer.",
|
|
107
|
+
deleteSuccess: "Registro eliminado exitosamente.",
|
|
108
|
+
saveSuccess: "Registro guardado exitosamente.",
|
|
109
|
+
noRecords: "No hay registros disponibles.",
|
|
110
|
+
recordsFound: "registros encontrados",
|
|
111
|
+
back: "Volver",
|
|
112
|
+
apply: "Aplicar",
|
|
113
|
+
close: "Cerrar",
|
|
114
|
+
signatureRegistered: "Firma registrada",
|
|
115
|
+
viewLarger: "Click en la firma para verla en pantalla grande",
|
|
116
|
+
previewMask: "Ver m\xE1s grande",
|
|
117
|
+
addSignature: "AGREGAR FIRMA",
|
|
118
|
+
replaceSignature: "REEMPLAZAR FIRMA",
|
|
119
|
+
uploadImage: "SUBIR IMAGEN",
|
|
120
|
+
uploadNewImage: "SUBIR NUEVA IMAGEN",
|
|
121
|
+
signOnScreen: "Firmar en pantalla",
|
|
122
|
+
signInstructions: "Dibuja la firma en el recuadro usando el dedo o el mouse:",
|
|
123
|
+
clear: "Limpiar",
|
|
124
|
+
saveSignature: "Guardar Firma",
|
|
125
|
+
selectOption: "-- Selecciona una opci\xF3n --",
|
|
126
|
+
loadingOptions: "Cargando opciones...",
|
|
127
|
+
cantFindClient: "\xBFNo encuentras el cliente?",
|
|
128
|
+
createClient: "Crear cliente",
|
|
129
|
+
newBtn: "Nuevo",
|
|
130
|
+
basicDetails: "Datos b\xE1sicos",
|
|
131
|
+
clientType: "Tipo",
|
|
132
|
+
clientDocType: "Tipo de documento",
|
|
133
|
+
clientIdentification: "Identificaci\xF3n",
|
|
134
|
+
clientBranch: "Sucursal o sede",
|
|
135
|
+
clientName: "Nombre",
|
|
136
|
+
clientEmail: "Email",
|
|
137
|
+
clientPhone: "Tel\xE9fono",
|
|
138
|
+
clientCity: "Ciudad",
|
|
139
|
+
clientAddress: "direcci\xF3n",
|
|
140
|
+
clientCreatedSuccess: "Cliente creado y seleccionado exitosamente.",
|
|
141
|
+
idRequired: "La identificaci\xF3n es obligatoria.",
|
|
142
|
+
nameRequired: "El nombre es obligatorio.",
|
|
143
|
+
signInTitle: "Iniciar sesi\xF3n",
|
|
144
|
+
signInSubtitle: "Ingresa tus credenciales para acceder al panel",
|
|
145
|
+
emailLabel: "Correo electr\xF3nico",
|
|
146
|
+
passwordLabel: "Contrase\xF1a",
|
|
147
|
+
signInButton: "Iniciar sesi\xF3n",
|
|
148
|
+
invalidCredentials: "Credenciales inv\xE1lidas",
|
|
149
|
+
loggingIn: "Iniciando sesi\xF3n...",
|
|
150
|
+
submissions: "Mensajes y Formularios",
|
|
151
|
+
noSubmissions: "No hay env\xEDos registrados",
|
|
152
|
+
exportCsv: "Exportar CSV",
|
|
153
|
+
markRead: "Marcar como le\xEDdo",
|
|
154
|
+
settingsTitle: "Ajustes del sitio",
|
|
155
|
+
entries: "registros"
|
|
156
|
+
},
|
|
157
|
+
en: {
|
|
158
|
+
menuDashboard: "Dashboard",
|
|
159
|
+
menuPages: "Pages",
|
|
160
|
+
menuCollections: "Collections",
|
|
161
|
+
menuData: "Data",
|
|
162
|
+
menuConfig: "Settings",
|
|
163
|
+
menuSettings: "Preferences",
|
|
164
|
+
menuSubscription: "Subscription",
|
|
165
|
+
liveEditor: "Live Editor",
|
|
166
|
+
viewSite: "View site",
|
|
167
|
+
signOut: "Sign out",
|
|
168
|
+
signedInAs: "Signed in as",
|
|
169
|
+
saving: "Saving...",
|
|
170
|
+
saved: "Saved",
|
|
171
|
+
saveChanges: "Save changes",
|
|
172
|
+
discardChanges: "Discard",
|
|
173
|
+
unsavedChanges: "Unsaved changes",
|
|
174
|
+
desktop: "Desktop",
|
|
175
|
+
tablet: "Tablet",
|
|
176
|
+
mobile: "Mobile",
|
|
177
|
+
search: "Search...",
|
|
178
|
+
filterBy: "Filter by...",
|
|
179
|
+
all: "All",
|
|
180
|
+
actions: "Actions",
|
|
181
|
+
edit: "Edit",
|
|
182
|
+
delete: "Delete",
|
|
183
|
+
cancel: "Cancel",
|
|
184
|
+
save: "Save",
|
|
185
|
+
create: "Create",
|
|
186
|
+
newEntry: "New",
|
|
187
|
+
createNew: "Create new",
|
|
188
|
+
confirmDeleteTitle: "Delete this record?",
|
|
189
|
+
confirmDeleteText: "This action cannot be undone.",
|
|
190
|
+
deleteSuccess: "Record deleted successfully.",
|
|
191
|
+
saveSuccess: "Record saved successfully.",
|
|
192
|
+
noRecords: "No records found.",
|
|
193
|
+
recordsFound: "records found",
|
|
194
|
+
back: "Back",
|
|
195
|
+
apply: "Apply",
|
|
196
|
+
close: "Close",
|
|
197
|
+
signatureRegistered: "Signature registered",
|
|
198
|
+
viewLarger: "Click signature to view full size",
|
|
199
|
+
previewMask: "View larger",
|
|
200
|
+
addSignature: "ADD SIGNATURE",
|
|
201
|
+
replaceSignature: "REPLACE SIGNATURE",
|
|
202
|
+
uploadImage: "UPLOAD IMAGE",
|
|
203
|
+
uploadNewImage: "UPLOAD NEW IMAGE",
|
|
204
|
+
signOnScreen: "Sign on screen",
|
|
205
|
+
signInstructions: "Draw signature in the box using finger or mouse:",
|
|
206
|
+
clear: "Clear",
|
|
207
|
+
saveSignature: "Save Signature",
|
|
208
|
+
selectOption: "-- Select an option --",
|
|
209
|
+
loadingOptions: "Loading options...",
|
|
210
|
+
cantFindClient: "Can't find the client?",
|
|
211
|
+
createClient: "Create client",
|
|
212
|
+
newBtn: "New",
|
|
213
|
+
basicDetails: "Basic details",
|
|
214
|
+
clientType: "Type",
|
|
215
|
+
clientDocType: "Document type",
|
|
216
|
+
clientIdentification: "Identification",
|
|
217
|
+
clientBranch: "Branch or site",
|
|
218
|
+
clientName: "Name",
|
|
219
|
+
clientEmail: "Email",
|
|
220
|
+
clientPhone: "Phone",
|
|
221
|
+
clientCity: "City",
|
|
222
|
+
clientAddress: "Address",
|
|
223
|
+
clientCreatedSuccess: "Client created and selected successfully.",
|
|
224
|
+
idRequired: "Identification is required.",
|
|
225
|
+
nameRequired: "Name is required.",
|
|
226
|
+
signInTitle: "Sign In",
|
|
227
|
+
signInSubtitle: "Enter your credentials to access the panel",
|
|
228
|
+
emailLabel: "Email address",
|
|
229
|
+
passwordLabel: "Password",
|
|
230
|
+
signInButton: "Sign In",
|
|
231
|
+
invalidCredentials: "Invalid credentials",
|
|
232
|
+
loggingIn: "Signing in...",
|
|
233
|
+
submissions: "Form Submissions",
|
|
234
|
+
noSubmissions: "No submissions yet",
|
|
235
|
+
exportCsv: "Export CSV",
|
|
236
|
+
markRead: "Mark as read",
|
|
237
|
+
settingsTitle: "Site Settings",
|
|
238
|
+
entries: "entries"
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
function getAdminTranslations(locale) {
|
|
242
|
+
const norm = String(locale || "").trim().toLowerCase();
|
|
243
|
+
if (norm === "es" || norm.startsWith("es-")) {
|
|
244
|
+
return translations.es;
|
|
245
|
+
}
|
|
246
|
+
return translations.en;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/admin/AdminApp.tsx
|
|
59
250
|
import { CreditCard, BarChart3 } from "lucide-react";
|
|
60
251
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
252
|
+
var AdminI18nContext = React.createContext(getAdminTranslations("en"));
|
|
253
|
+
function useAdminI18n() {
|
|
254
|
+
return React.useContext(AdminI18nContext);
|
|
255
|
+
}
|
|
61
256
|
var TIME_STORAGE_FORMAT = "HH:mm";
|
|
62
257
|
var TIME_DISPLAY_FORMAT = "h:mm A";
|
|
63
258
|
var TIME_PICKER_THEME = {
|
|
@@ -98,23 +293,24 @@ function AdminTimeRangePicker(props) {
|
|
|
98
293
|
}
|
|
99
294
|
) });
|
|
100
295
|
}
|
|
101
|
-
function AdminTimePicker(props) {
|
|
102
|
-
return /* @__PURE__ */ jsx(ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ jsx(
|
|
103
|
-
TimePicker,
|
|
104
|
-
{
|
|
105
|
-
...props,
|
|
106
|
-
className: `w-full min-w-0 ${props.className ?? ""}`,
|
|
107
|
-
style: {
|
|
108
|
-
boxShadow: "0 1px 2px rgba(15, 23, 42, 0.08)",
|
|
109
|
-
...props.style
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
) });
|
|
113
|
-
}
|
|
114
296
|
function toDayjsTime(value) {
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
|
|
297
|
+
const str = String(value ?? "").trim();
|
|
298
|
+
if (!str) return null;
|
|
299
|
+
const match12 = /^(\d{1,2}):(\d{2})\s*([ap]\.?m\.?)$/i.exec(str);
|
|
300
|
+
if (match12) {
|
|
301
|
+
let h = Number(match12[1]);
|
|
302
|
+
const m = Number(match12[2]);
|
|
303
|
+
const isPm = match12[3].toLowerCase().startsWith("p");
|
|
304
|
+
if (isPm && h < 12) h += 12;
|
|
305
|
+
if (!isPm && h === 12) h = 0;
|
|
306
|
+
return dayjs().hour(h).minute(m).second(0).millisecond(0);
|
|
307
|
+
}
|
|
308
|
+
const match24 = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(str);
|
|
309
|
+
if (match24) {
|
|
310
|
+
return dayjs().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
|
|
311
|
+
}
|
|
312
|
+
const parsed = dayjs(str, ["h:mm a", "h:mm A", "hh:mm a", "hh:mm A", "HH:mm"]);
|
|
313
|
+
return parsed.isValid() ? parsed : null;
|
|
118
314
|
}
|
|
119
315
|
function toStoredTime(value) {
|
|
120
316
|
return value?.format(TIME_STORAGE_FORMAT) ?? "";
|
|
@@ -175,6 +371,8 @@ function AdminApp(props) {
|
|
|
175
371
|
}
|
|
176
372
|
function AdminAppContent(props) {
|
|
177
373
|
const ctx = useCmsContext();
|
|
374
|
+
const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
|
|
375
|
+
const t = useMemo(() => getAdminTranslations(rawLocale), [rawLocale]);
|
|
178
376
|
const hasDashboard = Boolean(props.dashboard);
|
|
179
377
|
const [section, setSection] = useState(hasDashboard ? "dashboard" : "pages");
|
|
180
378
|
const [authChecking, setAuthChecking] = useState(true);
|
|
@@ -184,13 +382,13 @@ function AdminAppContent(props) {
|
|
|
184
382
|
const hideGlobals = props.hideGlobals ?? ctx.config.hideGlobals ?? false;
|
|
185
383
|
const hideConfig = props.hideConfig ?? ctx.config.hideConfig ?? false;
|
|
186
384
|
const menuLabels = {
|
|
187
|
-
dashboard:
|
|
188
|
-
pages:
|
|
189
|
-
collections:
|
|
190
|
-
data:
|
|
191
|
-
config:
|
|
192
|
-
settings:
|
|
193
|
-
subscription:
|
|
385
|
+
dashboard: t.menuDashboard,
|
|
386
|
+
pages: t.menuPages,
|
|
387
|
+
collections: t.menuCollections,
|
|
388
|
+
data: t.menuData,
|
|
389
|
+
config: t.menuConfig,
|
|
390
|
+
settings: t.menuSettings,
|
|
391
|
+
subscription: t.menuSubscription,
|
|
194
392
|
...ctx.config.menuLabels,
|
|
195
393
|
...props.menuLabels
|
|
196
394
|
};
|
|
@@ -226,7 +424,7 @@ function AdminAppContent(props) {
|
|
|
226
424
|
if (!isSubscriptionActive) {
|
|
227
425
|
return /* @__PURE__ */ 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__ */ jsx(SubscriptionPage, {}) });
|
|
228
426
|
}
|
|
229
|
-
return /* @__PURE__ */ 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: [
|
|
427
|
+
return /* @__PURE__ */ jsx(AdminI18nContext.Provider, { value: t, children: /* @__PURE__ */ 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: [
|
|
230
428
|
daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ 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." }),
|
|
231
429
|
daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ 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." }),
|
|
232
430
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
|
|
@@ -242,81 +440,155 @@ function AdminAppContent(props) {
|
|
|
242
440
|
] }),
|
|
243
441
|
/* @__PURE__ */ jsx("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
|
|
244
442
|
] }),
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
)
|
|
319
|
-
|
|
443
|
+
/* @__PURE__ */ 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: (() => {
|
|
444
|
+
const navItemsMap = /* @__PURE__ */ new Map();
|
|
445
|
+
if (hasDashboard) {
|
|
446
|
+
navItemsMap.set(
|
|
447
|
+
"dashboard",
|
|
448
|
+
/* @__PURE__ */ jsx(
|
|
449
|
+
SideItem,
|
|
450
|
+
{
|
|
451
|
+
active: section === "dashboard",
|
|
452
|
+
onClick: () => setSection("dashboard"),
|
|
453
|
+
icon: /* @__PURE__ */ jsx(BarChart3, { className: "h-4 w-4 shrink-0" }),
|
|
454
|
+
children: menuLabels.dashboard
|
|
455
|
+
},
|
|
456
|
+
"dashboard"
|
|
457
|
+
)
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
navItemsMap.set(
|
|
461
|
+
"pages",
|
|
462
|
+
/* @__PURE__ */ jsx(
|
|
463
|
+
SideItem,
|
|
464
|
+
{
|
|
465
|
+
active: section === "pages",
|
|
466
|
+
onClick: () => setSection("pages"),
|
|
467
|
+
icon: /* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 shrink-0" }),
|
|
468
|
+
children: menuLabels.pages
|
|
469
|
+
},
|
|
470
|
+
"pages"
|
|
471
|
+
)
|
|
472
|
+
);
|
|
473
|
+
navItemsMap.set(
|
|
474
|
+
"collections",
|
|
475
|
+
/* @__PURE__ */ jsx(
|
|
476
|
+
SideItem,
|
|
477
|
+
{
|
|
478
|
+
active: section === "collections",
|
|
479
|
+
onClick: () => setSection("collections"),
|
|
480
|
+
icon: /* @__PURE__ */ jsx(Boxes, { className: "h-4 w-4 shrink-0" }),
|
|
481
|
+
children: menuLabels.collections
|
|
482
|
+
},
|
|
483
|
+
"collections"
|
|
484
|
+
)
|
|
485
|
+
);
|
|
486
|
+
props.customSections?.forEach((cs) => {
|
|
487
|
+
navItemsMap.set(
|
|
488
|
+
cs.id,
|
|
489
|
+
/* @__PURE__ */ jsx(
|
|
490
|
+
SideItem,
|
|
491
|
+
{
|
|
492
|
+
active: section === cs.id,
|
|
493
|
+
onClick: () => setSection(cs.id),
|
|
494
|
+
icon: cs.icon || /* @__PURE__ */ jsx(Boxes, { className: "h-4 w-4 shrink-0" }),
|
|
495
|
+
children: cs.label
|
|
496
|
+
},
|
|
497
|
+
cs.id
|
|
498
|
+
)
|
|
499
|
+
);
|
|
500
|
+
});
|
|
501
|
+
if (!hideData) {
|
|
502
|
+
navItemsMap.set(
|
|
503
|
+
"submissions",
|
|
504
|
+
/* @__PURE__ */ jsx(
|
|
505
|
+
SideItem,
|
|
506
|
+
{
|
|
507
|
+
active: section === "submissions",
|
|
508
|
+
onClick: () => setSection("submissions"),
|
|
509
|
+
icon: /* @__PURE__ */ jsx(Inbox, { className: "h-4 w-4 shrink-0" }),
|
|
510
|
+
children: menuLabels.data
|
|
511
|
+
},
|
|
512
|
+
"submissions"
|
|
513
|
+
)
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
if (!hideConfig && !hideGlobals) {
|
|
517
|
+
navItemsMap.set(
|
|
518
|
+
"config",
|
|
519
|
+
/* @__PURE__ */ jsx(
|
|
520
|
+
SideItem,
|
|
521
|
+
{
|
|
522
|
+
active: section === "config",
|
|
523
|
+
onClick: () => setSection("config"),
|
|
524
|
+
icon: /* @__PURE__ */ jsx(SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
|
|
525
|
+
children: menuLabels.config
|
|
526
|
+
},
|
|
527
|
+
"config"
|
|
528
|
+
)
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
if (!hideSettings) {
|
|
532
|
+
navItemsMap.set(
|
|
533
|
+
"settings",
|
|
534
|
+
/* @__PURE__ */ jsx(
|
|
535
|
+
SideItem,
|
|
536
|
+
{
|
|
537
|
+
active: section === "settings",
|
|
538
|
+
onClick: () => setSection("settings"),
|
|
539
|
+
icon: /* @__PURE__ */ jsx(SettingsIcon, { className: "h-4 w-4 shrink-0" }),
|
|
540
|
+
children: menuLabels.settings
|
|
541
|
+
},
|
|
542
|
+
"settings"
|
|
543
|
+
)
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
if (subscriptionCtx) {
|
|
547
|
+
navItemsMap.set(
|
|
548
|
+
"subscription",
|
|
549
|
+
/* @__PURE__ */ jsx(
|
|
550
|
+
SideItem,
|
|
551
|
+
{
|
|
552
|
+
active: section === "subscription",
|
|
553
|
+
onClick: () => setSection("subscription"),
|
|
554
|
+
icon: /* @__PURE__ */ jsx(CreditCard, { className: "h-4 w-4 shrink-0" }),
|
|
555
|
+
children: menuLabels.subscription
|
|
556
|
+
},
|
|
557
|
+
"subscription"
|
|
558
|
+
)
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
const orderedKeys = [];
|
|
562
|
+
if (props.menuOrder && Array.isArray(props.menuOrder) && props.menuOrder.length > 0) {
|
|
563
|
+
props.menuOrder.forEach((k) => {
|
|
564
|
+
if (navItemsMap.has(k) && !orderedKeys.includes(k)) {
|
|
565
|
+
orderedKeys.push(k);
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
navItemsMap.forEach((_, k) => {
|
|
569
|
+
if (!orderedKeys.includes(k)) {
|
|
570
|
+
orderedKeys.push(k);
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
} else {
|
|
574
|
+
const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
|
|
575
|
+
const bottomCustom = (props.customSections || []).filter((cs) => cs.position === "bottom" || cs.position === "after-collections").map((cs) => cs.id);
|
|
576
|
+
const otherCustom = (props.customSections || []).filter(
|
|
577
|
+
(cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
|
|
578
|
+
).map((cs) => cs.id);
|
|
579
|
+
if (hasDashboard) orderedKeys.push("dashboard");
|
|
580
|
+
topCustom.forEach((k) => orderedKeys.push(k));
|
|
581
|
+
orderedKeys.push("pages");
|
|
582
|
+
orderedKeys.push("collections");
|
|
583
|
+
otherCustom.forEach((k) => orderedKeys.push(k));
|
|
584
|
+
bottomCustom.forEach((k) => orderedKeys.push(k));
|
|
585
|
+
if (!hideData) orderedKeys.push("submissions");
|
|
586
|
+
if (!hideConfig && !hideGlobals) orderedKeys.push("config");
|
|
587
|
+
if (!hideSettings) orderedKeys.push("settings");
|
|
588
|
+
if (subscriptionCtx) orderedKeys.push("subscription");
|
|
589
|
+
}
|
|
590
|
+
return orderedKeys.map((k) => navItemsMap.get(k));
|
|
591
|
+
})() }),
|
|
320
592
|
/* @__PURE__ */ jsx("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: /* @__PURE__ */ jsxs(
|
|
321
593
|
"button",
|
|
322
594
|
{
|
|
@@ -327,7 +599,7 @@ function AdminAppContent(props) {
|
|
|
327
599
|
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",
|
|
328
600
|
children: [
|
|
329
601
|
/* @__PURE__ */ jsx(LogOut, { className: "w-4 h-4" }),
|
|
330
|
-
|
|
602
|
+
t.signOut
|
|
331
603
|
]
|
|
332
604
|
}
|
|
333
605
|
) })
|
|
@@ -345,7 +617,7 @@ function AdminAppContent(props) {
|
|
|
345
617
|
)
|
|
346
618
|
] })
|
|
347
619
|
] })
|
|
348
|
-
] });
|
|
620
|
+
] }) });
|
|
349
621
|
}
|
|
350
622
|
function SideItem({
|
|
351
623
|
active,
|
|
@@ -454,6 +726,7 @@ function PagesSection() {
|
|
|
454
726
|
}
|
|
455
727
|
function PageEditor({ page, showList, onToggleList }) {
|
|
456
728
|
const ctx = useCmsContext();
|
|
729
|
+
const t = useAdminI18n();
|
|
457
730
|
const iframeRef = useRef(null);
|
|
458
731
|
const [registered, setRegistered] = useState([]);
|
|
459
732
|
const [selectedId, setSelectedId] = useState(null);
|
|
@@ -547,7 +820,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
547
820
|
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",
|
|
548
821
|
children: [
|
|
549
822
|
/* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" }),
|
|
550
|
-
|
|
823
|
+
t.discardChanges
|
|
551
824
|
]
|
|
552
825
|
}
|
|
553
826
|
),
|
|
@@ -559,7 +832,7 @@ function PageEditor({ page, showList, onToggleList }) {
|
|
|
559
832
|
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",
|
|
560
833
|
children: [
|
|
561
834
|
/* @__PURE__ */ jsx(Boxes, { className: "h-3.5 w-3.5" }),
|
|
562
|
-
|
|
835
|
+
t.save
|
|
563
836
|
]
|
|
564
837
|
}
|
|
565
838
|
)
|
|
@@ -1392,13 +1665,18 @@ function CollectionsSection() {
|
|
|
1392
1665
|
collections.find((c) => !c.isSeparator) ?? null
|
|
1393
1666
|
);
|
|
1394
1667
|
const [counts, setCounts] = useState({});
|
|
1668
|
+
const colIds = useMemo(
|
|
1669
|
+
() => (ctx.config.collections ?? []).filter((c) => !c.isSeparator).map((c) => c.id).join(","),
|
|
1670
|
+
[ctx.config.collections]
|
|
1671
|
+
);
|
|
1395
1672
|
useEffect(() => {
|
|
1396
|
-
|
|
1673
|
+
const list = ctx.config.collections ?? [];
|
|
1674
|
+
list.filter((c) => !c.isSeparator).forEach((c) => {
|
|
1397
1675
|
ctx.adapter.listEntries(c.id).then((entries) => {
|
|
1398
|
-
setCounts((prev) =>
|
|
1676
|
+
setCounts((prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length });
|
|
1399
1677
|
});
|
|
1400
1678
|
});
|
|
1401
|
-
}, [ctx.adapter,
|
|
1679
|
+
}, [ctx.adapter, colIds, ctx.collectionChangedAt]);
|
|
1402
1680
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
|
|
1403
1681
|
/* @__PURE__ */ 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: [
|
|
1404
1682
|
/* @__PURE__ */ jsx("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
|
|
@@ -1408,7 +1686,8 @@ function CollectionsSection() {
|
|
|
1408
1686
|
return /* @__PURE__ */ jsx(
|
|
1409
1687
|
"li",
|
|
1410
1688
|
{
|
|
1411
|
-
className: "my-
|
|
1689
|
+
className: "my-3 border-t border-slate-200/80 pt-2 px-1 list-none",
|
|
1690
|
+
children: c.name && /* @__PURE__ */ jsx("span", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400", children: c.name })
|
|
1412
1691
|
},
|
|
1413
1692
|
c.id || `sep-${idx}`
|
|
1414
1693
|
);
|
|
@@ -1451,8 +1730,10 @@ function CollectionsSection() {
|
|
|
1451
1730
|
}
|
|
1452
1731
|
function CollectionEditor({ collection }) {
|
|
1453
1732
|
const ctx = useCmsContext();
|
|
1733
|
+
const t = useAdminI18n();
|
|
1454
1734
|
const [entries, setEntries] = useState([]);
|
|
1455
1735
|
const [editing, setEditing] = useState(null);
|
|
1736
|
+
const [isCreatingManual, setIsCreatingManual] = useState(false);
|
|
1456
1737
|
const [saving, setSaving] = useState(false);
|
|
1457
1738
|
const [deletingId, setDeletingId] = useState(null);
|
|
1458
1739
|
const [loadingEntries, setLoadingEntries] = useState(true);
|
|
@@ -1478,6 +1759,7 @@ function CollectionEditor({ collection }) {
|
|
|
1478
1759
|
load();
|
|
1479
1760
|
}, [load]);
|
|
1480
1761
|
const startNew = () => {
|
|
1762
|
+
setIsCreatingManual(true);
|
|
1481
1763
|
const base = { id: crypto.randomUUID() };
|
|
1482
1764
|
collection.fields.forEach((f) => {
|
|
1483
1765
|
if (f.id === "order") {
|
|
@@ -1512,6 +1794,16 @@ function CollectionEditor({ collection }) {
|
|
|
1512
1794
|
try {
|
|
1513
1795
|
const finalEditing = { ...editing };
|
|
1514
1796
|
collection.fields.forEach((f) => {
|
|
1797
|
+
if (f.autoIncrement && isCreatingEntry && (!finalEditing[f.id] || Number(finalEditing[f.id]) === 0)) {
|
|
1798
|
+
const maxVal = entries.reduce(
|
|
1799
|
+
(max, e) => Math.max(max, Number(e[f.id]) || 0),
|
|
1800
|
+
0
|
|
1801
|
+
);
|
|
1802
|
+
finalEditing[f.id] = maxVal > 0 ? maxVal + 1 : 1;
|
|
1803
|
+
}
|
|
1804
|
+
if (f.id === "estado" && !finalEditing[f.id]) {
|
|
1805
|
+
finalEditing[f.id] = "Nueva";
|
|
1806
|
+
}
|
|
1515
1807
|
if (f.type === "time-range") {
|
|
1516
1808
|
delete finalEditing[f.id];
|
|
1517
1809
|
} else if (f.type === "slug" && !finalEditing[f.id]) {
|
|
@@ -1524,6 +1816,7 @@ function CollectionEditor({ collection }) {
|
|
|
1524
1816
|
await ctx.adapter.putEntry(collection.id, finalEditing);
|
|
1525
1817
|
ctx.notifyCollectionChanged();
|
|
1526
1818
|
setEditing(null);
|
|
1819
|
+
setIsCreatingManual(false);
|
|
1527
1820
|
load();
|
|
1528
1821
|
} finally {
|
|
1529
1822
|
setSaving(false);
|
|
@@ -1575,80 +1868,124 @@ function CollectionEditor({ collection }) {
|
|
|
1575
1868
|
setDraggedIdx(null);
|
|
1576
1869
|
setDragOverIdx(null);
|
|
1577
1870
|
};
|
|
1578
|
-
const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0,
|
|
1579
|
-
const isCreatingEntry = editing ? !entries.some((entry) => entry.id === editing.id) : false;
|
|
1871
|
+
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);
|
|
1872
|
+
const isCreatingEntry = isCreatingManual || (editing ? !entries.some((entry) => entry.id && entry.id === editing.id || entry._id && entry._id === (editing._id || editing.id)) : false);
|
|
1580
1873
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-5xl", children: [
|
|
1581
1874
|
/* @__PURE__ */ jsxs("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
1582
1875
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
1583
1876
|
/* @__PURE__ */ jsx("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
|
|
1584
1877
|
collection.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
|
|
1585
1878
|
] }),
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
|
|
1879
|
+
/* @__PURE__ */ jsx(
|
|
1880
|
+
Button,
|
|
1588
1881
|
{
|
|
1882
|
+
type: "primary",
|
|
1883
|
+
size: "large",
|
|
1884
|
+
icon: /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
1589
1885
|
onClick: startNew,
|
|
1590
|
-
className: "
|
|
1591
|
-
children:
|
|
1592
|
-
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
1593
|
-
" New Entry"
|
|
1594
|
-
]
|
|
1886
|
+
className: "rounded-xl font-bold shadow-sm",
|
|
1887
|
+
children: t.newEntry
|
|
1595
1888
|
}
|
|
1596
1889
|
)
|
|
1597
1890
|
] }),
|
|
1598
1891
|
!editing && (collection.searchBy?.length || collection.filterBy?.length) && /* @__PURE__ */ 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: [
|
|
1599
|
-
collection.searchBy?.length ? /* @__PURE__ */
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
"
|
|
1603
|
-
{
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
] }) : null,
|
|
1892
|
+
collection.searchBy?.length ? /* @__PURE__ */ jsx("div", { className: "relative flex-1 min-w-[220px]", children: /* @__PURE__ */ jsx(
|
|
1893
|
+
Input,
|
|
1894
|
+
{
|
|
1895
|
+
size: "large",
|
|
1896
|
+
prefix: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4 text-slate-400" }),
|
|
1897
|
+
placeholder: `Buscar por ${collection.searchBy.map((s) => s === "numero" ? "n\xFAmero" : s === "clienteNombre" ? "cliente" : s === "clienteId" ? "identificaci\xF3n" : s === "fecha" ? "fecha" : s).join(", ")}...`,
|
|
1898
|
+
value: search,
|
|
1899
|
+
allowClear: true,
|
|
1900
|
+
onChange: (e) => {
|
|
1901
|
+
setSearch(e.target.value);
|
|
1902
|
+
setPage(1);
|
|
1903
|
+
},
|
|
1904
|
+
className: "rounded-xl"
|
|
1905
|
+
}
|
|
1906
|
+
) }) : null,
|
|
1615
1907
|
collection.filterBy?.map((f) => {
|
|
1616
1908
|
const fieldDef = collection.fields.find((cf) => cf.id === f);
|
|
1617
|
-
|
|
1618
|
-
if (
|
|
1619
|
-
|
|
1620
|
-
/* @__PURE__ */
|
|
1621
|
-
|
|
1909
|
+
if (!fieldDef) return null;
|
|
1910
|
+
if (fieldDef.type === "date") {
|
|
1911
|
+
const dateVal = filters[f] ? dayjs(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]).isValid() ? dayjs(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]) : null : null;
|
|
1912
|
+
return /* @__PURE__ */ jsx("div", { className: "min-w-[180px]", children: /* @__PURE__ */ jsx(
|
|
1913
|
+
DatePicker,
|
|
1622
1914
|
{
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1915
|
+
size: "large",
|
|
1916
|
+
format: "YYYY/MM/DD",
|
|
1917
|
+
placeholder: `Filtrar por ${fieldDef.label}`,
|
|
1918
|
+
allowClear: true,
|
|
1919
|
+
value: dateVal,
|
|
1920
|
+
onChange: (_, dateStr) => {
|
|
1921
|
+
const val = Array.isArray(dateStr) ? dateStr[0] : dateStr;
|
|
1922
|
+
setFilters((prev) => ({ ...prev, [f]: val || "" }));
|
|
1626
1923
|
setPage(1);
|
|
1627
1924
|
},
|
|
1628
|
-
className: "w-full rounded-xl
|
|
1629
|
-
children: [
|
|
1630
|
-
/* @__PURE__ */ jsxs("option", { value: "", children: [
|
|
1631
|
-
"All ",
|
|
1632
|
-
fieldDef.label
|
|
1633
|
-
] }),
|
|
1634
|
-
uniqueVals.map((v) => /* @__PURE__ */ jsx("option", { value: v, children: v }, v))
|
|
1635
|
-
]
|
|
1925
|
+
className: "w-full rounded-xl"
|
|
1636
1926
|
}
|
|
1637
|
-
),
|
|
1638
|
-
|
|
1639
|
-
|
|
1927
|
+
) }, f);
|
|
1928
|
+
}
|
|
1929
|
+
const predefinedOptions = (fieldDef.options || []).map(
|
|
1930
|
+
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
1931
|
+
);
|
|
1932
|
+
const entryVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
|
|
1933
|
+
const combinedOptions = [...predefinedOptions];
|
|
1934
|
+
for (const ev of entryVals) {
|
|
1935
|
+
if (!combinedOptions.some((o) => o.value === ev)) {
|
|
1936
|
+
combinedOptions.push({ value: ev, label: ev });
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
return /* @__PURE__ */ jsx("div", { className: "min-w-[170px]", children: /* @__PURE__ */ jsx(
|
|
1940
|
+
Select,
|
|
1941
|
+
{
|
|
1942
|
+
size: "large",
|
|
1943
|
+
value: filters[f] || void 0,
|
|
1944
|
+
placeholder: `Filtrar por ${fieldDef.label}`,
|
|
1945
|
+
allowClear: true,
|
|
1946
|
+
onChange: (v) => {
|
|
1947
|
+
setFilters((prev) => ({ ...prev, [f]: v || "" }));
|
|
1948
|
+
setPage(1);
|
|
1949
|
+
},
|
|
1950
|
+
options: combinedOptions,
|
|
1951
|
+
className: "w-full"
|
|
1952
|
+
}
|
|
1953
|
+
) }, f);
|
|
1640
1954
|
})
|
|
1641
1955
|
] }),
|
|
1642
1956
|
/* @__PURE__ */ jsx(
|
|
1643
1957
|
Modal,
|
|
1644
1958
|
{
|
|
1645
1959
|
open: Boolean(editing),
|
|
1646
|
-
title: /* @__PURE__ */ jsxs("
|
|
1647
|
-
|
|
1648
|
-
|
|
1960
|
+
title: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pr-8", children: [
|
|
1961
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-slate-900 font-bold", children: [
|
|
1962
|
+
isCreatingEntry ? /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4 text-indigo-600" }),
|
|
1963
|
+
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}`
|
|
1964
|
+
] }),
|
|
1965
|
+
!isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1966
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
|
|
1967
|
+
/* @__PURE__ */ jsx(
|
|
1968
|
+
Select,
|
|
1969
|
+
{
|
|
1970
|
+
size: "middle",
|
|
1971
|
+
value: String(editing.estado || "Nueva"),
|
|
1972
|
+
onChange: (val) => setEditing({ ...editing, estado: val }),
|
|
1973
|
+
options: [
|
|
1974
|
+
{ value: "Nueva", label: "Nueva" },
|
|
1975
|
+
{ value: "Proceso", label: "Proceso" },
|
|
1976
|
+
{ value: "Terminado", label: "Terminado" },
|
|
1977
|
+
{ value: "Cancelado", label: "Cancelado" }
|
|
1978
|
+
],
|
|
1979
|
+
className: "w-32"
|
|
1980
|
+
}
|
|
1981
|
+
)
|
|
1982
|
+
] })
|
|
1649
1983
|
] }),
|
|
1650
1984
|
onCancel: () => {
|
|
1651
|
-
if (!saving)
|
|
1985
|
+
if (!saving) {
|
|
1986
|
+
setEditing(null);
|
|
1987
|
+
setIsCreatingManual(false);
|
|
1988
|
+
}
|
|
1652
1989
|
},
|
|
1653
1990
|
footer: null,
|
|
1654
1991
|
centered: true,
|
|
@@ -1669,463 +2006,559 @@ function CollectionEditor({ collection }) {
|
|
|
1669
2006
|
backdropFilter: "blur(8px)"
|
|
1670
2007
|
}
|
|
1671
2008
|
},
|
|
1672
|
-
children: editing && /* @__PURE__ */ jsxs("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
|
|
1673
|
-
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
{
|
|
1681
|
-
|
|
1682
|
-
value: editing[f.id],
|
|
1683
|
-
globalPrice: Number(editing.price) || 0,
|
|
1684
|
-
globalDiscount: Number(editing.discountPercent) || 0,
|
|
1685
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2009
|
+
children: editing && /* @__PURE__ */ jsx(ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ jsxs("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
|
|
2010
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ 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) => {
|
|
2011
|
+
if (f.id === "estado" && !isCreatingEntry) return false;
|
|
2012
|
+
if (isCreatingEntry && f.hideOnCreate) return false;
|
|
2013
|
+
if (f.dependsOn) {
|
|
2014
|
+
const targetVal = editing[f.dependsOn.field];
|
|
2015
|
+
if (Array.isArray(f.dependsOn.value)) {
|
|
2016
|
+
if (!f.dependsOn.value.includes(targetVal)) return false;
|
|
2017
|
+
} else if (targetVal !== f.dependsOn.value) {
|
|
2018
|
+
return false;
|
|
1686
2019
|
}
|
|
1687
|
-
|
|
1688
|
-
|
|
2020
|
+
}
|
|
2021
|
+
return true;
|
|
2022
|
+
}).map((f) => {
|
|
2023
|
+
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";
|
|
2024
|
+
const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
|
|
2025
|
+
return /* @__PURE__ */ jsxs("div", { className: `block ${colSpanClass}`, children: [
|
|
2026
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
|
|
2027
|
+
f.label,
|
|
2028
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
|
|
2029
|
+
] }),
|
|
2030
|
+
f.type === "branch-settings" ? /* @__PURE__ */ jsx(
|
|
2031
|
+
BranchSettingsEditor,
|
|
2032
|
+
{
|
|
2033
|
+
collectionId: f.collection || "",
|
|
2034
|
+
value: editing[f.id],
|
|
2035
|
+
globalPrice: Number(editing.price) || 0,
|
|
2036
|
+
globalDiscount: Number(editing.discountPercent) || 0,
|
|
2037
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2038
|
+
}
|
|
2039
|
+
) : f.type === "boolean" ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-3", children: [
|
|
1689
2040
|
/* @__PURE__ */ jsx(
|
|
1690
|
-
|
|
2041
|
+
Switch,
|
|
1691
2042
|
{
|
|
1692
|
-
type: "checkbox",
|
|
1693
2043
|
checked: !!editing[f.id],
|
|
1694
|
-
onChange: (
|
|
1695
|
-
className: "sr-only peer"
|
|
2044
|
+
onChange: (checked) => setEditing({ ...editing, [f.id]: checked })
|
|
1696
2045
|
}
|
|
1697
2046
|
),
|
|
1698
|
-
/* @__PURE__ */ jsx("
|
|
1699
|
-
] })
|
|
1700
|
-
|
|
1701
|
-
] }) : f.type === "number" ? /* @__PURE__ */ jsx(
|
|
1702
|
-
FormattedNumberInput,
|
|
1703
|
-
{
|
|
1704
|
-
value: editing[f.id],
|
|
1705
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
1706
|
-
isPrice: f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.toLowerCase().includes("valor") || f.label.includes("$"),
|
|
1707
|
-
isPercent: f.id.toLowerCase().includes("discount") || f.id.toLowerCase().includes("descuento") || f.label.toLowerCase().includes("descuento")
|
|
1708
|
-
}
|
|
1709
|
-
) : f.type === "time-range" ? /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
1710
|
-
/* @__PURE__ */ jsx(
|
|
1711
|
-
AdminTimeRangePicker,
|
|
2047
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
|
|
2048
|
+
] }) : f.type === "number" ? /* @__PURE__ */ jsx(
|
|
2049
|
+
InputNumber,
|
|
1712
2050
|
{
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
onChange: (
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
|
|
1721
|
-
...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
|
|
1722
|
-
} : current
|
|
1723
|
-
),
|
|
1724
|
-
allowEmpty: [true, true],
|
|
1725
|
-
className: "w-full",
|
|
1726
|
-
format: TIME_DISPLAY_FORMAT,
|
|
1727
|
-
order: false,
|
|
1728
|
-
placeholder: ["Hora de inicio", "Hora de cierre"],
|
|
1729
|
-
use12Hours: true
|
|
2051
|
+
size: "large",
|
|
2052
|
+
value: editing[f.id] !== void 0 && editing[f.id] !== null && editing[f.id] !== "" ? Number(editing[f.id]) : void 0,
|
|
2053
|
+
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
2054
|
+
disabled: f.readOnly,
|
|
2055
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
|
|
2056
|
+
className: "w-full rounded-xl",
|
|
2057
|
+
placeholder: "0"
|
|
1730
2058
|
}
|
|
1731
|
-
)
|
|
1732
|
-
|
|
1733
|
-
] }) : f.type === "time" ? /* @__PURE__ */ jsx(
|
|
1734
|
-
AdminTimePicker,
|
|
1735
|
-
{
|
|
1736
|
-
value: toDayjsTime(editing[f.id]),
|
|
1737
|
-
onChange: (time) => setEditing({ ...editing, [f.id]: toStoredTime(time) }),
|
|
1738
|
-
className: "w-full",
|
|
1739
|
-
format: TIME_DISPLAY_FORMAT,
|
|
1740
|
-
use12Hours: true
|
|
1741
|
-
}
|
|
1742
|
-
) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ jsx(
|
|
1743
|
-
"textarea",
|
|
1744
|
-
{
|
|
1745
|
-
value: String(editing[f.id] ?? ""),
|
|
1746
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1747
|
-
rows: 4,
|
|
1748
|
-
placeholder: `Escribe ${f.label.toLowerCase()}...`,
|
|
1749
|
-
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-sans text-slate-800"
|
|
1750
|
-
}
|
|
1751
|
-
) : f.type === "icon" ? /* @__PURE__ */ jsx(
|
|
1752
|
-
SearchableSelect,
|
|
1753
|
-
{
|
|
1754
|
-
value: String(editing[f.id] ?? ""),
|
|
1755
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
1756
|
-
options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
|
|
1757
|
-
placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
|
|
1758
|
-
iconMap: ctx.iconMap
|
|
1759
|
-
}
|
|
1760
|
-
) : f.type === "slug" ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1761
|
-
/* @__PURE__ */ jsx(
|
|
1762
|
-
"input",
|
|
2059
|
+
) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ jsx(
|
|
2060
|
+
DatePicker,
|
|
1763
2061
|
{
|
|
1764
|
-
|
|
1765
|
-
value: String(editing[f.id]
|
|
1766
|
-
onChange: (
|
|
1767
|
-
|
|
2062
|
+
size: "large",
|
|
2063
|
+
value: editing[f.id] ? dayjs(String(editing[f.id])).isValid() ? dayjs(String(editing[f.id])) : null : null,
|
|
2064
|
+
onChange: (date, dateString) => setEditing({ ...editing, [f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "") }),
|
|
2065
|
+
format: "YYYY/MM/DD",
|
|
2066
|
+
placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
|
|
2067
|
+
className: "w-full rounded-xl"
|
|
1768
2068
|
}
|
|
1769
|
-
),
|
|
1770
|
-
|
|
1771
|
-
|
|
2069
|
+
) : f.type === "time-range" ? /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
2070
|
+
/* @__PURE__ */ jsx(
|
|
2071
|
+
AdminTimeRangePicker,
|
|
2072
|
+
{
|
|
2073
|
+
value: [
|
|
2074
|
+
toDayjsTime(f.startField ? editing[f.startField] : ""),
|
|
2075
|
+
toDayjsTime(f.endField ? editing[f.endField] : "")
|
|
2076
|
+
],
|
|
2077
|
+
onChange: (times) => setEditing(
|
|
2078
|
+
(current) => current ? {
|
|
2079
|
+
...current,
|
|
2080
|
+
...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
|
|
2081
|
+
...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
|
|
2082
|
+
} : current
|
|
2083
|
+
),
|
|
2084
|
+
allowEmpty: [true, true],
|
|
2085
|
+
className: "w-full",
|
|
2086
|
+
format: "h:mm a",
|
|
2087
|
+
order: false,
|
|
2088
|
+
placeholder: ["Hora de inicio", "Hora de cierre"],
|
|
2089
|
+
use12Hours: true
|
|
2090
|
+
}
|
|
2091
|
+
),
|
|
2092
|
+
/* @__PURE__ */ 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." })
|
|
2093
|
+
] }) : f.type === "time" ? /* @__PURE__ */ jsx(
|
|
2094
|
+
TimePicker,
|
|
1772
2095
|
{
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
2096
|
+
size: "large",
|
|
2097
|
+
use12Hours: true,
|
|
2098
|
+
format: "h:mm a",
|
|
2099
|
+
value: toDayjsTime(editing[f.id]),
|
|
2100
|
+
onChange: (time, timeString) => setEditing({
|
|
2101
|
+
...editing,
|
|
2102
|
+
[f.id]: (Array.isArray(timeString) ? timeString[0] : timeString) || (time ? time.format("h:mm a") : "")
|
|
2103
|
+
}),
|
|
2104
|
+
placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
|
|
2105
|
+
className: "w-full rounded-xl"
|
|
1782
2106
|
}
|
|
1783
|
-
)
|
|
1784
|
-
|
|
1785
|
-
ReferenceSelect,
|
|
1786
|
-
{
|
|
1787
|
-
collectionId: f.collection,
|
|
1788
|
-
displayField: f.displayField,
|
|
1789
|
-
valueField: f.valueField,
|
|
1790
|
-
fallbackOptions: f.options,
|
|
1791
|
-
multiple: f.multiple,
|
|
1792
|
-
searchable: f.searchable,
|
|
1793
|
-
max: f.max,
|
|
1794
|
-
value: editing[f.id],
|
|
1795
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
1796
|
-
}
|
|
1797
|
-
) : f.type === "select" ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
1798
|
-
/* @__PURE__ */ jsxs(
|
|
1799
|
-
"select",
|
|
2107
|
+
) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ jsx(
|
|
2108
|
+
Input.TextArea,
|
|
1800
2109
|
{
|
|
2110
|
+
size: "large",
|
|
1801
2111
|
value: String(editing[f.id] ?? ""),
|
|
1802
2112
|
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
f.options?.map((opt) => {
|
|
1807
|
-
const val = typeof opt === "string" ? opt : opt.value;
|
|
1808
|
-
const lab = typeof opt === "string" ? opt : opt.label;
|
|
1809
|
-
return /* @__PURE__ */ jsx("option", { value: val, children: lab }, val);
|
|
1810
|
-
})
|
|
1811
|
-
]
|
|
2113
|
+
rows: 4,
|
|
2114
|
+
placeholder: `Escribe ${f.label.toLowerCase()}...`,
|
|
2115
|
+
className: "w-full rounded-xl font-sans"
|
|
1812
2116
|
}
|
|
1813
|
-
)
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
type: "button",
|
|
1824
|
-
onClick: () => {
|
|
1825
|
-
const arr = [...editing[f.id] || []];
|
|
1826
|
-
arr.splice(i, 1);
|
|
1827
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
1828
|
-
},
|
|
1829
|
-
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",
|
|
1830
|
-
children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3" })
|
|
1831
|
-
}
|
|
1832
|
-
)
|
|
1833
|
-
] }, i);
|
|
1834
|
-
}) }),
|
|
1835
|
-
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1836
|
-
/* @__PURE__ */ jsx(
|
|
1837
|
-
"input",
|
|
1838
|
-
{
|
|
1839
|
-
type: "url",
|
|
1840
|
-
placeholder: "Add media URL and press Enter...",
|
|
1841
|
-
onKeyDown: (e) => {
|
|
1842
|
-
if (e.key === "Enter" && e.currentTarget.value) {
|
|
1843
|
-
e.preventDefault();
|
|
1844
|
-
const arr = [...editing[f.id] || [], e.currentTarget.value];
|
|
1845
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
1846
|
-
e.currentTarget.value = "";
|
|
1847
|
-
}
|
|
1848
|
-
},
|
|
1849
|
-
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"
|
|
1850
|
-
}
|
|
1851
|
-
),
|
|
1852
|
-
/* @__PURE__ */ jsx(
|
|
1853
|
-
FilePickerButton,
|
|
1854
|
-
{
|
|
1855
|
-
accept: "image/*,video/*",
|
|
1856
|
-
multiple: true,
|
|
1857
|
-
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",
|
|
1858
|
-
onFiles: (files) => {
|
|
1859
|
-
files.forEach((file) => {
|
|
1860
|
-
void handleImageFile(
|
|
1861
|
-
file,
|
|
1862
|
-
(url) => {
|
|
1863
|
-
setEditing((prev) => {
|
|
1864
|
-
if (!prev) return prev;
|
|
1865
|
-
const current = prev[f.id] || [];
|
|
1866
|
-
if (f.max && current.length >= f.max) {
|
|
1867
|
-
return prev;
|
|
1868
|
-
}
|
|
1869
|
-
return { ...prev, [f.id]: [...current, url] };
|
|
1870
|
-
});
|
|
1871
|
-
},
|
|
1872
|
-
ctx.uploadImage
|
|
1873
|
-
);
|
|
1874
|
-
});
|
|
1875
|
-
},
|
|
1876
|
-
children: "Upload"
|
|
1877
|
-
}
|
|
1878
|
-
)
|
|
1879
|
-
] })
|
|
1880
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1881
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2117
|
+
) : f.type === "icon" ? /* @__PURE__ */ jsx(
|
|
2118
|
+
SearchableSelect,
|
|
2119
|
+
{
|
|
2120
|
+
value: String(editing[f.id] ?? ""),
|
|
2121
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2122
|
+
options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
|
|
2123
|
+
placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
|
|
2124
|
+
iconMap: ctx.iconMap
|
|
2125
|
+
}
|
|
2126
|
+
) : f.type === "slug" ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1882
2127
|
/* @__PURE__ */ jsx(
|
|
1883
|
-
|
|
2128
|
+
Input,
|
|
1884
2129
|
{
|
|
1885
|
-
|
|
2130
|
+
size: "large",
|
|
1886
2131
|
value: String(editing[f.id] ?? ""),
|
|
1887
2132
|
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1888
|
-
|
|
1889
|
-
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"
|
|
2133
|
+
className: "flex-1 rounded-xl"
|
|
1890
2134
|
}
|
|
1891
2135
|
),
|
|
1892
2136
|
/* @__PURE__ */ jsx(
|
|
1893
|
-
|
|
2137
|
+
Button,
|
|
1894
2138
|
{
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
file,
|
|
1902
|
-
(url) => setEditing(
|
|
1903
|
-
(current) => current ? { ...current, [f.id]: url } : current
|
|
1904
|
-
),
|
|
1905
|
-
ctx.uploadImage
|
|
1906
|
-
);
|
|
1907
|
-
}
|
|
2139
|
+
size: "large",
|
|
2140
|
+
onClick: () => {
|
|
2141
|
+
const sourceField = f.source || "title";
|
|
2142
|
+
let val = String(editing[sourceField] || editing.id || "");
|
|
2143
|
+
val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
2144
|
+
setEditing({ ...editing, [f.id]: val });
|
|
1908
2145
|
},
|
|
1909
|
-
|
|
2146
|
+
className: "rounded-xl font-semibold",
|
|
2147
|
+
children: "Generate"
|
|
1910
2148
|
}
|
|
1911
2149
|
)
|
|
1912
|
-
] })
|
|
1913
|
-
|
|
1914
|
-
"video",
|
|
1915
|
-
{
|
|
1916
|
-
src: String(editing[f.id]),
|
|
1917
|
-
controls: true,
|
|
1918
|
-
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
1919
|
-
}
|
|
1920
|
-
) : /* @__PURE__ */ jsx(
|
|
1921
|
-
"img",
|
|
1922
|
-
{
|
|
1923
|
-
src: String(editing[f.id]),
|
|
1924
|
-
alt: "",
|
|
1925
|
-
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
1926
|
-
}
|
|
1927
|
-
) }) : null
|
|
1928
|
-
] }) : f.type === "password" ? /* @__PURE__ */ jsx(
|
|
1929
|
-
PasswordField,
|
|
1930
|
-
{
|
|
1931
|
-
value: String(editing[f.id] ?? ""),
|
|
1932
|
-
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
1933
|
-
}
|
|
1934
|
-
) : f.type === "color" && !f.multiple ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1935
|
-
/* @__PURE__ */ jsx(
|
|
1936
|
-
"input",
|
|
1937
|
-
{
|
|
1938
|
-
type: "color",
|
|
1939
|
-
value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
|
|
1940
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1941
|
-
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
1942
|
-
}
|
|
1943
|
-
),
|
|
1944
|
-
/* @__PURE__ */ jsx(
|
|
1945
|
-
"input",
|
|
1946
|
-
{
|
|
1947
|
-
type: "text",
|
|
1948
|
-
value: String(editing[f.id] ?? ""),
|
|
1949
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
1950
|
-
placeholder: "#000000",
|
|
1951
|
-
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"
|
|
1952
|
-
}
|
|
1953
|
-
),
|
|
1954
|
-
/* @__PURE__ */ jsx(
|
|
1955
|
-
"div",
|
|
2150
|
+
] }) : f.type === "reference" || f.type === "select" && f.collection ? /* @__PURE__ */ jsx(
|
|
2151
|
+
ReferenceSelect,
|
|
1956
2152
|
{
|
|
1957
|
-
|
|
1958
|
-
|
|
2153
|
+
collectionId: f.collection,
|
|
2154
|
+
displayField: f.displayField,
|
|
2155
|
+
valueField: f.valueField,
|
|
2156
|
+
fallbackOptions: f.options,
|
|
2157
|
+
multiple: f.multiple,
|
|
2158
|
+
searchable: f.searchable,
|
|
2159
|
+
max: f.max,
|
|
2160
|
+
value: editing[f.id],
|
|
2161
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2162
|
+
onSelectRecord: (rec) => {
|
|
2163
|
+
if (f.id === "clienteId" && rec) {
|
|
2164
|
+
setEditing((prev) => prev ? {
|
|
2165
|
+
...prev,
|
|
2166
|
+
clienteId: rec.id || prev.clienteId,
|
|
2167
|
+
clienteNombre: rec.nombre || rec.name || prev.clienteNombre,
|
|
2168
|
+
ciudad: rec.ciudad || prev.ciudad,
|
|
2169
|
+
direccion: rec.direccion || prev.direccion,
|
|
2170
|
+
telefono: rec.telefono || prev.telefono
|
|
2171
|
+
} : prev);
|
|
2172
|
+
} else if (f.id === "empleadoId" && rec) {
|
|
2173
|
+
setEditing((prev) => prev ? {
|
|
2174
|
+
...prev,
|
|
2175
|
+
empleadoId: rec.id || prev.empleadoId,
|
|
2176
|
+
empleadoNombre: rec.apellido ? `${rec.nombre || rec.name || ""} ${rec.apellido}`.trim() : rec.nombre || rec.name || prev.empleadoNombre
|
|
2177
|
+
} : prev);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
1959
2180
|
}
|
|
1960
|
-
)
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
2181
|
+
) : f.type === "select" ? (() => {
|
|
2182
|
+
const dynamicOptions = f.optionsMap && f.dependsOnField ? f.optionsMap[String(editing[f.dependsOnField] || "")] || f.options || [] : f.options || [];
|
|
2183
|
+
return /* @__PURE__ */ jsx(
|
|
2184
|
+
Select,
|
|
2185
|
+
{
|
|
2186
|
+
size: "large",
|
|
2187
|
+
value: editing[f.id] ? String(editing[f.id]) : void 0,
|
|
2188
|
+
placeholder: f.label,
|
|
2189
|
+
allowClear: true,
|
|
2190
|
+
onChange: (val) => {
|
|
2191
|
+
const next = { ...editing, [f.id]: val || "" };
|
|
2192
|
+
collection.fields.forEach((otherField) => {
|
|
2193
|
+
if (otherField.dependsOnField === f.id && otherField.optionsMap) {
|
|
2194
|
+
const newOpts = otherField.optionsMap[String(val || "")];
|
|
2195
|
+
if (newOpts && newOpts.length > 0) {
|
|
2196
|
+
const firstVal = typeof newOpts[0] === "string" ? newOpts[0] : newOpts[0].value;
|
|
2197
|
+
next[otherField.id] = firstVal;
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
setEditing(next);
|
|
2202
|
+
},
|
|
2203
|
+
options: dynamicOptions.map((opt) => ({
|
|
2204
|
+
label: typeof opt === "string" ? opt : opt.label,
|
|
2205
|
+
value: typeof opt === "string" ? opt : opt.value
|
|
2206
|
+
})),
|
|
2207
|
+
className: "w-full"
|
|
2208
|
+
}
|
|
2209
|
+
);
|
|
2210
|
+
})() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2211
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
|
|
2212
|
+
const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
|
|
2213
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
|
|
2214
|
+
isVideo ? /* @__PURE__ */ jsx("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ jsx("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
|
|
2215
|
+
/* @__PURE__ */ jsx(
|
|
2216
|
+
"button",
|
|
2217
|
+
{
|
|
2218
|
+
type: "button",
|
|
2219
|
+
onClick: () => {
|
|
2220
|
+
const arr = [...editing[f.id] || []];
|
|
2221
|
+
arr.splice(i, 1);
|
|
2222
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2223
|
+
},
|
|
2224
|
+
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",
|
|
2225
|
+
children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3" })
|
|
2226
|
+
}
|
|
2227
|
+
)
|
|
2228
|
+
] }, i);
|
|
2229
|
+
}) }),
|
|
2230
|
+
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1966
2231
|
/* @__PURE__ */ jsx(
|
|
1967
2232
|
"input",
|
|
1968
2233
|
{
|
|
1969
|
-
type: "
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
2234
|
+
type: "url",
|
|
2235
|
+
placeholder: "Add media URL and press Enter...",
|
|
2236
|
+
onKeyDown: (e) => {
|
|
2237
|
+
if (e.key === "Enter" && e.currentTarget.value) {
|
|
2238
|
+
e.preventDefault();
|
|
2239
|
+
const arr = [...editing[f.id] || [], e.currentTarget.value];
|
|
2240
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2241
|
+
e.currentTarget.value = "";
|
|
2242
|
+
}
|
|
1975
2243
|
},
|
|
1976
|
-
className: "w-
|
|
2244
|
+
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"
|
|
1977
2245
|
}
|
|
1978
2246
|
),
|
|
1979
2247
|
/* @__PURE__ */ jsx(
|
|
1980
|
-
|
|
2248
|
+
FilePickerButton,
|
|
1981
2249
|
{
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
{
|
|
2003
|
-
type: "button",
|
|
2004
|
-
onClick: () => {
|
|
2005
|
-
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) : [];
|
|
2006
|
-
arr.splice(idx, 1);
|
|
2007
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
2250
|
+
accept: "image/*,video/*",
|
|
2251
|
+
multiple: true,
|
|
2252
|
+
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",
|
|
2253
|
+
onFiles: (files) => {
|
|
2254
|
+
files.forEach((file) => {
|
|
2255
|
+
void handleImageFile(
|
|
2256
|
+
file,
|
|
2257
|
+
(url) => {
|
|
2258
|
+
setEditing((prev) => {
|
|
2259
|
+
if (!prev) return prev;
|
|
2260
|
+
const current = prev[f.id] || [];
|
|
2261
|
+
if (f.max && current.length >= f.max) {
|
|
2262
|
+
return prev;
|
|
2263
|
+
}
|
|
2264
|
+
return { ...prev, [f.id]: [...current, url] };
|
|
2265
|
+
});
|
|
2266
|
+
},
|
|
2267
|
+
ctx.uploadImage
|
|
2268
|
+
);
|
|
2269
|
+
});
|
|
2008
2270
|
},
|
|
2009
|
-
|
|
2010
|
-
children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
|
|
2271
|
+
children: "Upload"
|
|
2011
2272
|
}
|
|
2012
2273
|
)
|
|
2013
|
-
] }
|
|
2014
|
-
}),
|
|
2015
|
-
|
|
2016
|
-
"button",
|
|
2017
|
-
{
|
|
2018
|
-
type: "button",
|
|
2019
|
-
onClick: () => {
|
|
2020
|
-
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) : [];
|
|
2021
|
-
arr.push("#000000");
|
|
2022
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
2023
|
-
},
|
|
2024
|
-
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",
|
|
2025
|
-
children: [
|
|
2026
|
-
/* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
|
|
2027
|
-
" Add Color"
|
|
2028
|
-
]
|
|
2029
|
-
}
|
|
2030
|
-
)
|
|
2031
|
-
] }) : f.type === "list" ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2032
|
-
(Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
|
|
2033
|
-
const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
|
|
2034
|
-
const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
|
|
2035
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
2036
|
-
/* @__PURE__ */ jsxs("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
|
|
2037
|
-
idx + 1,
|
|
2038
|
-
"."
|
|
2039
|
-
] }),
|
|
2274
|
+
] })
|
|
2275
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2276
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2040
2277
|
/* @__PURE__ */ jsx(
|
|
2041
2278
|
"input",
|
|
2042
2279
|
{
|
|
2043
|
-
type: "
|
|
2044
|
-
value: String(
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
arr[idx] = e.target.value;
|
|
2049
|
-
setEditing({ ...editing, [f.id]: arr });
|
|
2050
|
-
},
|
|
2051
|
-
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"
|
|
2280
|
+
type: "url",
|
|
2281
|
+
value: String(editing[f.id] ?? ""),
|
|
2282
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2283
|
+
placeholder: "https://...",
|
|
2284
|
+
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"
|
|
2052
2285
|
}
|
|
2053
2286
|
),
|
|
2054
2287
|
/* @__PURE__ */ jsx(
|
|
2055
|
-
|
|
2288
|
+
FilePickerButton,
|
|
2056
2289
|
{
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2290
|
+
accept: "image/*,video/*",
|
|
2291
|
+
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",
|
|
2292
|
+
onFiles: (files) => {
|
|
2293
|
+
const file = files[0];
|
|
2294
|
+
if (file) {
|
|
2295
|
+
void handleImageFile(
|
|
2296
|
+
file,
|
|
2297
|
+
(url) => setEditing(
|
|
2298
|
+
(current) => current ? { ...current, [f.id]: url } : current
|
|
2299
|
+
),
|
|
2300
|
+
ctx.uploadImage
|
|
2301
|
+
);
|
|
2302
|
+
}
|
|
2062
2303
|
},
|
|
2063
|
-
|
|
2064
|
-
title: "Eliminar elemento",
|
|
2065
|
-
children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
|
|
2304
|
+
children: "Upload"
|
|
2066
2305
|
}
|
|
2067
2306
|
)
|
|
2068
|
-
] },
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2307
|
+
] }),
|
|
2308
|
+
editing[f.id] ? /* @__PURE__ */ 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__ */ jsx(
|
|
2309
|
+
"video",
|
|
2310
|
+
{
|
|
2311
|
+
src: String(editing[f.id]),
|
|
2312
|
+
controls: true,
|
|
2313
|
+
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
2314
|
+
}
|
|
2315
|
+
) : /* @__PURE__ */ jsx(
|
|
2316
|
+
"img",
|
|
2317
|
+
{
|
|
2318
|
+
src: String(editing[f.id]),
|
|
2319
|
+
alt: "",
|
|
2320
|
+
className: "w-full h-auto max-h-48 object-contain rounded-lg"
|
|
2321
|
+
}
|
|
2322
|
+
) }) : null
|
|
2323
|
+
] }) : f.type === "password" ? /* @__PURE__ */ jsx(
|
|
2324
|
+
PasswordField,
|
|
2072
2325
|
{
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2326
|
+
value: String(editing[f.id] ?? ""),
|
|
2327
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2328
|
+
}
|
|
2329
|
+
) : f.type === "signature" ? /* @__PURE__ */ jsx(
|
|
2330
|
+
SignatureInput,
|
|
2331
|
+
{
|
|
2332
|
+
value: editing[f.id],
|
|
2333
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val }),
|
|
2334
|
+
label: f.label
|
|
2335
|
+
}
|
|
2336
|
+
) : f.type === "color" && !f.multiple ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2337
|
+
/* @__PURE__ */ jsx(
|
|
2338
|
+
"input",
|
|
2339
|
+
{
|
|
2340
|
+
type: "color",
|
|
2341
|
+
value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
|
|
2342
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2343
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
2344
|
+
}
|
|
2345
|
+
),
|
|
2346
|
+
/* @__PURE__ */ jsx(
|
|
2347
|
+
"input",
|
|
2348
|
+
{
|
|
2349
|
+
type: "text",
|
|
2350
|
+
value: String(editing[f.id] ?? ""),
|
|
2351
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2352
|
+
placeholder: "#000000",
|
|
2353
|
+
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"
|
|
2354
|
+
}
|
|
2355
|
+
),
|
|
2356
|
+
/* @__PURE__ */ jsx(
|
|
2357
|
+
"div",
|
|
2358
|
+
{
|
|
2359
|
+
className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
2360
|
+
style: { backgroundColor: String(editing[f.id] ?? "#000000") }
|
|
2361
|
+
}
|
|
2362
|
+
)
|
|
2363
|
+
] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2364
|
+
(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) => {
|
|
2365
|
+
const colorVal = String(item ?? "").trim();
|
|
2366
|
+
const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
|
|
2367
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
2368
|
+
/* @__PURE__ */ jsx(
|
|
2369
|
+
"input",
|
|
2370
|
+
{
|
|
2371
|
+
type: "color",
|
|
2372
|
+
value: validHex.length === 7 ? validHex : "#000000",
|
|
2373
|
+
onChange: (e) => {
|
|
2374
|
+
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) : [];
|
|
2375
|
+
arr[idx] = e.target.value;
|
|
2376
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2377
|
+
},
|
|
2378
|
+
className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
|
|
2379
|
+
}
|
|
2380
|
+
),
|
|
2381
|
+
/* @__PURE__ */ jsx(
|
|
2382
|
+
"input",
|
|
2383
|
+
{
|
|
2384
|
+
type: "text",
|
|
2385
|
+
value: colorVal,
|
|
2386
|
+
onChange: (e) => {
|
|
2387
|
+
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) : [];
|
|
2388
|
+
arr[idx] = e.target.value;
|
|
2389
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2390
|
+
},
|
|
2391
|
+
placeholder: "#1c2a44",
|
|
2392
|
+
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"
|
|
2393
|
+
}
|
|
2394
|
+
),
|
|
2395
|
+
/* @__PURE__ */ jsx(
|
|
2396
|
+
"div",
|
|
2397
|
+
{
|
|
2398
|
+
className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
|
|
2399
|
+
style: { backgroundColor: colorVal || "#000000" }
|
|
2400
|
+
}
|
|
2401
|
+
),
|
|
2402
|
+
/* @__PURE__ */ jsx(
|
|
2403
|
+
"button",
|
|
2404
|
+
{
|
|
2405
|
+
type: "button",
|
|
2406
|
+
onClick: () => {
|
|
2407
|
+
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) : [];
|
|
2408
|
+
arr.splice(idx, 1);
|
|
2409
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2410
|
+
},
|
|
2411
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
|
|
2412
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
|
|
2413
|
+
}
|
|
2414
|
+
)
|
|
2415
|
+
] }, idx);
|
|
2416
|
+
}),
|
|
2417
|
+
/* @__PURE__ */ jsxs(
|
|
2418
|
+
"button",
|
|
2419
|
+
{
|
|
2420
|
+
type: "button",
|
|
2421
|
+
onClick: () => {
|
|
2422
|
+
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) : [];
|
|
2423
|
+
arr.push("#000000");
|
|
2424
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2425
|
+
},
|
|
2426
|
+
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",
|
|
2427
|
+
children: [
|
|
2428
|
+
/* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
|
|
2429
|
+
" Add Color"
|
|
2430
|
+
]
|
|
2431
|
+
}
|
|
2432
|
+
)
|
|
2433
|
+
] }) : f.type === "list" ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
2434
|
+
(Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
|
|
2435
|
+
const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
|
|
2436
|
+
const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
|
|
2437
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
2438
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
|
|
2439
|
+
idx + 1,
|
|
2440
|
+
"."
|
|
2441
|
+
] }),
|
|
2442
|
+
/* @__PURE__ */ jsx(
|
|
2443
|
+
"input",
|
|
2444
|
+
{
|
|
2445
|
+
type: "text",
|
|
2446
|
+
value: String(item ?? ""),
|
|
2447
|
+
placeholder,
|
|
2448
|
+
onChange: (e) => {
|
|
2449
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
2450
|
+
arr[idx] = e.target.value;
|
|
2451
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2452
|
+
},
|
|
2453
|
+
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"
|
|
2454
|
+
}
|
|
2455
|
+
),
|
|
2456
|
+
/* @__PURE__ */ jsx(
|
|
2457
|
+
"button",
|
|
2458
|
+
{
|
|
2459
|
+
type: "button",
|
|
2460
|
+
onClick: () => {
|
|
2461
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
2462
|
+
arr.splice(idx, 1);
|
|
2463
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2464
|
+
},
|
|
2465
|
+
className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
|
|
2466
|
+
title: "Eliminar elemento",
|
|
2467
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
|
|
2468
|
+
}
|
|
2469
|
+
)
|
|
2470
|
+
] }, idx);
|
|
2471
|
+
}),
|
|
2472
|
+
/* @__PURE__ */ jsxs(
|
|
2473
|
+
"button",
|
|
2474
|
+
{
|
|
2475
|
+
type: "button",
|
|
2476
|
+
onClick: () => {
|
|
2477
|
+
let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
|
|
2478
|
+
arr.push("");
|
|
2479
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2480
|
+
},
|
|
2481
|
+
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",
|
|
2482
|
+
children: [
|
|
2483
|
+
/* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
|
|
2484
|
+
" ",
|
|
2485
|
+
f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
|
|
2486
|
+
]
|
|
2487
|
+
}
|
|
2488
|
+
)
|
|
2489
|
+
] }) : f.type === "link" ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
2490
|
+
/* @__PURE__ */ jsx(
|
|
2491
|
+
Input,
|
|
2492
|
+
{
|
|
2493
|
+
size: "large",
|
|
2494
|
+
value: String(editing[f.id] ?? ""),
|
|
2495
|
+
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
2496
|
+
disabled: f.readOnly,
|
|
2497
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2498
|
+
placeholder: f.label,
|
|
2499
|
+
className: "flex-1 rounded-xl"
|
|
2500
|
+
}
|
|
2501
|
+
),
|
|
2502
|
+
Boolean(editing[f.id]) && String(editing[f.id]).startsWith("http") ? /* @__PURE__ */ jsxs(
|
|
2503
|
+
"a",
|
|
2504
|
+
{
|
|
2505
|
+
href: String(editing[f.id]),
|
|
2506
|
+
target: "_blank",
|
|
2507
|
+
rel: "noopener noreferrer",
|
|
2508
|
+
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",
|
|
2509
|
+
children: [
|
|
2510
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "w-3.5 h-3.5" }),
|
|
2511
|
+
String(editing[f.id]).includes("maps") ? "Ver en Mapa" : "Abrir"
|
|
2512
|
+
]
|
|
2513
|
+
}
|
|
2514
|
+
) : null
|
|
2515
|
+
] }) : /* @__PURE__ */ jsx(
|
|
2516
|
+
Input,
|
|
2517
|
+
{
|
|
2518
|
+
size: "large",
|
|
2519
|
+
value: String(editing[f.id] ?? ""),
|
|
2520
|
+
readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
|
|
2521
|
+
disabled: f.readOnly,
|
|
2522
|
+
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2523
|
+
placeholder: f.label,
|
|
2524
|
+
className: "w-full rounded-xl"
|
|
2085
2525
|
}
|
|
2086
2526
|
)
|
|
2087
|
-
] })
|
|
2088
|
-
|
|
2089
|
-
{
|
|
2090
|
-
value: String(editing[f.id] ?? ""),
|
|
2091
|
-
onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
|
|
2092
|
-
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"
|
|
2093
|
-
}
|
|
2094
|
-
)
|
|
2095
|
-
] }, f.id)) }) }),
|
|
2527
|
+
] }, f.id);
|
|
2528
|
+
}) }) }),
|
|
2096
2529
|
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 justify-end gap-3 border-t border-slate-200 bg-white px-6 py-4", children: [
|
|
2097
2530
|
/* @__PURE__ */ jsx(
|
|
2098
|
-
|
|
2531
|
+
Button,
|
|
2099
2532
|
{
|
|
2100
|
-
|
|
2533
|
+
size: "large",
|
|
2534
|
+
onClick: () => {
|
|
2535
|
+
setEditing(null);
|
|
2536
|
+
setIsCreatingManual(false);
|
|
2537
|
+
},
|
|
2101
2538
|
disabled: saving,
|
|
2102
|
-
className: "rounded-xl
|
|
2103
|
-
children:
|
|
2539
|
+
className: "rounded-xl font-medium",
|
|
2540
|
+
children: t.cancel
|
|
2104
2541
|
}
|
|
2105
2542
|
),
|
|
2106
2543
|
/* @__PURE__ */ jsx(
|
|
2107
|
-
|
|
2544
|
+
Button,
|
|
2108
2545
|
{
|
|
2546
|
+
size: "large",
|
|
2547
|
+
type: "primary",
|
|
2109
2548
|
onClick: save,
|
|
2110
|
-
|
|
2111
|
-
className: "
|
|
2112
|
-
children:
|
|
2113
|
-
/* @__PURE__ */ 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: [
|
|
2114
|
-
/* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2115
|
-
/* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
2116
|
-
] }),
|
|
2117
|
-
"Saving..."
|
|
2118
|
-
] }) : "Save Entry"
|
|
2549
|
+
loading: saving,
|
|
2550
|
+
className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700",
|
|
2551
|
+
children: isCreatingEntry ? collection.submitLabel || (t.create ? t.create.toUpperCase() : "CREAR") : collection.saveLabel || (t.save ? t.save.toUpperCase() : "GUARDAR")
|
|
2119
2552
|
}
|
|
2120
2553
|
)
|
|
2121
2554
|
] })
|
|
2122
|
-
] })
|
|
2555
|
+
] }) })
|
|
2123
2556
|
}
|
|
2124
2557
|
),
|
|
2125
2558
|
/* @__PURE__ */ jsx("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm text-left", children: [
|
|
2126
2559
|
/* @__PURE__ */ jsx("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
2127
2560
|
visibleFields.map((f) => /* @__PURE__ */ jsx("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: f.label }, f.id)),
|
|
2128
|
-
/* @__PURE__ */ 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:
|
|
2561
|
+
/* @__PURE__ */ 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 })
|
|
2129
2562
|
] }) }),
|
|
2130
2563
|
/* @__PURE__ */ jsx("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
|
|
2131
2564
|
// Loading skeleton rows
|
|
@@ -2137,13 +2570,29 @@ function CollectionEditor({ collection }) {
|
|
|
2137
2570
|
(() => {
|
|
2138
2571
|
let res = entries;
|
|
2139
2572
|
if (search && collection.searchBy?.length) {
|
|
2140
|
-
const q = search.toLowerCase();
|
|
2141
|
-
res = res.filter((e) =>
|
|
2573
|
+
const q = search.toLowerCase().trim();
|
|
2574
|
+
res = res.filter((e) => {
|
|
2575
|
+
return collection.searchBy.some((field) => {
|
|
2576
|
+
const val = String(e[field] ?? "").toLowerCase();
|
|
2577
|
+
if (!val) return false;
|
|
2578
|
+
if (val.includes(q)) return true;
|
|
2579
|
+
const normVal = val.replace(/-/g, "/");
|
|
2580
|
+
const normQ = q.replace(/-/g, "/");
|
|
2581
|
+
return normVal.includes(normQ);
|
|
2582
|
+
});
|
|
2583
|
+
});
|
|
2142
2584
|
}
|
|
2143
2585
|
if (Object.keys(filters).length > 0) {
|
|
2144
2586
|
res = res.filter((e) => {
|
|
2145
2587
|
for (const [k, v] of Object.entries(filters)) {
|
|
2146
|
-
if (v
|
|
2588
|
+
if (!v) continue;
|
|
2589
|
+
const entryVal = String(e[k] ?? "").trim();
|
|
2590
|
+
const filterVal = String(v).trim();
|
|
2591
|
+
const normEntry = entryVal.replace(/-/g, "/");
|
|
2592
|
+
const normFilter = filterVal.replace(/-/g, "/");
|
|
2593
|
+
if (normEntry !== normFilter && !normEntry.includes(normFilter)) {
|
|
2594
|
+
return false;
|
|
2595
|
+
}
|
|
2147
2596
|
}
|
|
2148
2597
|
return true;
|
|
2149
2598
|
});
|
|
@@ -2159,18 +2608,33 @@ function CollectionEditor({ collection }) {
|
|
|
2159
2608
|
onDragEnd,
|
|
2160
2609
|
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" : ""}`,
|
|
2161
2610
|
children: [
|
|
2162
|
-
visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ jsx(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ jsx("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ 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__ */ 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__ */ 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__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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.
|
|
2611
|
+
visibleFields.map((f) => /* @__PURE__ */ jsx("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ jsx(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ jsx("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ 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__ */ 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__ */ 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__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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__ */ 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__ */ jsx("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ jsx("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ 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__ */ jsx(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__ */ jsxs("span", { className: "font-semibold text-slate-800", children: [
|
|
2163
2612
|
"$ ",
|
|
2164
2613
|
Number(e[f.id]).toLocaleString("es-CO")
|
|
2165
|
-
] }) : /* @__PURE__ */ jsx("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) :
|
|
2614
|
+
] }) : /* @__PURE__ */ 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__ */ jsxs(
|
|
2615
|
+
"a",
|
|
2616
|
+
{
|
|
2617
|
+
href: String(e[f.id]),
|
|
2618
|
+
target: "_blank",
|
|
2619
|
+
rel: "noopener noreferrer",
|
|
2620
|
+
className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
|
|
2621
|
+
children: [
|
|
2622
|
+
/* @__PURE__ */ jsx(ExternalLink, { className: "w-3 h-3" }),
|
|
2623
|
+
String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
|
|
2624
|
+
]
|
|
2625
|
+
}
|
|
2626
|
+
) : String(e[f.id] ?? "") }, f.id)),
|
|
2166
2627
|
/* @__PURE__ */ 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__ */ jsxs("div", { className: "flex items-center justify-end gap-2", children: [
|
|
2167
2628
|
/* @__PURE__ */ jsx("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ 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__ */ 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" }) }) }),
|
|
2168
2629
|
/* @__PURE__ */ jsx(
|
|
2169
2630
|
"button",
|
|
2170
2631
|
{
|
|
2171
|
-
onClick: () =>
|
|
2632
|
+
onClick: () => {
|
|
2633
|
+
setIsCreatingManual(false);
|
|
2634
|
+
setEditing(e);
|
|
2635
|
+
},
|
|
2172
2636
|
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
2173
|
-
title:
|
|
2637
|
+
title: t.edit,
|
|
2174
2638
|
children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" })
|
|
2175
2639
|
}
|
|
2176
2640
|
),
|
|
@@ -2180,7 +2644,7 @@ function CollectionEditor({ collection }) {
|
|
|
2180
2644
|
onClick: () => remove(e.id),
|
|
2181
2645
|
disabled: deletingId === e.id,
|
|
2182
2646
|
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
2183
|
-
title:
|
|
2647
|
+
title: t.delete,
|
|
2184
2648
|
children: deletingId === e.id ? /* @__PURE__ */ jsxs("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2185
2649
|
/* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2186
2650
|
/* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
@@ -2200,7 +2664,7 @@ function CollectionEditor({ collection }) {
|
|
|
2200
2664
|
className: "px-6 py-12 text-center text-slate-500",
|
|
2201
2665
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center", children: [
|
|
2202
2666
|
/* @__PURE__ */ jsx(Boxes, { className: "h-10 w-10 text-slate-300 mb-3" }),
|
|
2203
|
-
/* @__PURE__ */ jsx("p", { children:
|
|
2667
|
+
/* @__PURE__ */ jsx("p", { children: t.noRecords })
|
|
2204
2668
|
] })
|
|
2205
2669
|
}
|
|
2206
2670
|
) })
|
|
@@ -2221,7 +2685,7 @@ function CollectionEditor({ collection }) {
|
|
|
2221
2685
|
return true;
|
|
2222
2686
|
});
|
|
2223
2687
|
}
|
|
2224
|
-
return `${res.length}
|
|
2688
|
+
return `${res.length} ${t.entries}`;
|
|
2225
2689
|
})() }),
|
|
2226
2690
|
(() => {
|
|
2227
2691
|
let res = entries;
|
|
@@ -2871,6 +3335,197 @@ function PasswordField({ value, onChange }) {
|
|
|
2871
3335
|
)
|
|
2872
3336
|
] });
|
|
2873
3337
|
}
|
|
3338
|
+
function SignatureInput({
|
|
3339
|
+
value,
|
|
3340
|
+
onChange,
|
|
3341
|
+
label
|
|
3342
|
+
}) {
|
|
3343
|
+
const t = useAdminI18n();
|
|
3344
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
3345
|
+
const canvasRef = useRef(null);
|
|
3346
|
+
const isDrawingRef = useRef(false);
|
|
3347
|
+
const fileInputRef = useRef(null);
|
|
3348
|
+
const sigVal = typeof value === "string" ? value : "";
|
|
3349
|
+
const displayLabel = label || t.signatureRegistered;
|
|
3350
|
+
const startDrawing = (e) => {
|
|
3351
|
+
const canvas = canvasRef.current;
|
|
3352
|
+
if (!canvas) return;
|
|
3353
|
+
const ctx = canvas.getContext("2d");
|
|
3354
|
+
if (!ctx) return;
|
|
3355
|
+
isDrawingRef.current = true;
|
|
3356
|
+
const rect = canvas.getBoundingClientRect();
|
|
3357
|
+
const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
|
|
3358
|
+
const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
|
|
3359
|
+
ctx.beginPath();
|
|
3360
|
+
ctx.moveTo(x, y);
|
|
3361
|
+
};
|
|
3362
|
+
const draw = (e) => {
|
|
3363
|
+
if (!isDrawingRef.current) return;
|
|
3364
|
+
const canvas = canvasRef.current;
|
|
3365
|
+
if (!canvas) return;
|
|
3366
|
+
const ctx = canvas.getContext("2d");
|
|
3367
|
+
if (!ctx) return;
|
|
3368
|
+
const rect = canvas.getBoundingClientRect();
|
|
3369
|
+
const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
|
|
3370
|
+
const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
|
|
3371
|
+
ctx.lineTo(x, y);
|
|
3372
|
+
ctx.stroke();
|
|
3373
|
+
};
|
|
3374
|
+
const stopDrawing = () => {
|
|
3375
|
+
isDrawingRef.current = false;
|
|
3376
|
+
};
|
|
3377
|
+
const clearCanvas = () => {
|
|
3378
|
+
const canvas = canvasRef.current;
|
|
3379
|
+
if (!canvas) return;
|
|
3380
|
+
const ctx = canvas.getContext("2d");
|
|
3381
|
+
if (!ctx) return;
|
|
3382
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
3383
|
+
};
|
|
3384
|
+
const saveDrawnSignature = () => {
|
|
3385
|
+
const canvas = canvasRef.current;
|
|
3386
|
+
if (!canvas) return;
|
|
3387
|
+
const dataUrl = canvas.toDataURL("image/png");
|
|
3388
|
+
onChange(dataUrl);
|
|
3389
|
+
setModalOpen(false);
|
|
3390
|
+
};
|
|
3391
|
+
const handleFileUpload = (e) => {
|
|
3392
|
+
const file = e.target.files?.[0];
|
|
3393
|
+
if (!file) return;
|
|
3394
|
+
const reader = new FileReader();
|
|
3395
|
+
reader.onload = (evt) => {
|
|
3396
|
+
if (typeof evt.target?.result === "string") {
|
|
3397
|
+
onChange(evt.target.result);
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
reader.readAsDataURL(file);
|
|
3401
|
+
e.target.value = "";
|
|
3402
|
+
};
|
|
3403
|
+
useEffect(() => {
|
|
3404
|
+
if (modalOpen) {
|
|
3405
|
+
setTimeout(() => {
|
|
3406
|
+
const canvas = canvasRef.current;
|
|
3407
|
+
if (!canvas) return;
|
|
3408
|
+
const ctx = canvas.getContext("2d");
|
|
3409
|
+
if (ctx) {
|
|
3410
|
+
ctx.strokeStyle = "#0f172a";
|
|
3411
|
+
ctx.lineWidth = 2.5;
|
|
3412
|
+
ctx.lineCap = "round";
|
|
3413
|
+
ctx.lineJoin = "round";
|
|
3414
|
+
}
|
|
3415
|
+
}, 50);
|
|
3416
|
+
}
|
|
3417
|
+
}, [modalOpen]);
|
|
3418
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3419
|
+
sigVal ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-3 rounded-xl border border-slate-200 bg-slate-50/70", children: [
|
|
3420
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
3421
|
+
/* @__PURE__ */ jsx(
|
|
3422
|
+
Image,
|
|
3423
|
+
{
|
|
3424
|
+
src: sigVal,
|
|
3425
|
+
alt: displayLabel,
|
|
3426
|
+
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",
|
|
3427
|
+
preview: {
|
|
3428
|
+
mask: /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold", children: t.previewMask })
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
),
|
|
3432
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
3433
|
+
/* @__PURE__ */ 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 }),
|
|
3434
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-slate-500", children: t.viewLarger })
|
|
3435
|
+
] })
|
|
3436
|
+
] }),
|
|
3437
|
+
/* @__PURE__ */ jsx(
|
|
3438
|
+
Button,
|
|
3439
|
+
{
|
|
3440
|
+
danger: true,
|
|
3441
|
+
type: "text",
|
|
3442
|
+
icon: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" }),
|
|
3443
|
+
onClick: () => onChange(""),
|
|
3444
|
+
className: "hover:bg-red-50 text-red-600 font-medium",
|
|
3445
|
+
children: t.delete
|
|
3446
|
+
}
|
|
3447
|
+
)
|
|
3448
|
+
] }) : null,
|
|
3449
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
3450
|
+
/* @__PURE__ */ jsx(
|
|
3451
|
+
Button,
|
|
3452
|
+
{
|
|
3453
|
+
type: "primary",
|
|
3454
|
+
size: "large",
|
|
3455
|
+
onClick: () => {
|
|
3456
|
+
clearCanvas();
|
|
3457
|
+
setModalOpen(true);
|
|
3458
|
+
},
|
|
3459
|
+
className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
|
|
3460
|
+
children: sigVal ? t.replaceSignature : t.addSignature
|
|
3461
|
+
}
|
|
3462
|
+
),
|
|
3463
|
+
/* @__PURE__ */ jsx(
|
|
3464
|
+
Button,
|
|
3465
|
+
{
|
|
3466
|
+
type: "primary",
|
|
3467
|
+
size: "large",
|
|
3468
|
+
onClick: () => fileInputRef.current?.click(),
|
|
3469
|
+
className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
|
|
3470
|
+
children: sigVal ? t.uploadNewImage : t.uploadImage
|
|
3471
|
+
}
|
|
3472
|
+
),
|
|
3473
|
+
/* @__PURE__ */ jsx(
|
|
3474
|
+
"input",
|
|
3475
|
+
{
|
|
3476
|
+
type: "file",
|
|
3477
|
+
ref: fileInputRef,
|
|
3478
|
+
accept: "image/*",
|
|
3479
|
+
onChange: handleFileUpload,
|
|
3480
|
+
className: "hidden"
|
|
3481
|
+
}
|
|
3482
|
+
)
|
|
3483
|
+
] }),
|
|
3484
|
+
/* @__PURE__ */ jsx(
|
|
3485
|
+
Modal,
|
|
3486
|
+
{
|
|
3487
|
+
open: modalOpen,
|
|
3488
|
+
title: /* @__PURE__ */ jsx("span", { className: "font-bold text-slate-800", children: t.signOnScreen }),
|
|
3489
|
+
onCancel: () => setModalOpen(false),
|
|
3490
|
+
centered: true,
|
|
3491
|
+
width: 560,
|
|
3492
|
+
footer: [
|
|
3493
|
+
/* @__PURE__ */ jsx(Button, { onClick: clearCanvas, className: "rounded-xl font-medium", children: t.clear }, "clear"),
|
|
3494
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => setModalOpen(false), className: "rounded-xl font-medium", children: t.cancel }, "cancel"),
|
|
3495
|
+
/* @__PURE__ */ jsx(
|
|
3496
|
+
Button,
|
|
3497
|
+
{
|
|
3498
|
+
type: "primary",
|
|
3499
|
+
onClick: saveDrawnSignature,
|
|
3500
|
+
className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl",
|
|
3501
|
+
children: t.saveSignature
|
|
3502
|
+
},
|
|
3503
|
+
"save"
|
|
3504
|
+
)
|
|
3505
|
+
],
|
|
3506
|
+
children: /* @__PURE__ */ jsxs("div", { className: "py-2 space-y-2", children: [
|
|
3507
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-slate-500", children: t.signInstructions }),
|
|
3508
|
+
/* @__PURE__ */ jsx("div", { className: "border-2 border-dashed border-slate-300 rounded-2xl bg-white overflow-hidden touch-none", children: /* @__PURE__ */ jsx(
|
|
3509
|
+
"canvas",
|
|
3510
|
+
{
|
|
3511
|
+
ref: canvasRef,
|
|
3512
|
+
width: 500,
|
|
3513
|
+
height: 220,
|
|
3514
|
+
onMouseDown: startDrawing,
|
|
3515
|
+
onMouseMove: draw,
|
|
3516
|
+
onMouseUp: stopDrawing,
|
|
3517
|
+
onMouseLeave: stopDrawing,
|
|
3518
|
+
onTouchStart: startDrawing,
|
|
3519
|
+
onTouchMove: draw,
|
|
3520
|
+
onTouchEnd: stopDrawing,
|
|
3521
|
+
className: "w-full h-[220px] cursor-crosshair block"
|
|
3522
|
+
}
|
|
3523
|
+
) })
|
|
3524
|
+
] })
|
|
3525
|
+
}
|
|
3526
|
+
)
|
|
3527
|
+
] });
|
|
3528
|
+
}
|
|
2874
3529
|
function FormattedNumberInput({
|
|
2875
3530
|
value,
|
|
2876
3531
|
onChange,
|
|
@@ -3553,11 +4208,80 @@ function ReferenceSelect({
|
|
|
3553
4208
|
searchable = false,
|
|
3554
4209
|
max,
|
|
3555
4210
|
value,
|
|
3556
|
-
onChange
|
|
4211
|
+
onChange,
|
|
4212
|
+
onSelectRecord
|
|
3557
4213
|
}) {
|
|
3558
4214
|
const ctx = useCmsContext();
|
|
4215
|
+
const t = useAdminI18n();
|
|
3559
4216
|
const [options, setOptions] = useState([]);
|
|
3560
4217
|
const [loading, setLoading] = useState(true);
|
|
4218
|
+
const [clientModalOpen, setClientModalOpen] = useState(false);
|
|
4219
|
+
const [creatingClient, setCreatingClient] = useState(false);
|
|
4220
|
+
const [clientError, setClientError] = useState("");
|
|
4221
|
+
const [newClient, setNewClient] = useState({
|
|
4222
|
+
tipo: "Persona",
|
|
4223
|
+
tipoDocumento: "C\xE9dula de ciudadan\xEDa",
|
|
4224
|
+
id: "",
|
|
4225
|
+
sucursal: "",
|
|
4226
|
+
nombre: "",
|
|
4227
|
+
email: "",
|
|
4228
|
+
telefono: "",
|
|
4229
|
+
ciudad: "",
|
|
4230
|
+
direccion: ""
|
|
4231
|
+
});
|
|
4232
|
+
const handleSaveClient = async () => {
|
|
4233
|
+
setClientError("");
|
|
4234
|
+
if (!newClient.id.trim()) {
|
|
4235
|
+
setClientError(t.idRequired);
|
|
4236
|
+
return;
|
|
4237
|
+
}
|
|
4238
|
+
if (!newClient.nombre.trim()) {
|
|
4239
|
+
setClientError(t.nameRequired);
|
|
4240
|
+
return;
|
|
4241
|
+
}
|
|
4242
|
+
setCreatingClient(true);
|
|
4243
|
+
try {
|
|
4244
|
+
const entry = {
|
|
4245
|
+
...newClient,
|
|
4246
|
+
id: newClient.id.trim(),
|
|
4247
|
+
nombre: newClient.nombre.trim()
|
|
4248
|
+
};
|
|
4249
|
+
await ctx.adapter.putEntry("clients", entry);
|
|
4250
|
+
const res = await ctx.adapter.listEntries("clients");
|
|
4251
|
+
const fromCollection = (res || []).map((r) => {
|
|
4252
|
+
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
4253
|
+
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
4254
|
+
const lab = fullName || String(r[displayField] || r.name || r.id);
|
|
4255
|
+
return {
|
|
4256
|
+
value: val,
|
|
4257
|
+
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
4258
|
+
raw: r
|
|
4259
|
+
};
|
|
4260
|
+
});
|
|
4261
|
+
setOptions(fromCollection);
|
|
4262
|
+
onChange(entry.id);
|
|
4263
|
+
if (onSelectRecord) {
|
|
4264
|
+
onSelectRecord(entry);
|
|
4265
|
+
}
|
|
4266
|
+
setClientModalOpen(false);
|
|
4267
|
+
setNewClient({
|
|
4268
|
+
tipo: "Persona",
|
|
4269
|
+
tipoDocumento: "C\xE9dula de ciudadan\xEDa",
|
|
4270
|
+
id: "",
|
|
4271
|
+
sucursal: "",
|
|
4272
|
+
nombre: "",
|
|
4273
|
+
email: "",
|
|
4274
|
+
telefono: "",
|
|
4275
|
+
ciudad: "",
|
|
4276
|
+
direccion: ""
|
|
4277
|
+
});
|
|
4278
|
+
message.success(t.clientCreatedSuccess);
|
|
4279
|
+
} catch (err) {
|
|
4280
|
+
setClientError(err?.message || "Error al crear cliente.");
|
|
4281
|
+
} finally {
|
|
4282
|
+
setCreatingClient(false);
|
|
4283
|
+
}
|
|
4284
|
+
};
|
|
3561
4285
|
useEffect(() => {
|
|
3562
4286
|
if (!collectionId) {
|
|
3563
4287
|
if (fallbackOptions && fallbackOptions.length > 0) {
|
|
@@ -3568,65 +4292,279 @@ function ReferenceSelect({
|
|
|
3568
4292
|
}
|
|
3569
4293
|
setLoading(true);
|
|
3570
4294
|
ctx.adapter.listEntries(collectionId).then((res) => {
|
|
3571
|
-
const fromCollection = res.map((r) => {
|
|
4295
|
+
const fromCollection = (res || []).map((r) => {
|
|
3572
4296
|
const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
|
|
3573
|
-
const
|
|
3574
|
-
|
|
4297
|
+
const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
|
|
4298
|
+
const lab = fullName || String(r[displayField] || r.name || r.id);
|
|
4299
|
+
return {
|
|
4300
|
+
value: val,
|
|
4301
|
+
label: val && val !== lab ? `${lab} (${val})` : lab,
|
|
4302
|
+
raw: r
|
|
4303
|
+
};
|
|
3575
4304
|
});
|
|
3576
|
-
|
|
3577
|
-
(opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
|
|
3578
|
-
);
|
|
3579
|
-
const combined = [...fromCollection];
|
|
3580
|
-
for (const fb of fallbackList) {
|
|
3581
|
-
if (!combined.some((c) => c.value === fb.value || c.label === fb.label)) {
|
|
3582
|
-
combined.push(fb);
|
|
3583
|
-
}
|
|
3584
|
-
}
|
|
3585
|
-
setOptions(combined);
|
|
4305
|
+
setOptions(fromCollection);
|
|
3586
4306
|
setLoading(false);
|
|
3587
4307
|
}).catch(() => {
|
|
3588
|
-
|
|
3589
|
-
setOptions(fallbackOptions.map((opt) => typeof opt === "string" ? { value: opt, label: opt } : opt));
|
|
3590
|
-
}
|
|
4308
|
+
setOptions([]);
|
|
3591
4309
|
setLoading(false);
|
|
3592
4310
|
});
|
|
3593
|
-
}, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter]);
|
|
4311
|
+
}, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter, ctx.collectionChangedAt]);
|
|
3594
4312
|
if (multiple) {
|
|
3595
4313
|
const selectedList = Array.isArray(value) ? value.map(String) : typeof value === "string" && value.trim() ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
3596
4314
|
return /* @__PURE__ */ jsx(
|
|
3597
|
-
|
|
4315
|
+
Select,
|
|
3598
4316
|
{
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
onChange,
|
|
4317
|
+
size: "large",
|
|
4318
|
+
mode: "multiple",
|
|
3602
4319
|
loading,
|
|
3603
|
-
searchable,
|
|
4320
|
+
showSearch: searchable,
|
|
3604
4321
|
placeholder: "Seleccionar opciones...",
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
4322
|
+
filterOption: (input, option) => {
|
|
4323
|
+
if (!input) return true;
|
|
4324
|
+
const q = input.toLowerCase();
|
|
4325
|
+
const label = String(option?.label ?? "").toLowerCase();
|
|
4326
|
+
const val = String(option?.value ?? "").toLowerCase();
|
|
4327
|
+
return label.includes(q) || val.includes(q);
|
|
4328
|
+
},
|
|
4329
|
+
maxCount: max,
|
|
4330
|
+
value: selectedList,
|
|
4331
|
+
onChange,
|
|
4332
|
+
options,
|
|
4333
|
+
className: "w-full"
|
|
3608
4334
|
}
|
|
3609
4335
|
);
|
|
3610
4336
|
}
|
|
3611
|
-
const singleVal =
|
|
4337
|
+
const singleVal = value !== void 0 && value !== null && value !== "" ? String(value) : void 0;
|
|
3612
4338
|
const displayOptions = [...options];
|
|
3613
4339
|
if (singleVal && !displayOptions.some((o) => o.value === singleVal)) {
|
|
3614
4340
|
displayOptions.unshift({ value: singleVal, label: singleVal });
|
|
3615
4341
|
}
|
|
3616
|
-
return /* @__PURE__ */ jsxs(
|
|
3617
|
-
/* @__PURE__ */ jsxs(
|
|
3618
|
-
"
|
|
4342
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4343
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4344
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(
|
|
4345
|
+
Select,
|
|
4346
|
+
{
|
|
4347
|
+
size: "large",
|
|
4348
|
+
loading,
|
|
4349
|
+
showSearch: searchable,
|
|
4350
|
+
placeholder: loading ? t.loadingOptions : t.selectOption,
|
|
4351
|
+
allowClear: true,
|
|
4352
|
+
filterOption: (input, option) => {
|
|
4353
|
+
if (!input) return true;
|
|
4354
|
+
const q = input.toLowerCase();
|
|
4355
|
+
const label = String(option?.label ?? "").toLowerCase();
|
|
4356
|
+
const val = String(option?.value ?? "").toLowerCase();
|
|
4357
|
+
return label.includes(q) || val.includes(q);
|
|
4358
|
+
},
|
|
4359
|
+
value: singleVal,
|
|
4360
|
+
onChange: (v) => {
|
|
4361
|
+
onChange(v || "");
|
|
4362
|
+
if (onSelectRecord) {
|
|
4363
|
+
const found = options.find((o) => o.value === v);
|
|
4364
|
+
if (found?.raw) onSelectRecord(found.raw);
|
|
4365
|
+
}
|
|
4366
|
+
},
|
|
4367
|
+
options: displayOptions,
|
|
4368
|
+
dropdownRender: (menu) => /* @__PURE__ */ jsxs("div", { children: [
|
|
4369
|
+
menu,
|
|
4370
|
+
collectionId === "clients" && /* @__PURE__ */ jsxs("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
|
|
4371
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindClient }),
|
|
4372
|
+
/* @__PURE__ */ jsx(
|
|
4373
|
+
Button,
|
|
4374
|
+
{
|
|
4375
|
+
type: "primary",
|
|
4376
|
+
size: "small",
|
|
4377
|
+
icon: /* @__PURE__ */ jsx(Plus, { className: "w-3.5 h-3.5" }),
|
|
4378
|
+
onClick: () => {
|
|
4379
|
+
setClientError("");
|
|
4380
|
+
setClientModalOpen(true);
|
|
4381
|
+
},
|
|
4382
|
+
className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
|
|
4383
|
+
children: t.createClient
|
|
4384
|
+
}
|
|
4385
|
+
)
|
|
4386
|
+
] })
|
|
4387
|
+
] }),
|
|
4388
|
+
className: "w-full"
|
|
4389
|
+
}
|
|
4390
|
+
) }),
|
|
4391
|
+
collectionId === "clients" && /* @__PURE__ */ jsx(
|
|
4392
|
+
Button,
|
|
4393
|
+
{
|
|
4394
|
+
type: "primary",
|
|
4395
|
+
size: "large",
|
|
4396
|
+
icon: /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" }),
|
|
4397
|
+
onClick: () => {
|
|
4398
|
+
setClientError("");
|
|
4399
|
+
setClientModalOpen(true);
|
|
4400
|
+
},
|
|
4401
|
+
className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
|
|
4402
|
+
children: t.newBtn
|
|
4403
|
+
}
|
|
4404
|
+
)
|
|
4405
|
+
] }),
|
|
4406
|
+
collectionId === "clients" && /* @__PURE__ */ jsx(
|
|
4407
|
+
Modal,
|
|
3619
4408
|
{
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
4409
|
+
open: clientModalOpen,
|
|
4410
|
+
title: /* @__PURE__ */ jsx("span", { className: "text-xl font-bold text-slate-900 font-display", children: t.basicDetails }),
|
|
4411
|
+
onCancel: () => setClientModalOpen(false),
|
|
4412
|
+
centered: true,
|
|
4413
|
+
width: 650,
|
|
4414
|
+
footer: null,
|
|
4415
|
+
children: /* @__PURE__ */ jsxs("div", { className: "pt-2 space-y-4", children: [
|
|
4416
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
4417
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4418
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientType }),
|
|
4419
|
+
/* @__PURE__ */ jsx(
|
|
4420
|
+
Select,
|
|
4421
|
+
{
|
|
4422
|
+
size: "large",
|
|
4423
|
+
value: newClient.tipo,
|
|
4424
|
+
onChange: (val) => {
|
|
4425
|
+
setNewClient((prev) => ({
|
|
4426
|
+
...prev,
|
|
4427
|
+
tipo: val,
|
|
4428
|
+
tipoDocumento: val === "Empresa" ? "Nit" : "C\xE9dula de ciudadan\xEDa"
|
|
4429
|
+
}));
|
|
4430
|
+
},
|
|
4431
|
+
options: [
|
|
4432
|
+
{ label: "Persona", value: "Persona" },
|
|
4433
|
+
{ label: "Empresa", value: "Empresa" }
|
|
4434
|
+
],
|
|
4435
|
+
className: "w-full"
|
|
4436
|
+
}
|
|
4437
|
+
)
|
|
4438
|
+
] }),
|
|
4439
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4440
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientDocType }),
|
|
4441
|
+
/* @__PURE__ */ jsx(
|
|
4442
|
+
Select,
|
|
4443
|
+
{
|
|
4444
|
+
size: "large",
|
|
4445
|
+
value: newClient.tipoDocumento,
|
|
4446
|
+
onChange: (val) => setNewClient((prev) => ({ ...prev, tipoDocumento: val })),
|
|
4447
|
+
options: newClient.tipo === "Persona" ? [
|
|
4448
|
+
{ label: "C\xE9dula de ciudadan\xEDa", value: "C\xE9dula de ciudadan\xEDa" },
|
|
4449
|
+
{ label: "C\xE9dula de extranjer\xEDa", value: "C\xE9dula de extranjer\xEDa" },
|
|
4450
|
+
{ label: "Pasaporte", value: "Pasaporte" }
|
|
4451
|
+
] : [{ label: "Nit", value: "Nit" }],
|
|
4452
|
+
className: "w-full"
|
|
4453
|
+
}
|
|
4454
|
+
)
|
|
4455
|
+
] })
|
|
4456
|
+
] }),
|
|
4457
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
4458
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4459
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
|
|
4460
|
+
t.clientIdentification,
|
|
4461
|
+
" *"
|
|
4462
|
+
] }),
|
|
4463
|
+
/* @__PURE__ */ jsx(
|
|
4464
|
+
Input,
|
|
4465
|
+
{
|
|
4466
|
+
size: "large",
|
|
4467
|
+
placeholder: t.clientIdentification,
|
|
4468
|
+
value: newClient.id,
|
|
4469
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, id: e.target.value }))
|
|
4470
|
+
}
|
|
4471
|
+
)
|
|
4472
|
+
] }),
|
|
4473
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4474
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientBranch }),
|
|
4475
|
+
/* @__PURE__ */ jsx(
|
|
4476
|
+
Input,
|
|
4477
|
+
{
|
|
4478
|
+
size: "large",
|
|
4479
|
+
placeholder: t.clientBranch,
|
|
4480
|
+
value: newClient.sucursal,
|
|
4481
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, sucursal: e.target.value }))
|
|
4482
|
+
}
|
|
4483
|
+
)
|
|
4484
|
+
] })
|
|
4485
|
+
] }),
|
|
4486
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
4487
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4488
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
|
|
4489
|
+
t.clientName,
|
|
4490
|
+
" *"
|
|
4491
|
+
] }),
|
|
4492
|
+
/* @__PURE__ */ jsx(
|
|
4493
|
+
Input,
|
|
4494
|
+
{
|
|
4495
|
+
size: "large",
|
|
4496
|
+
placeholder: t.clientName,
|
|
4497
|
+
value: newClient.nombre,
|
|
4498
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, nombre: e.target.value }))
|
|
4499
|
+
}
|
|
4500
|
+
)
|
|
4501
|
+
] }),
|
|
4502
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4503
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientEmail }),
|
|
4504
|
+
/* @__PURE__ */ jsx(
|
|
4505
|
+
Input,
|
|
4506
|
+
{
|
|
4507
|
+
size: "large",
|
|
4508
|
+
placeholder: t.clientEmail,
|
|
4509
|
+
value: newClient.email,
|
|
4510
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, email: e.target.value }))
|
|
4511
|
+
}
|
|
4512
|
+
)
|
|
4513
|
+
] })
|
|
4514
|
+
] }),
|
|
4515
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
4516
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4517
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientPhone }),
|
|
4518
|
+
/* @__PURE__ */ jsx(
|
|
4519
|
+
Input,
|
|
4520
|
+
{
|
|
4521
|
+
size: "large",
|
|
4522
|
+
placeholder: t.clientPhone,
|
|
4523
|
+
value: newClient.telefono,
|
|
4524
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, telefono: e.target.value }))
|
|
4525
|
+
}
|
|
4526
|
+
)
|
|
4527
|
+
] }),
|
|
4528
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4529
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientCity }),
|
|
4530
|
+
/* @__PURE__ */ jsx(
|
|
4531
|
+
Input,
|
|
4532
|
+
{
|
|
4533
|
+
size: "large",
|
|
4534
|
+
placeholder: t.clientCity,
|
|
4535
|
+
value: newClient.ciudad,
|
|
4536
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, ciudad: e.target.value }))
|
|
4537
|
+
}
|
|
4538
|
+
)
|
|
4539
|
+
] })
|
|
4540
|
+
] }),
|
|
4541
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4542
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientAddress }),
|
|
4543
|
+
/* @__PURE__ */ jsx(
|
|
4544
|
+
Input,
|
|
4545
|
+
{
|
|
4546
|
+
size: "large",
|
|
4547
|
+
placeholder: t.clientAddress,
|
|
4548
|
+
value: newClient.direccion,
|
|
4549
|
+
onChange: (e) => setNewClient((prev) => ({ ...prev, direccion: e.target.value }))
|
|
4550
|
+
}
|
|
4551
|
+
)
|
|
4552
|
+
] }),
|
|
4553
|
+
clientError && /* @__PURE__ */ jsx("p", { className: "text-xs font-semibold text-red-600 bg-red-50 p-2.5 rounded-lg border border-red-200", children: clientError }),
|
|
4554
|
+
/* @__PURE__ */ jsx(
|
|
4555
|
+
Button,
|
|
4556
|
+
{
|
|
4557
|
+
type: "primary",
|
|
4558
|
+
size: "large",
|
|
4559
|
+
loading: creatingClient,
|
|
4560
|
+
onClick: handleSaveClient,
|
|
4561
|
+
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",
|
|
4562
|
+
children: t.create.toUpperCase()
|
|
4563
|
+
}
|
|
4564
|
+
)
|
|
4565
|
+
] })
|
|
3627
4566
|
}
|
|
3628
|
-
)
|
|
3629
|
-
/* @__PURE__ */ jsx(ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
|
|
4567
|
+
)
|
|
3630
4568
|
] });
|
|
3631
4569
|
}
|
|
3632
4570
|
function ReferenceTableCell({
|