transactions-mfe 1.0.0
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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/index.cjs +1165 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1155 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/types/app/components/EmbeddedShell.d.ts +3 -0
- package/dist/types/app/components/Sidebar.d.ts +1 -0
- package/dist/types/app/edit/[id]/page.d.ts +1 -0
- package/dist/types/app/layout.d.ts +6 -0
- package/dist/types/app/new/page.d.ts +1 -0
- package/dist/types/app/page.d.ts +1 -0
- package/dist/types/lib/index.d.ts +28 -0
- package/package.json +68 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var Link = require('next/link');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var navigation = require('next/navigation');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
12
|
+
|
|
13
|
+
// app/page.tsx
|
|
14
|
+
var COIN_STYLES = {
|
|
15
|
+
btc: { bg: "rgba(217,119,6,0.10)", color: "#b45309", border: "rgba(217,119,6,0.20)" },
|
|
16
|
+
bitcoin: { bg: "rgba(217,119,6,0.10)", color: "#b45309", border: "rgba(217,119,6,0.20)" },
|
|
17
|
+
eth: { bg: "rgba(79,70,229,0.10)", color: "#4338ca", border: "rgba(79,70,229,0.20)" },
|
|
18
|
+
ethereum: { bg: "rgba(79,70,229,0.10)", color: "#4338ca", border: "rgba(79,70,229,0.20)" },
|
|
19
|
+
sol: { bg: "rgba(124,58,237,0.10)", color: "#6d28d9", border: "rgba(124,58,237,0.20)" },
|
|
20
|
+
solana: { bg: "rgba(124,58,237,0.10)", color: "#6d28d9", border: "rgba(124,58,237,0.20)" },
|
|
21
|
+
usdt: { bg: "rgba(5,150,105,0.10)", color: "#047857", border: "rgba(5,150,105,0.20)" },
|
|
22
|
+
usdc: { bg: "rgba(2,132,199,0.10)", color: "#0369a1", border: "rgba(2,132,199,0.20)" },
|
|
23
|
+
bnb: { bg: "rgba(202,138,4,0.10)", color: "#a16207", border: "rgba(202,138,4,0.20)" },
|
|
24
|
+
xrp: { bg: "rgba(37,99,235,0.10)", color: "#1d4ed8", border: "rgba(37,99,235,0.20)" },
|
|
25
|
+
doge: { bg: "rgba(234,88,12,0.10)", color: "#c2410c", border: "rgba(234,88,12,0.20)" }
|
|
26
|
+
};
|
|
27
|
+
var DEFAULT_COIN = { bg: "rgba(145,158,171,0.12)", color: "#637381", border: "rgba(145,158,171,0.24)" };
|
|
28
|
+
var CoinBadge = ({ coin }) => {
|
|
29
|
+
const s = COIN_STYLES[coin.toLowerCase()] ?? DEFAULT_COIN;
|
|
30
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
className: "inline-flex items-center text-[11px] font-bold px-2.5 py-0.5 rounded-full",
|
|
34
|
+
style: { backgroundColor: s.bg, color: s.color, border: `1px solid ${s.border}`, letterSpacing: "0.05em" },
|
|
35
|
+
children: coin.toUpperCase()
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
var GRADIENTS = [
|
|
40
|
+
"linear-gradient(135deg,#6366f1,#4f46e5)",
|
|
41
|
+
"linear-gradient(135deg,#a78bfa,#7c3aed)",
|
|
42
|
+
"linear-gradient(135deg,#38bdf8,#0284c7)",
|
|
43
|
+
"linear-gradient(135deg,#34d399,#059669)",
|
|
44
|
+
"linear-gradient(135deg,#fb7185,#e11d48)",
|
|
45
|
+
"linear-gradient(135deg,#fbbf24,#d97706)"
|
|
46
|
+
];
|
|
47
|
+
var Avatar = ({ name }) => {
|
|
48
|
+
const ch = name?.charAt(0)?.toUpperCase() ?? "?";
|
|
49
|
+
const g = GRADIENTS[(ch.charCodeAt(0) - 65) % GRADIENTS.length];
|
|
50
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: "w-8 h-8 rounded-full flex items-center justify-center text-white text-xs font-bold shrink-0",
|
|
54
|
+
style: { background: g, boxShadow: "0 3px 6px rgba(0,0,0,0.12)" },
|
|
55
|
+
children: ch
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
var Skeleton = () => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-pulse", children: [1, 2, 3, 4, 5, 6].map((i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
className: "flex items-center gap-4 px-6 py-4",
|
|
63
|
+
style: { borderBottom: "1px solid rgba(145,158,171,0.12)" },
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-8 rounded-full bg-gray-200 shrink-0" }),
|
|
66
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-4 bg-gray-200 rounded w-28" }),
|
|
67
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-5 bg-gray-100 rounded-full w-14" }),
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 bg-gray-100 rounded w-20 ml-auto" }),
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 bg-gray-100 rounded w-24" }),
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
|
|
71
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-7 h-7 bg-gray-100 rounded-lg" }),
|
|
72
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-7 h-7 bg-gray-100 rounded-lg" })
|
|
73
|
+
] })
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
i
|
|
77
|
+
)) });
|
|
78
|
+
function TransactionsPage() {
|
|
79
|
+
const [transactions, setTransactions] = react.useState([]);
|
|
80
|
+
const [loading, setLoading] = react.useState(true);
|
|
81
|
+
const [error, setError] = react.useState(null);
|
|
82
|
+
const [deletingId, setDeletingId] = react.useState(null);
|
|
83
|
+
const [filterCoin, setFilterCoin] = react.useState("");
|
|
84
|
+
const [filterUser, setFilterUser] = react.useState("");
|
|
85
|
+
const API = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:3000";
|
|
86
|
+
const load = react.useCallback(async () => {
|
|
87
|
+
setLoading(true);
|
|
88
|
+
setError(null);
|
|
89
|
+
try {
|
|
90
|
+
const res = await fetch(`${API}/api/transactions`);
|
|
91
|
+
if (!res.ok) throw new Error(`Error ${res.status}`);
|
|
92
|
+
const data = await res.json();
|
|
93
|
+
setTransactions(data);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
setError(e instanceof Error ? e.message : "Error desconocido");
|
|
96
|
+
} finally {
|
|
97
|
+
setLoading(false);
|
|
98
|
+
}
|
|
99
|
+
}, [API]);
|
|
100
|
+
react.useEffect(() => {
|
|
101
|
+
load();
|
|
102
|
+
}, [load]);
|
|
103
|
+
const handleDelete = async (id) => {
|
|
104
|
+
if (!confirm("\xBFEliminar esta transacci\xF3n? Esta acci\xF3n no se puede deshacer.")) return;
|
|
105
|
+
setDeletingId(id);
|
|
106
|
+
try {
|
|
107
|
+
const res = await fetch(`${API}/api/transactions/${id}`, { method: "DELETE" });
|
|
108
|
+
if (!res.ok) throw new Error("No se pudo eliminar");
|
|
109
|
+
setTransactions((prev) => prev.filter((t) => t._id !== id));
|
|
110
|
+
} catch (e) {
|
|
111
|
+
alert(e instanceof Error ? e.message : "Error al eliminar");
|
|
112
|
+
} finally {
|
|
113
|
+
setDeletingId(null);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const filtered = transactions.filter((t) => {
|
|
117
|
+
const matchCoin = !filterCoin || t.coin.toLowerCase().includes(filterCoin.toLowerCase());
|
|
118
|
+
const matchUser = !filterUser || t.user.toLowerCase().includes(filterUser.toLowerCase());
|
|
119
|
+
return matchCoin && matchUser;
|
|
120
|
+
});
|
|
121
|
+
const coins = [...new Set(transactions.map((t) => t.coin))].sort();
|
|
122
|
+
const formatDate = (iso) => new Date(iso).toLocaleDateString("es-MX", { day: "numeric", month: "short", year: "numeric" });
|
|
123
|
+
const formatTime = (iso) => new Date(iso).toLocaleTimeString("es-MX", { hour: "2-digit", minute: "2-digit" });
|
|
124
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6 space-y-5", children: [
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
126
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
127
|
+
"select",
|
|
128
|
+
{
|
|
129
|
+
value: filterCoin,
|
|
130
|
+
onChange: (e) => setFilterCoin(e.target.value),
|
|
131
|
+
className: "text-sm px-3 py-2 rounded-lg transition-all outline-none",
|
|
132
|
+
style: {
|
|
133
|
+
border: "1px solid var(--border)",
|
|
134
|
+
backgroundColor: "white",
|
|
135
|
+
color: "var(--text-primary)",
|
|
136
|
+
minWidth: 140
|
|
137
|
+
},
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Todas las monedas" }),
|
|
140
|
+
coins.map((c) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: c, children: c.toUpperCase() }, c))
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
145
|
+
"input",
|
|
146
|
+
{
|
|
147
|
+
type: "text",
|
|
148
|
+
value: filterUser,
|
|
149
|
+
onChange: (e) => setFilterUser(e.target.value),
|
|
150
|
+
placeholder: "Buscar usuario...",
|
|
151
|
+
className: "text-sm px-3 py-2 rounded-lg transition-all outline-none",
|
|
152
|
+
style: {
|
|
153
|
+
border: "1px solid var(--border)",
|
|
154
|
+
backgroundColor: "white",
|
|
155
|
+
color: "var(--text-primary)",
|
|
156
|
+
minWidth: 180
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
!loading && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs ml-1", style: { color: "var(--text-disabled)" }, children: [
|
|
161
|
+
filtered.length,
|
|
162
|
+
" de ",
|
|
163
|
+
transactions.length,
|
|
164
|
+
" transacciones"
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" }),
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
168
|
+
"button",
|
|
169
|
+
{
|
|
170
|
+
onClick: load,
|
|
171
|
+
disabled: loading,
|
|
172
|
+
className: "w-9 h-9 rounded-lg flex items-center justify-center transition-all duration-150",
|
|
173
|
+
style: { backgroundColor: "white", border: "1px solid var(--border)", color: "var(--text-secondary)" },
|
|
174
|
+
title: "Refrescar",
|
|
175
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
176
|
+
"svg",
|
|
177
|
+
{
|
|
178
|
+
width: "16",
|
|
179
|
+
height: "16",
|
|
180
|
+
viewBox: "0 0 24 24",
|
|
181
|
+
fill: "none",
|
|
182
|
+
stroke: "currentColor",
|
|
183
|
+
strokeWidth: "2",
|
|
184
|
+
className: loading ? "animate-spin" : "",
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "23 4 23 10 17 10" }),
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "1 20 1 14 7 14" }),
|
|
188
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
195
|
+
Link__default.default,
|
|
196
|
+
{
|
|
197
|
+
href: "/new",
|
|
198
|
+
className: "inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold text-white transition-all duration-200",
|
|
199
|
+
style: {
|
|
200
|
+
background: "linear-gradient(135deg, #6366f1 0%, #4f46e5 100%)",
|
|
201
|
+
boxShadow: "0 8px 16px 0 rgba(79,70,229,0.28)",
|
|
202
|
+
letterSpacing: "0.03em"
|
|
203
|
+
},
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [
|
|
206
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
208
|
+
] }),
|
|
209
|
+
"Nueva Transacci\xF3n"
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
] }),
|
|
214
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl overflow-hidden", style: { boxShadow: "var(--shadow-card)" }, children: [
|
|
215
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
216
|
+
"div",
|
|
217
|
+
{
|
|
218
|
+
className: "px-6 py-4 flex items-center justify-between",
|
|
219
|
+
style: { borderBottom: "1px solid rgba(145,158,171,0.16)" },
|
|
220
|
+
children: [
|
|
221
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
222
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base font-bold", style: { color: "var(--text-primary)" }, children: "Historial de Transacciones" }),
|
|
223
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs mt-0.5", style: { color: "var(--text-secondary)" }, children: [
|
|
224
|
+
"CRUD completo \xB7 Llamando a ",
|
|
225
|
+
API,
|
|
226
|
+
"/api/transactions"
|
|
227
|
+
] })
|
|
228
|
+
] }),
|
|
229
|
+
!loading && !error && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
className: "flex items-center gap-1.5 text-xs font-semibold px-2.5 py-1 rounded-full",
|
|
233
|
+
style: { backgroundColor: "rgba(34,197,94,0.10)", color: "#16a34a", border: "1px solid rgba(34,197,94,0.24)" },
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse" }),
|
|
236
|
+
"API conectada"
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(Skeleton, {}),
|
|
244
|
+
!loading && error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-6 py-12 text-center", children: [
|
|
245
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
246
|
+
"div",
|
|
247
|
+
{
|
|
248
|
+
className: "w-14 h-14 rounded-full mx-auto mb-3 flex items-center justify-center",
|
|
249
|
+
style: { backgroundColor: "rgba(239,68,68,0.08)" },
|
|
250
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#dc2626", strokeWidth: "2", children: [
|
|
251
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
252
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
253
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
254
|
+
] })
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold mb-1", style: { color: "#dc2626" }, children: error }),
|
|
258
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs mb-4", style: { color: "var(--text-secondary)" }, children: [
|
|
259
|
+
"Verifica que el servidor principal est\xE9 corriendo en ",
|
|
260
|
+
API
|
|
261
|
+
] }),
|
|
262
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
263
|
+
"button",
|
|
264
|
+
{
|
|
265
|
+
onClick: load,
|
|
266
|
+
className: "px-4 py-2 rounded-lg text-sm font-semibold text-white",
|
|
267
|
+
style: { background: "var(--primary)" },
|
|
268
|
+
children: "Reintentar"
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
] }),
|
|
272
|
+
!loading && !error && filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-6 py-14 text-center", children: [
|
|
273
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
274
|
+
"div",
|
|
275
|
+
{
|
|
276
|
+
className: "w-14 h-14 rounded-full mx-auto mb-3 flex items-center justify-center",
|
|
277
|
+
style: { backgroundColor: "rgba(145,158,171,0.08)" },
|
|
278
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "var(--text-disabled)", strokeWidth: "1.5", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2v20M17 5H9.5a3.5 3.5 0 1 0 0 7h5a3.5 3.5 0 1 1 0 7H6" }) })
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold", style: { color: "var(--text-primary)" }, children: transactions.length === 0 ? "Sin transacciones" : "Sin resultados para los filtros aplicados" }),
|
|
282
|
+
transactions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
283
|
+
Link__default.default,
|
|
284
|
+
{
|
|
285
|
+
href: "/new",
|
|
286
|
+
className: "inline-block mt-4 px-4 py-2 rounded-lg text-sm font-semibold text-white",
|
|
287
|
+
style: { background: "var(--primary)" },
|
|
288
|
+
children: "Crear primera transacci\xF3n"
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
] }),
|
|
292
|
+
!loading && !error && filtered.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-x-auto", children: [
|
|
293
|
+
/* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full text-sm min-w-[700px]", children: [
|
|
294
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { style: { backgroundColor: "#F4F6F8", borderBottom: "1px solid rgba(145,158,171,0.24)" }, children: ["Usuario", "Moneda", "Monto", "Fecha", "Acciones"].map((h, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
295
|
+
"th",
|
|
296
|
+
{
|
|
297
|
+
className: "px-6 py-3 text-xs font-semibold uppercase tracking-[0.08em]",
|
|
298
|
+
style: {
|
|
299
|
+
color: "var(--text-secondary)",
|
|
300
|
+
textAlign: i >= 2 ? i === 4 ? "center" : "right" : "left"
|
|
301
|
+
},
|
|
302
|
+
children: h
|
|
303
|
+
},
|
|
304
|
+
h
|
|
305
|
+
)) }) }),
|
|
306
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: filtered.map((tx, idx) => {
|
|
307
|
+
const isLast = idx === filtered.length - 1;
|
|
308
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
309
|
+
"tr",
|
|
310
|
+
{
|
|
311
|
+
className: "transition-colors",
|
|
312
|
+
style: { borderBottom: isLast ? "none" : "1px solid rgba(145,158,171,0.10)" },
|
|
313
|
+
onMouseEnter: (e) => e.currentTarget.style.backgroundColor = "rgba(145,158,171,0.04)",
|
|
314
|
+
onMouseLeave: (e) => e.currentTarget.style.backgroundColor = "transparent",
|
|
315
|
+
children: [
|
|
316
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-6 py-3.5", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
|
|
317
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { name: tx.user }),
|
|
318
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
319
|
+
"span",
|
|
320
|
+
{
|
|
321
|
+
className: "font-medium truncate max-w-[140px]",
|
|
322
|
+
style: { color: "var(--text-primary)" },
|
|
323
|
+
children: tx.user
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
] }) }),
|
|
327
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-6 py-3.5", children: /* @__PURE__ */ jsxRuntime.jsx(CoinBadge, { coin: tx.coin }) }),
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-6 py-3.5 text-right", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
329
|
+
"span",
|
|
330
|
+
{
|
|
331
|
+
className: "font-semibold font-mono text-sm",
|
|
332
|
+
style: { color: "var(--text-primary)" },
|
|
333
|
+
children: typeof tx.amount === "number" ? tx.amount.toLocaleString("en-US", { maximumFractionDigits: 6 }) : tx.amount
|
|
334
|
+
}
|
|
335
|
+
) }),
|
|
336
|
+
/* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-6 py-3.5 text-right", children: [
|
|
337
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", style: { color: "var(--text-primary)" }, children: formatDate(tx.createdAt) }),
|
|
338
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] mt-0.5", style: { color: "var(--text-disabled)" }, children: formatTime(tx.createdAt) })
|
|
339
|
+
] }),
|
|
340
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-6 py-3.5", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-1.5", children: [
|
|
341
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
342
|
+
Link__default.default,
|
|
343
|
+
{
|
|
344
|
+
href: `/edit/${tx._id}`,
|
|
345
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all duration-150",
|
|
346
|
+
style: { color: "var(--text-secondary)", border: "1px solid var(--border)" },
|
|
347
|
+
onMouseEnter: (e) => {
|
|
348
|
+
const el = e.currentTarget;
|
|
349
|
+
el.style.backgroundColor = "rgba(79,70,229,0.08)";
|
|
350
|
+
el.style.borderColor = "rgba(79,70,229,0.30)";
|
|
351
|
+
el.style.color = "var(--primary)";
|
|
352
|
+
},
|
|
353
|
+
onMouseLeave: (e) => {
|
|
354
|
+
const el = e.currentTarget;
|
|
355
|
+
el.style.backgroundColor = "transparent";
|
|
356
|
+
el.style.borderColor = "var(--border)";
|
|
357
|
+
el.style.color = "var(--text-secondary)";
|
|
358
|
+
},
|
|
359
|
+
title: "Editar",
|
|
360
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
361
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
|
|
362
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
|
|
363
|
+
] })
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
367
|
+
"button",
|
|
368
|
+
{
|
|
369
|
+
onClick: () => handleDelete(tx._id),
|
|
370
|
+
disabled: deletingId === tx._id,
|
|
371
|
+
className: "w-8 h-8 rounded-lg flex items-center justify-center transition-all duration-150",
|
|
372
|
+
style: { color: "var(--text-secondary)", border: "1px solid var(--border)" },
|
|
373
|
+
onMouseEnter: (e) => {
|
|
374
|
+
const el = e.currentTarget;
|
|
375
|
+
el.style.backgroundColor = "rgba(239,68,68,0.08)";
|
|
376
|
+
el.style.borderColor = "rgba(239,68,68,0.30)";
|
|
377
|
+
el.style.color = "#dc2626";
|
|
378
|
+
},
|
|
379
|
+
onMouseLeave: (e) => {
|
|
380
|
+
const el = e.currentTarget;
|
|
381
|
+
el.style.backgroundColor = "transparent";
|
|
382
|
+
el.style.borderColor = "var(--border)";
|
|
383
|
+
el.style.color = "var(--text-secondary)";
|
|
384
|
+
},
|
|
385
|
+
title: "Eliminar",
|
|
386
|
+
children: deletingId === tx._id ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-3 h-3 border-2 border-gray-300 border-t-red-500 rounded-full animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "3 6 5 6 21 6" }),
|
|
388
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" }),
|
|
389
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 11v6M14 11v6" }),
|
|
390
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2" })
|
|
391
|
+
] })
|
|
392
|
+
}
|
|
393
|
+
)
|
|
394
|
+
] }) })
|
|
395
|
+
]
|
|
396
|
+
},
|
|
397
|
+
tx._id
|
|
398
|
+
);
|
|
399
|
+
}) })
|
|
400
|
+
] }),
|
|
401
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
402
|
+
"div",
|
|
403
|
+
{
|
|
404
|
+
className: "px-6 py-3 flex items-center justify-between",
|
|
405
|
+
style: { borderTop: "1px solid rgba(145,158,171,0.16)", backgroundColor: "#FAFAFA" },
|
|
406
|
+
children: [
|
|
407
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs", style: { color: "var(--text-disabled)" }, children: [
|
|
408
|
+
filtered.length,
|
|
409
|
+
" ",
|
|
410
|
+
filtered.length === 1 ? "transacci\xF3n" : "transacciones",
|
|
411
|
+
filterCoin || filterUser ? ` (filtradas de ${transactions.length})` : " en total"
|
|
412
|
+
] }),
|
|
413
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
414
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse" }),
|
|
415
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium", style: { color: "var(--text-secondary)" }, children: API })
|
|
416
|
+
] })
|
|
417
|
+
]
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
] })
|
|
421
|
+
] })
|
|
422
|
+
] });
|
|
423
|
+
}
|
|
424
|
+
var COINS = [
|
|
425
|
+
{ value: "BTC", label: "Bitcoin (BTC)" },
|
|
426
|
+
{ value: "ETH", label: "Ethereum (ETH)" },
|
|
427
|
+
{ value: "SOL", label: "Solana (SOL)" },
|
|
428
|
+
{ value: "BNB", label: "BNB Chain (BNB)" },
|
|
429
|
+
{ value: "XRP", label: "XRP" },
|
|
430
|
+
{ value: "USDT", label: "Tether (USDT)" },
|
|
431
|
+
{ value: "USDC", label: "USD Coin (USDC)" },
|
|
432
|
+
{ value: "DOGE", label: "Dogecoin (DOGE)" },
|
|
433
|
+
{ value: "ADA", label: "Cardano (ADA)" },
|
|
434
|
+
{ value: "MATIC", label: "Polygon (MATIC)" }
|
|
435
|
+
];
|
|
436
|
+
var Field = ({
|
|
437
|
+
id,
|
|
438
|
+
label,
|
|
439
|
+
children,
|
|
440
|
+
hint
|
|
441
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
442
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-1.5", children: [
|
|
443
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
444
|
+
"label",
|
|
445
|
+
{
|
|
446
|
+
htmlFor: id,
|
|
447
|
+
className: "text-xs font-semibold",
|
|
448
|
+
style: { color: "var(--text-secondary)" },
|
|
449
|
+
children: label
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", style: { color: "var(--text-disabled)" }, children: hint })
|
|
453
|
+
] }),
|
|
454
|
+
children
|
|
455
|
+
] });
|
|
456
|
+
function NewTransactionPage() {
|
|
457
|
+
const router = navigation.useRouter();
|
|
458
|
+
const API = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:3000";
|
|
459
|
+
const [user, setUser] = react.useState("");
|
|
460
|
+
const [coin, setCoin] = react.useState("BTC");
|
|
461
|
+
const [amount, setAmount] = react.useState("");
|
|
462
|
+
const [loading, setLoading] = react.useState(false);
|
|
463
|
+
const [error, setError] = react.useState(null);
|
|
464
|
+
const [success, setSuccess] = react.useState(false);
|
|
465
|
+
const inputStyle = (focused) => ({
|
|
466
|
+
width: "100%",
|
|
467
|
+
padding: focused ? "11px 13px" : "12px 14px",
|
|
468
|
+
border: `${focused ? 2 : 1}px solid ${focused ? "var(--primary)" : "var(--border)"}`,
|
|
469
|
+
borderRadius: 8,
|
|
470
|
+
fontSize: "0.875rem",
|
|
471
|
+
color: "var(--text-primary)",
|
|
472
|
+
backgroundColor: "white",
|
|
473
|
+
boxShadow: focused ? "0 0 0 3px rgba(79,70,229,0.08)" : "none",
|
|
474
|
+
outline: "none",
|
|
475
|
+
transition: "all 0.2s"
|
|
476
|
+
});
|
|
477
|
+
const [focusedField, setFocusedField] = react.useState(null);
|
|
478
|
+
const handleSubmit = async (e) => {
|
|
479
|
+
e.preventDefault();
|
|
480
|
+
if (!user.trim()) {
|
|
481
|
+
setError("El nombre de usuario es requerido");
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (!coin) {
|
|
485
|
+
setError("Selecciona una moneda");
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (!amount || isNaN(Number(amount)) || Number(amount) <= 0) {
|
|
489
|
+
setError("Ingresa un monto v\xE1lido mayor a 0");
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
setLoading(true);
|
|
493
|
+
setError(null);
|
|
494
|
+
try {
|
|
495
|
+
const res = await fetch(`${API}/api/transactions`, {
|
|
496
|
+
method: "POST",
|
|
497
|
+
headers: { "Content-Type": "application/json" },
|
|
498
|
+
body: JSON.stringify({ user: user.trim(), coin, amount: Number(amount) })
|
|
499
|
+
});
|
|
500
|
+
if (!res.ok) {
|
|
501
|
+
const data = await res.json().catch(() => ({}));
|
|
502
|
+
throw new Error(data.message ?? `Error ${res.status}`);
|
|
503
|
+
}
|
|
504
|
+
setSuccess(true);
|
|
505
|
+
setTimeout(() => router.push("/"), 1200);
|
|
506
|
+
} catch (err) {
|
|
507
|
+
setError(err instanceof Error ? err.message : "Error al crear la transacci\xF3n");
|
|
508
|
+
} finally {
|
|
509
|
+
setLoading(false);
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
if (success) {
|
|
513
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 flex items-center justify-center min-h-[60vh]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
514
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
515
|
+
"div",
|
|
516
|
+
{
|
|
517
|
+
className: "w-16 h-16 rounded-full mx-auto mb-4 flex items-center justify-center",
|
|
518
|
+
style: { background: "linear-gradient(135deg, #34d399, #059669)" },
|
|
519
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "20 6 9 17 4 12" }) })
|
|
520
|
+
}
|
|
521
|
+
),
|
|
522
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-bold mb-1", style: { color: "var(--text-primary)" }, children: "\xA1Transacci\xF3n creada!" }),
|
|
523
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", style: { color: "var(--text-secondary)" }, children: "Redirigiendo a la lista..." })
|
|
524
|
+
] }) });
|
|
525
|
+
}
|
|
526
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-lg mx-auto", children: [
|
|
527
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
528
|
+
Link__default.default,
|
|
529
|
+
{
|
|
530
|
+
href: "/",
|
|
531
|
+
className: "inline-flex items-center gap-2 text-sm mb-6 transition-colors",
|
|
532
|
+
style: { color: "var(--text-secondary)" },
|
|
533
|
+
children: [
|
|
534
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
535
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "19", y1: "12", x2: "5", y2: "12" }),
|
|
536
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "12 19 5 12 12 5" })
|
|
537
|
+
] }),
|
|
538
|
+
"Volver a la lista"
|
|
539
|
+
]
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl overflow-hidden", style: { boxShadow: "var(--shadow-card)" }, children: [
|
|
543
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-5", style: { borderBottom: "1px solid rgba(145,158,171,0.16)" }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
544
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
545
|
+
"div",
|
|
546
|
+
{
|
|
547
|
+
className: "w-10 h-10 rounded-xl flex items-center justify-center text-white",
|
|
548
|
+
style: { background: "linear-gradient(135deg, #6366f1, #4f46e5)", boxShadow: "0 8px 16px rgba(79,70,229,0.28)" },
|
|
549
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", children: [
|
|
550
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
551
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
552
|
+
] })
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
556
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base font-bold", style: { color: "var(--text-primary)" }, children: "Nueva Transacci\xF3n" }),
|
|
557
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs mt-0.5", style: { color: "var(--text-secondary)" }, children: [
|
|
558
|
+
"POST ",
|
|
559
|
+
API,
|
|
560
|
+
"/api/transactions"
|
|
561
|
+
] })
|
|
562
|
+
] })
|
|
563
|
+
] }) }),
|
|
564
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "px-6 py-6 space-y-5", children: [
|
|
565
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
566
|
+
"div",
|
|
567
|
+
{
|
|
568
|
+
className: "rounded-xl px-4 py-3 text-sm flex items-center gap-2.5",
|
|
569
|
+
style: { backgroundColor: "rgba(239,68,68,0.08)", border: "1px solid rgba(239,68,68,0.24)", color: "#dc2626" },
|
|
570
|
+
children: [
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [
|
|
572
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
573
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
574
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
575
|
+
] }),
|
|
576
|
+
error
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
),
|
|
580
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { id: "user", label: "Nombre de usuario", hint: "Quien realiza la transacci\xF3n", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
581
|
+
"input",
|
|
582
|
+
{
|
|
583
|
+
id: "user",
|
|
584
|
+
type: "text",
|
|
585
|
+
required: true,
|
|
586
|
+
value: user,
|
|
587
|
+
onChange: (e) => setUser(e.target.value),
|
|
588
|
+
onFocus: () => setFocusedField("user"),
|
|
589
|
+
onBlur: () => setFocusedField(null),
|
|
590
|
+
placeholder: "ej. Juan P\xE9rez",
|
|
591
|
+
style: inputStyle(focusedField === "user")
|
|
592
|
+
}
|
|
593
|
+
) }),
|
|
594
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { id: "coin", label: "Criptomoneda", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
595
|
+
"select",
|
|
596
|
+
{
|
|
597
|
+
id: "coin",
|
|
598
|
+
required: true,
|
|
599
|
+
value: coin,
|
|
600
|
+
onChange: (e) => setCoin(e.target.value),
|
|
601
|
+
onFocus: () => setFocusedField("coin"),
|
|
602
|
+
onBlur: () => setFocusedField(null),
|
|
603
|
+
style: inputStyle(focusedField === "coin"),
|
|
604
|
+
children: COINS.map((c) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: c.value, children: c.label }, c.value))
|
|
605
|
+
}
|
|
606
|
+
) }),
|
|
607
|
+
/* @__PURE__ */ jsxRuntime.jsx(Field, { id: "amount", label: "Monto", hint: "N\xFAmero de unidades de la criptomoneda", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
608
|
+
"input",
|
|
609
|
+
{
|
|
610
|
+
id: "amount",
|
|
611
|
+
type: "number",
|
|
612
|
+
required: true,
|
|
613
|
+
min: "0.000001",
|
|
614
|
+
step: "any",
|
|
615
|
+
value: amount,
|
|
616
|
+
onChange: (e) => setAmount(e.target.value),
|
|
617
|
+
onFocus: () => setFocusedField("amount"),
|
|
618
|
+
onBlur: () => setFocusedField(null),
|
|
619
|
+
placeholder: "ej. 0.5",
|
|
620
|
+
style: inputStyle(focusedField === "amount")
|
|
621
|
+
}
|
|
622
|
+
) }),
|
|
623
|
+
(user || amount) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl p-4", style: { backgroundColor: "#F4F6F8" }, children: [
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
625
|
+
"p",
|
|
626
|
+
{
|
|
627
|
+
className: "text-[10px] font-semibold uppercase tracking-[0.08em] mb-2",
|
|
628
|
+
style: { color: "var(--text-disabled)" },
|
|
629
|
+
children: "Request body (JSON)"
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs font-mono", style: { color: "var(--text-primary)" }, children: JSON.stringify({
|
|
633
|
+
user: user || "...",
|
|
634
|
+
coin,
|
|
635
|
+
amount: amount ? Number(amount) : "..."
|
|
636
|
+
}, null, 2) })
|
|
637
|
+
] }),
|
|
638
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3 pt-1", children: [
|
|
639
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
640
|
+
Link__default.default,
|
|
641
|
+
{
|
|
642
|
+
href: "/",
|
|
643
|
+
className: "flex-1 py-3 rounded-lg text-sm font-bold text-center transition-all duration-150",
|
|
644
|
+
style: { border: "1px solid var(--border)", color: "var(--text-secondary)", backgroundColor: "white" },
|
|
645
|
+
children: "Cancelar"
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
+
"button",
|
|
650
|
+
{
|
|
651
|
+
type: "submit",
|
|
652
|
+
disabled: loading,
|
|
653
|
+
className: "flex-1 py-3 rounded-lg text-sm font-bold text-white transition-all duration-200",
|
|
654
|
+
style: {
|
|
655
|
+
background: loading ? "rgba(79,70,229,0.6)" : "linear-gradient(135deg, #6366f1, #4f46e5)",
|
|
656
|
+
boxShadow: loading ? "none" : "0 8px 16px rgba(79,70,229,0.28)",
|
|
657
|
+
cursor: loading ? "not-allowed" : "pointer",
|
|
658
|
+
letterSpacing: "0.04em"
|
|
659
|
+
},
|
|
660
|
+
children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center justify-center gap-2", children: [
|
|
661
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
662
|
+
"span",
|
|
663
|
+
{
|
|
664
|
+
className: "w-4 h-4 border-2 rounded-full animate-spin",
|
|
665
|
+
style: { borderColor: "rgba(255,255,255,0.3)", borderTopColor: "white" }
|
|
666
|
+
}
|
|
667
|
+
),
|
|
668
|
+
"Creando..."
|
|
669
|
+
] }) : "CREAR TRANSACCI\xD3N"
|
|
670
|
+
}
|
|
671
|
+
)
|
|
672
|
+
] })
|
|
673
|
+
] })
|
|
674
|
+
] })
|
|
675
|
+
] }) });
|
|
676
|
+
}
|
|
677
|
+
var COINS2 = [
|
|
678
|
+
"BTC",
|
|
679
|
+
"ETH",
|
|
680
|
+
"SOL",
|
|
681
|
+
"BNB",
|
|
682
|
+
"XRP",
|
|
683
|
+
"USDT",
|
|
684
|
+
"USDC",
|
|
685
|
+
"DOGE",
|
|
686
|
+
"ADA",
|
|
687
|
+
"MATIC"
|
|
688
|
+
];
|
|
689
|
+
function EditTransactionPage() {
|
|
690
|
+
const { id } = navigation.useParams();
|
|
691
|
+
const router = navigation.useRouter();
|
|
692
|
+
const API = process.env.NEXT_PUBLIC_API_URL ?? "http://localhost:3000";
|
|
693
|
+
const [user, setUser] = react.useState("");
|
|
694
|
+
const [coin, setCoin] = react.useState("BTC");
|
|
695
|
+
const [amount, setAmount] = react.useState("");
|
|
696
|
+
const [loading, setLoading] = react.useState(false);
|
|
697
|
+
const [fetching, setFetching] = react.useState(true);
|
|
698
|
+
const [error, setError] = react.useState(null);
|
|
699
|
+
const [success, setSuccess] = react.useState(false);
|
|
700
|
+
const [focusedField, setFocusedField] = react.useState(null);
|
|
701
|
+
react.useEffect(() => {
|
|
702
|
+
const load = async () => {
|
|
703
|
+
try {
|
|
704
|
+
const res = await fetch(`${API}/api/transactions`);
|
|
705
|
+
if (!res.ok) throw new Error(`Error ${res.status}`);
|
|
706
|
+
const data = await res.json();
|
|
707
|
+
const tx = data.find((t) => t._id === id);
|
|
708
|
+
if (!tx) throw new Error("Transacci\xF3n no encontrada");
|
|
709
|
+
setUser(tx.user);
|
|
710
|
+
setCoin(tx.coin.toUpperCase());
|
|
711
|
+
setAmount(String(tx.amount));
|
|
712
|
+
} catch (e) {
|
|
713
|
+
setError(e instanceof Error ? e.message : "Error cargando datos");
|
|
714
|
+
} finally {
|
|
715
|
+
setFetching(false);
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
load();
|
|
719
|
+
}, [id, API]);
|
|
720
|
+
const inputStyle = (focused) => ({
|
|
721
|
+
width: "100%",
|
|
722
|
+
padding: focused ? "11px 13px" : "12px 14px",
|
|
723
|
+
border: `${focused ? 2 : 1}px solid ${focused ? "var(--primary)" : "var(--border)"}`,
|
|
724
|
+
borderRadius: 8,
|
|
725
|
+
fontSize: "0.875rem",
|
|
726
|
+
color: "var(--text-primary)",
|
|
727
|
+
backgroundColor: "white",
|
|
728
|
+
boxShadow: focused ? "0 0 0 3px rgba(79,70,229,0.08)" : "none",
|
|
729
|
+
outline: "none",
|
|
730
|
+
transition: "all 0.2s"
|
|
731
|
+
});
|
|
732
|
+
const handleSubmit = async (e) => {
|
|
733
|
+
e.preventDefault();
|
|
734
|
+
if (!user.trim()) {
|
|
735
|
+
setError("El nombre de usuario es requerido");
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
if (isNaN(Number(amount)) || Number(amount) <= 0) {
|
|
739
|
+
setError("Ingresa un monto v\xE1lido mayor a 0");
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
setLoading(true);
|
|
743
|
+
setError(null);
|
|
744
|
+
try {
|
|
745
|
+
const res = await fetch(`${API}/api/transactions/${id}`, {
|
|
746
|
+
method: "PUT",
|
|
747
|
+
headers: { "Content-Type": "application/json" },
|
|
748
|
+
body: JSON.stringify({ user: user.trim(), coin, amount: Number(amount) })
|
|
749
|
+
});
|
|
750
|
+
if (!res.ok) {
|
|
751
|
+
const data = await res.json().catch(() => ({}));
|
|
752
|
+
throw new Error(data.message ?? `Error ${res.status}`);
|
|
753
|
+
}
|
|
754
|
+
setSuccess(true);
|
|
755
|
+
setTimeout(() => router.push("/"), 1200);
|
|
756
|
+
} catch (err) {
|
|
757
|
+
setError(err instanceof Error ? err.message : "Error al actualizar");
|
|
758
|
+
} finally {
|
|
759
|
+
setLoading(false);
|
|
760
|
+
}
|
|
761
|
+
};
|
|
762
|
+
if (success) {
|
|
763
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 flex items-center justify-center min-h-[60vh]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
764
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
765
|
+
"div",
|
|
766
|
+
{
|
|
767
|
+
className: "w-16 h-16 rounded-full mx-auto mb-4 flex items-center justify-center",
|
|
768
|
+
style: { background: "linear-gradient(135deg, #34d399, #059669)" },
|
|
769
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "20 6 9 17 4 12" }) })
|
|
770
|
+
}
|
|
771
|
+
),
|
|
772
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-bold mb-1", style: { color: "var(--text-primary)" }, children: "\xA1Transacci\xF3n actualizada!" }),
|
|
773
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", style: { color: "var(--text-secondary)" }, children: "Redirigiendo..." })
|
|
774
|
+
] }) });
|
|
775
|
+
}
|
|
776
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-lg mx-auto", children: [
|
|
777
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
778
|
+
Link__default.default,
|
|
779
|
+
{
|
|
780
|
+
href: "/",
|
|
781
|
+
className: "inline-flex items-center gap-2 text-sm mb-6 transition-colors",
|
|
782
|
+
style: { color: "var(--text-secondary)" },
|
|
783
|
+
children: [
|
|
784
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
785
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "19", y1: "12", x2: "5", y2: "12" }),
|
|
786
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "12 19 5 12 12 5" })
|
|
787
|
+
] }),
|
|
788
|
+
"Volver a la lista"
|
|
789
|
+
]
|
|
790
|
+
}
|
|
791
|
+
),
|
|
792
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl overflow-hidden", style: { boxShadow: "var(--shadow-card)" }, children: [
|
|
793
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-5", style: { borderBottom: "1px solid rgba(145,158,171,0.16)" }, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
794
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
795
|
+
"div",
|
|
796
|
+
{
|
|
797
|
+
className: "w-10 h-10 rounded-xl flex items-center justify-center text-white",
|
|
798
|
+
style: { background: "linear-gradient(135deg, #a78bfa, #7c3aed)", boxShadow: "0 8px 16px rgba(124,58,237,0.28)" },
|
|
799
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", children: [
|
|
800
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
|
|
801
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
|
|
802
|
+
] })
|
|
803
|
+
}
|
|
804
|
+
),
|
|
805
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base font-bold", style: { color: "var(--text-primary)" }, children: "Editar Transacci\xF3n" }),
|
|
807
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs mt-0.5 font-mono", style: { color: "var(--text-disabled)" }, children: [
|
|
808
|
+
"ID: ",
|
|
809
|
+
id?.slice(-12)
|
|
810
|
+
] })
|
|
811
|
+
] })
|
|
812
|
+
] }) }),
|
|
813
|
+
fetching ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-12 animate-pulse space-y-4", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
814
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 w-20 bg-gray-200 rounded mb-2" }),
|
|
815
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-11 bg-gray-100 rounded-lg" })
|
|
816
|
+
] }, i)) }) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "px-6 py-6 space-y-5", children: [
|
|
817
|
+
error && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
818
|
+
"div",
|
|
819
|
+
{
|
|
820
|
+
className: "rounded-xl px-4 py-3 text-sm flex items-center gap-2.5",
|
|
821
|
+
style: { backgroundColor: "rgba(239,68,68,0.08)", border: "1px solid rgba(239,68,68,0.24)", color: "#dc2626" },
|
|
822
|
+
children: [
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", children: [
|
|
824
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
825
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
827
|
+
] }),
|
|
828
|
+
error
|
|
829
|
+
]
|
|
830
|
+
}
|
|
831
|
+
),
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
833
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
834
|
+
"label",
|
|
835
|
+
{
|
|
836
|
+
htmlFor: "user",
|
|
837
|
+
className: "block text-xs font-semibold mb-1.5",
|
|
838
|
+
style: { color: "var(--text-secondary)" },
|
|
839
|
+
children: "Nombre de usuario"
|
|
840
|
+
}
|
|
841
|
+
),
|
|
842
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
843
|
+
"input",
|
|
844
|
+
{
|
|
845
|
+
id: "user",
|
|
846
|
+
type: "text",
|
|
847
|
+
required: true,
|
|
848
|
+
value: user,
|
|
849
|
+
onChange: (e) => setUser(e.target.value),
|
|
850
|
+
onFocus: () => setFocusedField("user"),
|
|
851
|
+
onBlur: () => setFocusedField(null),
|
|
852
|
+
style: inputStyle(focusedField === "user")
|
|
853
|
+
}
|
|
854
|
+
)
|
|
855
|
+
] }),
|
|
856
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
857
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
858
|
+
"label",
|
|
859
|
+
{
|
|
860
|
+
htmlFor: "coin",
|
|
861
|
+
className: "block text-xs font-semibold mb-1.5",
|
|
862
|
+
style: { color: "var(--text-secondary)" },
|
|
863
|
+
children: "Criptomoneda"
|
|
864
|
+
}
|
|
865
|
+
),
|
|
866
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
867
|
+
"select",
|
|
868
|
+
{
|
|
869
|
+
id: "coin",
|
|
870
|
+
required: true,
|
|
871
|
+
value: coin,
|
|
872
|
+
onChange: (e) => setCoin(e.target.value),
|
|
873
|
+
onFocus: () => setFocusedField("coin"),
|
|
874
|
+
onBlur: () => setFocusedField(null),
|
|
875
|
+
style: inputStyle(focusedField === "coin"),
|
|
876
|
+
children: COINS2.map((c) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: c, children: c }, c))
|
|
877
|
+
}
|
|
878
|
+
)
|
|
879
|
+
] }),
|
|
880
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
882
|
+
"label",
|
|
883
|
+
{
|
|
884
|
+
htmlFor: "amount",
|
|
885
|
+
className: "block text-xs font-semibold mb-1.5",
|
|
886
|
+
style: { color: "var(--text-secondary)" },
|
|
887
|
+
children: "Monto"
|
|
888
|
+
}
|
|
889
|
+
),
|
|
890
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
891
|
+
"input",
|
|
892
|
+
{
|
|
893
|
+
id: "amount",
|
|
894
|
+
type: "number",
|
|
895
|
+
required: true,
|
|
896
|
+
min: "0.000001",
|
|
897
|
+
step: "any",
|
|
898
|
+
value: amount,
|
|
899
|
+
onChange: (e) => setAmount(e.target.value),
|
|
900
|
+
onFocus: () => setFocusedField("amount"),
|
|
901
|
+
onBlur: () => setFocusedField(null),
|
|
902
|
+
style: inputStyle(focusedField === "amount")
|
|
903
|
+
}
|
|
904
|
+
)
|
|
905
|
+
] }),
|
|
906
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3 pt-1", children: [
|
|
907
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
908
|
+
Link__default.default,
|
|
909
|
+
{
|
|
910
|
+
href: "/",
|
|
911
|
+
className: "flex-1 py-3 rounded-lg text-sm font-bold text-center",
|
|
912
|
+
style: { border: "1px solid var(--border)", color: "var(--text-secondary)", backgroundColor: "white" },
|
|
913
|
+
children: "Cancelar"
|
|
914
|
+
}
|
|
915
|
+
),
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
917
|
+
"button",
|
|
918
|
+
{
|
|
919
|
+
type: "submit",
|
|
920
|
+
disabled: loading,
|
|
921
|
+
className: "flex-1 py-3 rounded-lg text-sm font-bold text-white",
|
|
922
|
+
style: {
|
|
923
|
+
background: loading ? "rgba(124,58,237,0.6)" : "linear-gradient(135deg, #a78bfa, #7c3aed)",
|
|
924
|
+
boxShadow: loading ? "none" : "0 8px 16px rgba(124,58,237,0.28)",
|
|
925
|
+
cursor: loading ? "not-allowed" : "pointer",
|
|
926
|
+
letterSpacing: "0.04em"
|
|
927
|
+
},
|
|
928
|
+
children: loading ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center justify-center gap-2", children: [
|
|
929
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
930
|
+
"span",
|
|
931
|
+
{
|
|
932
|
+
className: "w-4 h-4 border-2 rounded-full animate-spin",
|
|
933
|
+
style: { borderColor: "rgba(255,255,255,0.3)", borderTopColor: "white" }
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
"Guardando..."
|
|
937
|
+
] }) : "GUARDAR CAMBIOS"
|
|
938
|
+
}
|
|
939
|
+
)
|
|
940
|
+
] })
|
|
941
|
+
] })
|
|
942
|
+
] })
|
|
943
|
+
] }) });
|
|
944
|
+
}
|
|
945
|
+
var IconList = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "19", height: "19", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
946
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
|
|
947
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
|
|
948
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
|
|
949
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "3", y1: "6", x2: "3.01", y2: "6" }),
|
|
950
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "3", y1: "12", x2: "3.01", y2: "12" }),
|
|
951
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "3", y1: "18", x2: "3.01", y2: "18" })
|
|
952
|
+
] });
|
|
953
|
+
var IconPlus = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "19", height: "19", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
954
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
955
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "8", x2: "12", y2: "16" }),
|
|
956
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "8", y1: "12", x2: "16", y2: "12" })
|
|
957
|
+
] });
|
|
958
|
+
var IconArrowLeft = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
959
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "19", y1: "12", x2: "5", y2: "12" }),
|
|
960
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "12 19 5 12 12 5" })
|
|
961
|
+
] });
|
|
962
|
+
var IconLogo = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2v20M17 5H9.5a3.5 3.5 0 1 0 0 7h5a3.5 3.5 0 1 1 0 7H6" }) });
|
|
963
|
+
var NAV_ITEMS = [
|
|
964
|
+
{ href: "/", label: "Lista de Transacciones", icon: /* @__PURE__ */ jsxRuntime.jsx(IconList, {}) },
|
|
965
|
+
{ href: "/new", label: "Nueva Transacci\xF3n", icon: /* @__PURE__ */ jsxRuntime.jsx(IconPlus, {}) }
|
|
966
|
+
];
|
|
967
|
+
function Sidebar() {
|
|
968
|
+
const pathname = navigation.usePathname();
|
|
969
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
970
|
+
"aside",
|
|
971
|
+
{
|
|
972
|
+
className: "w-64 min-h-screen flex flex-col shrink-0",
|
|
973
|
+
style: {
|
|
974
|
+
backgroundColor: "var(--sidebar-bg)",
|
|
975
|
+
borderRight: "1px solid var(--sidebar-border)"
|
|
976
|
+
},
|
|
977
|
+
children: [
|
|
978
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
979
|
+
"div",
|
|
980
|
+
{
|
|
981
|
+
className: "px-5 py-5",
|
|
982
|
+
style: { borderBottom: "1px solid var(--sidebar-border)" },
|
|
983
|
+
children: [
|
|
984
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 mb-3", children: [
|
|
985
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
986
|
+
"div",
|
|
987
|
+
{
|
|
988
|
+
className: "w-9 h-9 rounded-lg flex items-center justify-center text-white shrink-0",
|
|
989
|
+
style: {
|
|
990
|
+
background: "linear-gradient(135deg, #6366f1 0%, #4f46e5 100%)",
|
|
991
|
+
boxShadow: "0 8px 16px 0 rgba(79,70,229,0.35)"
|
|
992
|
+
},
|
|
993
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(IconLogo, {})
|
|
994
|
+
}
|
|
995
|
+
),
|
|
996
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
997
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-sm font-bold text-white leading-none", children: "Crypto Dashboard" }),
|
|
998
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] mt-0.5 leading-none", style: { color: "#637381" }, children: "Panel de Control" })
|
|
999
|
+
] })
|
|
1000
|
+
] }),
|
|
1001
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1002
|
+
"div",
|
|
1003
|
+
{
|
|
1004
|
+
className: "inline-flex items-center gap-1.5 text-[10px] font-bold px-2.5 py-1 rounded-full",
|
|
1005
|
+
style: {
|
|
1006
|
+
backgroundColor: "rgba(79,70,229,0.20)",
|
|
1007
|
+
color: "#818CF8",
|
|
1008
|
+
border: "1px solid rgba(79,70,229,0.30)"
|
|
1009
|
+
},
|
|
1010
|
+
children: [
|
|
1011
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-indigo-400 animate-pulse" }),
|
|
1012
|
+
"MFE \xB7 Transacciones \xB7 :3001"
|
|
1013
|
+
]
|
|
1014
|
+
}
|
|
1015
|
+
)
|
|
1016
|
+
]
|
|
1017
|
+
}
|
|
1018
|
+
),
|
|
1019
|
+
/* @__PURE__ */ jsxRuntime.jsxs("nav", { className: "flex-1 px-3 py-5", children: [
|
|
1020
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1021
|
+
"p",
|
|
1022
|
+
{
|
|
1023
|
+
className: "text-[10px] font-bold uppercase tracking-[0.1em] px-3 mb-2",
|
|
1024
|
+
style: { color: "rgba(145,158,171,0.48)" },
|
|
1025
|
+
children: "M\xF3dulo"
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: NAV_ITEMS.map((item) => {
|
|
1029
|
+
const fullPath = `/dashboard/transactions${item.href === "/" ? "" : item.href}`;
|
|
1030
|
+
const isActive = pathname === fullPath;
|
|
1031
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1032
|
+
Link__default.default,
|
|
1033
|
+
{
|
|
1034
|
+
href: item.href,
|
|
1035
|
+
className: "group flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-all duration-150 relative",
|
|
1036
|
+
style: {
|
|
1037
|
+
color: isActive ? "var(--sidebar-text-active)" : "var(--sidebar-text)",
|
|
1038
|
+
backgroundColor: isActive ? "var(--sidebar-active-bg)" : "transparent"
|
|
1039
|
+
},
|
|
1040
|
+
onMouseEnter: (e) => {
|
|
1041
|
+
if (!isActive) {
|
|
1042
|
+
e.currentTarget.style.backgroundColor = "rgba(255,255,255,0.06)";
|
|
1043
|
+
e.currentTarget.style.color = "#C4CDD5";
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
onMouseLeave: (e) => {
|
|
1047
|
+
if (!isActive) {
|
|
1048
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
1049
|
+
e.currentTarget.style.color = "var(--sidebar-text)";
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
children: [
|
|
1053
|
+
isActive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1054
|
+
"span",
|
|
1055
|
+
{
|
|
1056
|
+
className: "absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-6 rounded-r-full",
|
|
1057
|
+
style: { backgroundColor: "#818CF8" }
|
|
1058
|
+
}
|
|
1059
|
+
),
|
|
1060
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: isActive ? "#818CF8" : "#637381" }, children: item.icon }),
|
|
1061
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
|
|
1062
|
+
]
|
|
1063
|
+
},
|
|
1064
|
+
item.href
|
|
1065
|
+
);
|
|
1066
|
+
}) })
|
|
1067
|
+
] }),
|
|
1068
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1069
|
+
"div",
|
|
1070
|
+
{
|
|
1071
|
+
className: "px-3 py-4",
|
|
1072
|
+
style: { borderTop: "1px solid var(--sidebar-border)" },
|
|
1073
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1074
|
+
"a",
|
|
1075
|
+
{
|
|
1076
|
+
href: "http://localhost:3000/dashboard",
|
|
1077
|
+
className: "flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-all duration-150 w-full",
|
|
1078
|
+
style: { color: "#637381" },
|
|
1079
|
+
onMouseEnter: (e) => {
|
|
1080
|
+
e.currentTarget.style.color = "#C4CDD5";
|
|
1081
|
+
e.currentTarget.style.backgroundColor = "rgba(255,255,255,0.06)";
|
|
1082
|
+
},
|
|
1083
|
+
onMouseLeave: (e) => {
|
|
1084
|
+
e.currentTarget.style.color = "#637381";
|
|
1085
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
1086
|
+
},
|
|
1087
|
+
children: [
|
|
1088
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconArrowLeft, {}),
|
|
1089
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Dashboard Principal" })
|
|
1090
|
+
]
|
|
1091
|
+
}
|
|
1092
|
+
)
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
]
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
function EmbeddedShell({ children }) {
|
|
1100
|
+
const [isEmbedded, setIsEmbedded] = react.useState(false);
|
|
1101
|
+
react.useEffect(() => {
|
|
1102
|
+
try {
|
|
1103
|
+
setIsEmbedded(window.self !== window.top);
|
|
1104
|
+
} catch {
|
|
1105
|
+
setIsEmbedded(true);
|
|
1106
|
+
}
|
|
1107
|
+
}, []);
|
|
1108
|
+
if (isEmbedded) {
|
|
1109
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { backgroundColor: "var(--background)", minHeight: "100vh" }, children });
|
|
1110
|
+
}
|
|
1111
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-screen", style: { backgroundColor: "var(--background)" }, children: [
|
|
1112
|
+
/* @__PURE__ */ jsxRuntime.jsx(Sidebar, {}),
|
|
1113
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col min-w-0", children: [
|
|
1114
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1115
|
+
"header",
|
|
1116
|
+
{
|
|
1117
|
+
className: "h-16 flex items-center px-6 shrink-0",
|
|
1118
|
+
style: {
|
|
1119
|
+
backgroundColor: "rgba(244,246,248,0.95)",
|
|
1120
|
+
borderBottom: "1px solid rgba(145,158,171,0.24)",
|
|
1121
|
+
position: "sticky",
|
|
1122
|
+
top: 0,
|
|
1123
|
+
zIndex: 40
|
|
1124
|
+
},
|
|
1125
|
+
children: [
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsxs("nav", { className: "flex items-center gap-1.5 text-xs mb-0.5", children: [
|
|
1128
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "var(--text-secondary)" }, children: "Inicio" }),
|
|
1129
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "9 18 15 12 9 6" }) }),
|
|
1130
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "var(--text-secondary)" }, children: "Gesti\xF3n" }),
|
|
1131
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "9 18 15 12 9 6" }) }),
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", style: { color: "var(--text-primary)" }, children: "Transacciones" })
|
|
1133
|
+
] }),
|
|
1134
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-bold leading-none", style: { color: "var(--text-primary)" }, children: "Transacciones" })
|
|
1135
|
+
] }),
|
|
1136
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1137
|
+
"div",
|
|
1138
|
+
{
|
|
1139
|
+
className: "hidden sm:flex items-center gap-2 text-xs font-semibold px-3 py-1.5 rounded-full",
|
|
1140
|
+
style: {
|
|
1141
|
+
backgroundColor: "rgba(79,70,229,0.10)",
|
|
1142
|
+
color: "var(--primary)",
|
|
1143
|
+
border: "1px solid rgba(79,70,229,0.20)"
|
|
1144
|
+
},
|
|
1145
|
+
children: [
|
|
1146
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-indigo-500 animate-pulse" }),
|
|
1147
|
+
"Microfrontend \xB7 Puerto 3001"
|
|
1148
|
+
]
|
|
1149
|
+
}
|
|
1150
|
+
)
|
|
1151
|
+
]
|
|
1152
|
+
}
|
|
1153
|
+
),
|
|
1154
|
+
/* @__PURE__ */ jsxRuntime.jsx("main", { className: "flex-1 overflow-auto", children })
|
|
1155
|
+
] })
|
|
1156
|
+
] });
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
exports.EditTransactionPage = EditTransactionPage;
|
|
1160
|
+
exports.EmbeddedShell = EmbeddedShell;
|
|
1161
|
+
exports.NewTransactionPage = NewTransactionPage;
|
|
1162
|
+
exports.Sidebar = Sidebar;
|
|
1163
|
+
exports.TransactionsListPage = TransactionsPage;
|
|
1164
|
+
//# sourceMappingURL=index.cjs.map
|
|
1165
|
+
//# sourceMappingURL=index.cjs.map
|