strapi-plugin-magic-mail 2.10.11 → 3.0.1

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 (27) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +28 -14
  3. package/dist/{_chunks/App-CInlcJMb.js → admin/App-BhDvUsMa.js} +97 -789
  4. package/dist/{_chunks/App-D4bFKNcg.mjs → admin/App-CjlxXCZb.mjs} +109 -801
  5. package/dist/{_chunks/PluginSettings-cZXE_vy8.js → admin/PluginSettings-Css2nHrB.js} +10 -4
  6. package/dist/{_chunks/PluginSettings-XwyzH95_.mjs → admin/PluginSettings-Duc_Y571.mjs} +10 -4
  7. package/dist/{_chunks/StyledButtons-CdOf4Sps.mjs → admin/StyledButtons-aq1EWrQ-.mjs} +1 -2
  8. package/dist/{_chunks/StyledButtons-DVGuFoqy.js → admin/StyledButtons-jHF7TXal.js} +1 -2
  9. package/dist/{_chunks/de-CF2ItE3Z.js → admin/de-DKEFnBGC.js} +0 -21
  10. package/dist/{_chunks/de-CwbYw2jT.mjs → admin/de-SKsLY2de.mjs} +0 -21
  11. package/dist/{_chunks/en-CK6UpShS.js → admin/en-CvtZE1HH.js} +0 -21
  12. package/dist/{_chunks/en-ZRmfU4qX.mjs → admin/en-Ds2Q7fue.mjs} +0 -21
  13. package/dist/{_chunks/es-DQHwzPpP.mjs → admin/es-BEvzLtTg.mjs} +20 -21
  14. package/dist/{_chunks/es-BpV1MIdm.js → admin/es-BbLLes3D.js} +20 -21
  15. package/dist/{_chunks/fr-BG1WfEVm.mjs → admin/fr-CRpwImX6.mjs} +20 -21
  16. package/dist/{_chunks/fr-vpziIpRp.js → admin/fr-nH9uN6s9.js} +20 -21
  17. package/dist/admin/index.js +6 -44
  18. package/dist/admin/index.mjs +4 -43
  19. package/dist/{_chunks/pt-CMoGrOib.mjs → admin/pt-CjOe2N_n.mjs} +20 -21
  20. package/dist/{_chunks/pt-ODpAhDNa.js → admin/pt-qt_48NxL.js} +20 -21
  21. package/dist/server/index.js +8052 -17573
  22. package/dist/server/index.mjs +8079 -17578
  23. package/package.json +40 -27
  24. package/dist/_chunks/LicensePage-B61HnhyD.mjs +0 -352
  25. package/dist/_chunks/LicensePage-sB-xDRL9.js +0 -354
  26. package/dist/_chunks/Settings-BRFoD1yZ.js +0 -354
  27. package/dist/_chunks/Settings-DoSrZKfp.mjs +0 -352
@@ -3,10 +3,10 @@ import React, { useRef, useEffect, useState, useCallback } from "react";
3
3
  import { useNavigate, useLocation } from "react-router-dom";
4
4
  import { Modal, Typography, Flex, Box, Field, TextInput, Alert, Textarea, NumberInput, Divider, Toggle, Badge, Button, Loader, SingleSelect, SingleSelectOption, Thead, Tr, Th, Tbody, Td, Table, Tabs, Accordion } from "@strapi/design-system";
5
5
  import { useFetchClient, useNotification, Page } from "@strapi/strapi/admin";
6
- import { EnvelopeIcon, ServerIcon, SparklesIcon, PlusIcon, PencilIcon, PlayIcon, TrashIcon, MagnifyingGlassIcon, FunnelIcon, CheckIcon, Cog6ToothIcon, DocumentTextIcon, ChartBarIcon, BoltIcon, CheckCircleIcon, ArrowUpTrayIcon, ArrowDownTrayIcon, DocumentArrowDownIcon, CodeBracketIcon, DocumentDuplicateIcon, PaperAirplaneIcon, ClipboardDocumentIcon, ArrowLeftIcon, ClockIcon, XMarkIcon, ArrowUturnLeftIcon, EnvelopeOpenIcon, CursorArrowRaysIcon, ExclamationTriangleIcon, XCircleIcon, KeyIcon, ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
6
+ import { EnvelopeIcon, ServerIcon, SparklesIcon, PlusIcon, PencilIcon, PlayIcon, TrashIcon, MagnifyingGlassIcon, FunnelIcon, CheckIcon, Cog6ToothIcon, DocumentTextIcon, ChartBarIcon, CheckCircleIcon, ArrowUpTrayIcon, ArrowDownTrayIcon, DocumentArrowDownIcon, CodeBracketIcon, DocumentDuplicateIcon, BoltIcon, PaperAirplaneIcon, ClipboardDocumentIcon, ArrowLeftIcon, ClockIcon, XMarkIcon, ArrowUturnLeftIcon, EnvelopeOpenIcon, CursorArrowRaysIcon, ExclamationTriangleIcon, XCircleIcon, ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
7
7
  import styled, { css, keyframes } from "styled-components";
8
8
  import { Star, Mail, Server, Lock, Cog, Check, Cloud, Key, ArrowLeft, ArrowRight, ArrowClockwise, Play, Cross } from "@strapi/icons";
9
- import { T as TertiaryButton, G as GradientButton$1, C as CTAButton, I as IconButton, a as IconButtonPrimary, b as IconButtonDanger, S as SecondaryButton, c as IconButtonPurple, d as IconButtonSuccess, D as DangerButton } from "./StyledButtons-CdOf4Sps.mjs";
9
+ import { T as TertiaryButton, G as GradientButton, C as CTAButton, I as IconButton, a as IconButtonPrimary, b as IconButtonDanger, S as SecondaryButton, c as IconButtonPurple, d as IconButtonSuccess, D as DangerButton } from "./StyledButtons-aq1EWrQ-.mjs";
10
10
  import * as ReactEmailEditor from "react-email-editor";
11
11
  const useAuthRefresh = () => {
12
12
  const { get } = useFetchClient();
@@ -61,7 +61,7 @@ const theme$3 = {
61
61
  xl: "16px"
62
62
  }
63
63
  };
64
- const fadeIn$6 = keyframes`
64
+ const fadeIn$5 = keyframes`
65
65
  from {
66
66
  opacity: 0;
67
67
  transform: translateY(10px);
@@ -107,7 +107,7 @@ const StepHeader = styled(Box)`
107
107
  padding-bottom: 24px;
108
108
  margin-bottom: 32px;
109
109
  position: relative;
110
- animation: ${fadeIn$6} 0.4s ease;
110
+ animation: ${fadeIn$5} 0.4s ease;
111
111
 
112
112
  &::after {
113
113
  content: '';
@@ -202,7 +202,7 @@ const ProviderCategoryHeader = styled(Box)`
202
202
  align-items: center;
203
203
  gap: 12px;
204
204
  margin: 0 0 16px;
205
- animation: ${fadeIn$6} 0.4s ease;
205
+ animation: ${fadeIn$5} 0.4s ease;
206
206
 
207
207
  &::after {
208
208
  content: '';
@@ -344,7 +344,7 @@ const ProviderTagline = styled(Typography)`
344
344
  const InfoAlert = styled(Alert)`
345
345
  background: ${colors$1.primaryLight};
346
346
  border: 1px solid ${colors$1.primary}33;
347
- animation: ${fadeIn$6} 0.4s ease;
347
+ animation: ${fadeIn$5} 0.4s ease;
348
348
 
349
349
  svg {
350
350
  color: ${colors$1.primary};
@@ -1208,7 +1208,9 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
1208
1208
  Toggle,
1209
1209
  {
1210
1210
  checked: formData.secure,
1211
- onChange: () => handleChange("secure", !formData.secure)
1211
+ onChange: () => handleChange("secure", !formData.secure),
1212
+ onLabel: "Enabled",
1213
+ offLabel: "Disabled"
1212
1214
  }
1213
1215
  ),
1214
1216
  /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, style: { flex: 1 }, children: [
@@ -1842,7 +1844,9 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
1842
1844
  Toggle,
1843
1845
  {
1844
1846
  checked: formData.isActive,
1845
- onChange: () => handleChange("isActive", !formData.isActive)
1847
+ onChange: () => handleChange("isActive", !formData.isActive),
1848
+ onLabel: "Active",
1849
+ offLabel: "Inactive"
1846
1850
  }
1847
1851
  ) }),
1848
1852
  /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
@@ -1874,7 +1878,9 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
1874
1878
  Toggle,
1875
1879
  {
1876
1880
  checked: formData.isPrimary,
1877
- onChange: () => handleChange("isPrimary", !formData.isPrimary)
1881
+ onChange: () => handleChange("isPrimary", !formData.isPrimary),
1882
+ onLabel: "Primary",
1883
+ offLabel: "Off"
1878
1884
  }
1879
1885
  ) }),
1880
1886
  /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
@@ -1901,7 +1907,7 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
1901
1907
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
1902
1908
  /* @__PURE__ */ jsx(TertiaryButton, { onClick: onClose, children: "Cancel" }),
1903
1909
  currentStep < 4 ? /* @__PURE__ */ jsx(
1904
- GradientButton$1,
1910
+ GradientButton,
1905
1911
  {
1906
1912
  endIcon: /* @__PURE__ */ jsx(ArrowRight, {}),
1907
1913
  onClick: () => setCurrentStep(currentStep + 1),
@@ -1909,7 +1915,7 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
1909
1915
  children: "Continue"
1910
1916
  }
1911
1917
  ) : /* @__PURE__ */ jsx(
1912
- GradientButton$1,
1918
+ GradientButton,
1913
1919
  {
1914
1920
  onClick: handleSubmit,
1915
1921
  loading,
@@ -1922,7 +1928,7 @@ const AddAccountModal = ({ isOpen, onClose, onAccountAdded, editAccount = null }
1922
1928
  ] }) })
1923
1929
  ] }) });
1924
1930
  };
1925
- const fadeIn$5 = keyframes`
1931
+ const fadeIn$4 = keyframes`
1926
1932
  from { opacity: 0; transform: translateY(10px); }
1927
1933
  to { opacity: 1; transform: translateY(0); }
1928
1934
  `;
@@ -1950,7 +1956,7 @@ const breakpoints$3 = {
1950
1956
  mobile: "768px"
1951
1957
  };
1952
1958
  const Container$4 = styled(Box)`
1953
- ${css`animation: ${fadeIn$5} ${theme$3.transitions.slow};`}
1959
+ ${css`animation: ${fadeIn$4} ${theme$3.transitions.slow};`}
1954
1960
  min-height: 100vh;
1955
1961
  max-width: 1440px;
1956
1962
  margin: 0 auto;
@@ -2068,7 +2074,7 @@ const StatCard$3 = styled(Box)`
2068
2074
  position: relative;
2069
2075
  overflow: hidden;
2070
2076
  transition: all ${theme$3.transitions.normal};
2071
- ${css`animation: ${fadeIn$5} ${theme$3.transitions.slow} backwards;`}
2077
+ ${css`animation: ${fadeIn$4} ${theme$3.transitions.slow} backwards;`}
2072
2078
  animation-delay: ${(props) => props.$delay || "0s"};
2073
2079
  box-shadow: ${theme$3.shadows.sm};
2074
2080
  border: 1px solid rgba(128, 128, 128, 0.2);
@@ -2573,7 +2579,7 @@ const HomePage = () => {
2573
2579
  ] }) : /* @__PURE__ */ jsxs(AccountsContainer, { children: [
2574
2580
  /* @__PURE__ */ jsx(Box, { style: { marginBottom: theme$3.spacing.md }, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, children: [
2575
2581
  /* @__PURE__ */ jsx(Typography, { variant: "delta", textColor: "neutral700", style: { fontSize: "1.5rem", fontWeight: 600 }, children: "📧 Email Accounts" }),
2576
- /* @__PURE__ */ jsx(GradientButton$1, { startIcon: /* @__PURE__ */ jsx(PlusIcon, { style: { width: 16, height: 16 } }), onClick: () => setShowAddModal(true), children: "Add Account" })
2582
+ /* @__PURE__ */ jsx(GradientButton, { startIcon: /* @__PURE__ */ jsx(PlusIcon, { style: { width: 16, height: 16 } }), onClick: () => setShowAddModal(true), children: "Add Account" })
2577
2583
  ] }) }),
2578
2584
  /* @__PURE__ */ jsxs(FilterBar$3, { children: [
2579
2585
  /* @__PURE__ */ jsxs(SearchInputWrapper$2, { children: [
@@ -2912,7 +2918,7 @@ const TestEmailModal = ({ account, onClose, onTest }) => {
2912
2918
  /* @__PURE__ */ jsx(StyledModalFooter$1, { children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", style: { width: "100%" }, children: [
2913
2919
  /* @__PURE__ */ jsx(TertiaryButton, { onClick: onClose, children: "Cancel" }),
2914
2920
  testMode === "direct" ? /* @__PURE__ */ jsx(
2915
- GradientButton$1,
2921
+ GradientButton,
2916
2922
  {
2917
2923
  onClick: () => onTest(testEmail, { priority, type: emailType, unsubscribeUrl }),
2918
2924
  disabled: !testEmail || !testEmail.includes("@") || emailType === "marketing" && !unsubscribeUrl,
@@ -2920,7 +2926,7 @@ const TestEmailModal = ({ account, onClose, onTest }) => {
2920
2926
  children: "Send Test Email"
2921
2927
  }
2922
2928
  ) : /* @__PURE__ */ jsx(
2923
- GradientButton$1,
2929
+ GradientButton,
2924
2930
  {
2925
2931
  onClick: testStrapiService,
2926
2932
  disabled: !testEmail || !testEmail.includes("@"),
@@ -2956,7 +2962,7 @@ const theme$2 = {
2956
2962
  xl: "16px"
2957
2963
  }
2958
2964
  };
2959
- const fadeIn$4 = keyframes`
2965
+ const fadeIn$3 = keyframes`
2960
2966
  from { opacity: 0; transform: translateY(10px); }
2961
2967
  to { opacity: 1; transform: translateY(0); }
2962
2968
  `;
@@ -2984,7 +2990,7 @@ const breakpoints$2 = {
2984
2990
  mobile: "768px"
2985
2991
  };
2986
2992
  const Container$3 = styled(Box)`
2987
- ${css`animation: ${fadeIn$4} ${theme$2.transitions.slow};`}
2993
+ ${css`animation: ${fadeIn$3} ${theme$2.transitions.slow};`}
2988
2994
  min-height: 100vh;
2989
2995
  max-width: 1440px;
2990
2996
  margin: 0 auto;
@@ -3102,7 +3108,7 @@ const StatCard$2 = styled(Box)`
3102
3108
  position: relative;
3103
3109
  overflow: hidden;
3104
3110
  transition: all ${theme$2.transitions.normal};
3105
- ${css`animation: ${fadeIn$4} ${theme$2.transitions.slow} backwards;`}
3111
+ ${css`animation: ${fadeIn$3} ${theme$2.transitions.slow} backwards;`}
3106
3112
  animation-delay: ${(props) => props.$delay || "0s"};
3107
3113
  box-shadow: ${theme$2.shadows.sm};
3108
3114
  border: 1px solid rgba(128, 128, 128, 0.2);
@@ -3451,7 +3457,7 @@ const RoutingRulesPage = () => {
3451
3457
  ] }) : /* @__PURE__ */ jsxs(RulesContainer, { children: [
3452
3458
  /* @__PURE__ */ jsx(Box, { style: { marginBottom: theme$2.spacing.md }, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, children: [
3453
3459
  /* @__PURE__ */ jsx(Typography, { variant: "delta", textColor: "neutral700", style: { fontSize: "1.5rem", fontWeight: 600 }, children: "🎯 Routing Rules" }),
3454
- /* @__PURE__ */ jsx(GradientButton$1, { startIcon: /* @__PURE__ */ jsx(PlusIcon, { style: { width: 16, height: 16 } }), onClick: () => setShowModal(true), children: "Create Rule" })
3460
+ /* @__PURE__ */ jsx(GradientButton, { startIcon: /* @__PURE__ */ jsx(PlusIcon, { style: { width: 16, height: 16 } }), onClick: () => setShowModal(true), children: "Create Rule" })
3455
3461
  ] }) }),
3456
3462
  /* @__PURE__ */ jsxs(FilterBar$2, { children: [
3457
3463
  /* @__PURE__ */ jsxs(SearchInputWrapper$1, { children: [
@@ -3554,13 +3560,13 @@ const RoutingRulesPage = () => {
3554
3560
  /* @__PURE__ */ jsx(
3555
3561
  IconButtonDanger,
3556
3562
  {
3557
- onClick: () => deleteRule(rule.id, rule.name),
3563
+ onClick: () => deleteRule(rule.documentId || rule.id, rule.name),
3558
3564
  "aria-label": "Delete Rule",
3559
3565
  children: /* @__PURE__ */ jsx(TrashIcon, {})
3560
3566
  }
3561
3567
  )
3562
3568
  ] }) })
3563
- ] }, rule.id)) })
3569
+ ] }, rule.documentId || rule.id)) })
3564
3570
  ] }) }) : /* @__PURE__ */ jsx(Box, { padding: 8, style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Typography, { variant: "beta", textColor: "neutral600", children: "No rules found matching your filters" }) })
3565
3571
  ] }),
3566
3572
  (showModal || editingRule) && /* @__PURE__ */ jsx(
@@ -3600,7 +3606,7 @@ const RuleModal = ({ rule, accounts, onClose, onSave }) => {
3600
3606
  setLoading(true);
3601
3607
  try {
3602
3608
  if (isEditMode) {
3603
- await put(`/magic-mail/routing-rules/${rule.id}`, formData);
3609
+ await put(`/magic-mail/routing-rules/${rule.documentId || rule.id}`, formData);
3604
3610
  toggleNotification({
3605
3611
  type: "success",
3606
3612
  message: "Routing rule updated successfully"
@@ -3763,7 +3769,9 @@ const RuleModal = ({ rule, accounts, onClose, onSave }) => {
3763
3769
  Toggle,
3764
3770
  {
3765
3771
  checked: formData.whatsappFallback,
3766
- onChange: () => handleChange("whatsappFallback", !formData.whatsappFallback)
3772
+ onChange: () => handleChange("whatsappFallback", !formData.whatsappFallback),
3773
+ onLabel: "Enabled",
3774
+ offLabel: "Disabled"
3767
3775
  }
3768
3776
  ),
3769
3777
  /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
@@ -3807,7 +3815,9 @@ const RuleModal = ({ rule, accounts, onClose, onSave }) => {
3807
3815
  Toggle,
3808
3816
  {
3809
3817
  checked: formData.isActive,
3810
- onChange: () => handleChange("isActive", !formData.isActive)
3818
+ onChange: () => handleChange("isActive", !formData.isActive),
3819
+ onLabel: "Active",
3820
+ offLabel: "Inactive"
3811
3821
  }
3812
3822
  ),
3813
3823
  /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
@@ -3832,7 +3842,7 @@ const RuleModal = ({ rule, accounts, onClose, onSave }) => {
3832
3842
  /* @__PURE__ */ jsx(Modal.Footer, { children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "flex-end", gap: 2, style: { width: "100%" }, children: [
3833
3843
  /* @__PURE__ */ jsx(TertiaryButton, { onClick: onClose, children: "Cancel" }),
3834
3844
  /* @__PURE__ */ jsx(
3835
- GradientButton$1,
3845
+ GradientButton,
3836
3846
  {
3837
3847
  onClick: handleSubmit,
3838
3848
  loading,
@@ -3844,124 +3854,6 @@ const RuleModal = ({ rule, accounts, onClose, onSave }) => {
3844
3854
  ] }) })
3845
3855
  ] }) });
3846
3856
  };
3847
- const useLicense = () => {
3848
- const { get } = useFetchClient();
3849
- const [isPremium, setIsPremium] = useState(false);
3850
- const [isAdvanced, setIsAdvanced] = useState(false);
3851
- const [isEnterprise, setIsEnterprise] = useState(false);
3852
- const [loading, setLoading] = useState(true);
3853
- const [error, setError] = useState(null);
3854
- const [licenseData, setLicenseData] = useState(null);
3855
- useEffect(() => {
3856
- let mounted = true;
3857
- const fetchLicense = async () => {
3858
- if (mounted) {
3859
- await checkLicense();
3860
- }
3861
- };
3862
- fetchLicense();
3863
- const interval = setInterval(() => {
3864
- if (mounted) {
3865
- checkLicense(true);
3866
- }
3867
- }, 60 * 60 * 1e3);
3868
- return () => {
3869
- mounted = false;
3870
- clearInterval(interval);
3871
- };
3872
- }, []);
3873
- const checkLicense = async (silent = false) => {
3874
- if (!silent) {
3875
- setLoading(true);
3876
- }
3877
- try {
3878
- const response = await get("/magic-mail/license/status");
3879
- const isValid = response.data?.valid || false;
3880
- const hasPremiumFeature = response.data?.data?.features?.premium || false;
3881
- const hasAdvancedFeature = response.data?.data?.features?.advanced || false;
3882
- const hasEnterpriseFeature = response.data?.data?.features?.enterprise || false;
3883
- setIsPremium(isValid && hasPremiumFeature);
3884
- setIsAdvanced(isValid && hasAdvancedFeature);
3885
- setIsEnterprise(isValid && hasEnterpriseFeature);
3886
- setLicenseData(response.data?.data || null);
3887
- setError(null);
3888
- } catch (err) {
3889
- if (err.name === "AbortError") {
3890
- return;
3891
- }
3892
- if (!silent) {
3893
- console.error("[MagicMail] License check error:", err);
3894
- }
3895
- setIsPremium(false);
3896
- setIsAdvanced(false);
3897
- setIsEnterprise(false);
3898
- setLicenseData(null);
3899
- setError(err);
3900
- } finally {
3901
- if (!silent) {
3902
- setLoading(false);
3903
- }
3904
- }
3905
- };
3906
- const hasFeature = (featureName) => {
3907
- if (!featureName) return false;
3908
- const freeFeatures = [
3909
- "basic-smtp",
3910
- "oauth-gmail",
3911
- "oauth-microsoft",
3912
- "oauth-yahoo",
3913
- "basic-routing",
3914
- "email-logging",
3915
- "account-testing",
3916
- "strapi-service-override",
3917
- "email-designer-basic"
3918
- ];
3919
- if (freeFeatures.includes(featureName)) return true;
3920
- const premiumFeatures = [
3921
- "email-designer-templates"
3922
- ];
3923
- if (premiumFeatures.includes(featureName) && isPremium) return true;
3924
- const advancedFeatures = [
3925
- "sendgrid",
3926
- "mailgun",
3927
- "dkim-signing",
3928
- "priority-headers",
3929
- "list-unsubscribe",
3930
- "security-validation",
3931
- "analytics-dashboard",
3932
- "advanced-routing",
3933
- "email-designer-versioning",
3934
- "email-designer-import-export"
3935
- ];
3936
- if (advancedFeatures.includes(featureName) && isAdvanced) return true;
3937
- const enterpriseFeatures = [
3938
- "multi-tenant",
3939
- "compliance-reports",
3940
- "custom-security-rules",
3941
- "priority-support",
3942
- "email-designer-custom-blocks",
3943
- "email-designer-team-library",
3944
- "email-designer-a-b-testing"
3945
- ];
3946
- if (enterpriseFeatures.includes(featureName) && isEnterprise) return true;
3947
- return false;
3948
- };
3949
- return {
3950
- isPremium,
3951
- isAdvanced,
3952
- isEnterprise,
3953
- loading,
3954
- error,
3955
- licenseData,
3956
- features: {
3957
- premium: isPremium,
3958
- advanced: isAdvanced,
3959
- enterprise: isEnterprise
3960
- },
3961
- hasFeature,
3962
- refetch: checkLicense
3963
- };
3964
- };
3965
3857
  const theme$1 = {
3966
3858
  shadows: {
3967
3859
  sm: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
@@ -3973,7 +3865,7 @@ const theme$1 = {
3973
3865
  spacing: { xs: "4px", sm: "8px", md: "16px", lg: "24px", xl: "32px", "2xl": "48px" },
3974
3866
  borderRadius: { md: "8px", lg: "12px", xl: "16px" }
3975
3867
  };
3976
- const fadeIn$3 = keyframes`
3868
+ const fadeIn$2 = keyframes`
3977
3869
  from { opacity: 0; transform: translateY(10px); }
3978
3870
  to { opacity: 1; transform: translateY(0); }
3979
3871
  `;
@@ -4127,7 +4019,7 @@ const CopyButton = styled(Button)`
4127
4019
  height: 14px;
4128
4020
  }
4129
4021
  `;
4130
- const InfoBox$2 = styled(Box)`
4022
+ const InfoBox$1 = styled(Box)`
4131
4023
  background: linear-gradient(135deg, ${"rgba(2, 132, 199, 0.06)"}, ${"rgba(2, 132, 199, 0.12)"});
4132
4024
  border-left: 4px solid ${"var(--colors-primary600, #0EA5E9)"};
4133
4025
  border-radius: 8px;
@@ -4144,37 +4036,12 @@ const WarningBox = styled(Box)`
4144
4036
  align-items: center;
4145
4037
  gap: 8px;
4146
4038
  `;
4147
- const LimitWarning = styled(Box)`
4148
- background: linear-gradient(135deg, ${"rgba(234, 179, 8, 0.06)"}, rgba(251, 191, 36, 0.1));
4149
- border: 1px solid rgba(234, 179, 8, 0.2);
4150
- border-radius: 12px;
4151
- padding: 16px;
4152
- margin-bottom: 24px;
4153
- display: flex;
4154
- align-items: center;
4155
- justify-content: space-between;
4156
- `;
4157
- const UpgradeButton = styled(Button)`
4158
- background: linear-gradient(135deg, ${"var(--colors-warning600, #F59E0B)"}, ${"var(--colors-warning600, #D97706)"});
4159
- color: white;
4160
- font-weight: 600;
4161
- padding: 8px 16px;
4162
- font-size: 13px;
4163
- display: inline-flex;
4164
- align-items: center;
4165
- gap: 6px;
4166
-
4167
- &:hover {
4168
- background: linear-gradient(135deg, ${"var(--colors-warning600, #D97706)"}, ${"var(--colors-warning600, #A16207)"});
4169
- transform: translateY(-1px);
4170
- }
4171
- `;
4172
4039
  const breakpoints$1 = {
4173
4040
  mobile: "768px",
4174
4041
  tablet: "1024px"
4175
4042
  };
4176
4043
  const Container$2 = styled(Box)`
4177
- ${css`animation: ${fadeIn$3} ${theme$1.transitions.slow};`}
4044
+ ${css`animation: ${fadeIn$2} ${theme$1.transitions.slow};`}
4178
4045
  min-height: 100vh;
4179
4046
  max-width: 1440px;
4180
4047
  margin: 0 auto;
@@ -4287,7 +4154,7 @@ const StatCard$1 = styled(Box)`
4287
4154
  position: relative;
4288
4155
  overflow: hidden;
4289
4156
  transition: all ${theme$1.transitions.normal};
4290
- ${css`animation: ${fadeIn$3} ${theme$1.transitions.slow} backwards;`}
4157
+ ${css`animation: ${fadeIn$2} ${theme$1.transitions.slow} backwards;`}
4291
4158
  animation-delay: ${(props) => props.$delay || "0s"};
4292
4159
  box-shadow: ${theme$1.shadows.sm};
4293
4160
  border: 1px solid rgba(128, 128, 128, 0.2);
@@ -4482,9 +4349,9 @@ const PaginationWrapper = styled(Flex)`
4482
4349
  border-radius: 0 0 ${theme$1.borderRadius.lg} ${theme$1.borderRadius.lg};
4483
4350
  `;
4484
4351
  const PaginationButton = styled.button`
4485
- background: ${(props) => props.active ? "linear-gradient(135deg, var(--colors-primary600, #0EA5E9) 0%, var(--colors-secondary500, #A855F7) 100%)" : "${(p) => p.theme.colors.neutral0}"};
4486
- color: ${(props) => props.active ? "white" : "var(--colors-neutral700)"};
4487
- border: 1px solid ${(props) => props.active ? "transparent" : "rgba(128, 128, 128, 0.3)"};
4352
+ background: ${(props) => props.$active ? "linear-gradient(135deg, var(--colors-primary600, #0EA5E9) 0%, var(--colors-secondary500, #A855F7) 100%)" : props.theme.colors.neutral0};
4353
+ color: ${(props) => props.$active ? "white" : "var(--colors-neutral700)"};
4354
+ border: 1px solid ${(props) => props.$active ? "transparent" : "rgba(128, 128, 128, 0.3)"};
4488
4355
  padding: 6px 12px;
4489
4356
  min-width: 36px;
4490
4357
  height: 36px;
@@ -4495,8 +4362,8 @@ const PaginationButton = styled.button`
4495
4362
  transition: all 0.2s ease;
4496
4363
 
4497
4364
  &:hover:not(:disabled) {
4498
- background: ${(props) => props.active ? "linear-gradient(135deg, var(--colors-primary700, #0284C7) 0%, var(--colors-secondary600, #9333EA) 100%)" : "var(--colors-neutral100)"};
4499
- border-color: ${(props) => props.active ? "transparent" : "rgba(128, 128, 128, 0.4)"};
4365
+ background: ${(props) => props.$active ? "linear-gradient(135deg, var(--colors-primary700, #0284C7) 0%, var(--colors-secondary600, #9333EA) 100%)" : "var(--colors-neutral100)"};
4366
+ border-color: ${(props) => props.$active ? "transparent" : "rgba(128, 128, 128, 0.4)"};
4500
4367
  }
4501
4368
 
4502
4369
  &:disabled {
@@ -4716,7 +4583,6 @@ const TemplateList = () => {
4716
4583
  const { get, del, post } = useFetchClient();
4717
4584
  const { toggleNotification } = useNotification();
4718
4585
  const navigate = useNavigate();
4719
- useLicense();
4720
4586
  useAuthRefresh();
4721
4587
  const [templates, setTemplates] = useState([]);
4722
4588
  const [stats, setStats] = useState(null);
@@ -4726,7 +4592,6 @@ const TemplateList = () => {
4726
4592
  const [showCodeExample, setShowCodeExample] = useState(false);
4727
4593
  const [selectedTemplate, setSelectedTemplate] = useState(null);
4728
4594
  const [copiedCode, setCopiedCode] = useState(null);
4729
- const [limits, setLimits] = useState(null);
4730
4595
  const [showTestSendModal, setShowTestSendModal] = useState(false);
4731
4596
  const [testEmail, setTestEmail] = useState("");
4732
4597
  const [currentPage, setCurrentPage] = useState(1);
@@ -4748,7 +4613,6 @@ const TemplateList = () => {
4748
4613
  ];
4749
4614
  useEffect(() => {
4750
4615
  fetchData();
4751
- fetchLimits();
4752
4616
  fetchAccounts();
4753
4617
  }, []);
4754
4618
  const fetchData = async () => {
@@ -4766,24 +4630,6 @@ const TemplateList = () => {
4766
4630
  setLoading(false);
4767
4631
  }
4768
4632
  };
4769
- const fetchLimits = async () => {
4770
- try {
4771
- const response = await get("/magic-mail/license/limits");
4772
- console.log("[DEBUG] License limits response:", response.data);
4773
- try {
4774
- const debugResponse = await get("/magic-mail/license/debug");
4775
- console.log("[DEBUG] License debug data:", debugResponse.data);
4776
- } catch (debugError) {
4777
- console.error("[DEBUG] Failed to fetch debug data:", debugError);
4778
- }
4779
- setLimits({
4780
- ...response.data?.limits,
4781
- tier: response.data?.tier || "free"
4782
- });
4783
- } catch (error) {
4784
- console.error("Failed to fetch license limits:", error);
4785
- }
4786
- };
4787
4633
  const fetchAccounts = async () => {
4788
4634
  try {
4789
4635
  const response = await get("/magic-mail/accounts");
@@ -4827,38 +4673,6 @@ const TemplateList = () => {
4827
4673
  });
4828
4674
  }
4829
4675
  };
4830
- const getTierInfo = () => {
4831
- const tier = limits?.tier || "free";
4832
- const tierInfo = {
4833
- free: {
4834
- name: "FREE",
4835
- color: "neutral",
4836
- next: "PREMIUM",
4837
- nextTemplates: 50,
4838
- features: ["10 Templates", "1 Account", "Import/Export"]
4839
- },
4840
- premium: {
4841
- name: "PREMIUM",
4842
- color: "secondary",
4843
- next: "ADVANCED",
4844
- nextTemplates: 200,
4845
- features: ["50 Templates", "5 Accounts", "Versioning", "Basic Analytics"]
4846
- },
4847
- advanced: {
4848
- name: "ADVANCED",
4849
- color: "primary",
4850
- next: "ENTERPRISE",
4851
- nextTemplates: -1,
4852
- features: ["200 Templates", "Unlimited Accounts", "Advanced Analytics", "API Integrations"]
4853
- },
4854
- enterprise: {
4855
- name: "ENTERPRISE",
4856
- color: "warning",
4857
- features: ["Unlimited Everything", "Priority Support", "Custom Features", "SLA"]
4858
- }
4859
- };
4860
- return tierInfo[tier] || tierInfo.free;
4861
- };
4862
4676
  const fetchTemplates = async () => {
4863
4677
  try {
4864
4678
  const response = await get("/magic-mail/designer/templates");
@@ -4943,23 +4757,6 @@ const TemplateList = () => {
4943
4757
  setTimeout(() => setCopiedCode(null), 2e3);
4944
4758
  };
4945
4759
  const handleCreateTemplate = () => {
4946
- if (limits?.emailTemplates && !limits.emailTemplates.canCreate) {
4947
- const max = limits.emailTemplates.max;
4948
- let upgradeMessage = "";
4949
- if (max === 10) {
4950
- upgradeMessage = `You've reached the FREE tier limit of ${max} templates. Upgrade to PREMIUM for 50 templates, versioning, and more!`;
4951
- } else if (max === 50) {
4952
- upgradeMessage = `You've reached the PREMIUM tier limit of ${max} templates. Upgrade to ADVANCED for 200 templates and advanced features!`;
4953
- } else if (max === 200) {
4954
- upgradeMessage = `You've reached the ADVANCED tier limit of ${max} templates. Upgrade to ENTERPRISE for unlimited templates!`;
4955
- }
4956
- toggleNotification({
4957
- type: "warning",
4958
- title: "🚀 Time to Upgrade!",
4959
- message: upgradeMessage
4960
- });
4961
- return;
4962
- }
4963
4760
  navigate("/plugins/magic-mail/designer/new");
4964
4761
  };
4965
4762
  const handleExport = async () => {
@@ -4977,7 +4774,7 @@ const TemplateList = () => {
4977
4774
  } catch (error) {
4978
4775
  toggleNotification({
4979
4776
  type: "danger",
4980
- message: error.response?.data?.message || "Export failed"
4777
+ message: error.response?.data?.error?.message || error.response?.data?.message || "Export failed"
4981
4778
  });
4982
4779
  }
4983
4780
  };
@@ -5000,7 +4797,10 @@ const TemplateList = () => {
5000
4797
  fetchTemplates();
5001
4798
  fetchStats();
5002
4799
  } catch (error) {
5003
- toggleNotification({ type: "danger", message: "Import failed" });
4800
+ toggleNotification({
4801
+ type: "danger",
4802
+ message: error.response?.data?.error?.message || error.response?.data?.message || "Import failed"
4803
+ });
5004
4804
  }
5005
4805
  };
5006
4806
  const getCategoryBadge = (category) => {
@@ -5029,31 +4829,12 @@ const TemplateList = () => {
5029
4829
  /* @__PURE__ */ jsx(DocumentTextIcon, {}),
5030
4830
  "Email Templates"
5031
4831
  ] }) }),
5032
- stats && limits && /* @__PURE__ */ jsx(Subtitle$1, { variant: "epsilon", children: /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center", gap: "8px" }, children: [
5033
- /* @__PURE__ */ jsxs("span", { children: [
5034
- stats.total,
5035
- " template",
5036
- stats.total !== 1 ? "s" : "",
5037
- " created"
5038
- ] }),
5039
- /* @__PURE__ */ jsx("span", { style: { opacity: 0.8 }, children: "•" }),
5040
- !limits.emailTemplates.unlimited ? /* @__PURE__ */ jsxs("span", { style: {
5041
- background: "rgba(255, 255, 255, 0.2)",
5042
- padding: "2px 10px",
5043
- borderRadius: "12px",
5044
- fontWeight: "600"
5045
- }, children: [
5046
- limits.emailTemplates.max - limits.emailTemplates.current,
5047
- " of ",
5048
- limits.emailTemplates.max,
5049
- " slots remaining"
5050
- ] }) : /* @__PURE__ */ jsx("span", { style: {
5051
- background: "rgba(255, 255, 255, 0.2)",
5052
- padding: "2px 10px",
5053
- borderRadius: "12px",
5054
- fontWeight: "600"
5055
- }, children: "Unlimited templates" })
5056
- ] }) })
4832
+ stats && /* @__PURE__ */ jsx(Subtitle$1, { variant: "epsilon", children: /* @__PURE__ */ jsx("span", { style: { display: "inline-flex", alignItems: "center", gap: "8px" }, children: /* @__PURE__ */ jsxs("span", { children: [
4833
+ stats.total,
4834
+ " template",
4835
+ stats.total !== 1 ? "s" : "",
4836
+ " created"
4837
+ ] }) }) })
5057
4838
  ] }) }) }),
5058
4839
  /* @__PURE__ */ jsxs(StatsGrid$1, { children: [
5059
4840
  /* @__PURE__ */ jsxs(StatCard$1, { $delay: "0.1s", $color: "var(--colors-primary600, #0EA5E9)", children: [
@@ -5065,40 +4846,9 @@ const TemplateList = () => {
5065
4846
  /* @__PURE__ */ jsx(StatIcon$1, { className: "stat-icon", $bg: "rgba(22, 163, 74, 0.12)", $color: "var(--colors-success600, #16A34A)", children: /* @__PURE__ */ jsx(ChartBarIcon, {}) }),
5066
4847
  /* @__PURE__ */ jsx(StatValue$1, { className: "stat-value", variant: "alpha", children: showSkeleton ? "..." : stats?.active || 0 }),
5067
4848
  /* @__PURE__ */ jsx(StatLabel$1, { variant: "pi", children: "Active" })
5068
- ] }),
5069
- limits?.emailTemplates && !limits.emailTemplates.unlimited && /* @__PURE__ */ jsxs(StatCard$1, { $delay: "0.3s", $color: "var(--colors-warning600, #F59E0B)", children: [
5070
- /* @__PURE__ */ jsx(StatIcon$1, { className: "stat-icon", $bg: "rgba(234, 179, 8, 0.12)", $color: "var(--colors-warning600, #D97706)", children: /* @__PURE__ */ jsx(SparklesIcon, {}) }),
5071
- /* @__PURE__ */ jsx(StatValue$1, { className: "stat-value", variant: "alpha", children: showSkeleton ? "..." : limits.emailTemplates.max - limits.emailTemplates.current }),
5072
- /* @__PURE__ */ jsx(StatLabel$1, { variant: "pi", children: "Remaining" })
5073
4849
  ] })
5074
4850
  ] }),
5075
4851
  /* @__PURE__ */ jsx(Box, { style: { margin: "0 -32px 32px -32px" }, children: /* @__PURE__ */ jsx(Divider, {}) }),
5076
- limits?.emailTemplates && !limits.emailTemplates.unlimited && limits.emailTemplates.current >= limits.emailTemplates.max * 0.8 && /* @__PURE__ */ jsxs(LimitWarning, { children: [
5077
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 3, children: [
5078
- /* @__PURE__ */ jsx(SparklesIcon, { style: { width: 24, height: 24, color: "var(--colors-warning600, #D97706)" } }),
5079
- /* @__PURE__ */ jsxs(Box, { children: [
5080
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", children: limits.emailTemplates.current >= limits.emailTemplates.max ? `You've reached your ${getTierInfo().name} limit!` : `You're approaching your ${getTierInfo().name} limit!` }),
5081
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { marginTop: "4px" }, children: [
5082
- "Using ",
5083
- limits.emailTemplates.current,
5084
- " of ",
5085
- limits.emailTemplates.max,
5086
- " templates.",
5087
- getTierInfo().next && ` Upgrade to ${getTierInfo().next} for ${getTierInfo().nextTemplates === -1 ? "unlimited" : getTierInfo().nextTemplates} templates!`
5088
- ] })
5089
- ] })
5090
- ] }),
5091
- /* @__PURE__ */ jsxs(
5092
- UpgradeButton,
5093
- {
5094
- onClick: () => navigate("/admin/settings/magic-mail/upgrade"),
5095
- children: [
5096
- /* @__PURE__ */ jsx(BoltIcon, { style: { width: 16, height: 16, marginRight: "6px" } }),
5097
- "Upgrade Now"
5098
- ]
5099
- }
5100
- )
5101
- ] }),
5102
4852
  /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTab, onValueChange: setActiveTab, children: [
5103
4853
  /* @__PURE__ */ jsxs(Tabs.List, { children: [
5104
4854
  /* @__PURE__ */ jsx(Tabs.Trigger, { value: "customTemplates", children: "Custom Templates" }),
@@ -5175,7 +4925,7 @@ const TemplateList = () => {
5175
4925
  /* @__PURE__ */ jsx(SectionHeader, { children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, children: [
5176
4926
  /* @__PURE__ */ jsx(Typography, { variant: "delta", textColor: "neutral700", style: { fontSize: "1.5rem", fontWeight: 600 }, children: "Email Templates" }),
5177
4927
  /* @__PURE__ */ jsx(
5178
- GradientButton$1,
4928
+ GradientButton,
5179
4929
  {
5180
4930
  startIcon: /* @__PURE__ */ jsx(PlusIcon, { style: { width: 20, height: 20 } }),
5181
4931
  onClick: handleCreateTemplate,
@@ -5355,7 +5105,7 @@ const TemplateList = () => {
5355
5105
  return /* @__PURE__ */ jsx(
5356
5106
  PaginationButton,
5357
5107
  {
5358
- active: currentPage === pageNum,
5108
+ $active: currentPage === pageNum,
5359
5109
  onClick: () => setCurrentPage(pageNum),
5360
5110
  children: pageNum
5361
5111
  },
@@ -5392,7 +5142,6 @@ const TemplateList = () => {
5392
5142
  variant: "secondary",
5393
5143
  onClick: () => {
5394
5144
  setSearchTerm("");
5395
- setActiveCategory("all");
5396
5145
  },
5397
5146
  style: { marginTop: "20px" },
5398
5147
  children: "Clear Filters"
@@ -5444,7 +5193,7 @@ const TemplateList = () => {
5444
5193
  selectedTemplate.name
5445
5194
  ] }) }),
5446
5195
  /* @__PURE__ */ jsxs(ScrollableDialogBody, { children: [
5447
- /* @__PURE__ */ jsx(InfoBox$2, { style: { marginTop: 0, marginBottom: "20px" }, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "center", justifyContent: "space-between", children: [
5196
+ /* @__PURE__ */ jsx(InfoBox$1, { style: { marginTop: 0, marginBottom: "20px" }, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "center", justifyContent: "space-between", children: [
5448
5197
  /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { color: "var(--colors-primary600, #075985)" }, children: [
5449
5198
  /* @__PURE__ */ jsx("strong", { children: "Template ID:" }),
5450
5199
  " #",
@@ -5659,7 +5408,7 @@ const TemplateList = () => {
5659
5408
  /* @__PURE__ */ jsxs(StyledModalFooter, { children: [
5660
5409
  /* @__PURE__ */ jsx(TertiaryButton, { onClick: () => setShowTestSendModal(false), children: "Cancel" }),
5661
5410
  /* @__PURE__ */ jsx(
5662
- GradientButton$1,
5411
+ GradientButton,
5663
5412
  {
5664
5413
  onClick: sendTestEmail,
5665
5414
  startIcon: /* @__PURE__ */ jsx(PaperAirplaneIcon, { style: { width: 16, height: 16 } }),
@@ -6140,7 +5889,7 @@ const DeleteButton = styled(Button)`
6140
5889
  height: 14px;
6141
5890
  }
6142
5891
  `;
6143
- const CloseButton$1 = styled.button`
5892
+ const CloseButton = styled.button`
6144
5893
  background: none;
6145
5894
  border: none;
6146
5895
  cursor: pointer;
@@ -6184,7 +5933,6 @@ const EditorPage = () => {
6184
5933
  const { get, post, put } = useFetchClient();
6185
5934
  const { toggleNotification } = useNotification();
6186
5935
  const navigate = useNavigate();
6187
- const { hasFeature } = useLicense();
6188
5936
  const emailEditorRef = useRef(null);
6189
5937
  const pathname = location.pathname;
6190
5938
  const coreMatch = pathname.match(/\/designer\/core\/(.+)$/);
@@ -6208,7 +5956,6 @@ const EditorPage = () => {
6208
5956
  bodyText: "",
6209
5957
  tags: []
6210
5958
  });
6211
- const canVersion = hasFeature("email-designer-versioning");
6212
5959
  const [showVersionHistory, setShowVersionHistory] = useState(false);
6213
5960
  const [versions, setVersions] = useState([]);
6214
5961
  const [loadingVersions, setLoadingVersions] = useState(false);
@@ -6457,7 +6204,7 @@ const EditorPage = () => {
6457
6204
  } catch (error) {
6458
6205
  toggleNotification({
6459
6206
  type: "danger",
6460
- message: error.response?.data?.message || "Failed to save"
6207
+ message: error.response?.data?.error?.message || error.response?.data?.message || "Failed to save"
6461
6208
  });
6462
6209
  } finally {
6463
6210
  setSaving(false);
@@ -6512,7 +6259,7 @@ const EditorPage = () => {
6512
6259
  /* @__PURE__ */ jsx(BackButton, { onClick: () => navigate("/plugins/magic-mail/designer"), children: /* @__PURE__ */ jsx(ArrowLeftIcon, {}) }),
6513
6260
  /* @__PURE__ */ jsxs(TitleContainer, { children: [
6514
6261
  /* @__PURE__ */ jsx(Typography, { variant: "alpha", children: isCoreEmail ? `${coreEmailType === "reset-password" ? "Reset Password" : "Email Confirmation"}` : isNewTemplate ? "New Template" : `${templateData.name}` }),
6515
- canVersion && !isNewTemplate && !isCoreEmail && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Versioning enabled" }),
6262
+ !isNewTemplate && !isCoreEmail && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Versioning enabled" }),
6516
6263
  isCoreEmail && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: "Core Strapi Email Template" })
6517
6264
  ] })
6518
6265
  ] }),
@@ -6528,7 +6275,7 @@ const EditorPage = () => {
6528
6275
  /* @__PURE__ */ jsx(ArrowDownTrayIcon, {}),
6529
6276
  "Export Design"
6530
6277
  ] }),
6531
- !isCoreEmail && !isNewTemplate && canVersion && /* @__PURE__ */ jsxs(VersionButton, { onClick: handleOpenVersionHistory, children: [
6278
+ !isCoreEmail && !isNewTemplate && /* @__PURE__ */ jsxs(VersionButton, { onClick: handleOpenVersionHistory, children: [
6532
6279
  /* @__PURE__ */ jsx(ClockIcon, {}),
6533
6280
  "Version History"
6534
6281
  ] }),
@@ -6600,7 +6347,9 @@ const EditorPage = () => {
6600
6347
  Toggle,
6601
6348
  {
6602
6349
  checked: templateData.isActive,
6603
- onChange: () => setTemplateData({ ...templateData, isActive: !templateData.isActive })
6350
+ onChange: () => setTemplateData({ ...templateData, isActive: !templateData.isActive }),
6351
+ onLabel: "Active",
6352
+ offLabel: "Inactive"
6604
6353
  }
6605
6354
  ),
6606
6355
  /* @__PURE__ */ jsx(Typography, { variant: "omega", children: templateData.isActive ? "Active" : "Inactive" })
@@ -6835,7 +6584,7 @@ const EditorPage = () => {
6835
6584
  children: "Delete All"
6836
6585
  }
6837
6586
  ),
6838
- /* @__PURE__ */ jsx(CloseButton$1, { onClick: () => setShowVersionHistory(false), children: /* @__PURE__ */ jsx(XMarkIcon, {}) })
6587
+ /* @__PURE__ */ jsx(CloseButton, { onClick: () => setShowVersionHistory(false), children: /* @__PURE__ */ jsx(XMarkIcon, {}) })
6839
6588
  ] })
6840
6589
  ] }),
6841
6590
  /* @__PURE__ */ jsx(VersionModalContent, { children: loadingVersions ? /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx(Loader, {}) }) : versions.length === 0 ? /* @__PURE__ */ jsxs(EmptyVersions, { children: [
@@ -6898,7 +6647,7 @@ const theme = {
6898
6647
  spacing: { xs: "4px", sm: "8px", md: "16px", lg: "24px", xl: "32px", "2xl": "48px" },
6899
6648
  borderRadius: { lg: "12px", xl: "16px" }
6900
6649
  };
6901
- const fadeIn$2 = keyframes`
6650
+ const fadeIn$1 = keyframes`
6902
6651
  from { opacity: 0; transform: translateY(10px); }
6903
6652
  to { opacity: 1; transform: translateY(0); }
6904
6653
  `;
@@ -6914,7 +6663,7 @@ const breakpoints = {
6914
6663
  mobile: "768px"
6915
6664
  };
6916
6665
  const Container = styled(Box)`
6917
- ${css`animation: ${fadeIn$2} ${theme.transitions.slow};`}
6666
+ ${css`animation: ${fadeIn$1} ${theme.transitions.slow};`}
6918
6667
  min-height: 100vh;
6919
6668
  max-width: 1440px;
6920
6669
  margin: 0 auto;
@@ -7027,7 +6776,7 @@ const StatCard = styled(Box)`
7027
6776
  position: relative;
7028
6777
  overflow: hidden;
7029
6778
  transition: all ${theme.transitions.normal};
7030
- ${css`animation: ${fadeIn$2} ${theme.transitions.slow} backwards;`}
6779
+ ${css`animation: ${fadeIn$1} ${theme.transitions.slow} backwards;`}
7031
6780
  animation-delay: ${(props) => props.$delay || "0s"};
7032
6781
  box-shadow: ${theme.shadows.sm};
7033
6782
  border: 1px solid rgba(128, 128, 128, 0.2);
@@ -7216,22 +6965,18 @@ const Analytics = () => {
7216
6965
  useAuthRefresh();
7217
6966
  const { get, del } = useFetchClient();
7218
6967
  const { toggleNotification } = useNotification();
7219
- const { hasFeature } = useLicense();
7220
6968
  const [loading, setLoading] = useState(true);
7221
6969
  const [stats, setStats] = useState(null);
7222
6970
  const [emailLogs, setEmailLogs] = useState([]);
6971
+ const [logsError, setLogsError] = useState(null);
6972
+ const [pagination, setPagination] = useState(null);
7223
6973
  const [searchTerm, setSearchTerm] = useState("");
7224
6974
  const [showClearDialog, setShowClearDialog] = useState(false);
7225
6975
  const [isDeleting, setIsDeleting] = useState(false);
7226
- const hasBasicAnalytics = hasFeature("email-logging");
7227
6976
  useEffect(() => {
7228
- if (hasBasicAnalytics) {
7229
- fetchAnalytics();
7230
- fetchEmailLogs();
7231
- } else {
7232
- setLoading(false);
7233
- }
7234
- }, [hasBasicAnalytics]);
6977
+ fetchAnalytics();
6978
+ fetchEmailLogs();
6979
+ }, []);
7235
6980
  const fetchAnalytics = async () => {
7236
6981
  try {
7237
6982
  const response = await get("/magic-mail/analytics/stats");
@@ -7248,10 +6993,17 @@ const Analytics = () => {
7248
6993
  const fetchEmailLogs = async () => {
7249
6994
  setLoading(true);
7250
6995
  try {
7251
- const response = await get("/magic-mail/analytics/emails?_limit=50&_sort=sentAt:DESC");
6996
+ const response = await get("/magic-mail/analytics/emails?page=1&pageSize=50");
7252
6997
  setEmailLogs(response.data?.data || []);
6998
+ setPagination(response.data?.pagination || null);
6999
+ setLogsError(null);
7253
7000
  } catch (error) {
7254
7001
  console.error("Failed to fetch email logs:", error);
7002
+ const message = error.response?.data?.error?.message || error.response?.data?.message || "Failed to load email logs";
7003
+ setEmailLogs([]);
7004
+ setPagination(null);
7005
+ setLogsError(message);
7006
+ toggleNotification({ type: "danger", message });
7255
7007
  } finally {
7256
7008
  setLoading(false);
7257
7009
  }
@@ -7290,29 +7042,6 @@ const Analytics = () => {
7290
7042
  const filteredLogs = emailLogs.filter(
7291
7043
  (log) => log.recipient?.toLowerCase().includes(searchTerm.toLowerCase()) || log.subject?.toLowerCase().includes(searchTerm.toLowerCase()) || log.templateName?.toLowerCase().includes(searchTerm.toLowerCase())
7292
7044
  );
7293
- if (!hasBasicAnalytics) {
7294
- return /* @__PURE__ */ jsxs(Container, { children: [
7295
- /* @__PURE__ */ jsx(Header, { children: /* @__PURE__ */ jsx(HeaderContent, { justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
7296
- /* @__PURE__ */ jsxs(Title, { variant: "alpha", children: [
7297
- /* @__PURE__ */ jsx(ChartBarIcon, {}),
7298
- "Email Analytics"
7299
- ] }),
7300
- /* @__PURE__ */ jsx(Subtitle, { variant: "epsilon", children: "Upgrade to Premium to unlock detailed email analytics and tracking" })
7301
- ] }) }) }),
7302
- /* @__PURE__ */ jsx(EmptyState, { children: /* @__PURE__ */ jsxs(EmptyContent, { children: [
7303
- /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(ChartBarIcon, {}) }),
7304
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: "Analytics Available in Premium" }),
7305
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { marginBottom: "32px", lineHeight: "1.6", display: "block" }, children: "Upgrade to Premium to unlock email analytics, tracking, open rates, click rates, and detailed reports about your email campaigns." }),
7306
- /* @__PURE__ */ jsx(
7307
- GradientButton$1,
7308
- {
7309
- onClick: () => window.location.href = "/admin/settings/magic-mail/upgrade",
7310
- children: "View Upgrade Plans"
7311
- }
7312
- )
7313
- ] }) })
7314
- ] });
7315
- }
7316
7045
  if (loading) {
7317
7046
  return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Loader, { children: "Loading analytics..." }) }) });
7318
7047
  }
@@ -7350,6 +7079,7 @@ const Analytics = () => {
7350
7079
  /* @__PURE__ */ jsxs(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral700", children: [
7351
7080
  "Recent Emails (",
7352
7081
  filteredLogs.length,
7082
+ pagination?.total ? ` of ${pagination.total}` : "",
7353
7083
  ")"
7354
7084
  ] }),
7355
7085
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
@@ -7374,7 +7104,11 @@ const Analytics = () => {
7374
7104
  )
7375
7105
  ] })
7376
7106
  ] }) }),
7377
- filteredLogs.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { children: /* @__PURE__ */ jsxs(EmptyContent, { children: [
7107
+ logsError ? /* @__PURE__ */ jsx(EmptyState, { children: /* @__PURE__ */ jsxs(EmptyContent, { children: [
7108
+ /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(ExclamationTriangleIcon, {}) }),
7109
+ /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: "Couldn't load email logs" }),
7110
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { lineHeight: "1.6", display: "block" }, children: logsError })
7111
+ ] }) }) : filteredLogs.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { children: /* @__PURE__ */ jsxs(EmptyContent, { children: [
7378
7112
  /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(EnvelopeIcon, {}) }),
7379
7113
  /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: searchTerm ? "No emails found" : "No emails sent yet" }),
7380
7114
  /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { lineHeight: "1.6", display: "block" }, children: searchTerm ? "Try adjusting your search terms" : "Send your first email to see analytics and tracking information here!" })
@@ -7451,7 +7185,7 @@ const Analytics = () => {
7451
7185
  ] }) })
7452
7186
  ] });
7453
7187
  };
7454
- const fadeIn$1 = keyframes`
7188
+ const fadeIn = keyframes`
7455
7189
  from {
7456
7190
  opacity: 0;
7457
7191
  transform: translateY(10px);
@@ -7495,7 +7229,7 @@ const PageContainer = styled(Box)`
7495
7229
  padding: 40px;
7496
7230
  max-width: 900px;
7497
7231
  margin: 0 auto;
7498
- animation: ${fadeIn$1} 0.4s ease;
7232
+ animation: ${fadeIn} 0.4s ease;
7499
7233
  `;
7500
7234
  const HeaderSection = styled(Box)`
7501
7235
  text-align: center;
@@ -7587,7 +7321,7 @@ const ContentCard = styled(Box)`
7587
7321
  border-radius: 16px;
7588
7322
  padding: 32px;
7589
7323
  margin-bottom: 24px;
7590
- animation: ${fadeIn$1} 0.4s ease;
7324
+ animation: ${fadeIn} 0.4s ease;
7591
7325
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
7592
7326
  `;
7593
7327
  const QRCodeContainer = styled.div`
@@ -7657,7 +7391,7 @@ const ConnectedCard = styled(Box)`
7657
7391
  padding: 32px;
7658
7392
  text-align: center;
7659
7393
  `;
7660
- const InfoBox$1 = styled(Box)`
7394
+ const InfoBox = styled(Box)`
7661
7395
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.06) 0%, ${colors.whatsappLight} 100%);
7662
7396
  border: 1px solid rgba(2, 132, 199, 0.2);
7663
7397
  border-radius: 12px;
@@ -7773,7 +7507,7 @@ const AlertIcon = styled.div`
7773
7507
  font-weight: bold;
7774
7508
  flex-shrink: 0;
7775
7509
  `;
7776
- const SuccessBox$1 = styled(Box)`
7510
+ const SuccessBox = styled(Box)`
7777
7511
  background: rgba(22, 163, 74, 0.06);
7778
7512
  border: 1px solid rgba(22, 163, 74, 0.2);
7779
7513
  border-radius: 12px;
@@ -7793,7 +7527,7 @@ const SuccessIcon = styled.div`
7793
7527
  justify-content: center;
7794
7528
  flex-shrink: 0;
7795
7529
  `;
7796
- const WhatsAppButton = styled(GradientButton$1)`
7530
+ const WhatsAppButton = styled(GradientButton)`
7797
7531
  && {
7798
7532
  background: linear-gradient(135deg, ${colors.whatsapp} 0%, ${colors.whatsappDark} 100%) !important;
7799
7533
 
@@ -8034,7 +7768,7 @@ const WhatsAppPage = () => {
8034
7768
  currentStep === 1 && /* @__PURE__ */ jsxs(ContentCard, { children: [
8035
7769
  /* @__PURE__ */ jsx(Typography, { variant: "beta", fontWeight: "bold", style: { display: "block", marginBottom: "8px" }, children: "Check Installation" }),
8036
7770
  /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { display: "block", marginBottom: "24px" }, children: "First, we need to verify that the required dependencies are installed." }),
8037
- isAvailable ? /* @__PURE__ */ jsxs(SuccessBox$1, { children: [
7771
+ isAvailable ? /* @__PURE__ */ jsxs(SuccessBox, { children: [
8038
7772
  /* @__PURE__ */ jsx(SuccessIcon, { children: /* @__PURE__ */ jsx(Check, { style: { width: 14, height: 14 } }) }),
8039
7773
  /* @__PURE__ */ jsxs(Box, { children: [
8040
7774
  /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", style: { display: "block", marginBottom: "4px", color: "var(--colors-success600, #15803D)" }, children: "Dependencies Installed" }),
@@ -8072,7 +7806,7 @@ const WhatsAppPage = () => {
8072
7806
  }
8073
7807
  ),
8074
7808
  /* @__PURE__ */ jsx(
8075
- GradientButton$1,
7809
+ GradientButton,
8076
7810
  {
8077
7811
  onClick: () => setCurrentStep(2),
8078
7812
  disabled: !isAvailable,
@@ -8085,7 +7819,7 @@ const WhatsAppPage = () => {
8085
7819
  currentStep === 2 && /* @__PURE__ */ jsxs(ContentCard, { children: [
8086
7820
  /* @__PURE__ */ jsx(Typography, { variant: "beta", fontWeight: "bold", style: { display: "block", marginBottom: "8px" }, children: "Connect Your WhatsApp" }),
8087
7821
  /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { display: "block", marginBottom: "24px" }, children: "Click the button below to start the connection process. A QR code will be generated for you to scan." }),
8088
- /* @__PURE__ */ jsxs(InfoBox$1, { children: [
7822
+ /* @__PURE__ */ jsxs(InfoBox, { children: [
8089
7823
  /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "16px", color: "var(--colors-primary600, #075985)" }, children: "How it works" }),
8090
7824
  /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
8091
7825
  /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral700", children: '1. Click "Connect WhatsApp" to generate a QR code' }),
@@ -8131,7 +7865,7 @@ const WhatsAppPage = () => {
8131
7865
  /* @__PURE__ */ jsx(SpinningLoader, { style: { width: "40px", height: "40px" } }),
8132
7866
  /* @__PURE__ */ jsx(Typography, { variant: "omega", children: "Generating QR code..." })
8133
7867
  ] }) }),
8134
- /* @__PURE__ */ jsxs(InfoBox$1, { children: [
7868
+ /* @__PURE__ */ jsxs(InfoBox, { children: [
8135
7869
  /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", style: { display: "block", marginBottom: "16px", color: "var(--colors-primary600, #075985)" }, children: "Instructions" }),
8136
7870
  /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
8137
7871
  /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral700", children: "1. Open WhatsApp on your phone" }),
@@ -8259,440 +7993,14 @@ await whatsapp.sendTemplateMessage('49123456789', 'welcome', {
8259
7993
  ] })
8260
7994
  ] });
8261
7995
  };
8262
- const fadeIn = keyframes`
8263
- from { opacity: 0; }
8264
- to { opacity: 1; }
8265
- `;
8266
- const slideUp = keyframes`
8267
- from {
8268
- opacity: 0;
8269
- transform: translateY(30px);
8270
- }
8271
- to {
8272
- opacity: 1;
8273
- transform: translateY(0);
8274
- }
8275
- `;
8276
- const ModalOverlay = styled.div`
8277
- position: fixed;
8278
- top: 0;
8279
- left: 0;
8280
- right: 0;
8281
- bottom: 0;
8282
- background: rgba(4, 28, 47, 0.85);
8283
- backdrop-filter: blur(8px);
8284
- z-index: 9999;
8285
- display: flex;
8286
- align-items: center;
8287
- justify-content: center;
8288
- animation: ${fadeIn} 0.3s ease-out;
8289
- padding: 20px;
8290
- `;
8291
- const ModalContent = styled(Box)`
8292
- background: ${(p) => p.theme.colors.neutral0};
8293
- border-radius: 16px;
8294
- width: 100%;
8295
- max-width: 580px;
8296
- box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
8297
- animation: ${slideUp} 0.4s cubic-bezier(0.4, 0, 0.2, 1);
8298
- overflow: hidden;
8299
- `;
8300
- const GradientHeader = styled(Box)`
8301
- background: linear-gradient(135deg, #4945ff 0%, #7c3aed 100%);
8302
- padding: 32px 40px;
8303
- position: relative;
8304
- overflow: hidden;
8305
-
8306
- &::before {
8307
- content: '';
8308
- position: absolute;
8309
- top: -50%;
8310
- right: -50%;
8311
- width: 200%;
8312
- height: 200%;
8313
- background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
8314
- }
8315
- `;
8316
- const IconWrapper = styled.div`
8317
- width: 72px;
8318
- height: 72px;
8319
- border-radius: 50%;
8320
- background: rgba(255, 255, 255, 0.2);
8321
- display: flex;
8322
- align-items: center;
8323
- justify-content: center;
8324
- margin: 0 auto 16px;
8325
- backdrop-filter: blur(10px);
8326
- border: 2px solid rgba(255, 255, 255, 0.3);
8327
-
8328
- svg {
8329
- width: 36px;
8330
- height: 36px;
8331
- color: white;
8332
- }
8333
- `;
8334
- const CloseButton = styled.button`
8335
- position: absolute;
8336
- top: 16px;
8337
- right: 16px;
8338
- background: rgba(255, 255, 255, 0.2);
8339
- border: 2px solid rgba(255, 255, 255, 0.3);
8340
- border-radius: 50%;
8341
- width: 36px;
8342
- height: 36px;
8343
- display: flex;
8344
- align-items: center;
8345
- justify-content: center;
8346
- cursor: pointer;
8347
- transition: all 0.2s;
8348
- z-index: 10;
8349
-
8350
- svg {
8351
- width: 20px;
8352
- height: 20px;
8353
- color: white;
8354
- }
8355
-
8356
- &:hover {
8357
- background: rgba(255, 255, 255, 0.3);
8358
- transform: scale(1.1);
8359
- }
8360
-
8361
- &:active {
8362
- transform: scale(0.95);
8363
- }
8364
- `;
8365
- const GradientButton = styled(Button)`
8366
- && {
8367
- background: linear-gradient(135deg, #4945ff 0%, #7c3aed 100%);
8368
- color: white;
8369
- font-weight: 600;
8370
- border: none;
8371
- box-shadow: 0 4px 12px rgba(73, 69, 255, 0.4);
8372
- padding: 12px 24px;
8373
- min-height: 44px;
8374
-
8375
- &:hover:not(:disabled) {
8376
- background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
8377
- box-shadow: 0 6px 16px rgba(73, 69, 255, 0.5);
8378
- }
8379
-
8380
- &:disabled {
8381
- opacity: 0.6;
8382
- cursor: not-allowed;
8383
- }
8384
- }
8385
- `;
8386
- styled(Button)`
8387
- && {
8388
- background: rgba(73, 69, 255, 0.06);
8389
- color: #4945ff;
8390
- font-weight: 600;
8391
- border: 2px solid #4945ff;
8392
- padding: 12px 24px;
8393
- min-height: 44px;
8394
-
8395
- &:hover:not(:disabled) {
8396
- background: rgba(73, 69, 255, 0.12);
8397
- }
8398
- }
8399
- `;
8400
- const ToggleButton = styled.button`
8401
- background: none;
8402
- border: none;
8403
- color: #4945ff;
8404
- font-size: 13px;
8405
- font-weight: 600;
8406
- cursor: pointer;
8407
- padding: 8px 0;
8408
- text-decoration: underline;
8409
- transition: color 0.2s;
8410
-
8411
- &:hover {
8412
- color: #7c3aed;
8413
- }
8414
-
8415
- &:disabled {
8416
- opacity: 0.5;
8417
- cursor: not-allowed;
8418
- }
8419
- `;
8420
- const InfoBox = styled(Box)`
8421
- background: rgba(73, 69, 255, 0.06);
8422
- border: 2px solid rgba(73, 69, 255, 0.3);
8423
- border-radius: 8px;
8424
- padding: 16px;
8425
- width: 100%;
8426
- `;
8427
- const SuccessBox = styled(Box)`
8428
- background: rgba(34, 197, 94, 0.06);
8429
- border: 2px solid rgba(34, 197, 94, 0.3);
8430
- border-radius: 8px;
8431
- padding: 20px;
8432
- text-align: center;
8433
- `;
8434
- const InfoText = styled(Typography)`
8435
- font-size: 13px;
8436
- line-height: 1.6;
8437
- color: ${(p) => p.theme.colors.neutral800};
8438
- `;
8439
- const LicenseGuard = ({ children }) => {
8440
- const { get, post } = useFetchClient();
8441
- const { toggleNotification } = useNotification();
8442
- const navigate = useNavigate();
8443
- useAuthRefresh();
8444
- const [isChecking, setIsChecking] = useState(true);
8445
- const [needsLicense, setNeedsLicense] = useState(false);
8446
- const [isCreating, setIsCreating] = useState(false);
8447
- const [useExistingKey, setUseExistingKey] = useState(false);
8448
- const [useAutoCreate, setUseAutoCreate] = useState(true);
8449
- const [existingLicenseKey, setExistingLicenseKey] = useState("");
8450
- const [existingEmail, setExistingEmail] = useState("");
8451
- const [adminUser, setAdminUser] = useState(null);
8452
- useEffect(() => {
8453
- checkLicenseStatus();
8454
- fetchAdminUser();
8455
- }, []);
8456
- const fetchAdminUser = async () => {
8457
- try {
8458
- const response = await get("/admin/users/me");
8459
- const userData = response.data?.data || response.data;
8460
- if (userData) {
8461
- setAdminUser(userData);
8462
- }
8463
- } catch (error) {
8464
- console.debug("[MagicMail] Could not fetch admin user");
8465
- }
8466
- };
8467
- const checkLicenseStatus = async () => {
8468
- setIsChecking(true);
8469
- try {
8470
- const response = await get("/magic-mail/license/status");
8471
- if (response.data.valid) {
8472
- setNeedsLicense(false);
8473
- } else {
8474
- setNeedsLicense(true);
8475
- }
8476
- } catch (error) {
8477
- console.error("[MagicMail] License check error:", error);
8478
- setNeedsLicense(true);
8479
- } finally {
8480
- setIsChecking(false);
8481
- }
8482
- };
8483
- const handleAutoCreateLicense = async (e) => {
8484
- e.preventDefault();
8485
- setIsCreating(true);
8486
- try {
8487
- const response = await post("/magic-mail/license/auto-create", {});
8488
- if (response.data && response.data.success) {
8489
- toggleNotification({
8490
- type: "success",
8491
- message: "✅ License created! Reloading..."
8492
- });
8493
- setNeedsLicense(false);
8494
- setTimeout(() => {
8495
- window.location.reload();
8496
- }, 500);
8497
- } else {
8498
- throw new Error("Failed to auto-create license");
8499
- }
8500
- } catch (error) {
8501
- console.error("[MagicMail] Error:", error);
8502
- toggleNotification({
8503
- type: "danger",
8504
- message: "Failed to create license. Try manual entry."
8505
- });
8506
- setIsCreating(false);
8507
- setUseAutoCreate(false);
8508
- }
8509
- };
8510
- const handleValidateExistingKey = async (e) => {
8511
- e.preventDefault();
8512
- if (!existingLicenseKey.trim() || !existingEmail.trim()) {
8513
- toggleNotification({
8514
- type: "warning",
8515
- message: "Please enter both license key and email address"
8516
- });
8517
- return;
8518
- }
8519
- setIsCreating(true);
8520
- try {
8521
- const response = await post("/magic-mail/license/store-key", {
8522
- licenseKey: existingLicenseKey.trim(),
8523
- email: existingEmail.trim()
8524
- });
8525
- if (response.data && response.data.success) {
8526
- toggleNotification({
8527
- type: "success",
8528
- message: "✅ License activated! Reloading..."
8529
- });
8530
- setNeedsLicense(false);
8531
- setTimeout(() => {
8532
- window.location.reload();
8533
- }, 500);
8534
- } else {
8535
- throw new Error("Invalid license");
8536
- }
8537
- } catch (error) {
8538
- toggleNotification({
8539
- type: "danger",
8540
- message: "Invalid license key or email address"
8541
- });
8542
- setIsCreating(false);
8543
- }
8544
- };
8545
- const handleClose = () => {
8546
- navigate("/content-manager");
8547
- };
8548
- if (isChecking) {
8549
- return /* @__PURE__ */ jsx(Box, { padding: 8, style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Loader, { children: "Checking license..." }) });
8550
- }
8551
- if (needsLicense) {
8552
- return /* @__PURE__ */ jsx(ModalOverlay, { children: /* @__PURE__ */ jsxs(ModalContent, { children: [
8553
- /* @__PURE__ */ jsxs(GradientHeader, { children: [
8554
- /* @__PURE__ */ jsx(CloseButton, { onClick: handleClose, type: "button", children: /* @__PURE__ */ jsx(XMarkIcon, {}) }),
8555
- /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(KeyIcon, {}) }),
8556
- /* @__PURE__ */ jsxs(Box, { style: { textAlign: "center", position: "relative" }, children: [
8557
- /* @__PURE__ */ jsx(
8558
- Typography,
8559
- {
8560
- variant: "alpha",
8561
- style: {
8562
- color: "white",
8563
- fontSize: "24px",
8564
- fontWeight: "700",
8565
- marginBottom: "12px",
8566
- display: "block"
8567
- },
8568
- children: "🔐 Activate MagicMail"
8569
- }
8570
- ),
8571
- /* @__PURE__ */ jsx(
8572
- Typography,
8573
- {
8574
- variant: "epsilon",
8575
- style: {
8576
- color: "rgba(255, 255, 255, 0.9)",
8577
- fontSize: "14px",
8578
- display: "block"
8579
- },
8580
- children: useExistingKey ? "Enter your existing license key" : "Create a license to start using the plugin"
8581
- }
8582
- )
8583
- ] })
8584
- ] }),
8585
- /* @__PURE__ */ jsx("form", { onSubmit: useExistingKey ? handleValidateExistingKey : handleAutoCreateLicense, children: /* @__PURE__ */ jsx(Box, { padding: 6, paddingLeft: 8, paddingRight: 8, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 5, style: { width: "100%" }, children: [
8586
- /* @__PURE__ */ jsx(Box, { style: { textAlign: "center", width: "100%" }, children: /* @__PURE__ */ jsx(
8587
- ToggleButton,
8588
- {
8589
- type: "button",
8590
- onClick: () => setUseExistingKey(!useExistingKey),
8591
- disabled: isCreating,
8592
- children: useExistingKey ? "← Create new license" : "Have a license key? →"
8593
- }
8594
- ) }),
8595
- /* @__PURE__ */ jsx(InfoBox, { children: /* @__PURE__ */ jsx(InfoText, { variant: "omega", children: useExistingKey ? "Enter your email and license key to activate." : adminUser && adminUser.email ? `Click "Activate" to auto-create a license with your account (${adminUser.email})` : 'Click "Activate" to auto-create a license with your admin account' }) }),
8596
- useExistingKey ? (
8597
- // Existing License Key Input
8598
- /* @__PURE__ */ jsxs(Fragment, { children: [
8599
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
8600
- /* @__PURE__ */ jsx(
8601
- Typography,
8602
- {
8603
- variant: "pi",
8604
- fontWeight: "bold",
8605
- style: { marginBottom: "8px", display: "block" },
8606
- children: "Email Address *"
8607
- }
8608
- ),
8609
- /* @__PURE__ */ jsx(
8610
- TextInput,
8611
- {
8612
- placeholder: "admin@example.com",
8613
- type: "email",
8614
- value: existingEmail,
8615
- onChange: (e) => setExistingEmail(e.target.value),
8616
- required: true,
8617
- disabled: isCreating
8618
- }
8619
- ),
8620
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { fontSize: "11px", marginTop: "4px" }, children: "Enter the email address associated with this license" })
8621
- ] }),
8622
- /* @__PURE__ */ jsxs(Box, { style: { width: "100%" }, children: [
8623
- /* @__PURE__ */ jsx(
8624
- Typography,
8625
- {
8626
- variant: "pi",
8627
- fontWeight: "bold",
8628
- style: { marginBottom: "8px", display: "block" },
8629
- children: "License Key *"
8630
- }
8631
- ),
8632
- /* @__PURE__ */ jsx(
8633
- TextInput,
8634
- {
8635
- placeholder: "MAGIC-MAIL-XXXX-XXXX-XXXX",
8636
- value: existingLicenseKey,
8637
- onChange: (e) => setExistingLicenseKey(e.target.value),
8638
- required: true,
8639
- disabled: isCreating
8640
- }
8641
- ),
8642
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { fontSize: "11px", marginTop: "4px" }, children: "Enter the license key" })
8643
- ] })
8644
- ] })
8645
- ) : adminUser ? (
8646
- // Auto-create mode - Show user info
8647
- /* @__PURE__ */ jsxs(SuccessBox, { children: [
8648
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: "Ready to activate with your account:" }),
8649
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", style: { marginBottom: "4px", display: "block" }, children: [
8650
- adminUser.firstname || "Admin",
8651
- " ",
8652
- adminUser.lastname || "User"
8653
- ] }),
8654
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: adminUser.email || "Loading..." })
8655
- ] })
8656
- ) : /* @__PURE__ */ jsxs(Box, { padding: 4, background: "neutral100", hasRadius: true, style: { textAlign: "center" }, children: [
8657
- /* @__PURE__ */ jsx(Loader, { small: true }),
8658
- /* @__PURE__ */ jsx(Typography, { variant: "pi", marginTop: 2, children: "Loading admin user data..." })
8659
- ] }),
8660
- /* @__PURE__ */ jsx(Flex, { gap: 3, justifyContent: "center", style: { marginTop: "16px" }, children: useExistingKey ? /* @__PURE__ */ jsx(
8661
- GradientButton,
8662
- {
8663
- type: "submit",
8664
- size: "L",
8665
- startIcon: /* @__PURE__ */ jsx(CheckIcon, { style: { width: 20, height: 20 } }),
8666
- loading: isCreating,
8667
- disabled: isCreating || !existingLicenseKey.trim() || !existingEmail.trim(),
8668
- children: "Validate License"
8669
- }
8670
- ) : /* @__PURE__ */ jsx(
8671
- GradientButton,
8672
- {
8673
- type: "submit",
8674
- size: "L",
8675
- startIcon: /* @__PURE__ */ jsx(CheckIcon, { style: { width: 20, height: 20 } }),
8676
- loading: isCreating,
8677
- disabled: isCreating || !adminUser,
8678
- children: "Activate License"
8679
- }
8680
- ) })
8681
- ] }) }) })
8682
- ] }) });
8683
- }
8684
- return /* @__PURE__ */ jsx(Fragment, { children });
8685
- };
8686
7996
  const pluginId = "magic-mail";
8687
7997
  const pluginPermissions = {
8688
7998
  access: [{ action: `plugin::${pluginId}.access`, subject: null }]
8689
7999
  };
8690
8000
  const App = () => {
8001
+ useAuthRefresh();
8691
8002
  const location = useLocation();
8692
8003
  const navigate = useNavigate();
8693
- const { hasFeature } = useLicense();
8694
- const hasEmailDesigner = hasFeature("email-designer-basic");
8695
- const hasAnalytics = hasFeature("email-logging");
8696
8004
  const isEditorRoute = /\/designer\/(new|\d+|core\/.+)/.test(location.pathname);
8697
8005
  const getActiveTab = () => {
8698
8006
  if (location.pathname.includes("/analytics")) return "analytics";
@@ -8711,9 +8019,9 @@ const App = () => {
8711
8019
  if (tab === "whatsapp") navigate("/plugins/magic-mail/whatsapp");
8712
8020
  };
8713
8021
  if (isEditorRoute) {
8714
- return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(EditorPage, {}) }) });
8022
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsx(EditorPage, {}) });
8715
8023
  }
8716
- return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsx(LicenseGuard, { children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTab, onValueChange: handleTabChange, children: [
8024
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions.access, children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTab, onValueChange: handleTabChange, children: [
8717
8025
  /* @__PURE__ */ jsxs(Tabs.List, { children: [
8718
8026
  /* @__PURE__ */ jsx(Tabs.Trigger, { value: "accounts", children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
8719
8027
  /* @__PURE__ */ jsx(EnvelopeIcon, { style: { width: 16, height: 16 } }),
@@ -8723,11 +8031,11 @@ const App = () => {
8723
8031
  /* @__PURE__ */ jsx(FunnelIcon, { style: { width: 16, height: 16 } }),
8724
8032
  "Routing Rules"
8725
8033
  ] }) }),
8726
- hasEmailDesigner && /* @__PURE__ */ jsx(Tabs.Trigger, { value: "templates", children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
8034
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "templates", children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
8727
8035
  /* @__PURE__ */ jsx(DocumentTextIcon, { style: { width: 16, height: 16 } }),
8728
8036
  "Email Templates"
8729
8037
  ] }) }),
8730
- hasAnalytics && /* @__PURE__ */ jsx(Tabs.Trigger, { value: "analytics", children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
8038
+ /* @__PURE__ */ jsx(Tabs.Trigger, { value: "analytics", children: /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
8731
8039
  /* @__PURE__ */ jsx(ChartBarIcon, { style: { width: 16, height: 16 } }),
8732
8040
  "Analytics"
8733
8041
  ] }) }),
@@ -8738,10 +8046,10 @@ const App = () => {
8738
8046
  ] }),
8739
8047
  /* @__PURE__ */ jsx(Tabs.Content, { value: "accounts", children: /* @__PURE__ */ jsx(HomePage, {}) }),
8740
8048
  /* @__PURE__ */ jsx(Tabs.Content, { value: "routing", children: /* @__PURE__ */ jsx(RoutingRulesPage, {}) }),
8741
- hasEmailDesigner && /* @__PURE__ */ jsx(Tabs.Content, { value: "templates", children: /* @__PURE__ */ jsx(TemplateList, {}) }),
8742
- hasAnalytics && /* @__PURE__ */ jsx(Tabs.Content, { value: "analytics", children: /* @__PURE__ */ jsx(Analytics, {}) }),
8049
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "templates", children: /* @__PURE__ */ jsx(TemplateList, {}) }),
8050
+ /* @__PURE__ */ jsx(Tabs.Content, { value: "analytics", children: /* @__PURE__ */ jsx(Analytics, {}) }),
8743
8051
  /* @__PURE__ */ jsx(Tabs.Content, { value: "whatsapp", children: /* @__PURE__ */ jsx(WhatsAppPage, {}) })
8744
- ] }) }) }) });
8052
+ ] }) }) });
8745
8053
  };
8746
8054
  export {
8747
8055
  App as default