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