strapi-plugin-magic-mark 3.4.0 → 4.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +366 -0
  2. package/README.md +390 -619
  3. package/dist/admin/App-C9PsvW9C.mjs +580 -0
  4. package/dist/admin/App-KJvUCwN1.js +580 -0
  5. package/dist/admin/PinnedBookmarksWidget-ClskVR1i.mjs +55 -0
  6. package/dist/admin/PinnedBookmarksWidget-DlD8lDhq.js +55 -0
  7. package/dist/admin/de-BF0nCjGF.mjs +183 -0
  8. package/dist/admin/de-Cn90CcnC.js +183 -0
  9. package/dist/admin/en-D-EGHodf.mjs +183 -0
  10. package/dist/admin/en-GDfO_EfL.js +183 -0
  11. package/dist/admin/es-6o-_RABX.js +183 -0
  12. package/dist/admin/es-C33BufuB.mjs +183 -0
  13. package/dist/admin/fr-BOZS5mJT.js +183 -0
  14. package/dist/admin/fr-DJHTjkmb.mjs +183 -0
  15. package/dist/admin/index-CLjQOzqv.js +1770 -0
  16. package/dist/admin/index-X8I03cOT.mjs +1769 -0
  17. package/dist/admin/index.js +4 -2
  18. package/dist/admin/index.mjs +2 -1
  19. package/dist/admin/pt-D13SxuK2.js +183 -0
  20. package/dist/admin/pt-yoB1jrsq.mjs +183 -0
  21. package/dist/server/index.js +1129 -1542
  22. package/dist/server/index.mjs +1126 -1539
  23. package/package.json +90 -54
  24. package/strapi-admin.js +5 -0
  25. package/strapi-server.js +2 -1
  26. package/COPYRIGHT_NOTICE.txt +0 -20
  27. package/dist/_chunks/App-DNyxeldt.js +0 -1451
  28. package/dist/_chunks/App-D_Vllkur.mjs +0 -1449
  29. package/dist/_chunks/UpgradePage-DuyIskve.mjs +0 -351
  30. package/dist/_chunks/UpgradePage-SzlmS6po.js +0 -353
  31. package/dist/_chunks/de-Cs9dd3Mr.js +0 -138
  32. package/dist/_chunks/de-DOVki5VS.mjs +0 -138
  33. package/dist/_chunks/en-CE3r46Y2.js +0 -138
  34. package/dist/_chunks/en-Cf5-O03L.mjs +0 -138
  35. package/dist/_chunks/es-Ba6JcPIm.mjs +0 -138
  36. package/dist/_chunks/es-D4AOyJYJ.js +0 -138
  37. package/dist/_chunks/fr-CWSfoA8i.js +0 -138
  38. package/dist/_chunks/fr-CrMBXR3c.mjs +0 -138
  39. package/dist/_chunks/index-CBwb0AEf.js +0 -3618
  40. package/dist/_chunks/index-JirQF8zE.mjs +0 -328
  41. package/dist/_chunks/index-QkINaIgJ.mjs +0 -3614
  42. package/dist/_chunks/index-uUErgmi9.js +0 -330
  43. package/dist/_chunks/pt-BXxZ1Zym.mjs +0 -138
  44. package/dist/_chunks/pt-DW_6r_mP.js +0 -138
  45. package/pics/advancedFilters.png +0 -0
  46. package/pics/dashboard.png +0 -0
  47. package/pics/quickaccesinContentmanager.png +0 -0
  48. package/pics/saveAsMagicMark.png +0 -0
@@ -1,1449 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { useIntl } from "react-intl";
4
- import { useNavigate } from "react-router-dom";
5
- import styled, { keyframes } from "styled-components";
6
- import { Flex, Loader, Box, Typography, SingleSelect, SingleSelectOption, Thead, Tr, Th, VisuallyHidden, Tbody, Td, Button, Table, TextInput } from "@strapi/design-system";
7
- import { Pin, Eye, Pencil, Trash, Cross, Key, User, Mail, Check } from "@strapi/icons";
8
- import { BookOpenIcon, UserIcon, SparklesIcon, LinkIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline";
9
- import { useFetchClient, useNotification } from "@strapi/strapi/admin";
10
- import { u as useLicenseInfo, p as pluginId, g as getIconById, C as CreateEditModal } from "./index-QkINaIgJ.mjs";
11
- const theme = {
12
- colors: {
13
- primary: {
14
- 50: "#F0F9FF",
15
- 100: "#E0F2FE",
16
- 500: "#0EA5E9",
17
- 600: "#0284C7",
18
- 700: "#0369A1"
19
- },
20
- secondary: {
21
- 600: "#9333EA"
22
- },
23
- success: {
24
- 100: "#DCFCE7",
25
- 500: "#22C55E",
26
- 600: "#16A34A"
27
- },
28
- warning: {
29
- 100: "#FEF3C7",
30
- 500: "#F59E0B",
31
- 600: "#D97706"
32
- },
33
- danger: {
34
- 100: "#FEE2E2",
35
- 500: "#EF4444",
36
- 600: "#DC2626"
37
- },
38
- neutral: {
39
- 0: "#FFFFFF",
40
- 100: "#F3F4F6",
41
- 600: "#4B5563"
42
- }
43
- },
44
- shadows: {
45
- sm: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
46
- xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"
47
- },
48
- transitions: {
49
- fast: "150ms cubic-bezier(0.4, 0, 0.2, 1)",
50
- normal: "300ms cubic-bezier(0.4, 0, 0.2, 1)",
51
- slow: "500ms cubic-bezier(0.4, 0, 0.2, 1)"
52
- },
53
- spacing: {
54
- xs: "4px",
55
- sm: "8px",
56
- md: "16px",
57
- lg: "24px",
58
- xl: "32px",
59
- "2xl": "48px"
60
- },
61
- borderRadius: {
62
- md: "8px",
63
- lg: "12px",
64
- xl: "16px"
65
- }
66
- };
67
- const fadeIn$1 = keyframes`
68
- from { opacity: 0; transform: translateY(10px); }
69
- to { opacity: 1; transform: translateY(0); }
70
- `;
71
- keyframes`
72
- from { opacity: 0; transform: translateX(-10px); }
73
- to { opacity: 1; transform: translateX(0); }
74
- `;
75
- const shimmer = keyframes`
76
- 0% { background-position: -200% 0; }
77
- 100% { background-position: 200% 0; }
78
- `;
79
- const float = keyframes`
80
- 0%, 100% { transform: translateY(0px); }
81
- 50% { transform: translateY(-5px); }
82
- `;
83
- const breakpoints = {
84
- mobile: "768px"
85
- };
86
- const Container = styled(Box)`
87
- animation: ${fadeIn$1} ${theme.transitions.slow};
88
- min-height: 100vh;
89
- max-width: 1440px;
90
- margin: 0 auto;
91
- padding: ${theme.spacing.xl} ${theme.spacing.lg} 0;
92
-
93
- @media screen and (max-width: ${breakpoints.mobile}) {
94
- padding: ${theme.spacing.md} ${theme.spacing.sm} 0;
95
- }
96
- `;
97
- const Header = styled(Box)`
98
- background: linear-gradient(135deg,
99
- ${theme.colors.primary[600]} 0%,
100
- ${theme.colors.secondary[600]} 100%
101
- );
102
- border-radius: ${theme.borderRadius.xl};
103
- padding: ${theme.spacing.xl} ${theme.spacing["2xl"]};
104
- margin-bottom: ${theme.spacing.xl};
105
- position: relative;
106
- overflow: hidden;
107
- box-shadow: ${theme.shadows.xl};
108
-
109
- @media screen and (max-width: ${breakpoints.mobile}) {
110
- padding: ${theme.spacing.lg} ${theme.spacing.md} !important;
111
- border-radius: ${theme.borderRadius.lg} !important;
112
- }
113
-
114
- &::before {
115
- content: '';
116
- position: absolute;
117
- top: 0;
118
- left: -100%;
119
- width: 200%;
120
- height: 100%;
121
- background: linear-gradient(
122
- 90deg,
123
- transparent,
124
- rgba(255, 255, 255, 0.1),
125
- transparent
126
- );
127
- animation: ${shimmer} 3s infinite;
128
- }
129
-
130
- &::after {
131
- content: '';
132
- position: absolute;
133
- top: 0;
134
- right: 0;
135
- width: 100%;
136
- height: 100%;
137
- background-image: radial-gradient(circle at 20% 80%, transparent 50%, rgba(255, 255, 255, 0.1) 50%);
138
- background-size: 15px 15px;
139
- opacity: 0.3;
140
- }
141
- `;
142
- const HeaderContent = styled(Flex)`
143
- position: relative;
144
- z-index: 1;
145
- `;
146
- const Title = styled(Typography)`
147
- color: ${theme.colors.neutral[0]};
148
- font-size: 2rem;
149
- font-weight: 700;
150
- letter-spacing: -0.025em;
151
- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
152
- display: flex;
153
- align-items: center;
154
- gap: ${theme.spacing.sm};
155
-
156
- svg {
157
- width: 28px;
158
- height: 28px;
159
- animation: ${float} 3s ease-in-out infinite;
160
- }
161
- `;
162
- const Subtitle = styled(Typography)`
163
- color: rgba(255, 255, 255, 0.9);
164
- font-size: 0.95rem;
165
- font-weight: 400;
166
- margin-top: ${theme.spacing.xs};
167
- letter-spacing: 0.01em;
168
- `;
169
- const StatsGrid = styled.div`
170
- margin-bottom: ${theme.spacing.xl};
171
- display: grid;
172
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
173
- gap: ${theme.spacing.md};
174
- justify-content: center;
175
- max-width: 1200px;
176
- margin-left: auto;
177
- margin-right: auto;
178
-
179
- @media screen and (max-width: ${breakpoints.mobile}) {
180
- grid-template-columns: repeat(2, 1fr) !important;
181
- gap: 12px !important;
182
- margin-bottom: 24px !important;
183
- }
184
- `;
185
- const StatCard = styled(Box)`
186
- background: ${(p) => p.theme.colors.neutral0};
187
- border-radius: ${theme.borderRadius.lg};
188
- padding: ${theme.spacing.lg};
189
- position: relative;
190
- overflow: hidden;
191
- transition: all ${theme.transitions.normal};
192
- animation: ${fadeIn$1} ${theme.transitions.slow} backwards;
193
- animation-delay: ${(props) => props.$delay || "0s"};
194
- box-shadow: ${theme.shadows.sm};
195
- border: 1px solid rgba(128, 128, 128, 0.2);
196
- min-width: 200px;
197
- flex: 1;
198
- text-align: center;
199
- display: flex;
200
- flex-direction: column;
201
- align-items: center;
202
- justify-content: center;
203
-
204
- &:hover {
205
- transform: translateY(-4px);
206
- box-shadow: ${theme.shadows.xl};
207
- border-color: ${(props) => props.$color || theme.colors.primary[500]};
208
-
209
- .stat-icon {
210
- transform: scale(1.1);
211
- }
212
-
213
- .stat-value {
214
- transform: scale(1.05);
215
- }
216
- }
217
-
218
- @media screen and (max-width: ${breakpoints.mobile}) {
219
- min-width: unset !important;
220
- padding: ${theme.spacing.md} !important;
221
-
222
- &:hover {
223
- transform: none !important;
224
- }
225
- }
226
- `;
227
- const StatIcon = styled(Box)`
228
- width: 64px;
229
- height: 64px;
230
- border-radius: ${theme.borderRadius.md};
231
- display: flex;
232
- align-items: center;
233
- justify-content: center;
234
- background: ${(props) => props.$bg || theme.colors.primary[100]};
235
- transition: all ${theme.transitions.normal};
236
- margin-bottom: ${theme.spacing.md};
237
-
238
- svg {
239
- width: 32px;
240
- height: 32px;
241
- color: ${(props) => props.$color || theme.colors.primary[600]};
242
- }
243
- `;
244
- const StatValue = styled(Typography)`
245
- font-size: 2.5rem;
246
- font-weight: 700;
247
- color: ${(p) => p.theme.colors.neutral800};
248
- line-height: 1;
249
- margin-bottom: ${theme.spacing.xs};
250
- transition: transform ${theme.transitions.normal};
251
- `;
252
- const StatLabel = styled(Typography)`
253
- font-size: 0.875rem;
254
- color: ${(p) => p.theme.colors.neutral600};
255
- font-weight: 500;
256
- letter-spacing: 0.025em;
257
- text-transform: capitalize;
258
- `;
259
- const DataTable = styled(Box)`
260
- background: ${(p) => p.theme.colors.neutral0};
261
- border-radius: ${theme.borderRadius.lg};
262
- overflow: hidden;
263
- box-shadow: ${theme.shadows.sm};
264
- border: 1px solid rgba(128, 128, 128, 0.2);
265
- margin-bottom: ${theme.spacing.xl};
266
- `;
267
- const StyledTable = styled(Table)`
268
- thead {
269
- background: ${(p) => p.theme.colors.neutral0};
270
- border-bottom: 2px solid rgba(128, 128, 128, 0.15);
271
-
272
- th {
273
- font-weight: 600;
274
- color: ${(p) => p.theme.colors.neutral700};
275
- font-size: 0.875rem;
276
- text-transform: uppercase;
277
- letter-spacing: 0.025em;
278
- padding: ${theme.spacing.lg} ${theme.spacing.lg};
279
- }
280
- }
281
-
282
- tbody tr {
283
- transition: all ${theme.transitions.fast};
284
- border-bottom: 1px solid rgba(128, 128, 128, 0.1);
285
-
286
- &:last-child {
287
- border-bottom: none;
288
- }
289
-
290
- &:hover {
291
- background: ${(p) => p.theme.colors.neutral100};
292
-
293
- .action-buttons {
294
- opacity: 1;
295
- }
296
- }
297
-
298
- td {
299
- padding: ${theme.spacing.lg} ${theme.spacing.lg};
300
- color: ${(p) => p.theme.colors.neutral700};
301
- vertical-align: middle;
302
- }
303
- }
304
- `;
305
- styled(Box)`
306
- width: 4px;
307
- height: 40px;
308
- background: ${(props) => props.$isPinned ? theme.colors.warning[500] : "transparent"};
309
- border-radius: 2px;
310
- transition: all ${theme.transitions.normal};
311
- `;
312
- const BookmarkIconWrapper = styled.div`
313
- display: flex;
314
- align-items: center;
315
- justify-content: center;
316
- width: 40px;
317
- height: 40px;
318
- background: linear-gradient(135deg, ${theme.colors.primary[100]} 0%, #E0E7FF 100%);
319
- border-radius: 8px;
320
- flex-shrink: 0;
321
-
322
- svg {
323
- width: 20px;
324
- height: 20px;
325
- color: ${theme.colors.primary[600]};
326
- }
327
- `;
328
- const ActionButtons = styled(Flex)`
329
- opacity: 1;
330
- transition: all ${theme.transitions.fast};
331
- gap: ${theme.spacing.xs};
332
- justify-content: flex-end;
333
- `;
334
- const FloatingIcon = styled.div`
335
- position: absolute;
336
- bottom: 40px;
337
- right: 40px;
338
- opacity: 0.08;
339
- animation: ${float} 4s ease-in-out infinite;
340
-
341
- svg {
342
- width: 72px;
343
- height: 72px;
344
- color: ${theme.colors.warning[500]};
345
- }
346
- `;
347
- const FilterBar = styled(Flex)`
348
- background: ${(p) => p.theme.colors.neutral0};
349
- padding: ${theme.spacing.md} ${theme.spacing.lg};
350
- border-radius: ${theme.borderRadius.lg};
351
- margin-bottom: ${theme.spacing.lg};
352
- box-shadow: ${theme.shadows.sm};
353
- border: 1px solid rgba(128, 128, 128, 0.2);
354
- gap: ${theme.spacing.md};
355
- align-items: center;
356
- `;
357
- const FilterSelect = styled(Box)`
358
- min-width: 120px;
359
- `;
360
- const SearchInputWrapper = styled.div`
361
- position: relative;
362
- width: 100%;
363
- display: flex;
364
- align-items: center;
365
- `;
366
- const SearchIconStyled = styled(MagnifyingGlassIcon)`
367
- position: absolute;
368
- left: 12px;
369
- width: 16px;
370
- height: 16px;
371
- color: ${(p) => p.theme.colors.neutral600};
372
- pointer-events: none;
373
- `;
374
- const StyledSearchInput = styled.input`
375
- width: 100%;
376
- padding: ${theme.spacing.sm} ${theme.spacing.sm} ${theme.spacing.sm} 36px;
377
- border: 1px solid rgba(128, 128, 128, 0.2);
378
- border-radius: ${theme.borderRadius.md};
379
- font-size: 0.875rem;
380
- transition: all ${theme.transitions.fast};
381
- background: ${(p) => p.theme.colors.neutral0};
382
- color: ${(p) => p.theme.colors.neutral800};
383
-
384
- &:focus {
385
- outline: none;
386
- border-color: ${theme.colors.primary[500]};
387
- box-shadow: 0 0 0 3px ${theme.colors.primary[100]};
388
- }
389
-
390
- &::placeholder {
391
- color: ${(p) => p.theme.colors.neutral600};
392
- }
393
- `;
394
- const HomePageModern = () => {
395
- const { formatMessage } = useIntl();
396
- const navigate = useNavigate();
397
- const { get, post, del } = useFetchClient();
398
- useLicenseInfo();
399
- const [currentUser, setCurrentUser] = useState(null);
400
- const [bookmarks, setBookmarks] = useState([]);
401
- const [loading, setLoading] = useState(false);
402
- const [showModal, setShowModal] = useState(false);
403
- const [editingBookmark, setEditingBookmark] = useState(null);
404
- const [searchQuery, setSearchQuery] = useState("");
405
- const [filterType, setFilterType] = useState("all");
406
- const [entriesPerPage, setEntriesPerPage] = useState("10");
407
- const [availableRoles, setAvailableRoles] = useState([]);
408
- const [availableUsers, setAvailableUsers] = useState([]);
409
- const [licenseLimits, setLicenseLimits] = useState({
410
- maxBookmarks: 10,
411
- currentBookmarks: 0,
412
- canCreate: true,
413
- tier: "free",
414
- features: {}
415
- });
416
- useEffect(() => {
417
- fetchBookmarks();
418
- fetchCurrentUser();
419
- fetchRoles();
420
- fetchUsers();
421
- fetchLicenseLimits();
422
- }, []);
423
- const fetchRoles = async () => {
424
- try {
425
- const response = await get(`/${pluginId}/roles`);
426
- const roles = response.data?.data?.data || response.data?.data || [];
427
- console.log("[Magic-Mark] Available roles in HomePage:", roles);
428
- setAvailableRoles(roles);
429
- } catch (error) {
430
- console.error("[Magic-Mark] Error fetching roles:", error);
431
- }
432
- };
433
- const fetchUsers = async () => {
434
- try {
435
- const response = await get("/admin/users?pageSize=100&page=1&sort=firstname");
436
- console.log("[Magic-Mark] Admin users API response:", response);
437
- const allUsers = response.data?.data?.results || response.data?.results || [];
438
- console.log("[Magic-Mark] All users from API in HomePage:", allUsers);
439
- const users = currentUser && Array.isArray(allUsers) ? allUsers.filter((u) => u.id !== currentUser.id) : allUsers;
440
- console.log("[Magic-Mark] Available users in HomePage:", users);
441
- setAvailableUsers(users);
442
- } catch (error) {
443
- console.error("[Magic-Mark] Error fetching users from admin API:", error);
444
- try {
445
- const response = await get(`/${pluginId}/users`);
446
- const users = response.data?.data?.data || response.data?.data || [];
447
- setAvailableUsers(users);
448
- } catch (fallbackError) {
449
- console.warn("[Magic-Mark] Both user endpoints failed");
450
- setAvailableUsers([]);
451
- }
452
- }
453
- };
454
- const fetchCurrentUser = async () => {
455
- try {
456
- const response = await get("/admin/users/me");
457
- console.log("[Magic-Mark] Current user response:", response);
458
- const userData = response.data?.data || response.data || response;
459
- setCurrentUser(userData);
460
- console.log("[Magic-Mark] Current user set to:", userData);
461
- } catch (error) {
462
- console.error("[Magic-Mark] Error fetching current user:", error);
463
- }
464
- };
465
- const isCurrentUserOwner = (bookmark) => {
466
- if (!bookmark.createdBy || !currentUser) return false;
467
- if (bookmark.createdBy.documentId && currentUser.documentId) {
468
- return bookmark.createdBy.documentId === currentUser.documentId;
469
- }
470
- if (bookmark.createdBy.id && currentUser.id) {
471
- return String(bookmark.createdBy.id) === String(currentUser.id);
472
- }
473
- if (bookmark.createdBy.id && currentUser.documentId) {
474
- return String(bookmark.createdBy.id) === String(currentUser.documentId);
475
- }
476
- return false;
477
- };
478
- const fetchLicenseLimits = async () => {
479
- try {
480
- const response = await get(`/${pluginId}/license/limits`);
481
- if (response.data?.success) {
482
- setLicenseLimits(response.data.data);
483
- console.log("[Magic-Mark] License limits loaded:", response.data.data);
484
- }
485
- } catch (error) {
486
- console.error("[Magic-Mark] Error fetching license limits:", error);
487
- }
488
- };
489
- const fetchBookmarks = async () => {
490
- setLoading(true);
491
- try {
492
- const { data } = await get(`/${pluginId}/bookmarks`);
493
- console.log("[Magic-Mark HomePage] Bookmarks loaded:", data);
494
- console.log("[Magic-Mark HomePage] Current user state:", currentUser);
495
- setBookmarks(data.data || []);
496
- } catch (error) {
497
- console.error("[Magic-Mark HomePage] Error fetching bookmarks:", error);
498
- } finally {
499
- setLoading(false);
500
- }
501
- };
502
- const handleDelete = async (bookmark) => {
503
- if (!confirm(formatMessage({
504
- id: `${pluginId}.confirm.delete`,
505
- defaultMessage: "Are you sure you want to delete this bookmark?"
506
- }))) {
507
- return;
508
- }
509
- const deleteId = bookmark.documentId || bookmark.id;
510
- try {
511
- await del(`/${pluginId}/bookmarks/${deleteId}`);
512
- console.log("[Magic-Mark HomePage] Bookmark deleted:", deleteId);
513
- fetchBookmarks();
514
- } catch (error) {
515
- console.error("[Magic-Mark HomePage] Error deleting bookmark:", error);
516
- }
517
- };
518
- const handlePin = async (bookmark) => {
519
- const pinId = bookmark.documentId || bookmark.id;
520
- try {
521
- await post(`/${pluginId}/bookmarks/${pinId}/pin`, {
522
- isPinned: !bookmark.isPinned
523
- });
524
- console.log("[Magic-Mark HomePage] Bookmark pinned:", pinId);
525
- fetchBookmarks();
526
- } catch (error) {
527
- console.error("[Magic-Mark HomePage] Error pinning bookmark:", error);
528
- }
529
- };
530
- const handleEdit = (bookmark) => {
531
- setEditingBookmark(bookmark);
532
- setShowModal(true);
533
- };
534
- const handleModalClose = () => {
535
- setShowModal(false);
536
- setEditingBookmark(null);
537
- };
538
- const handleModalSuccess = () => {
539
- setShowModal(false);
540
- setEditingBookmark(null);
541
- fetchBookmarks();
542
- fetchLicenseLimits();
543
- };
544
- const handleBookmarkClick = (bookmark) => {
545
- if (bookmark.path) {
546
- let path = bookmark.path;
547
- if (path.startsWith("/admin/")) {
548
- path = path.substring(6);
549
- }
550
- const url = bookmark.query ? `${path}?${bookmark.query}` : path;
551
- console.log("[HomePage] Navigating to:", url);
552
- navigate(url);
553
- }
554
- };
555
- const filteredBookmarks = bookmarks.filter((bookmark) => {
556
- if (filterType === "pinned" && !bookmark.isPinned) return false;
557
- if (filterType === "unpinned" && bookmark.isPinned) return false;
558
- if (!searchQuery) return true;
559
- const query = searchQuery.toLowerCase();
560
- return bookmark.name.toLowerCase().includes(query) || bookmark.description && bookmark.description.toLowerCase().includes(query) || bookmark.path.toLowerCase().includes(query);
561
- }).slice(0, parseInt(entriesPerPage));
562
- const pinnedBookmarks = bookmarks.filter((b) => b.isPinned);
563
- const myBookmarks = bookmarks.filter((b) => isCurrentUserOwner(b));
564
- const sharedWithMe = bookmarks.filter((b) => !isCurrentUserOwner(b) && b.createdBy);
565
- return /* @__PURE__ */ jsxs(Container, { padding: 8, children: [
566
- /* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsxs(HeaderContent, { direction: "column", alignItems: "flex-start", gap: 2, children: [
567
- /* @__PURE__ */ jsxs(Title, { children: [
568
- /* @__PURE__ */ jsx(BookOpenIcon, {}),
569
- " MagicMark"
570
- ] }),
571
- /* @__PURE__ */ jsx(Subtitle, { children: "Save filtered views and navigate with one click" })
572
- ] }) }),
573
- /* @__PURE__ */ jsxs(StatsGrid, { children: [
574
- /* @__PURE__ */ jsxs(StatCard, { $delay: "0.1s", $color: theme.colors.primary[500], children: [
575
- /* @__PURE__ */ jsx(StatIcon, { className: "stat-icon", $bg: theme.colors.primary[100], $color: theme.colors.primary[600], children: /* @__PURE__ */ jsx(UserIcon, {}) }),
576
- /* @__PURE__ */ jsx(StatValue, { className: "stat-value", children: myBookmarks.length }),
577
- /* @__PURE__ */ jsx(StatLabel, { children: "My Bookmarks" })
578
- ] }),
579
- /* @__PURE__ */ jsxs(StatCard, { $delay: "0.2s", $color: theme.colors.success[500], children: [
580
- /* @__PURE__ */ jsx(StatIcon, { className: "stat-icon", $bg: theme.colors.success[100], $color: theme.colors.success[600], children: /* @__PURE__ */ jsx(SparklesIcon, {}) }),
581
- /* @__PURE__ */ jsx(StatValue, { className: "stat-value", children: sharedWithMe.length }),
582
- /* @__PURE__ */ jsx(StatLabel, { children: formatMessage({ id: `${pluginId}.stats.shared`, defaultMessage: "Shared with Me" }) })
583
- ] }),
584
- /* @__PURE__ */ jsxs(StatCard, { $delay: "0.3s", $color: theme.colors.warning[500], children: [
585
- /* @__PURE__ */ jsx(StatIcon, { className: "stat-icon", $bg: theme.colors.warning[100], $color: theme.colors.warning[600], children: /* @__PURE__ */ jsx(Pin, {}) }),
586
- /* @__PURE__ */ jsx(StatValue, { className: "stat-value", children: pinnedBookmarks.length }),
587
- /* @__PURE__ */ jsx(StatLabel, { children: formatMessage({ id: `${pluginId}.stats.pinned`, defaultMessage: "Pinned" }) })
588
- ] }),
589
- /* @__PURE__ */ jsxs(
590
- StatCard,
591
- {
592
- $delay: "0.4s",
593
- $color: licenseLimits.canCreate ? theme.colors.neutral[600] : theme.colors.danger[500],
594
- onClick: () => !licenseLimits.canCreate && navigate(`/settings/${pluginId}/upgrade`),
595
- style: { cursor: !licenseLimits.canCreate ? "pointer" : "default" },
596
- children: [
597
- /* @__PURE__ */ jsx(
598
- StatIcon,
599
- {
600
- className: "stat-icon",
601
- $bg: licenseLimits.canCreate ? theme.colors.neutral[100] : theme.colors.danger[100],
602
- $color: licenseLimits.canCreate ? theme.colors.neutral[600] : theme.colors.danger[600],
603
- children: /* @__PURE__ */ jsx(LinkIcon, {})
604
- }
605
- ),
606
- /* @__PURE__ */ jsxs(StatValue, { className: "stat-value", children: [
607
- licenseLimits.currentBookmarks,
608
- "/",
609
- licenseLimits.maxBookmarks === -1 ? "∞" : licenseLimits.maxBookmarks
610
- ] }),
611
- /* @__PURE__ */ jsx(StatLabel, { children: licenseLimits.canCreate ? formatMessage({ id: `${pluginId}.stats.limit`, defaultMessage: "Bookmark Limit" }) : formatMessage({ id: `${pluginId}.stats.limitReached`, defaultMessage: "Limit Reached - Upgrade" }) })
612
- ]
613
- }
614
- )
615
- ] }),
616
- loading && /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsx(Loader, { children: formatMessage({ id: `${pluginId}.loading`, defaultMessage: "Loading bookmarks..." }) }) }),
617
- !loading && sharedWithMe.length > 0 && /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsxs(Box, { style: {
618
- padding: theme.spacing.lg,
619
- background: theme.colors.primary[50],
620
- borderRadius: theme.borderRadius.lg,
621
- border: `1px solid ${theme.colors.primary[200]}`
622
- }, children: [
623
- /* @__PURE__ */ jsx(Typography, { variant: "beta", style: { marginBottom: theme.spacing.sm, color: theme.colors.primary[700] }, children: formatMessage({ id: `${pluginId}.shared.title`, defaultMessage: "🤝 Shared with You" }) }),
624
- /* @__PURE__ */ jsx(Typography, { variant: "pi", style: { color: theme.colors.primary[600] }, children: sharedWithMe.length > 1 ? formatMessage({ id: `${pluginId}.shared.countPlural`, defaultMessage: "{count} bookmarks have been shared with you" }, { count: sharedWithMe.length }) : formatMessage({ id: `${pluginId}.shared.count`, defaultMessage: "{count} bookmark has been shared with you" }, { count: sharedWithMe.length }) }),
625
- /* @__PURE__ */ jsx(Box, { marginTop: 2, children: [...new Map(sharedWithMe.map((b) => [b.createdBy?.id, b.createdBy])).values()].map((creator) => {
626
- const creatorBookmarks = sharedWithMe.filter((b) => b.createdBy?.id === creator?.id);
627
- return creator && /* @__PURE__ */ jsxs(Flex, { alignItems: "center", marginTop: 1, children: [
628
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "semiBold", children: [
629
- creator.firstname || formatMessage({ id: `${pluginId}.bookmark.unknown`, defaultMessage: "Unknown" }),
630
- " ",
631
- creator.lastname || "",
632
- ":"
633
- ] }),
634
- /* @__PURE__ */ jsx(Typography, { variant: "pi", marginLeft: 1, children: creatorBookmarks.length > 1 ? formatMessage({ id: `${pluginId}.shared.byCreatorPlural`, defaultMessage: "{count} bookmarks" }, { count: creatorBookmarks.length }) : formatMessage({ id: `${pluginId}.shared.byCreator`, defaultMessage: "{count} bookmark" }, { count: creatorBookmarks.length }) })
635
- ] }, creator.id);
636
- }) })
637
- ] }) }),
638
- !loading && bookmarks.length > 0 && /* @__PURE__ */ jsxs(Box, { children: [
639
- /* @__PURE__ */ jsx(Box, { style: { marginBottom: theme.spacing.md }, children: /* @__PURE__ */ jsx(Typography, { variant: "delta", style: { marginBottom: theme.spacing.md, color: "var(--colors-neutral700, #374151)" }, children: formatMessage({ id: `${pluginId}.allBookmarks.title`, defaultMessage: "🔖 All Available Bookmarks" }) }) }),
640
- /* @__PURE__ */ jsxs(FilterBar, { children: [
641
- /* @__PURE__ */ jsxs(SearchInputWrapper, { style: { flex: 1 }, children: [
642
- /* @__PURE__ */ jsx(SearchIconStyled, {}),
643
- /* @__PURE__ */ jsx(
644
- StyledSearchInput,
645
- {
646
- value: searchQuery,
647
- onChange: (e) => setSearchQuery(e.target.value),
648
- placeholder: formatMessage({ id: `${pluginId}.search.placeholder`, defaultMessage: "Search by name, description..." }),
649
- type: "text"
650
- }
651
- )
652
- ] }),
653
- /* @__PURE__ */ jsx(FilterSelect, { children: /* @__PURE__ */ jsxs(
654
- SingleSelect,
655
- {
656
- value: filterType,
657
- onChange: setFilterType,
658
- placeholder: formatMessage({ id: `${pluginId}.filter.placeholder`, defaultMessage: "Filter" }),
659
- size: "S",
660
- children: [
661
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "all", children: formatMessage({ id: `${pluginId}.filter.all`, defaultMessage: "Show All" }) }),
662
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "pinned", children: formatMessage({ id: `${pluginId}.filter.pinned`, defaultMessage: "Pinned Only" }) }),
663
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "unpinned", children: formatMessage({ id: `${pluginId}.filter.unpinned`, defaultMessage: "Unpinned Only" }) })
664
- ]
665
- }
666
- ) }),
667
- /* @__PURE__ */ jsx(FilterSelect, { children: /* @__PURE__ */ jsxs(
668
- SingleSelect,
669
- {
670
- value: entriesPerPage,
671
- onChange: setEntriesPerPage,
672
- placeholder: formatMessage({ id: `${pluginId}.entries.placeholder`, defaultMessage: "Entries" }),
673
- size: "S",
674
- children: [
675
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "10", children: formatMessage({ id: `${pluginId}.entries.10`, defaultMessage: "10 entries" }) }),
676
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "25", children: formatMessage({ id: `${pluginId}.entries.25`, defaultMessage: "25 entries" }) }),
677
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "50", children: formatMessage({ id: `${pluginId}.entries.50`, defaultMessage: "50 entries" }) }),
678
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "100", children: formatMessage({ id: `${pluginId}.entries.100`, defaultMessage: "100 entries" }) })
679
- ]
680
- }
681
- ) })
682
- ] }),
683
- /* @__PURE__ */ jsx(DataTable, { children: /* @__PURE__ */ jsxs(StyledTable, { children: [
684
- /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
685
- /* @__PURE__ */ jsx(Th, { children: formatMessage({
686
- id: `${pluginId}.table.name`,
687
- defaultMessage: "Name"
688
- }) }),
689
- /* @__PURE__ */ jsx(Th, { children: formatMessage({
690
- id: `${pluginId}.table.description`,
691
- defaultMessage: "Description"
692
- }) }),
693
- /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: "Actions" }) })
694
- ] }) }),
695
- /* @__PURE__ */ jsx(Tbody, { children: filteredBookmarks.map((bookmark) => /* @__PURE__ */ jsxs(Tr, { style: {
696
- background: bookmark.isPinned ? theme.colors.warning[50] : "transparent"
697
- }, children: [
698
- /* @__PURE__ */ jsx(Td, { onClick: () => handleBookmarkClick(bookmark), style: { cursor: "pointer" }, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 3, children: [
699
- /* @__PURE__ */ jsx(BookmarkIconWrapper, { children: (() => {
700
- const IconComponent = getIconById(bookmark.icon || bookmark.emoji || "bookmark");
701
- return /* @__PURE__ */ jsx(IconComponent, {});
702
- })() }),
703
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 0, children: [
704
- /* @__PURE__ */ jsx(Typography, { fontWeight: "semiBold", ellipsis: true, style: { fontSize: "1.125rem", lineHeight: "1.4" }, children: bookmark.name }),
705
- /* @__PURE__ */ jsxs(Flex, { gap: 1, alignItems: "center", children: [
706
- isCurrentUserOwner(bookmark) ? /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.primary[600], fontWeight: 500 }, children: [
707
- "• ",
708
- formatMessage({ id: `${pluginId}.bookmark.myBookmark`, defaultMessage: "My Bookmark" })
709
- ] }) : /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { fontSize: "0.75rem", color: "var(--colors-neutral600, #4B5563)" }, children: [
710
- "• ",
711
- formatMessage({ id: `${pluginId}.bookmark.sharedBy`, defaultMessage: "Shared by {name}" }, { name: bookmark.createdBy?.firstname || formatMessage({ id: `${pluginId}.bookmark.unknown`, defaultMessage: "Unknown" }) })
712
- ] }),
713
- bookmark.isPublic && /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.success[600], marginLeft: "8px" }, children: [
714
- "• ",
715
- formatMessage({ id: `${pluginId}.bookmark.public`, defaultMessage: "Public" })
716
- ] }),
717
- bookmark.sharedWithRoles && bookmark.sharedWithRoles.length > 0 && !bookmark.isPublic && /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.warning[600], marginLeft: "8px" }, children: [
718
- "• Roles: ",
719
- bookmark.sharedWithRoles.map((roleId) => {
720
- const role = availableRoles.find((r) => r.id === roleId);
721
- return role?.name || `Role ${roleId}`;
722
- }).join(", ")
723
- ] }),
724
- bookmark.sharedWithUsers && bookmark.sharedWithUsers.length > 0 && !bookmark.isPublic && /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { fontSize: "0.75rem", color: theme.colors.primary[600], marginLeft: "8px" }, children: [
725
- "• Users: ",
726
- bookmark.sharedWithUsers.map((userId) => {
727
- const user = availableUsers.find((u) => u.id === userId);
728
- return user ? `${user.firstname} ${user.lastname}` : `User ${userId}`;
729
- }).join(", ")
730
- ] })
731
- ] })
732
- ] })
733
- ] }) }),
734
- /* @__PURE__ */ jsx(Td, { onClick: () => handleBookmarkClick(bookmark), style: { cursor: "pointer" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, style: { fontSize: "1rem", lineHeight: "1.6", fontWeight: 400 }, children: bookmark.description || "-" }) }),
735
- /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(
736
- ActionButtons,
737
- {
738
- className: "action-buttons",
739
- children: [
740
- /* @__PURE__ */ jsx(
741
- Button,
742
- {
743
- variant: bookmark.isPinned ? "secondary" : "ghost",
744
- size: "S",
745
- onClick: (e) => {
746
- e.stopPropagation();
747
- handlePin(bookmark);
748
- },
749
- style: {
750
- color: bookmark.isPinned ? theme.colors.warning[600] : "inherit",
751
- background: bookmark.isPinned ? theme.colors.warning[100] : "transparent"
752
- },
753
- children: /* @__PURE__ */ jsx(Pin, {})
754
- }
755
- ),
756
- /* @__PURE__ */ jsx(
757
- Button,
758
- {
759
- variant: "ghost",
760
- size: "S",
761
- onClick: (e) => {
762
- e.stopPropagation();
763
- handleBookmarkClick(bookmark);
764
- },
765
- children: /* @__PURE__ */ jsx(Eye, {})
766
- }
767
- ),
768
- /* @__PURE__ */ jsx(
769
- Button,
770
- {
771
- variant: "ghost",
772
- size: "S",
773
- onClick: (e) => {
774
- e.stopPropagation();
775
- handleEdit(bookmark);
776
- },
777
- disabled: !isCurrentUserOwner(bookmark),
778
- children: /* @__PURE__ */ jsx(Pencil, {})
779
- }
780
- ),
781
- isCurrentUserOwner(bookmark) && /* @__PURE__ */ jsx(
782
- Button,
783
- {
784
- variant: "ghost",
785
- size: "S",
786
- onClick: (e) => {
787
- e.stopPropagation();
788
- handleDelete(bookmark);
789
- },
790
- children: /* @__PURE__ */ jsx(Trash, {})
791
- }
792
- )
793
- ]
794
- }
795
- ) })
796
- ] }, bookmark.id)) })
797
- ] }) })
798
- ] }),
799
- !loading && bookmarks.length === 0 && /* @__PURE__ */ jsxs(
800
- Box,
801
- {
802
- style: {
803
- background: "transparent",
804
- borderRadius: theme.borderRadius.xl,
805
- border: "2px dashed rgba(128, 128, 128, 0.2)",
806
- padding: theme.spacing["3xl"],
807
- textAlign: "center",
808
- position: "relative",
809
- overflow: "hidden",
810
- minHeight: "400px",
811
- display: "flex",
812
- alignItems: "center",
813
- justifyContent: "center"
814
- },
815
- children: [
816
- /* @__PURE__ */ jsx(
817
- Box,
818
- {
819
- style: {
820
- content: "",
821
- position: "absolute",
822
- top: 0,
823
- left: 0,
824
- right: 0,
825
- bottom: 0,
826
- background: `linear-gradient(135deg, ${theme.colors.primary[50]} 0%, ${theme.colors.secondary[50]} 100%)`,
827
- opacity: 0.3,
828
- zIndex: 0
829
- }
830
- }
831
- ),
832
- /* @__PURE__ */ jsx(FloatingIcon, { children: /* @__PURE__ */ jsx(SparklesIcon, {}) }),
833
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 6, style: { position: "relative", zIndex: 1 }, children: [
834
- /* @__PURE__ */ jsx(
835
- Box,
836
- {
837
- style: {
838
- width: "120px",
839
- height: "120px",
840
- borderRadius: "50%",
841
- background: `linear-gradient(135deg, ${theme.colors.primary[100]} 0%, ${theme.colors.secondary[100]} 100%)`,
842
- display: "flex",
843
- alignItems: "center",
844
- justifyContent: "center",
845
- boxShadow: theme.shadows.xl
846
- },
847
- children: /* @__PURE__ */ jsx(SparklesIcon, { style: { width: "60px", height: "60px", color: theme.colors.primary[600] } })
848
- }
849
- ),
850
- /* @__PURE__ */ jsx(
851
- Typography,
852
- {
853
- variant: "alpha",
854
- style: {
855
- fontSize: "1.75rem",
856
- fontWeight: "700",
857
- color: "var(--colors-neutral800, #1F2937)",
858
- marginBottom: "8px"
859
- },
860
- children: formatMessage({ id: `${pluginId}.empty.title`, defaultMessage: "No bookmarks yet" })
861
- }
862
- ),
863
- /* @__PURE__ */ jsx(
864
- Typography,
865
- {
866
- variant: "omega",
867
- textColor: "neutral600",
868
- style: {
869
- fontSize: "1rem",
870
- maxWidth: "500px",
871
- lineHeight: "1.6"
872
- },
873
- children: formatMessage({ id: `${pluginId}.empty.description`, defaultMessage: 'Navigate to any Content Manager view, apply filters, and click "Save Bookmark" to create quick access shortcuts' })
874
- }
875
- )
876
- ] })
877
- ]
878
- }
879
- ),
880
- showModal && /* @__PURE__ */ jsx(
881
- CreateEditModal,
882
- {
883
- bookmark: editingBookmark,
884
- pluginId,
885
- onClose: handleModalClose,
886
- onSuccess: handleModalSuccess,
887
- currentPath: "",
888
- currentQuery: ""
889
- }
890
- )
891
- ] });
892
- };
893
- const fadeIn = keyframes`
894
- from { opacity: 0; }
895
- to { opacity: 1; }
896
- `;
897
- const slideUp = keyframes`
898
- from {
899
- opacity: 0;
900
- transform: translateY(30px);
901
- }
902
- to {
903
- opacity: 1;
904
- transform: translateY(0);
905
- }
906
- `;
907
- const ModalOverlay = styled.div`
908
- position: fixed;
909
- top: 0;
910
- left: 0;
911
- right: 0;
912
- bottom: 0;
913
- background: rgba(4, 28, 47, 0.85);
914
- backdrop-filter: blur(8px);
915
- z-index: 9999;
916
- display: flex;
917
- align-items: center;
918
- justify-content: center;
919
- animation: ${fadeIn} 0.3s ease-out;
920
- padding: 20px;
921
- `;
922
- const ModalContent = styled(Box)`
923
- background: ${(p) => p.theme.colors.neutral0};
924
- border-radius: 16px;
925
- width: 100%;
926
- max-width: 580px;
927
- box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
928
- animation: ${slideUp} 0.4s cubic-bezier(0.4, 0, 0.2, 1);
929
- overflow: hidden;
930
- `;
931
- const GradientHeader = styled(Box)`
932
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
933
- padding: 32px 40px;
934
- position: relative;
935
- overflow: hidden;
936
-
937
- &::before {
938
- content: '';
939
- position: absolute;
940
- top: -50%;
941
- right: -50%;
942
- width: 200%;
943
- height: 200%;
944
- background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
945
- }
946
- `;
947
- const IconWrapper = styled.div`
948
- width: 72px;
949
- height: 72px;
950
- border-radius: 50%;
951
- background: rgba(255, 255, 255, 0.2);
952
- display: flex;
953
- align-items: center;
954
- justify-content: center;
955
- margin: 0 auto 16px;
956
- backdrop-filter: blur(10px);
957
- border: 2px solid rgba(255, 255, 255, 0.3);
958
-
959
- svg {
960
- width: 36px;
961
- height: 36px;
962
- color: white;
963
- }
964
- `;
965
- const CloseButton = styled.button`
966
- position: absolute;
967
- top: 16px;
968
- right: 16px;
969
- background: rgba(255, 255, 255, 0.2);
970
- border: 2px solid rgba(255, 255, 255, 0.3);
971
- border-radius: 50%;
972
- width: 36px;
973
- height: 36px;
974
- display: flex;
975
- align-items: center;
976
- justify-content: center;
977
- cursor: pointer;
978
- transition: all 0.2s;
979
- z-index: 10;
980
-
981
- svg {
982
- width: 20px;
983
- height: 20px;
984
- color: white;
985
- }
986
-
987
- &:hover {
988
- background: rgba(255, 255, 255, 0.3);
989
- transform: scale(1.1);
990
- }
991
-
992
- &:active {
993
- transform: scale(0.95);
994
- }
995
- `;
996
- const ToggleButton = styled.button`
997
- background: none;
998
- border: none;
999
- color: #667eea;
1000
- font-size: 13px;
1001
- font-weight: 600;
1002
- cursor: pointer;
1003
- padding: 8px 0;
1004
- text-decoration: underline;
1005
- transition: color 0.2s;
1006
-
1007
- &:hover {
1008
- color: #764ba2;
1009
- }
1010
- `;
1011
- const LicenseGuard = ({ children }) => {
1012
- const { get, post } = useFetchClient();
1013
- const { toggleNotification } = useNotification();
1014
- const navigate = useNavigate();
1015
- const [isChecking, setIsChecking] = useState(true);
1016
- const [needsLicense, setNeedsLicense] = useState(false);
1017
- const [isCreating, setIsCreating] = useState(false);
1018
- const [useExistingKey, setUseExistingKey] = useState(false);
1019
- const [useAutoCreate, setUseAutoCreate] = useState(true);
1020
- const [existingLicenseKey, setExistingLicenseKey] = useState("");
1021
- const [existingEmail, setExistingEmail] = useState("");
1022
- const [adminUser, setAdminUser] = useState(null);
1023
- const [formData, setFormData] = useState({
1024
- email: "",
1025
- firstName: "",
1026
- lastName: ""
1027
- });
1028
- useEffect(() => {
1029
- checkLicenseStatus();
1030
- fetchAdminUser();
1031
- }, []);
1032
- const fetchAdminUser = async () => {
1033
- try {
1034
- const response = await get("/admin/users/me");
1035
- console.log("Admin user response:", response);
1036
- const userData = response.data?.data || response.data;
1037
- console.log("User data extracted:", userData);
1038
- if (userData) {
1039
- setAdminUser(userData);
1040
- setFormData({
1041
- email: userData.email || "",
1042
- firstName: userData.firstname || "",
1043
- lastName: userData.lastname || ""
1044
- });
1045
- console.log("Admin user set:", {
1046
- email: userData.email,
1047
- firstname: userData.firstname,
1048
- lastname: userData.lastname
1049
- });
1050
- }
1051
- } catch (error) {
1052
- console.error("Error fetching admin user:", error);
1053
- }
1054
- };
1055
- const checkLicenseStatus = async () => {
1056
- setIsChecking(true);
1057
- try {
1058
- const response = await get("/magic-mark/license/status");
1059
- if (response.data.valid) {
1060
- setNeedsLicense(false);
1061
- } else {
1062
- setNeedsLicense(true);
1063
- }
1064
- } catch (error) {
1065
- console.error("Error checking license:", error);
1066
- setNeedsLicense(true);
1067
- } finally {
1068
- setIsChecking(false);
1069
- }
1070
- };
1071
- const handleAutoCreateLicense = async (e) => {
1072
- e.preventDefault();
1073
- setIsCreating(true);
1074
- try {
1075
- console.log("Auto-creating license with admin user data...");
1076
- const response = await post("/magic-mark/license/auto-create", {});
1077
- if (response.data && response.data.success) {
1078
- toggleNotification({
1079
- type: "success",
1080
- message: `License automatically created! Reloading...`
1081
- });
1082
- setNeedsLicense(false);
1083
- setTimeout(() => {
1084
- window.location.reload();
1085
- }, 500);
1086
- } else {
1087
- throw new Error("Failed to auto-create license");
1088
- }
1089
- } catch (error) {
1090
- console.error("Error auto-creating license:", error);
1091
- toggleNotification({
1092
- type: "danger",
1093
- message: error?.response?.data?.error?.message || "Failed to auto-create license. Try manual creation."
1094
- });
1095
- setIsCreating(false);
1096
- setUseAutoCreate(false);
1097
- }
1098
- };
1099
- const handleCreateLicense = async (e) => {
1100
- e.preventDefault();
1101
- if (!formData.email || !formData.firstName || !formData.lastName) {
1102
- toggleNotification({
1103
- type: "warning",
1104
- message: "Please fill in all fields"
1105
- });
1106
- return;
1107
- }
1108
- setIsCreating(true);
1109
- try {
1110
- console.log("Creating license with data:", formData);
1111
- const response = await post("/magic-mark/license/create", formData);
1112
- console.log("License creation response:", response);
1113
- if (response.data && response.data.success) {
1114
- toggleNotification({
1115
- type: "success",
1116
- message: `License created successfully! Reloading...`
1117
- });
1118
- setNeedsLicense(false);
1119
- setTimeout(() => {
1120
- window.location.reload();
1121
- }, 500);
1122
- } else {
1123
- throw new Error("Failed to create license");
1124
- }
1125
- } catch (error) {
1126
- console.error("Error creating license:", error);
1127
- toggleNotification({
1128
- type: "danger",
1129
- message: error?.response?.data?.error?.message || "Failed to create license. Please try again."
1130
- });
1131
- setIsCreating(false);
1132
- }
1133
- };
1134
- const handleValidateExistingKey = async (e) => {
1135
- e.preventDefault();
1136
- if (!existingLicenseKey.trim() || !existingEmail.trim()) {
1137
- toggleNotification({
1138
- type: "warning",
1139
- message: "Please enter both license key and email address"
1140
- });
1141
- return;
1142
- }
1143
- setIsCreating(true);
1144
- try {
1145
- console.log("Validating existing license key...");
1146
- const pluginStore = await post("/magic-mark/license/store-key", {
1147
- licenseKey: existingLicenseKey.trim(),
1148
- email: existingEmail.trim()
1149
- });
1150
- if (pluginStore.data && pluginStore.data.success) {
1151
- toggleNotification({
1152
- type: "success",
1153
- message: "License key validated successfully! Reloading..."
1154
- });
1155
- setNeedsLicense(false);
1156
- setTimeout(() => {
1157
- window.location.reload();
1158
- }, 500);
1159
- } else {
1160
- throw new Error("Invalid license key or email");
1161
- }
1162
- } catch (error) {
1163
- console.error("Error validating license key:", error);
1164
- toggleNotification({
1165
- type: "danger",
1166
- message: error?.response?.data?.error?.message || "Invalid license key or email address. Please check and try again."
1167
- });
1168
- setIsCreating(false);
1169
- }
1170
- };
1171
- const handleClose = () => {
1172
- navigate("/content-manager");
1173
- };
1174
- if (isChecking) {
1175
- return /* @__PURE__ */ jsx(Box, { padding: 8, style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Loader, { children: "Checking license..." }) });
1176
- }
1177
- if (needsLicense) {
1178
- return /* @__PURE__ */ jsx(ModalOverlay, { children: /* @__PURE__ */ jsxs(ModalContent, { children: [
1179
- /* @__PURE__ */ jsxs(GradientHeader, { children: [
1180
- /* @__PURE__ */ jsx(CloseButton, { onClick: handleClose, type: "button", children: /* @__PURE__ */ jsx(Cross, {}) }),
1181
- /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(Key, {}) }),
1182
- /* @__PURE__ */ jsxs(Box, { style: { textAlign: "center", position: "relative" }, children: [
1183
- /* @__PURE__ */ jsx(
1184
- Typography,
1185
- {
1186
- variant: "alpha",
1187
- style: {
1188
- color: "white",
1189
- fontSize: "24px",
1190
- fontWeight: "700",
1191
- marginBottom: "12px",
1192
- display: "block"
1193
- },
1194
- children: "Activate MagicMark Plugin"
1195
- }
1196
- ),
1197
- /* @__PURE__ */ jsx(
1198
- Typography,
1199
- {
1200
- variant: "epsilon",
1201
- style: {
1202
- color: "rgba(255, 255, 255, 0.9)",
1203
- fontSize: "14px",
1204
- display: "block"
1205
- },
1206
- children: useExistingKey ? "Enter your existing license key" : "Create a license to start using the plugin"
1207
- }
1208
- )
1209
- ] })
1210
- ] }),
1211
- /* @__PURE__ */ jsx("form", { onSubmit: useExistingKey ? handleValidateExistingKey : useAutoCreate ? handleAutoCreateLicense : handleCreateLicense, children: /* @__PURE__ */ jsx(
1212
- Box,
1213
- {
1214
- padding: 6,
1215
- paddingLeft: 8,
1216
- paddingRight: 8,
1217
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 5, style: { width: "100%" }, children: [
1218
- /* @__PURE__ */ jsxs(Box, { style: { textAlign: "center", width: "100%" }, children: [
1219
- !useExistingKey && /* @__PURE__ */ jsx(
1220
- ToggleButton,
1221
- {
1222
- type: "button",
1223
- onClick: () => setUseAutoCreate(!useAutoCreate),
1224
- disabled: isCreating,
1225
- style: { marginBottom: "8px", display: "block", margin: "0 auto" },
1226
- children: useAutoCreate ? "→ Manual entry" : "← Auto-create with my account"
1227
- }
1228
- ),
1229
- /* @__PURE__ */ jsx(
1230
- ToggleButton,
1231
- {
1232
- type: "button",
1233
- onClick: () => {
1234
- setUseExistingKey(!useExistingKey);
1235
- if (!useExistingKey) setUseAutoCreate(false);
1236
- },
1237
- disabled: isCreating,
1238
- children: useExistingKey ? "← Create new license" : "Have a license key? →"
1239
- }
1240
- )
1241
- ] }),
1242
- /* @__PURE__ */ jsx(
1243
- Box,
1244
- {
1245
- background: "primary100",
1246
- padding: 4,
1247
- style: {
1248
- borderRadius: "8px",
1249
- border: "2px solid rgba(14, 165, 233, 0.3)",
1250
- width: "100%"
1251
- },
1252
- children: /* @__PURE__ */ jsx(Typography, { variant: "omega", style: { fontSize: "13px", lineHeight: "1.6" }, children: useExistingKey ? "Enter your email and license key to activate." : useAutoCreate && adminUser && adminUser.email ? `Click "Activate" to auto-create a license with your account (${adminUser.email})` : useAutoCreate ? 'Click "Activate" to auto-create a license with your admin account' : "A license will be created with the details below." })
1253
- }
1254
- ),
1255
- useExistingKey ? (
1256
- // Existing License Key Input
1257
- /* @__PURE__ */ jsxs(Fragment, { children: [
1258
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
1259
- /* @__PURE__ */ jsx(
1260
- Typography,
1261
- {
1262
- variant: "pi",
1263
- fontWeight: "bold",
1264
- style: { marginBottom: "8px", display: "block" },
1265
- children: "Email Address *"
1266
- }
1267
- ),
1268
- /* @__PURE__ */ jsx(
1269
- TextInput,
1270
- {
1271
- placeholder: "admin@example.com",
1272
- type: "email",
1273
- value: existingEmail,
1274
- onChange: (e) => setExistingEmail(e.target.value),
1275
- required: true,
1276
- disabled: isCreating
1277
- }
1278
- ),
1279
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { fontSize: "11px", marginTop: "4px" }, children: "Enter the email address associated with this license" })
1280
- ] }),
1281
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
1282
- /* @__PURE__ */ jsx(
1283
- Typography,
1284
- {
1285
- variant: "pi",
1286
- fontWeight: "bold",
1287
- style: { marginBottom: "8px", display: "block" },
1288
- children: "License Key *"
1289
- }
1290
- ),
1291
- /* @__PURE__ */ jsx(
1292
- TextInput,
1293
- {
1294
- placeholder: "67C5-40D2-7695-718C",
1295
- value: existingLicenseKey,
1296
- onChange: (e) => setExistingLicenseKey(e.target.value),
1297
- required: true,
1298
- disabled: isCreating
1299
- }
1300
- ),
1301
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { fontSize: "11px", marginTop: "4px" }, children: "Enter the license key in the format: XXXX-XXXX-XXXX-XXXX" })
1302
- ] })
1303
- ] })
1304
- ) : useAutoCreate && adminUser ? (
1305
- // Auto-create mode - Show user info
1306
- /* @__PURE__ */ jsxs(
1307
- Box,
1308
- {
1309
- background: "success100",
1310
- padding: 5,
1311
- style: {
1312
- borderRadius: "8px",
1313
- border: "2px solid rgba(34, 197, 94, 0.15)",
1314
- textAlign: "center"
1315
- },
1316
- children: [
1317
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: "Ready to activate with your account:" }),
1318
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, style: { marginBottom: "4px" }, children: [
1319
- /* @__PURE__ */ jsx(User, { fill: "neutral700", width: "14px", height: "14px" }),
1320
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", children: [
1321
- adminUser.firstname || "Admin",
1322
- " ",
1323
- adminUser.lastname || "User"
1324
- ] })
1325
- ] }),
1326
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, children: [
1327
- /* @__PURE__ */ jsx(Mail, { fill: "neutral600", width: "14px", height: "14px" }),
1328
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: adminUser.email || "Loading..." })
1329
- ] })
1330
- ]
1331
- }
1332
- )
1333
- ) : (
1334
- // Manual Create License Fields
1335
- /* @__PURE__ */ jsxs(Fragment, { children: [
1336
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
1337
- /* @__PURE__ */ jsx(
1338
- Typography,
1339
- {
1340
- variant: "pi",
1341
- fontWeight: "bold",
1342
- style: { marginBottom: "8px", display: "block" },
1343
- children: "Email Address *"
1344
- }
1345
- ),
1346
- /* @__PURE__ */ jsx(
1347
- TextInput,
1348
- {
1349
- placeholder: "admin@example.com",
1350
- type: "email",
1351
- value: formData.email,
1352
- onChange: (e) => setFormData({ ...formData, email: e.target.value }),
1353
- required: true,
1354
- disabled: isCreating
1355
- }
1356
- )
1357
- ] }),
1358
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
1359
- /* @__PURE__ */ jsx(
1360
- Typography,
1361
- {
1362
- variant: "pi",
1363
- fontWeight: "bold",
1364
- style: { marginBottom: "8px", display: "block" },
1365
- children: "First Name *"
1366
- }
1367
- ),
1368
- /* @__PURE__ */ jsx(
1369
- TextInput,
1370
- {
1371
- placeholder: "John",
1372
- value: formData.firstName,
1373
- onChange: (e) => setFormData({ ...formData, firstName: e.target.value }),
1374
- required: true,
1375
- disabled: isCreating
1376
- }
1377
- )
1378
- ] }),
1379
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
1380
- /* @__PURE__ */ jsx(
1381
- Typography,
1382
- {
1383
- variant: "pi",
1384
- fontWeight: "bold",
1385
- style: { marginBottom: "8px", display: "block" },
1386
- children: "Last Name *"
1387
- }
1388
- ),
1389
- /* @__PURE__ */ jsx(
1390
- TextInput,
1391
- {
1392
- placeholder: "Doe",
1393
- value: formData.lastName,
1394
- onChange: (e) => setFormData({ ...formData, lastName: e.target.value }),
1395
- required: true,
1396
- disabled: isCreating
1397
- }
1398
- )
1399
- ] })
1400
- ] })
1401
- ),
1402
- /* @__PURE__ */ jsx(Flex, { gap: 3, justifyContent: "center", style: { marginTop: "16px" }, children: useExistingKey ? /* @__PURE__ */ jsx(
1403
- Button,
1404
- {
1405
- type: "submit",
1406
- size: "L",
1407
- startIcon: /* @__PURE__ */ jsx(Check, {}),
1408
- loading: isCreating,
1409
- disabled: isCreating || !existingLicenseKey.trim() || !existingEmail.trim(),
1410
- style: {
1411
- background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1412
- color: "white",
1413
- fontWeight: "600",
1414
- border: "none",
1415
- boxShadow: "0 4px 12px rgba(102, 126, 234, 0.4)"
1416
- },
1417
- children: "Validate License"
1418
- }
1419
- ) : /* @__PURE__ */ jsx(
1420
- Button,
1421
- {
1422
- type: "submit",
1423
- size: "L",
1424
- startIcon: /* @__PURE__ */ jsx(Check, {}),
1425
- loading: isCreating,
1426
- disabled: isCreating || !useAutoCreate && (!formData.email || !formData.firstName || !formData.lastName),
1427
- style: {
1428
- background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
1429
- color: "white",
1430
- fontWeight: "600",
1431
- border: "none",
1432
- boxShadow: "0 4px 12px rgba(102, 126, 234, 0.4)"
1433
- },
1434
- children: useAutoCreate ? "Activate License" : "Create License"
1435
- }
1436
- ) })
1437
- ] })
1438
- }
1439
- ) })
1440
- ] }) });
1441
- }
1442
- return /* @__PURE__ */ jsx(Fragment, { children });
1443
- };
1444
- const App = () => {
1445
- return /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(HomePageModern, {}) });
1446
- };
1447
- export {
1448
- App as default
1449
- };