Spaces:
Sleeping
feat(platform): BRIDGE Modules hub with /modules/e and /modules/s routed workspaces
Browse files- ModuleHub launcher at / with direct-launch cards for both modules
- ModuleShell launch guard: slow-motion random-reassembly of real dashboard
primitives (StatCard, GlassCard, StatusBadge, Recharts frame, list rows,
Skeleton), re-seeded every launch (mulberry32: Date.now ^ moduleId ^ seq)
- transform+opacity only, will-change hygiene, double-rAF start, chunk
preloading, prefers-reduced-motion instant reveal, reverse-assembly exit
- PlatformSidebar: BRIDGE MODULES direct-launch section + per-module nav
- Module S ported under src/modules/s (original design preserved; true-indigo
palette restored via scoped Tailwind v4 var overrides)
- ThemeContext: PROD_THEME palette engine; TopBar/Logo module-aware
- routes: /modules/{e,s}/**, legacy redirects, server /api/health
- tests: animation engine, routing, naming gates (26 passing)
- package-lock.json +0 -0
- package.json +1 -0
- server.ts +5 -0
- src/App.tsx +73 -35
- src/components/Logo.tsx +2 -4
- src/components/TopBar.tsx +25 -22
- src/context/ThemeContext.tsx +48 -15
- src/index.css +47 -1
- src/modules/LaunchContext.tsx +68 -0
- src/modules/ModuleHub.tsx +188 -0
- src/modules/ModuleLaunchAnimation.test.tsx +47 -0
- src/modules/ModuleLaunchAnimation.tsx +411 -0
- src/modules/ModuleShell.tsx +132 -0
- src/modules/PlatformSidebar.tsx +147 -0
- src/modules/lazyPages.tsx +77 -0
- src/modules/naming.test.ts +45 -0
- src/modules/registry.tsx +83 -0
- src/modules/routing.test.tsx +130 -0
- src/modules/s/components/AnimatedLogo.tsx +69 -0
- src/modules/s/components/GlassCard.tsx +15 -0
- src/modules/s/components/StatCard.tsx +149 -0
- src/modules/s/pages/Analytics.tsx +247 -0
- src/modules/s/pages/CampaignDetail.tsx +709 -0
- src/modules/s/pages/Campaigns.tsx +440 -0
- src/modules/s/pages/Clients.tsx +214 -0
- src/modules/s/pages/Dashboard.tsx +543 -0
- src/modules/s/pages/EmailAccounts.tsx +391 -0
- src/modules/s/pages/Inbox.tsx +303 -0
- src/modules/s/pages/Leads.tsx +618 -0
- src/modules/s/pages/Settings.tsx +434 -0
- src/modules/s/pages/Warmup.tsx +260 -0
- src/modules/s/pages/Webhooks.tsx +316 -0
- src/pages/Analytics.test.tsx +2 -2
- src/pages/CampaignDetail.tsx +1 -1
- src/pages/Dashboard.tsx +2 -2
- vite.config.ts +13 -0
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
@@ -49,6 +49,7 @@
|
|
| 49 |
"devDependencies": {
|
| 50 |
"@testing-library/dom": "^10.4.1",
|
| 51 |
"@testing-library/react": "^16.3.2",
|
|
|
|
| 52 |
"@types/cors": "^2.8.19",
|
| 53 |
"@types/dompurify": "^3.2.0",
|
| 54 |
"@types/express": "^5.0.6",
|
|
|
|
| 49 |
"devDependencies": {
|
| 50 |
"@testing-library/dom": "^10.4.1",
|
| 51 |
"@testing-library/react": "^16.3.2",
|
| 52 |
+
"@testing-library/user-event": "^14.6.8",
|
| 53 |
"@types/cors": "^2.8.19",
|
| 54 |
"@types/dompurify": "^3.2.0",
|
| 55 |
"@types/express": "^5.0.6",
|
|
@@ -501,6 +501,11 @@ async function startServer() {
|
|
| 501 |
res.json({ pong: true, timestamp: new Date().toISOString() });
|
| 502 |
});
|
| 503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
// Helper to check if real Smartlead API call should be attempted
|
| 505 |
const shouldProxyToSmartlead = (apiKey: string | undefined) => {
|
| 506 |
return Boolean(apiKey && apiKey.length > 10 && !apiKey.startsWith("demo_") && !apiKey.startsWith("mock_"));
|
|
|
|
| 501 |
res.json({ pong: true, timestamp: new Date().toISOString() });
|
| 502 |
});
|
| 503 |
|
| 504 |
+
// Platform health probe (carried over from Module S prod)
|
| 505 |
+
app.get("/api/health", (req, res) => {
|
| 506 |
+
res.json({ status: "ok", platform: "BRIDGE Modules", modules: ["e", "s"], timestamp: new Date().toISOString() });
|
| 507 |
+
});
|
| 508 |
+
|
| 509 |
// Helper to check if real Smartlead API call should be attempted
|
| 510 |
const shouldProxyToSmartlead = (apiKey: string | undefined) => {
|
| 511 |
return Boolean(apiKey && apiKey.length > 10 && !apiKey.startsWith("demo_") && !apiKey.startsWith("mock_"));
|
|
@@ -1,23 +1,17 @@
|
|
| 1 |
-
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
| 2 |
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
| 3 |
import { Toaster } from "react-hot-toast";
|
| 4 |
import { ApiKeyProvider } from "./context/ApiKeyContext";
|
| 5 |
import { ThemeProvider } from "./context/ThemeContext";
|
| 6 |
-
import
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
import
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
import Inbox from "./pages/Inbox";
|
| 16 |
-
import Webhooks from "./pages/Webhooks";
|
| 17 |
-
import Analytics from "./pages/Analytics";
|
| 18 |
-
import Clients from "./pages/Clients";
|
| 19 |
-
import Pricing from "./pages/Pricing";
|
| 20 |
-
import Settings from "./pages/Settings";
|
| 21 |
|
| 22 |
const queryClient = new QueryClient({
|
| 23 |
defaultOptions: {
|
|
@@ -29,30 +23,75 @@ const queryClient = new QueryClient({
|
|
| 29 |
},
|
| 30 |
});
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
export default function App() {
|
| 33 |
return (
|
| 34 |
<QueryClientProvider client={queryClient}>
|
| 35 |
<ThemeProvider>
|
| 36 |
<ApiKeyProvider>
|
| 37 |
<BrowserRouter>
|
| 38 |
-
<
|
| 39 |
-
<
|
| 40 |
-
<Route
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
<Route path="
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
</BrowserRouter>
|
| 55 |
-
<Toaster
|
| 56 |
position="bottom-right"
|
| 57 |
toastOptions={{
|
| 58 |
style: {
|
|
@@ -60,11 +99,10 @@ export default function App() {
|
|
| 60 |
color: '#fff',
|
| 61 |
border: '1px solid #27272a'
|
| 62 |
}
|
| 63 |
-
}}
|
| 64 |
/>
|
| 65 |
</ApiKeyProvider>
|
| 66 |
</ThemeProvider>
|
| 67 |
</QueryClientProvider>
|
| 68 |
);
|
| 69 |
}
|
| 70 |
-
|
|
|
|
| 1 |
+
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
|
| 2 |
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
| 3 |
import { Toaster } from "react-hot-toast";
|
| 4 |
import { ApiKeyProvider } from "./context/ApiKeyContext";
|
| 5 |
import { ThemeProvider } from "./context/ThemeContext";
|
| 6 |
+
import { LaunchProvider } from "./modules/LaunchContext";
|
| 7 |
+
import ModuleShell from "./modules/ModuleShell";
|
| 8 |
+
import ModuleHub from "./modules/ModuleHub";
|
| 9 |
+
import {
|
| 10 |
+
EDashboard, ECampaigns, ECampaignDetail, ELeads, EEmailAccounts, EWarmup,
|
| 11 |
+
EInbox, EWebhooks, EAnalytics, EClients, EPricing, ESettings,
|
| 12 |
+
SDashboard, SCampaigns, SCampaignDetail, SLeads, SEmailAccounts, SWarmup,
|
| 13 |
+
SInbox, SWebhooks, SAnalytics, SClients, SSettings,
|
| 14 |
+
} from "./modules/lazyPages";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
const queryClient = new QueryClient({
|
| 17 |
defaultOptions: {
|
|
|
|
| 23 |
},
|
| 24 |
});
|
| 25 |
|
| 26 |
+
/* Legacy deep links (pre-platform routes) redirect into Module E. */
|
| 27 |
+
const LEGACY_PATHS = [
|
| 28 |
+
"campaigns",
|
| 29 |
+
"leads",
|
| 30 |
+
"email-accounts",
|
| 31 |
+
"warmup",
|
| 32 |
+
"inbox",
|
| 33 |
+
"webhooks",
|
| 34 |
+
"analytics",
|
| 35 |
+
"clients",
|
| 36 |
+
"pricing",
|
| 37 |
+
"settings",
|
| 38 |
+
];
|
| 39 |
+
|
| 40 |
export default function App() {
|
| 41 |
return (
|
| 42 |
<QueryClientProvider client={queryClient}>
|
| 43 |
<ThemeProvider>
|
| 44 |
<ApiKeyProvider>
|
| 45 |
<BrowserRouter>
|
| 46 |
+
<LaunchProvider>
|
| 47 |
+
<Routes>
|
| 48 |
+
<Route path="/" element={<ModuleHub />} />
|
| 49 |
+
|
| 50 |
+
{/* Module E — mint GreenTheme workspace */}
|
| 51 |
+
<Route path="/modules/e" element={<ModuleShell module="e" />}>
|
| 52 |
+
<Route index element={<EDashboard />} />
|
| 53 |
+
<Route path="campaigns" element={<ECampaigns />} />
|
| 54 |
+
<Route path="campaigns/:id" element={<ECampaignDetail />} />
|
| 55 |
+
<Route path="leads" element={<ELeads />} />
|
| 56 |
+
<Route path="email-accounts" element={<EEmailAccounts />} />
|
| 57 |
+
<Route path="warmup" element={<EWarmup />} />
|
| 58 |
+
<Route path="inbox" element={<EInbox />} />
|
| 59 |
+
<Route path="webhooks" element={<EWebhooks />} />
|
| 60 |
+
<Route path="analytics" element={<EAnalytics />} />
|
| 61 |
+
<Route path="clients" element={<EClients />} />
|
| 62 |
+
<Route path="pricing" element={<EPricing />} />
|
| 63 |
+
<Route path="settings" element={<ESettings />} />
|
| 64 |
+
</Route>
|
| 65 |
+
|
| 66 |
+
{/* Module S — prod indigo workspace */}
|
| 67 |
+
<Route path="/modules/s" element={<ModuleShell module="s" />}>
|
| 68 |
+
<Route index element={<SDashboard />} />
|
| 69 |
+
<Route path="campaigns" element={<SCampaigns />} />
|
| 70 |
+
<Route path="campaigns/:id" element={<SCampaignDetail />} />
|
| 71 |
+
<Route path="leads" element={<SLeads />} />
|
| 72 |
+
<Route path="email-accounts" element={<SEmailAccounts />} />
|
| 73 |
+
<Route path="warmup" element={<SWarmup />} />
|
| 74 |
+
<Route path="inbox" element={<SInbox />} />
|
| 75 |
+
<Route path="webhooks" element={<SWebhooks />} />
|
| 76 |
+
<Route path="analytics" element={<SAnalytics />} />
|
| 77 |
+
<Route path="clients" element={<SClients />} />
|
| 78 |
+
<Route path="settings" element={<SSettings />} />
|
| 79 |
+
</Route>
|
| 80 |
+
|
| 81 |
+
{/* Legacy route compatibility */}
|
| 82 |
+
{LEGACY_PATHS.map((p) => (
|
| 83 |
+
<Route
|
| 84 |
+
key={p}
|
| 85 |
+
path={`/${p}`}
|
| 86 |
+
element={<Navigate to={`/modules/e/${p}`} replace />}
|
| 87 |
+
/>
|
| 88 |
+
))}
|
| 89 |
+
|
| 90 |
+
<Route path="*" element={<Navigate to="/" replace />} />
|
| 91 |
+
</Routes>
|
| 92 |
+
</LaunchProvider>
|
| 93 |
</BrowserRouter>
|
| 94 |
+
<Toaster
|
| 95 |
position="bottom-right"
|
| 96 |
toastOptions={{
|
| 97 |
style: {
|
|
|
|
| 99 |
color: '#fff',
|
| 100 |
border: '1px solid #27272a'
|
| 101 |
}
|
| 102 |
+
}}
|
| 103 |
/>
|
| 104 |
</ApiKeyProvider>
|
| 105 |
</ThemeProvider>
|
| 106 |
</QueryClientProvider>
|
| 107 |
);
|
| 108 |
}
|
|
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import { motion } from 'motion/react';
|
| 2 |
import { useTheme } from '../context/ThemeContext';
|
| 3 |
|
| 4 |
-
export default function Logo() {
|
| 5 |
const { config } = useTheme();
|
| 6 |
|
| 7 |
return (
|
|
@@ -12,7 +12,7 @@ export default function Logo() {
|
|
| 12 |
className="flex flex-col font-sans select-none"
|
| 13 |
>
|
| 14 |
<div className="text-sm font-bold tracking-[0.08em] text-white flex items-center">
|
| 15 |
-
BRIDGE<span style={{ color: config.accent }}>
|
| 16 |
</div>
|
| 17 |
<div className="text-[8px] font-bold tracking-[0.2em] text-zinc-500 uppercase -mt-0.5 font-mono">
|
| 18 |
Outbound Systems OS
|
|
@@ -20,5 +20,3 @@ export default function Logo() {
|
|
| 20 |
</motion.div>
|
| 21 |
);
|
| 22 |
}
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 1 |
import { motion } from 'motion/react';
|
| 2 |
import { useTheme } from '../context/ThemeContext';
|
| 3 |
|
| 4 |
+
export default function Logo({ wordmark = "ModuleE" }: { wordmark?: string }) {
|
| 5 |
const { config } = useTheme();
|
| 6 |
|
| 7 |
return (
|
|
|
|
| 12 |
className="flex flex-col font-sans select-none"
|
| 13 |
>
|
| 14 |
<div className="text-sm font-bold tracking-[0.08em] text-white flex items-center">
|
| 15 |
+
BRIDGE<span style={{ color: config.accent }}>{wordmark}</span>
|
| 16 |
</div>
|
| 17 |
<div className="text-[8px] font-bold tracking-[0.2em] text-zinc-500 uppercase -mt-0.5 font-mono">
|
| 18 |
Outbound Systems OS
|
|
|
|
| 20 |
</motion.div>
|
| 21 |
);
|
| 22 |
}
|
|
|
|
|
|
|
@@ -26,6 +26,7 @@ import { useTheme } from "../context/ThemeContext";
|
|
| 26 |
import { Link, useNavigate } from "react-router-dom";
|
| 27 |
import { useQuery } from "@tanstack/react-query";
|
| 28 |
import { apiClient } from "../lib/apiClient";
|
|
|
|
| 29 |
|
| 30 |
interface SearchItem {
|
| 31 |
title: string;
|
|
@@ -36,8 +37,10 @@ interface SearchItem {
|
|
| 36 |
detail?: string;
|
| 37 |
}
|
| 38 |
|
| 39 |
-
export default function TopBar({ onMenuClick }: { onMenuClick?: () => void }) {
|
| 40 |
const { apiKeys, activeKeyId, setActiveKeyId, activeKey } = useApiKey();
|
|
|
|
|
|
|
| 41 |
const { config } = useTheme();
|
| 42 |
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
| 43 |
const [searchQuery, setSearchQuery] = useState("");
|
|
@@ -94,44 +97,44 @@ export default function TopBar({ onMenuClick }: { onMenuClick?: () => void }) {
|
|
| 94 |
if (!isInput) {
|
| 95 |
if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "d") {
|
| 96 |
e.preventDefault();
|
| 97 |
-
navigate(
|
| 98 |
} else if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "i") {
|
| 99 |
e.preventDefault();
|
| 100 |
-
navigate("
|
| 101 |
} else if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "l") {
|
| 102 |
e.preventDefault();
|
| 103 |
-
navigate("
|
| 104 |
} else if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "c") {
|
| 105 |
e.preventDefault();
|
| 106 |
-
navigate("
|
| 107 |
}
|
| 108 |
}
|
| 109 |
};
|
| 110 |
|
| 111 |
window.addEventListener("keydown", handleKeyDown);
|
| 112 |
return () => window.removeEventListener("keydown", handleKeyDown);
|
| 113 |
-
}, [navigate]);
|
| 114 |
|
| 115 |
// Static navigation routes
|
| 116 |
const navItems: SearchItem[] = [
|
| 117 |
-
{ title:
|
| 118 |
-
{ title: "Unified Inbox", category: "Core Navigation", link: "
|
| 119 |
-
{ title: "Lead Intelligence", category: "Core Navigation", link: "
|
| 120 |
-
{ title: "Outbound Campaigns", category: "Core Navigation", link: "
|
| 121 |
-
{ title: "Email Accounts & Domains", category: "Core Navigation", link: "
|
| 122 |
-
{ title: "Autonomous Warmup Radar", category: "Core Navigation", link: "
|
| 123 |
-
{ title: "Deliverability Analytics", category: "Core Navigation", link: "
|
| 124 |
-
{ title: "Agency Clients", category: "Core Navigation", link: "
|
| 125 |
-
{ title: "Credits & Billing", category: "Core Navigation", link: "
|
| 126 |
-
{ title: "Webhook Dispatcher", category: "Core Navigation", link: "
|
| 127 |
-
{ title: "System Settings", category: "Core Navigation", link: "
|
| 128 |
];
|
| 129 |
|
| 130 |
// Dynamic items from backend APIs
|
| 131 |
const realCampaignItems: SearchItem[] = (Array.isArray(campaigns) ? campaigns : []).map((c: any) => ({
|
| 132 |
title: c.name || "Campaign",
|
| 133 |
category: "Campaigns",
|
| 134 |
-
link: `
|
| 135 |
icon: Megaphone,
|
| 136 |
detail: `${c.lead_count || 0} leads • ${c.sent_count || 0} sent`
|
| 137 |
}));
|
|
@@ -139,7 +142,7 @@ export default function TopBar({ onMenuClick }: { onMenuClick?: () => void }) {
|
|
| 139 |
const realLeadItems: SearchItem[] = (Array.isArray(leads) ? leads : []).slice(0, 8).map((l: any) => ({
|
| 140 |
title: `${l.first_name || ""} ${l.last_name || ""}`.trim() || l.email,
|
| 141 |
category: "Leads",
|
| 142 |
-
link: "
|
| 143 |
icon: Users,
|
| 144 |
detail: `${l.company_name || ""} • ${l.email || ""}`
|
| 145 |
}));
|
|
@@ -147,7 +150,7 @@ export default function TopBar({ onMenuClick }: { onMenuClick?: () => void }) {
|
|
| 147 |
const realInboxItems: SearchItem[] = (Array.isArray(emailAccounts) ? emailAccounts : []).map((e: any) => ({
|
| 148 |
title: e.email || "Email Account",
|
| 149 |
category: "Inboxes",
|
| 150 |
-
link: "
|
| 151 |
icon: Mail,
|
| 152 |
detail: `Status: ${e.status || "active"}`
|
| 153 |
}));
|
|
@@ -185,8 +188,8 @@ export default function TopBar({ onMenuClick }: { onMenuClick?: () => void }) {
|
|
| 185 |
<span className="text-zinc-500">SYSTEM</span>
|
| 186 |
<span className="text-zinc-700">/</span>
|
| 187 |
<span className="text-zinc-300 font-semibold tracking-wide flex items-center gap-1.5">
|
| 188 |
-
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse shadow-[
|
| 189 |
-
|
| 190 |
</span>
|
| 191 |
</div>
|
| 192 |
</div>
|
|
|
|
| 26 |
import { Link, useNavigate } from "react-router-dom";
|
| 27 |
import { useQuery } from "@tanstack/react-query";
|
| 28 |
import { apiClient } from "../lib/apiClient";
|
| 29 |
+
import { MODULES, ModuleId, moduleHref } from "../modules/registry";
|
| 30 |
|
| 31 |
interface SearchItem {
|
| 32 |
title: string;
|
|
|
|
| 37 |
detail?: string;
|
| 38 |
}
|
| 39 |
|
| 40 |
+
export default function TopBar({ onMenuClick, module = "e" }: { onMenuClick?: () => void; module?: ModuleId }) {
|
| 41 |
const { apiKeys, activeKeyId, setActiveKeyId, activeKey } = useApiKey();
|
| 42 |
+
const moduleDef = MODULES[module];
|
| 43 |
+
const base = moduleDef.basePath;
|
| 44 |
const { config } = useTheme();
|
| 45 |
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
| 46 |
const [searchQuery, setSearchQuery] = useState("");
|
|
|
|
| 97 |
if (!isInput) {
|
| 98 |
if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "d") {
|
| 99 |
e.preventDefault();
|
| 100 |
+
navigate(base);
|
| 101 |
} else if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "i") {
|
| 102 |
e.preventDefault();
|
| 103 |
+
navigate(moduleHref(module, "inbox"));
|
| 104 |
} else if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "l") {
|
| 105 |
e.preventDefault();
|
| 106 |
+
navigate(moduleHref(module, "leads"));
|
| 107 |
} else if (isCmdOrCtrl && e.shiftKey && e.key.toLowerCase() === "c") {
|
| 108 |
e.preventDefault();
|
| 109 |
+
navigate(moduleHref(module, "campaigns"));
|
| 110 |
}
|
| 111 |
}
|
| 112 |
};
|
| 113 |
|
| 114 |
window.addEventListener("keydown", handleKeyDown);
|
| 115 |
return () => window.removeEventListener("keydown", handleKeyDown);
|
| 116 |
+
}, [navigate, base, module]);
|
| 117 |
|
| 118 |
// Static navigation routes
|
| 119 |
const navItems: SearchItem[] = [
|
| 120 |
+
{ title: `${moduleDef.label} Dashboard`, category: "Core Navigation", link: base, icon: LayoutDashboard, shortcut: "⌘⇧D" },
|
| 121 |
+
{ title: "Unified Inbox", category: "Core Navigation", link: moduleHref(module, "inbox"), icon: Inbox, shortcut: "⌘⇧I" },
|
| 122 |
+
{ title: "Lead Intelligence", category: "Core Navigation", link: moduleHref(module, "leads"), icon: Users, shortcut: "⌘⇧L" },
|
| 123 |
+
{ title: "Outbound Campaigns", category: "Core Navigation", link: moduleHref(module, "campaigns"), icon: Megaphone, shortcut: "⌘⇧C" },
|
| 124 |
+
{ title: "Email Accounts & Domains", category: "Core Navigation", link: moduleHref(module, "email-accounts"), icon: Mail },
|
| 125 |
+
{ title: "Autonomous Warmup Radar", category: "Core Navigation", link: moduleHref(module, "warmup"), icon: Flame },
|
| 126 |
+
{ title: "Deliverability Analytics", category: "Core Navigation", link: moduleHref(module, "analytics"), icon: BarChart2 },
|
| 127 |
+
{ title: "Agency Clients", category: "Core Navigation", link: moduleHref(module, "clients"), icon: Building2 },
|
| 128 |
+
{ title: "Credits & Billing", category: "Core Navigation", link: moduleHref(module, "pricing"), icon: CreditCard },
|
| 129 |
+
{ title: "Webhook Dispatcher", category: "Core Navigation", link: moduleHref(module, "webhooks"), icon: Webhook },
|
| 130 |
+
{ title: "System Settings", category: "Core Navigation", link: moduleHref(module, "settings"), icon: Settings },
|
| 131 |
];
|
| 132 |
|
| 133 |
// Dynamic items from backend APIs
|
| 134 |
const realCampaignItems: SearchItem[] = (Array.isArray(campaigns) ? campaigns : []).map((c: any) => ({
|
| 135 |
title: c.name || "Campaign",
|
| 136 |
category: "Campaigns",
|
| 137 |
+
link: moduleHref(module, `campaigns/${c.id}`),
|
| 138 |
icon: Megaphone,
|
| 139 |
detail: `${c.lead_count || 0} leads • ${c.sent_count || 0} sent`
|
| 140 |
}));
|
|
|
|
| 142 |
const realLeadItems: SearchItem[] = (Array.isArray(leads) ? leads : []).slice(0, 8).map((l: any) => ({
|
| 143 |
title: `${l.first_name || ""} ${l.last_name || ""}`.trim() || l.email,
|
| 144 |
category: "Leads",
|
| 145 |
+
link: moduleHref(module, "leads"),
|
| 146 |
icon: Users,
|
| 147 |
detail: `${l.company_name || ""} • ${l.email || ""}`
|
| 148 |
}));
|
|
|
|
| 150 |
const realInboxItems: SearchItem[] = (Array.isArray(emailAccounts) ? emailAccounts : []).map((e: any) => ({
|
| 151 |
title: e.email || "Email Account",
|
| 152 |
category: "Inboxes",
|
| 153 |
+
link: moduleHref(module, "email-accounts"),
|
| 154 |
icon: Mail,
|
| 155 |
detail: `Status: ${e.status || "active"}`
|
| 156 |
}));
|
|
|
|
| 188 |
<span className="text-zinc-500">SYSTEM</span>
|
| 189 |
<span className="text-zinc-700">/</span>
|
| 190 |
<span className="text-zinc-300 font-semibold tracking-wide flex items-center gap-1.5">
|
| 191 |
+
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse shadow-[0_0_8px_var(--theme-accent,#00e5bc)]" />
|
| 192 |
+
{moduleDef.engineLabel}
|
| 193 |
</span>
|
| 194 |
</div>
|
| 195 |
</div>
|
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import React, { createContext, useContext, useEffect } from "react";
|
| 2 |
|
| 3 |
export interface ThemeConfig {
|
| 4 |
-
id: "mint";
|
| 5 |
code: string;
|
| 6 |
name: string;
|
| 7 |
accent: string;
|
|
@@ -54,35 +54,68 @@ export const MINT_THEME: ThemeConfig = {
|
|
| 54 |
description: "Autonomous outbound infrastructure with reputation shielding, multi-mailbox rotation, and live sequence telemetry.",
|
| 55 |
};
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
interface ThemeContextType {
|
| 58 |
-
theme: "mint";
|
| 59 |
config: ThemeConfig;
|
| 60 |
}
|
| 61 |
|
| 62 |
-
const ThemeContext = createContext<ThemeContextType>({
|
| 63 |
theme: "mint",
|
| 64 |
config: MINT_THEME,
|
| 65 |
});
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
| 68 |
const config = MINT_THEME;
|
| 69 |
|
| 70 |
useEffect(() => {
|
| 71 |
-
|
| 72 |
-
root.setAttribute("data-theme", "mint");
|
| 73 |
-
root.style.setProperty("--theme-accent", config.accent);
|
| 74 |
-
root.style.setProperty("--theme-accent-hover", config.accentHover);
|
| 75 |
-
root.style.setProperty("--theme-accent-text", config.accentText);
|
| 76 |
-
root.style.setProperty("--theme-accent-glow", config.accentGlow);
|
| 77 |
-
root.style.setProperty("--theme-badge-bg", config.badgeBg);
|
| 78 |
-
root.style.setProperty("--theme-badge-border", config.badgeBorder);
|
| 79 |
-
root.style.setProperty("--theme-badge-text", config.badgeText);
|
| 80 |
-
root.style.setProperty("--theme-btn-bg", config.buttonBg);
|
| 81 |
-
root.style.setProperty("--theme-btn-text", config.buttonText);
|
| 82 |
}, []);
|
| 83 |
|
| 84 |
return (
|
| 85 |
-
<ThemeContext.Provider value={{ theme:
|
| 86 |
{children}
|
| 87 |
</ThemeContext.Provider>
|
| 88 |
);
|
|
|
|
| 1 |
import React, { createContext, useContext, useEffect } from "react";
|
| 2 |
|
| 3 |
export interface ThemeConfig {
|
| 4 |
+
id: "mint" | "prod";
|
| 5 |
code: string;
|
| 6 |
name: string;
|
| 7 |
accent: string;
|
|
|
|
| 54 |
description: "Autonomous outbound infrastructure with reputation shielding, multi-mailbox rotation, and live sequence telemetry.",
|
| 55 |
};
|
| 56 |
|
| 57 |
+
/** Module S platform palette — the original "prod indigo" identity, preserved. */
|
| 58 |
+
export const PROD_THEME: ThemeConfig = {
|
| 59 |
+
id: "prod",
|
| 60 |
+
code: "01 Prod",
|
| 61 |
+
name: "Prod Indigo",
|
| 62 |
+
accent: "#6366f1",
|
| 63 |
+
accentHover: "#818cf8",
|
| 64 |
+
accentText: "#a5b4fc",
|
| 65 |
+
accentGlow: "rgba(99, 102, 241, 0.4)",
|
| 66 |
+
badgeBg: "rgba(99, 102, 241, 0.12)",
|
| 67 |
+
badgeBorder: "rgba(99, 102, 241, 0.3)",
|
| 68 |
+
badgeText: "#a5b4fc",
|
| 69 |
+
buttonBg: "#6366f1",
|
| 70 |
+
buttonText: "#ffffff",
|
| 71 |
+
chartColor1: "#818cf8",
|
| 72 |
+
chartColor2: "#6366f1",
|
| 73 |
+
chartColor3: "#22d3ee",
|
| 74 |
+
chartColor4: "#64748b",
|
| 75 |
+
chartColor5: "#334155",
|
| 76 |
+
bgGradientFrom: "rgba(99, 102, 241, 0.14)",
|
| 77 |
+
bgGradientTo: "rgba(56, 189, 248, 0.05)",
|
| 78 |
+
heroOrbitalColor: "#818cf8",
|
| 79 |
+
heroOrbitalColor2: "#22d3ee",
|
| 80 |
+
tagline: "Ship outbound",
|
| 81 |
+
taglineHighlight: "faster.",
|
| 82 |
+
description: "Advanced campaign management, sequences, unified inbox, email warmup, lead database, analytics, and webhook automation.",
|
| 83 |
+
};
|
| 84 |
+
|
| 85 |
interface ThemeContextType {
|
| 86 |
+
theme: "mint" | "prod";
|
| 87 |
config: ThemeConfig;
|
| 88 |
}
|
| 89 |
|
| 90 |
+
export const ThemeContext = createContext<ThemeContextType>({
|
| 91 |
theme: "mint",
|
| 92 |
config: MINT_THEME,
|
| 93 |
});
|
| 94 |
|
| 95 |
+
/** Applies a module palette to CSS custom properties consumed by chrome + primitives. */
|
| 96 |
+
export function applyThemeVars(config: ThemeConfig) {
|
| 97 |
+
const root = document.documentElement;
|
| 98 |
+
root.setAttribute("data-theme", config.id);
|
| 99 |
+
root.style.setProperty("--theme-accent", config.accent);
|
| 100 |
+
root.style.setProperty("--theme-accent-hover", config.accentHover);
|
| 101 |
+
root.style.setProperty("--theme-accent-text", config.accentText);
|
| 102 |
+
root.style.setProperty("--theme-accent-glow", config.accentGlow);
|
| 103 |
+
root.style.setProperty("--theme-badge-bg", config.badgeBg);
|
| 104 |
+
root.style.setProperty("--theme-badge-border", config.badgeBorder);
|
| 105 |
+
root.style.setProperty("--theme-badge-text", config.badgeText);
|
| 106 |
+
root.style.setProperty("--theme-btn-bg", config.buttonBg);
|
| 107 |
+
root.style.setProperty("--theme-btn-text", config.buttonText);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
| 111 |
const config = MINT_THEME;
|
| 112 |
|
| 113 |
useEffect(() => {
|
| 114 |
+
applyThemeVars(config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}, []);
|
| 116 |
|
| 117 |
return (
|
| 118 |
+
<ThemeContext.Provider value={{ theme: config.id, config }}>
|
| 119 |
{children}
|
| 120 |
</ThemeContext.Provider>
|
| 121 |
);
|
|
@@ -41,7 +41,7 @@
|
|
| 41 |
--color-emerald-400: #00e5bc;
|
| 42 |
--color-emerald-500: #00e5bc;
|
| 43 |
--color-emerald-900: rgba(0, 229, 188, 0.2);
|
| 44 |
-
|
| 45 |
--color-rose-400: #fb7185;
|
| 46 |
--color-rose-500: #f43f5e;
|
| 47 |
--color-rose-900: rgba(244, 63, 94, 0.2);
|
|
@@ -53,3 +53,49 @@ body {
|
|
| 53 |
color: var(--color-zinc-100);
|
| 54 |
min-height: 100vh;
|
| 55 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
--color-emerald-400: #00e5bc;
|
| 42 |
--color-emerald-500: #00e5bc;
|
| 43 |
--color-emerald-900: rgba(0, 229, 188, 0.2);
|
| 44 |
+
|
| 45 |
--color-rose-400: #fb7185;
|
| 46 |
--color-rose-500: #f43f5e;
|
| 47 |
--color-rose-900: rgba(244, 63, 94, 0.2);
|
|
|
|
| 53 |
color: var(--color-zinc-100);
|
| 54 |
min-height: 100vh;
|
| 55 |
}
|
| 56 |
+
|
| 57 |
+
/* ------------------------------------------------------------------
|
| 58 |
+
Module S ("Prod Indigo") — scoped palette restoration.
|
| 59 |
+
Tailwind v4 utilities compile to var(--color-*) references, so
|
| 60 |
+
overriding the custom properties on the module container restores
|
| 61 |
+
the ORIGINAL Module S look (true indigo, real zinc) without
|
| 62 |
+
touching Module E's mint remap. Design preserved 1:1.
|
| 63 |
+
------------------------------------------------------------------ */
|
| 64 |
+
[data-module="s"] {
|
| 65 |
+
--color-indigo-300: #a5b4fc;
|
| 66 |
+
--color-indigo-400: #818cf8;
|
| 67 |
+
--color-indigo-500: #6366f1;
|
| 68 |
+
--color-indigo-600: #4f46e5;
|
| 69 |
+
--color-indigo-900: rgba(79, 70, 229, 0.5);
|
| 70 |
+
--color-indigo-950: #1e1b4b;
|
| 71 |
+
|
| 72 |
+
--color-emerald-400: #34d399;
|
| 73 |
+
--color-emerald-500: #10b981;
|
| 74 |
+
--color-emerald-900: rgba(16, 185, 129, 0.2);
|
| 75 |
+
|
| 76 |
+
--color-zinc-800: #27272a;
|
| 77 |
+
--color-zinc-900: #18181b;
|
| 78 |
+
--color-zinc-950: #09090b;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/* Module S ambient background — original slate→black gradient. */
|
| 82 |
+
.bg-module-s {
|
| 83 |
+
background: linear-gradient(180deg, #0f172a 0%, #000000 100%);
|
| 84 |
+
background-attachment: fixed;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* GPU-compositing hygiene for the launch animation system. */
|
| 88 |
+
.module-launch-piece {
|
| 89 |
+
will-change: transform, opacity;
|
| 90 |
+
}
|
| 91 |
+
.module-launch-piece.module-launch-settled {
|
| 92 |
+
will-change: auto;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/* Respect users who prefer reduced motion — global safeguard. */
|
| 96 |
+
@media (prefers-reduced-motion: reduce) {
|
| 97 |
+
.module-launch-piece {
|
| 98 |
+
animation: none !important;
|
| 99 |
+
transition: none !important;
|
| 100 |
+
}
|
| 101 |
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
|
| 2 |
+
import { useNavigate } from "react-router-dom";
|
| 3 |
+
import { ModuleId, moduleHref } from "./registry";
|
| 4 |
+
|
| 5 |
+
interface LaunchState {
|
| 6 |
+
/** Monotonic counter — increments on every explicit launch so the animation re-seeds. */
|
| 7 |
+
seq: number;
|
| 8 |
+
/** Module currently being exited (reverse-assembly playing). */
|
| 9 |
+
exiting: ModuleId | null;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
interface LaunchContextType extends LaunchState {
|
| 13 |
+
/** Play exit choreography (if inside a module), then navigate to the target module/hub. */
|
| 14 |
+
startLaunch: (target: ModuleId | "hub") => void;
|
| 15 |
+
/** Called by the exiting shell once its reverse-assembly finished. */
|
| 16 |
+
finishExit: () => void;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
const LaunchContext = createContext<LaunchContextType>({
|
| 20 |
+
seq: 0,
|
| 21 |
+
exiting: null,
|
| 22 |
+
startLaunch: () => {},
|
| 23 |
+
finishExit: () => {},
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
const EXIT_DURATION_MS = 850;
|
| 27 |
+
|
| 28 |
+
export const LaunchProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
| 29 |
+
const [state, setState] = useState<LaunchState>({ seq: 0, exiting: null });
|
| 30 |
+
const navigate = useNavigate();
|
| 31 |
+
|
| 32 |
+
const startLaunch = useCallback(
|
| 33 |
+
(target: ModuleId | "hub") => {
|
| 34 |
+
setState((prev) => {
|
| 35 |
+
const navigateAfterExit = () => {
|
| 36 |
+
navigate(target === "hub" ? "/" : moduleHref(target));
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
// Bumping seq always re-seeds the next enter animation.
|
| 40 |
+
const next = { seq: prev.seq + 1, exiting: prev.exiting };
|
| 41 |
+
|
| 42 |
+
// Controlled exit: if a module shell is currently mounted, let it play
|
| 43 |
+
// its reverse-assembly first, then navigate.
|
| 44 |
+
const onHub = window.location.pathname === "/" || !window.location.pathname.startsWith("/modules/");
|
| 45 |
+
if (!onHub) {
|
| 46 |
+
next.exiting = (window.location.pathname.startsWith("/modules/s") ? "s" : "e") as ModuleId;
|
| 47 |
+
window.setTimeout(navigateAfterExit, EXIT_DURATION_MS);
|
| 48 |
+
} else {
|
| 49 |
+
// On the hub nothing needs to disassemble — navigate immediately.
|
| 50 |
+
window.setTimeout(navigateAfterExit, 0);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
return next;
|
| 54 |
+
});
|
| 55 |
+
},
|
| 56 |
+
[navigate]
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
const finishExit = useCallback(() => {
|
| 60 |
+
setState((prev) => ({ ...prev, exiting: null }));
|
| 61 |
+
}, []);
|
| 62 |
+
|
| 63 |
+
const value = useMemo(() => ({ ...state, startLaunch, finishExit }), [state, startLaunch, finishExit]);
|
| 64 |
+
|
| 65 |
+
return <LaunchContext.Provider value={value}>{children}</LaunchContext.Provider>;
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
export const useLaunch = () => useContext(LaunchContext);
|
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useEffect } from "react";
|
| 2 |
+
import { motion } from "motion/react";
|
| 3 |
+
import { ArrowRight, Boxes, CheckCircle2, XCircle, Zap } from "lucide-react";
|
| 4 |
+
import GlassCard from "../components/GlassCard";
|
| 5 |
+
import AnimatedLogo from "../components/AnimatedLogo";
|
| 6 |
+
import { useApiKey } from "../context/ApiKeyContext";
|
| 7 |
+
import { MINT_THEME } from "../context/ThemeContext";
|
| 8 |
+
import { useLaunch } from "./LaunchContext";
|
| 9 |
+
import { MODULES, MODULE_IDS } from "./registry";
|
| 10 |
+
import { preloadModulePages } from "./lazyPages";
|
| 11 |
+
|
| 12 |
+
const MODULE_CAPS: Record<string, string[]> = {
|
| 13 |
+
e: ["Sequence automation", "Unified inbox", "Warmup radar", "Deliverability analytics"],
|
| 14 |
+
s: ["Campaign management", "Lead database", "Webhook automation", "Email warmup"],
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* BRIDGE platform hub — the launcher. Real platform primitives only
|
| 19 |
+
* (GlassCard, AnimatedLogo, API-key status). Buttons trigger the module
|
| 20 |
+
* launch animation (re-seeded per launch) via LaunchContext.
|
| 21 |
+
*/
|
| 22 |
+
export default function ModuleHub() {
|
| 23 |
+
const { startLaunch } = useLaunch();
|
| 24 |
+
const { activeKey } = useApiKey();
|
| 25 |
+
|
| 26 |
+
useEffect(() => {
|
| 27 |
+
// Preload both modules' chunks so the first launch never janks.
|
| 28 |
+
const idle = window.requestIdleCallback ?? ((cb: () => void) => window.setTimeout(cb, 200));
|
| 29 |
+
const handle = idle(() => {
|
| 30 |
+
preloadModulePages("e");
|
| 31 |
+
preloadModulePages("s");
|
| 32 |
+
});
|
| 33 |
+
return () => {
|
| 34 |
+
if (typeof window.cancelIdleCallback === "function" && typeof handle === "number") {
|
| 35 |
+
window.cancelIdleCallback(handle);
|
| 36 |
+
}
|
| 37 |
+
};
|
| 38 |
+
}, []);
|
| 39 |
+
|
| 40 |
+
return (
|
| 41 |
+
<div className="min-h-screen bg-[#05070a] text-zinc-100 relative overflow-hidden">
|
| 42 |
+
{/* Ambient layers — platform primitives */}
|
| 43 |
+
<div
|
| 44 |
+
className="absolute inset-0 pointer-events-none"
|
| 45 |
+
style={{
|
| 46 |
+
background:
|
| 47 |
+
"radial-gradient(ellipse at top right, rgba(0, 229, 188, 0.10), transparent 60%), radial-gradient(ellipse at bottom left, rgba(99, 102, 241, 0.12), transparent 60%)",
|
| 48 |
+
}}
|
| 49 |
+
/>
|
| 50 |
+
|
| 51 |
+
<div className="relative z-10 max-w-5xl mx-auto px-4 md:px-8 py-12 md:py-20">
|
| 52 |
+
{/* Header */}
|
| 53 |
+
<div className="flex flex-col items-start gap-6 mb-12">
|
| 54 |
+
<div className="flex items-center gap-3">
|
| 55 |
+
<AnimatedLogo className="w-10 h-10" />
|
| 56 |
+
<div>
|
| 57 |
+
<div className="text-lg font-bold tracking-[0.08em] text-white">
|
| 58 |
+
BRIDGE<span className="text-[#00e5bc]">Modules</span>
|
| 59 |
+
</div>
|
| 60 |
+
<div className="text-[9px] font-bold tracking-[0.2em] text-zinc-500 uppercase font-mono">
|
| 61 |
+
Outbound Systems OS · Platform Hub
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
<div>
|
| 66 |
+
<h1 className="text-2xl md:text-3xl font-bold text-white tracking-tight">
|
| 67 |
+
Launch a workspace.
|
| 68 |
+
</h1>
|
| 69 |
+
<p className="text-sm text-zinc-400 mt-2 max-w-xl">
|
| 70 |
+
Two autonomous outbound engines, one command platform. Each module
|
| 71 |
+
assembles its own dashboard from live primitives when launched.
|
| 72 |
+
</p>
|
| 73 |
+
</div>
|
| 74 |
+
<div className="flex items-center gap-2">
|
| 75 |
+
{activeKey ? (
|
| 76 |
+
<div className="flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider px-2.5 py-1 rounded-full border shadow-sm text-[#00e5bc] bg-[rgba(0,229,188,0.12)] border-[rgba(0,229,188,0.3)]">
|
| 77 |
+
<CheckCircle2 className="w-3 h-3" />
|
| 78 |
+
API Connected
|
| 79 |
+
</div>
|
| 80 |
+
) : (
|
| 81 |
+
<div className="flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-rose-300 bg-rose-500/10 border border-rose-500/20 px-2.5 py-1 rounded-full">
|
| 82 |
+
<XCircle className="w-3 h-3" />
|
| 83 |
+
API Key Missing — set one in a module's Settings
|
| 84 |
+
</div>
|
| 85 |
+
)}
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
{/* Module launcher cards — real primitives */}
|
| 90 |
+
<div className="grid md:grid-cols-2 gap-4 md:gap-6">
|
| 91 |
+
{MODULE_IDS.map((id) => {
|
| 92 |
+
const def = MODULES[id];
|
| 93 |
+
const Icon = def.icon;
|
| 94 |
+
const theme = def.theme;
|
| 95 |
+
const mint = id === "e" ? MINT_THEME : null;
|
| 96 |
+
return (
|
| 97 |
+
<motion.div
|
| 98 |
+
key={id}
|
| 99 |
+
initial={{ opacity: 0, y: 18 }}
|
| 100 |
+
animate={{ opacity: 1, y: 0 }}
|
| 101 |
+
transition={{ duration: 0.6, ease: [0.22, 1, 0.36, 1], delay: id === "e" ? 0.05 : 0.15 }}
|
| 102 |
+
>
|
| 103 |
+
<GlassCard className="p-6 md:p-7 h-full flex flex-col group hover:border-white/10 transition-all duration-500">
|
| 104 |
+
<div className="flex items-start justify-between mb-5">
|
| 105 |
+
<div
|
| 106 |
+
className="w-11 h-11 rounded-xl flex items-center justify-center border"
|
| 107 |
+
style={{
|
| 108 |
+
backgroundColor: `${theme.accent}14`,
|
| 109 |
+
borderColor: `${theme.accent}44`,
|
| 110 |
+
boxShadow: `0 0 24px ${theme.accent}22`,
|
| 111 |
+
}}
|
| 112 |
+
>
|
| 113 |
+
<Icon className="w-5 h-5" style={{ color: theme.accent }} />
|
| 114 |
+
</div>
|
| 115 |
+
<span
|
| 116 |
+
className="text-[9px] font-bold font-mono uppercase tracking-[0.18em] px-2 py-1 rounded-md border"
|
| 117 |
+
style={{
|
| 118 |
+
color: theme.accentText,
|
| 119 |
+
borderColor: `${theme.accent}44`,
|
| 120 |
+
backgroundColor: `${theme.accent}14`,
|
| 121 |
+
}}
|
| 122 |
+
>
|
| 123 |
+
{theme.code}
|
| 124 |
+
</span>
|
| 125 |
+
</div>
|
| 126 |
+
|
| 127 |
+
<h2 className="text-xl font-bold text-white tracking-tight">
|
| 128 |
+
BRIDGE
|
| 129 |
+
<span style={{ color: theme.accent }}>{def.wordmark}</span>
|
| 130 |
+
</h2>
|
| 131 |
+
<p className="text-[13px] text-zinc-400 mt-2 leading-relaxed flex-1">
|
| 132 |
+
{def.blurb}
|
| 133 |
+
</p>
|
| 134 |
+
|
| 135 |
+
<ul className="mt-5 space-y-1.5">
|
| 136 |
+
{MODULE_CAPS[id].map((cap) => (
|
| 137 |
+
<li key={cap} className="flex items-center gap-2 text-xs text-zinc-300">
|
| 138 |
+
<span
|
| 139 |
+
className="w-1 h-1 rounded-full shrink-0"
|
| 140 |
+
style={{ backgroundColor: theme.accent, boxShadow: `0 0 6px ${theme.accent}` }}
|
| 141 |
+
/>
|
| 142 |
+
{cap}
|
| 143 |
+
</li>
|
| 144 |
+
))}
|
| 145 |
+
</ul>
|
| 146 |
+
|
| 147 |
+
<div className="mt-6 flex items-center justify-between gap-3">
|
| 148 |
+
<div className="flex items-center gap-1.5 text-[10px] font-mono text-zinc-500 uppercase tracking-wider">
|
| 149 |
+
<Boxes className="w-3.5 h-3.5" />
|
| 150 |
+
Slow-mo assembly on launch
|
| 151 |
+
</div>
|
| 152 |
+
<button
|
| 153 |
+
type="button"
|
| 154 |
+
onClick={() => startLaunch(id)}
|
| 155 |
+
onMouseEnter={() => preloadModulePages(id)}
|
| 156 |
+
className="flex items-center gap-2 px-4 py-2.5 rounded-lg text-[13px] font-bold transition-all duration-300 active:scale-[0.98] border"
|
| 157 |
+
style={{
|
| 158 |
+
backgroundColor: theme.buttonBg,
|
| 159 |
+
color: theme.buttonText,
|
| 160 |
+
borderColor: theme.buttonBg,
|
| 161 |
+
boxShadow: `0 0 24px ${theme.accent}33`,
|
| 162 |
+
}}
|
| 163 |
+
aria-label={`Launch ${def.label}`}
|
| 164 |
+
>
|
| 165 |
+
{id === "e" ? <Zap className="w-4 h-4" /> : <Boxes className="w-4 h-4" />}
|
| 166 |
+
Launch {def.label.replace(/^Module /, "")}
|
| 167 |
+
<ArrowRight className="w-4 h-4 group-hover:translate-x-0.5 transition-transform" />
|
| 168 |
+
</button>
|
| 169 |
+
</div>
|
| 170 |
+
|
| 171 |
+
{mint && (
|
| 172 |
+
<div className="mt-4 text-[10px] font-mono text-zinc-600 uppercase tracking-[0.16em]">
|
| 173 |
+
GreenTheme build · accent {mint.accent}
|
| 174 |
+
</div>
|
| 175 |
+
)}
|
| 176 |
+
</GlassCard>
|
| 177 |
+
</motion.div>
|
| 178 |
+
);
|
| 179 |
+
})}
|
| 180 |
+
</div>
|
| 181 |
+
|
| 182 |
+
<div className="mt-10 text-center text-[10px] font-mono text-zinc-600 uppercase tracking-[0.2em]">
|
| 183 |
+
Bridge Modules · Direct URLs — /modules/e · /modules/s
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
);
|
| 188 |
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { describe, it, expect } from "vitest";
|
| 2 |
+
import { mulberry32, hashModuleId, buildPieceSpecs, ASSEMBLY_EASE } from "./ModuleLaunchAnimation";
|
| 3 |
+
|
| 4 |
+
describe("launch animation randomness engine", () => {
|
| 5 |
+
it("mulberry32 is deterministic per seed and well-distributed", () => {
|
| 6 |
+
const a = mulberry32(12345);
|
| 7 |
+
const b = mulberry32(12345);
|
| 8 |
+
const seqA = [a(), a(), a(), a()];
|
| 9 |
+
const seqB = [b(), b(), b(), b()];
|
| 10 |
+
expect(seqA).toEqual(seqB);
|
| 11 |
+
seqA.forEach((v) => {
|
| 12 |
+
expect(v).toBeGreaterThanOrEqual(0);
|
| 13 |
+
expect(v).toBeLessThan(1);
|
| 14 |
+
});
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
it("different seeds produce different assemblies (re-seed per launch)", () => {
|
| 18 |
+
const specs1 = buildPieceSpecs(mulberry32(hashModuleId("e") ^ 1), 11);
|
| 19 |
+
const specs2 = buildPieceSpecs(mulberry32(hashModuleId("e") ^ 2), 11);
|
| 20 |
+
const sig1 = JSON.stringify(specs1.map((s) => [s.from.x, s.from.y, s.from.rotate, s.from.delay]));
|
| 21 |
+
const sig2 = JSON.stringify(specs2.map((s) => [s.from.x, s.from.y, s.from.rotate, s.from.delay]));
|
| 22 |
+
expect(sig1).not.toEqual(sig2);
|
| 23 |
+
});
|
| 24 |
+
|
| 25 |
+
it("piece transforms stay inside the mandated motion budget", () => {
|
| 26 |
+
const specs = buildPieceSpecs(mulberry32(42), 11);
|
| 27 |
+
expect(specs).toHaveLength(11);
|
| 28 |
+
specs.forEach((s) => {
|
| 29 |
+
const distance = Math.hypot(s.from.x, s.from.y);
|
| 30 |
+
expect(distance).toBeGreaterThanOrEqual(240);
|
| 31 |
+
expect(distance).toBeLessThanOrEqual(720);
|
| 32 |
+
expect(Math.abs(s.from.rotate)).toBeGreaterThanOrEqual(8);
|
| 33 |
+
expect(Math.abs(s.from.rotate)).toBeLessThanOrEqual(45);
|
| 34 |
+
expect(s.from.scale).toBeGreaterThanOrEqual(0.55);
|
| 35 |
+
expect(s.from.scale).toBeLessThanOrEqual(1.35);
|
| 36 |
+
// stagger: i*55 + 40..90ms
|
| 37 |
+
expect(s.from.delay).toBeGreaterThan(0);
|
| 38 |
+
// slow-motion duration 2.4–3.2s
|
| 39 |
+
expect(s.from.duration).toBeGreaterThanOrEqual(2.4);
|
| 40 |
+
expect(s.from.duration).toBeLessThanOrEqual(3.2);
|
| 41 |
+
});
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
it("uses the mandated slow-motion easing curve", () => {
|
| 45 |
+
expect(Array.from(ASSEMBLY_EASE)).toEqual([0.22, 1, 0.36, 1]);
|
| 46 |
+
});
|
| 47 |
+
});
|
|
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
| 2 |
+
import { motion, useReducedMotion } from "motion/react";
|
| 3 |
+
import { Activity, ArrowUpRight, Mail, Megaphone, ShieldCheck, TrendingUp, Users } from "lucide-react";
|
| 4 |
+
import { Area, AreaChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
| 5 |
+
import StatCard from "../components/StatCard";
|
| 6 |
+
import { Skeleton } from "../components/Skeleton";
|
| 7 |
+
import SStatCard from "./s/components/StatCard";
|
| 8 |
+
import SGlassCard from "./s/components/GlassCard";
|
| 9 |
+
import { cn } from "../utils/cn";
|
| 10 |
+
import { ModuleId } from "./registry";
|
| 11 |
+
|
| 12 |
+
/* ------------------------------------------------------------------ */
|
| 13 |
+
/* Deterministic seeded PRNG (mulberry32) — re-seeded on every launch. */
|
| 14 |
+
/* ------------------------------------------------------------------ */
|
| 15 |
+
export function mulberry32(seed: number) {
|
| 16 |
+
let a = seed >>> 0;
|
| 17 |
+
return () => {
|
| 18 |
+
a |= 0;
|
| 19 |
+
a = (a + 0x6d2b79f5) | 0;
|
| 20 |
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
| 21 |
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
| 22 |
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
| 23 |
+
};
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
export function hashModuleId(id: string): number {
|
| 27 |
+
let h = 2166136261;
|
| 28 |
+
for (let i = 0; i < id.length; i++) {
|
| 29 |
+
h ^= id.charCodeAt(i);
|
| 30 |
+
h = Math.imul(h, 16777619);
|
| 31 |
+
}
|
| 32 |
+
return h >>> 0;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/* Slow-motion reassembly curve mandated by the brief. */
|
| 36 |
+
export const ASSEMBLY_EASE: [number, number, number, number] = [0.22, 1, 0.36, 1];
|
| 37 |
+
|
| 38 |
+
interface PieceTransform {
|
| 39 |
+
x: number;
|
| 40 |
+
y: number;
|
| 41 |
+
rotate: number;
|
| 42 |
+
scale: number;
|
| 43 |
+
delay: number;
|
| 44 |
+
duration: number;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
interface PieceSpec {
|
| 48 |
+
key: string;
|
| 49 |
+
span: string; // grid column span classes
|
| 50 |
+
from: PieceTransform;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
const MIN_DISTANCE = 240;
|
| 54 |
+
const MAX_DISTANCE = 720;
|
| 55 |
+
const MIN_STAGGER_BASE = 40;
|
| 56 |
+
const MAX_STAGGER_JITTER = 50; // stagger = i*55 + rand(40..90) per brief
|
| 57 |
+
const MIN_DURATION = 2.4;
|
| 58 |
+
const MAX_DURATION = 3.2;
|
| 59 |
+
|
| 60 |
+
export function buildPieceSpecs(rand: () => number, count: number): PieceSpec[] {
|
| 61 |
+
const spans = [
|
| 62 |
+
"sm:col-span-3 sm:row-span-1 col-span-6",
|
| 63 |
+
"sm:col-span-3 sm:row-span-1 col-span-6",
|
| 64 |
+
"sm:col-span-3 sm:row-span-1 col-span-6",
|
| 65 |
+
"sm:col-span-3 sm:row-span-1 col-span-6",
|
| 66 |
+
"sm:col-span-4 sm:row-span-2 col-span-6",
|
| 67 |
+
"sm:col-span-2 sm:row-span-2 col-span-6",
|
| 68 |
+
"col-span-6",
|
| 69 |
+
"sm:col-span-2 col-span-6",
|
| 70 |
+
"sm:col-span-2 col-span-6",
|
| 71 |
+
"sm:col-span-2 col-span-6",
|
| 72 |
+
"col-span-6",
|
| 73 |
+
];
|
| 74 |
+
return Array.from({ length: count }, (_, i) => {
|
| 75 |
+
const angle = rand() * Math.PI * 2;
|
| 76 |
+
const distance = MIN_DISTANCE + rand() * (MAX_DISTANCE - MIN_DISTANCE);
|
| 77 |
+
const direction = i % 2 === 0 ? 1 : -1; // pieces fly in from both sides of the canvas
|
| 78 |
+
return {
|
| 79 |
+
key: `piece-${i}`,
|
| 80 |
+
span: spans[i % spans.length],
|
| 81 |
+
from: {
|
| 82 |
+
x: Math.cos(angle) * distance * direction,
|
| 83 |
+
y: Math.sin(angle) * distance,
|
| 84 |
+
rotate: (8 + rand() * 37) * (rand() > 0.5 ? 1 : -1),
|
| 85 |
+
scale: 0.55 + rand() * 0.8,
|
| 86 |
+
delay: i * 55 + MIN_STAGGER_BASE + rand() * MAX_STAGGER_JITTER,
|
| 87 |
+
duration: MIN_DURATION + rand() * (MAX_DURATION - MIN_DURATION),
|
| 88 |
+
},
|
| 89 |
+
};
|
| 90 |
+
});
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/* ------------------------------------------------------------------ */
|
| 94 |
+
/* Real dashboard primitives rendered by the assembly grid */
|
| 95 |
+
/* ------------------------------------------------------------------ */
|
| 96 |
+
|
| 97 |
+
const CHART_DATA = [
|
| 98 |
+
{ d: "Mon", v: 3200, b: 2100 },
|
| 99 |
+
{ d: "Tue", v: 4100, b: 2600 },
|
| 100 |
+
{ d: "Wed", v: 3800, b: 2400 },
|
| 101 |
+
{ d: "Thu", v: 5200, b: 3100 },
|
| 102 |
+
{ d: "Fri", v: 4800, b: 2900 },
|
| 103 |
+
{ d: "Sat", v: 6100, b: 3600 },
|
| 104 |
+
{ d: "Sun", v: 7400, b: 4200 },
|
| 105 |
+
];
|
| 106 |
+
|
| 107 |
+
const LIST_ROWS = [
|
| 108 |
+
{ email: "ava.reyes@northwind.io", badge: "DELIVERED" as const, tone: "text-emerald-300 bg-emerald-500/10 border-emerald-500/20" },
|
| 109 |
+
{ email: "marcus.chen@brightlab.co", badge: "OPENED" as const, tone: "text-sky-300 bg-sky-500/10 border-sky-500/20" },
|
| 110 |
+
{ email: "lena.hoffmann@vanta.dev", badge: "REPLIED" as const, tone: "text-violet-300 bg-violet-500/10 border-violet-500/20" },
|
| 111 |
+
{ email: "j.torres@quanticloud.ai", badge: "ACTIVE" as const, tone: "text-emerald-300 bg-emerald-500/10 border-emerald-500/20" },
|
| 112 |
+
{ email: "priya.nair@helioshift.com", badge: "QUEUED" as const, tone: "text-zinc-300 bg-white/5 border-white/10" },
|
| 113 |
+
];
|
| 114 |
+
|
| 115 |
+
interface AnimationProps {
|
| 116 |
+
module: ModuleId;
|
| 117 |
+
mode: "enter" | "exit";
|
| 118 |
+
/** Re-seed source: Date.now() ^ hashModuleId(module) ^ launchSeq */
|
| 119 |
+
seed: number;
|
| 120 |
+
onDone: () => void;
|
| 121 |
+
/** Accent colors from the active module theme (engineLabel uses it too). */
|
| 122 |
+
accent: string;
|
| 123 |
+
accentSoft: string;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
export default function ModuleLaunchAnimation({ module, mode, seed, onDone, accent, accentSoft }: AnimationProps) {
|
| 127 |
+
const prefersReducedMotion = useReducedMotion();
|
| 128 |
+
const [play, setPlay] = useState(false);
|
| 129 |
+
const [settled, setSettled] = useState<Set<number>>(new Set());
|
| 130 |
+
const doneRef = useRef(false);
|
| 131 |
+
const watchdogRef = useRef<number | null>(null);
|
| 132 |
+
|
| 133 |
+
const specs = useMemo(
|
| 134 |
+
() => buildPieceSpecs(mulberry32(seed), 11),
|
| 135 |
+
[seed]
|
| 136 |
+
);
|
| 137 |
+
|
| 138 |
+
// Double-rAF: mount pieces in their hidden state first, then start the
|
| 139 |
+
// timeline — guarantees the first paint of the overlay is cheap (no jank).
|
| 140 |
+
useEffect(() => {
|
| 141 |
+
if (prefersReducedMotion) {
|
| 142 |
+
setPlay(true);
|
| 143 |
+
setSettled(new Set(specs.map((_, i) => i)));
|
| 144 |
+
return;
|
| 145 |
+
}
|
| 146 |
+
let raf2 = 0;
|
| 147 |
+
const raf1 = requestAnimationFrame(() => {
|
| 148 |
+
raf2 = requestAnimationFrame(() => setPlay(true));
|
| 149 |
+
});
|
| 150 |
+
return () => {
|
| 151 |
+
cancelAnimationFrame(raf1);
|
| 152 |
+
cancelAnimationFrame(raf2);
|
| 153 |
+
};
|
| 154 |
+
}, [prefersReducedMotion, specs]);
|
| 155 |
+
|
| 156 |
+
const finish = useCallback(() => {
|
| 157 |
+
if (doneRef.current) return;
|
| 158 |
+
doneRef.current = true;
|
| 159 |
+
onDone();
|
| 160 |
+
}, [onDone]);
|
| 161 |
+
|
| 162 |
+
// Watchdog is the single source of truth for completion (deterministic:
|
| 163 |
+
// longest stagger + longest duration + margin). onAnimationComplete only
|
| 164 |
+
// drives will-change cleanup.
|
| 165 |
+
useEffect(() => {
|
| 166 |
+
if (!play) return;
|
| 167 |
+
const maxTime = Math.max(...specs.map((s) => s.from.delay + s.from.duration * 1000));
|
| 168 |
+
watchdogRef.current = window.setTimeout(
|
| 169 |
+
finish,
|
| 170 |
+
prefersReducedMotion ? 0 : (mode === "enter" ? maxTime + 120 : maxTime) + 80
|
| 171 |
+
);
|
| 172 |
+
return () => {
|
| 173 |
+
if (watchdogRef.current) window.clearTimeout(watchdogRef.current);
|
| 174 |
+
};
|
| 175 |
+
}, [play, specs, finish, mode, prefersReducedMotion]);
|
| 176 |
+
|
| 177 |
+
const markSettled = useCallback((i: number) => {
|
| 178 |
+
setSettled((prev) => {
|
| 179 |
+
if (prev.has(i)) return prev;
|
| 180 |
+
const next = new Set(prev);
|
| 181 |
+
next.add(i);
|
| 182 |
+
return next;
|
| 183 |
+
});
|
| 184 |
+
}, []);
|
| 185 |
+
|
| 186 |
+
const isEnter = mode === "enter";
|
| 187 |
+
const StatCardVariant = module === "s" ? SStatCard : StatCard;
|
| 188 |
+
const Frame = module === "s" ? SGlassCard : React.Fragment;
|
| 189 |
+
|
| 190 |
+
const frameProps = module === "s" ? { className: "p-4" } : {};
|
| 191 |
+
|
| 192 |
+
return (
|
| 193 |
+
<div
|
| 194 |
+
className="absolute inset-0 z-30 flex items-center justify-center overflow-hidden p-4 md:p-8 pointer-events-none"
|
| 195 |
+
aria-hidden="true"
|
| 196 |
+
data-testid="module-launch-animation"
|
| 197 |
+
>
|
| 198 |
+
<div className="grid grid-cols-6 auto-rows-min gap-3 md:gap-4 w-full max-w-5xl">
|
| 199 |
+
{specs.map((spec, i) => {
|
| 200 |
+
const initial =
|
| 201 |
+
isEnter && !prefersReducedMotion
|
| 202 |
+
? { x: spec.from.x, y: spec.from.y, rotate: spec.from.rotate, scale: spec.from.scale, opacity: 0 }
|
| 203 |
+
: isEnter
|
| 204 |
+
? { x: 0, y: 0, rotate: 0, scale: 1, opacity: 1 }
|
| 205 |
+
: { x: 0, y: 0, rotate: 0, scale: 1, opacity: 1 };
|
| 206 |
+
const animate = isEnter
|
| 207 |
+
? { x: 0, y: 0, rotate: 0, scale: 1, opacity: 1 }
|
| 208 |
+
: prefersReducedMotion
|
| 209 |
+
? { x: 0, y: 0, opacity: 0 }
|
| 210 |
+
: {
|
| 211 |
+
x: spec.from.x,
|
| 212 |
+
y: spec.from.y,
|
| 213 |
+
rotate: spec.from.rotate,
|
| 214 |
+
scale: spec.from.scale,
|
| 215 |
+
opacity: 0,
|
| 216 |
+
};
|
| 217 |
+
|
| 218 |
+
return (
|
| 219 |
+
<motion.div
|
| 220 |
+
key={`${spec.key}-${seed}`}
|
| 221 |
+
className={cn("module-launch-piece min-w-0", spec.span, settled.has(i) && "module-launch-settled")}
|
| 222 |
+
initial={initial}
|
| 223 |
+
animate={play ? animate : initial}
|
| 224 |
+
transition={
|
| 225 |
+
prefersReducedMotion
|
| 226 |
+
? { duration: 0 }
|
| 227 |
+
: {
|
| 228 |
+
delay: (isEnter ? spec.from.delay : i * 24) / 1000,
|
| 229 |
+
duration: isEnter ? spec.from.duration : 0.85,
|
| 230 |
+
ease: ASSEMBLY_EASE,
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
onAnimationComplete={() => {
|
| 234 |
+
if (play) markSettled(i);
|
| 235 |
+
}}
|
| 236 |
+
style={{ transformOrigin: "center center" }}
|
| 237 |
+
>
|
| 238 |
+
<Piece
|
| 239 |
+
index={i}
|
| 240 |
+
module={module}
|
| 241 |
+
accent={accent}
|
| 242 |
+
accentSoft={accentSoft}
|
| 243 |
+
StatCardVariant={StatCardVariant}
|
| 244 |
+
Frame={Frame}
|
| 245 |
+
frameProps={frameProps}
|
| 246 |
+
/>
|
| 247 |
+
</motion.div>
|
| 248 |
+
);
|
| 249 |
+
})}
|
| 250 |
+
</div>
|
| 251 |
+
|
| 252 |
+
{/* Engine strip — reassembles last, identifies the module being launched */}
|
| 253 |
+
<motion.div
|
| 254 |
+
className="absolute bottom-6 left-1/2 -translate-x-1/2 flex items-center gap-2 px-3 py-1.5 rounded-full border border-white/10 bg-black/50 backdrop-blur-md"
|
| 255 |
+
initial={{ opacity: 0, y: 14 }}
|
| 256 |
+
animate={play ? { opacity: 1, y: 0 } : { opacity: 0, y: 14 }}
|
| 257 |
+
transition={prefersReducedMotion ? { duration: 0 } : { delay: 0.35, duration: 0.7, ease: ASSEMBLY_EASE }}
|
| 258 |
+
>
|
| 259 |
+
<span className="w-1.5 h-1.5 rounded-full animate-pulse" style={{ backgroundColor: accent, boxShadow: `0 0 10px ${accent}` }} />
|
| 260 |
+
<span className="text-[10px] font-mono uppercase tracking-[0.2em] text-zinc-400">
|
| 261 |
+
{isEnter ? "Assembling" : "Releasing"} {module === "s" ? "ModuleS" : "ModuleE"} workspace
|
| 262 |
+
</span>
|
| 263 |
+
<span className="text-[10px] font-mono" style={{ color: accentSoft }}>
|
| 264 |
+
{Math.round(MIN_DURATION * 10) / 10}–{MAX_DURATION}s
|
| 265 |
+
</span>
|
| 266 |
+
</motion.div>
|
| 267 |
+
</div>
|
| 268 |
+
);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
/* ------------------------------------------------------------------ */
|
| 272 |
+
/* Piece renderer — every slot is a REAL platform component */
|
| 273 |
+
/* ------------------------------------------------------------------ */
|
| 274 |
+
|
| 275 |
+
interface PieceProps {
|
| 276 |
+
index: number;
|
| 277 |
+
module: ModuleId;
|
| 278 |
+
accent: string;
|
| 279 |
+
accentSoft: string;
|
| 280 |
+
StatCardVariant: typeof StatCard;
|
| 281 |
+
Frame: React.ComponentType<{ children?: React.ReactNode; className?: string }> | typeof React.Fragment;
|
| 282 |
+
frameProps: Record<string, unknown>;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
function Piece({ index, module, accent, accentSoft, StatCardVariant, Frame, frameProps }: PieceProps) {
|
| 286 |
+
switch (index) {
|
| 287 |
+
case 0:
|
| 288 |
+
return (
|
| 289 |
+
<StatCardVariant
|
| 290 |
+
title="Total Leads"
|
| 291 |
+
value="12,847"
|
| 292 |
+
icon={Users}
|
| 293 |
+
iconColor="indigo"
|
| 294 |
+
change={{ value: "+12.4%", isPositive: true, period: "vs last week" }}
|
| 295 |
+
/>
|
| 296 |
+
);
|
| 297 |
+
case 1:
|
| 298 |
+
return (
|
| 299 |
+
<StatCardVariant
|
| 300 |
+
title="Active Campaigns"
|
| 301 |
+
value="24"
|
| 302 |
+
icon={Megaphone}
|
| 303 |
+
iconColor="emerald"
|
| 304 |
+
change={{ value: "3 launching", isPositive: null }}
|
| 305 |
+
/>
|
| 306 |
+
);
|
| 307 |
+
case 2:
|
| 308 |
+
return (
|
| 309 |
+
<StatCardVariant
|
| 310 |
+
title="Reply Rate"
|
| 311 |
+
value="8.2%"
|
| 312 |
+
icon={Mail}
|
| 313 |
+
iconColor="purple"
|
| 314 |
+
change={{ value: "+0.9%", isPositive: true, period: "7-day avg" }}
|
| 315 |
+
/>
|
| 316 |
+
);
|
| 317 |
+
case 3:
|
| 318 |
+
return (
|
| 319 |
+
<StatCardVariant
|
| 320 |
+
title="Deliverability"
|
| 321 |
+
value="98.2%"
|
| 322 |
+
icon={ShieldCheck}
|
| 323 |
+
iconColor="teal"
|
| 324 |
+
subtitle="Reputation shield active"
|
| 325 |
+
progress={98}
|
| 326 |
+
/>
|
| 327 |
+
);
|
| 328 |
+
case 4:
|
| 329 |
+
return (
|
| 330 |
+
<Frame {...frameProps}>
|
| 331 |
+
<div className="flex items-center justify-between mb-2">
|
| 332 |
+
<div className="flex items-center gap-2 min-w-0">
|
| 333 |
+
<TrendingUp className="w-3.5 h-3.5 shrink-0" style={{ color: accent }} />
|
| 334 |
+
<span className="text-[11px] font-mono uppercase tracking-wider text-zinc-400 truncate">Sequence telemetry</span>
|
| 335 |
+
</div>
|
| 336 |
+
<span className="text-[10px] font-mono px-1.5 py-0.5 rounded border" style={{ color: accentSoft, borderColor: accentSoft + "55", backgroundColor: accentSoft + "14" }}>
|
| 337 |
+
LIVE
|
| 338 |
+
</span>
|
| 339 |
+
</div>
|
| 340 |
+
<div className="h-28 -ml-2">
|
| 341 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 342 |
+
<AreaChart data={CHART_DATA} margin={{ top: 4, right: 4, bottom: 0, left: 4 }}>
|
| 343 |
+
<defs>
|
| 344 |
+
<linearGradient id={`launch-grad-${module}`} x1="0" y1="0" x2="0" y2="1">
|
| 345 |
+
<stop offset="0%" stopColor={accent} stopOpacity={0.45} />
|
| 346 |
+
<stop offset="100%" stopColor={accent} stopOpacity={0.02} />
|
| 347 |
+
</linearGradient>
|
| 348 |
+
</defs>
|
| 349 |
+
<XAxis dataKey="d" hide />
|
| 350 |
+
<YAxis hide />
|
| 351 |
+
<Tooltip cursor={{ stroke: accent + "55" }} contentStyle={{ background: "#0c0d10", border: "1px solid rgba(255,255,255,0.1)", borderRadius: 8, fontSize: 10 }} />
|
| 352 |
+
<Area type="monotone" dataKey="b" stroke="transparent" fill={`url(#launch-grad-${module})`} isAnimationActive={false} />
|
| 353 |
+
<Area type="monotone" dataKey="v" stroke={accent} strokeWidth={1.5} fill="transparent" isAnimationActive={false} dot={false} />
|
| 354 |
+
</AreaChart>
|
| 355 |
+
</ResponsiveContainer>
|
| 356 |
+
</div>
|
| 357 |
+
</Frame>
|
| 358 |
+
);
|
| 359 |
+
case 5:
|
| 360 |
+
return (
|
| 361 |
+
<Frame {...frameProps}>
|
| 362 |
+
<div className="flex items-center gap-2 mb-2">
|
| 363 |
+
<Activity className="w-3.5 h-3.5 shrink-0" style={{ color: accent }} />
|
| 364 |
+
<span className="text-[11px] font-mono uppercase tracking-wider text-zinc-400 truncate">Live feed</span>
|
| 365 |
+
</div>
|
| 366 |
+
<div className="space-y-2">
|
| 367 |
+
{LIST_ROWS.map((row) => (
|
| 368 |
+
<div key={row.email} className="flex items-center justify-between gap-2">
|
| 369 |
+
<div className="flex items-center gap-2 min-w-0">
|
| 370 |
+
<span className="w-1.5 h-1.5 rounded-full shrink-0" style={{ backgroundColor: accent }} />
|
| 371 |
+
<span className="text-[11px] text-zinc-300 truncate">{row.email}</span>
|
| 372 |
+
</div>
|
| 373 |
+
<span className={cn("text-[8px] font-bold tracking-wider px-1.5 py-0.5 rounded border shrink-0", row.tone)}>{row.badge}</span>
|
| 374 |
+
</div>
|
| 375 |
+
))}
|
| 376 |
+
</div>
|
| 377 |
+
</Frame>
|
| 378 |
+
);
|
| 379 |
+
case 6:
|
| 380 |
+
return (
|
| 381 |
+
<div className="flex items-center gap-2 flex-wrap">
|
| 382 |
+
{["SEQUENCES", "WARMUP", "UNIBOX"].map((tag) => (
|
| 383 |
+
<span key={tag} className="text-[9px] font-bold tracking-[0.18em] px-2 py-1 rounded-md border border-white/10 bg-white/5 text-zinc-300">
|
| 384 |
+
{tag}
|
| 385 |
+
</span>
|
| 386 |
+
))}
|
| 387 |
+
<span className="text-[9px] font-bold tracking-[0.18em] px-2 py-1 rounded-md border" style={{ color: accentSoft, borderColor: accentSoft + "55", backgroundColor: accentSoft + "14" }}>
|
| 388 |
+
DELIVERABILITY
|
| 389 |
+
</span>
|
| 390 |
+
</div>
|
| 391 |
+
);
|
| 392 |
+
case 7:
|
| 393 |
+
return (
|
| 394 |
+
<StatCardVariant title="Open Rate" value="64.7%" icon={Mail} iconColor="blue" change={{ value: "+2.1%", isPositive: true }} />
|
| 395 |
+
);
|
| 396 |
+
case 8:
|
| 397 |
+
return <StatCardVariant title="Bounce Rate" value="0.4%" icon={ArrowUpRight} iconColor="rose" change={{ value: "-0.2%", isPositive: true }} />;
|
| 398 |
+
case 9:
|
| 399 |
+
return (
|
| 400 |
+
<StatCardVariant title="Mailboxes Rotating" value="38" icon={Users} iconColor="amber" subtitle="Multi-mailbox rotation on" />
|
| 401 |
+
);
|
| 402 |
+
default:
|
| 403 |
+
return (
|
| 404 |
+
<div className="space-y-2.5">
|
| 405 |
+
<Skeleton className="h-3 w-1/3" />
|
| 406 |
+
<Skeleton className="h-3 w-2/3" />
|
| 407 |
+
<Skeleton className="h-3 w-1/2" />
|
| 408 |
+
</div>
|
| 409 |
+
);
|
| 410 |
+
}
|
| 411 |
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
| 2 |
+
import { Outlet } from "react-router-dom";
|
| 3 |
+
import { AnimatePresence, motion } from "motion/react";
|
| 4 |
+
import { ThemeConfig, ThemeContext } from "../context/ThemeContext";
|
| 5 |
+
import GeometricBackground from "../components/GeometricBackground";
|
| 6 |
+
import BackgroundElements from "../components/BackgroundElements";
|
| 7 |
+
import TopBar from "../components/TopBar";
|
| 8 |
+
import PlatformSidebar from "./PlatformSidebar";
|
| 9 |
+
import ModuleLaunchAnimation, { hashModuleId } from "./ModuleLaunchAnimation";
|
| 10 |
+
import { useLaunch } from "./LaunchContext";
|
| 11 |
+
import { MODULES, ModuleId } from "./registry";
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Nested theme provider — overrides the platform default (mint) with the
|
| 15 |
+
* active module palette for the whole module subtree.
|
| 16 |
+
*/
|
| 17 |
+
function ModuleThemeProvider({ config, children }: { config: ThemeConfig; children: React.ReactNode }) {
|
| 18 |
+
const value = useMemo(() => ({ theme: config.id, config }), [config]);
|
| 19 |
+
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
interface ModuleShellProps {
|
| 23 |
+
module: ModuleId;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Route shell for /modules/e and /modules/s.
|
| 28 |
+
*
|
| 29 |
+
* Launch guard: on every mount (menu launch, hub launch, direct URL) the
|
| 30 |
+
* module's real dashboard primitives random-reassemble in slow motion before
|
| 31 |
+
* the workspace is revealed. Leaving via the menu plays the reverse-assembly
|
| 32 |
+
* exit. Internal navigation never replays the animation (shell stays mounted).
|
| 33 |
+
*/
|
| 34 |
+
export default function ModuleShell({ module }: ModuleShellProps) {
|
| 35 |
+
const def = MODULES[module];
|
| 36 |
+
const { seq, exiting, finishExit } = useLaunch();
|
| 37 |
+
const [launchDone, setLaunchDone] = useState(false);
|
| 38 |
+
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
| 39 |
+
const seedRef = useRef<number>(0);
|
| 40 |
+
if (seedRef.current === 0) {
|
| 41 |
+
seedRef.current = Date.now() ^ hashModuleId(module) ^ ((seq + 1) * 0x9e3779b9);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
// A fresh mount is a fresh launch — clear any stale exit flag from the
|
| 45 |
+
// previous module.
|
| 46 |
+
useEffect(() => {
|
| 47 |
+
if (exiting) finishExit();
|
| 48 |
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 49 |
+
}, []);
|
| 50 |
+
|
| 51 |
+
const isExiting = exiting === module;
|
| 52 |
+
|
| 53 |
+
return (
|
| 54 |
+
<ModuleThemeProvider config={def.theme}>
|
| 55 |
+
<div
|
| 56 |
+
data-module={module}
|
| 57 |
+
data-testid={`module-shell-${module}`}
|
| 58 |
+
className={module === "s" ? "bg-module-s min-h-full" : ""}
|
| 59 |
+
>
|
| 60 |
+
<div className="flex h-screen bg-transparent text-zinc-100 overflow-hidden relative">
|
| 61 |
+
<GeometricBackground />
|
| 62 |
+
<BackgroundElements />
|
| 63 |
+
|
| 64 |
+
{/* Mobile overlay */}
|
| 65 |
+
{isSidebarOpen && (
|
| 66 |
+
<div
|
| 67 |
+
className="fixed inset-0 bg-black/60 z-30 md:hidden backdrop-blur-sm"
|
| 68 |
+
onClick={() => setIsSidebarOpen(false)}
|
| 69 |
+
/>
|
| 70 |
+
)}
|
| 71 |
+
|
| 72 |
+
{/* Sidebar with mobile slide transition */}
|
| 73 |
+
<div
|
| 74 |
+
className={`fixed inset-y-0 left-0 z-40 transform transition-transform duration-300 ease-in-out md:relative md:translate-x-0 ${
|
| 75 |
+
isSidebarOpen ? "translate-x-0" : "-translate-x-full"
|
| 76 |
+
}`}
|
| 77 |
+
>
|
| 78 |
+
<PlatformSidebar module={module} onClose={() => setIsSidebarOpen(false)} />
|
| 79 |
+
</div>
|
| 80 |
+
|
| 81 |
+
<div className="flex flex-col flex-1 min-w-0 overflow-hidden w-full">
|
| 82 |
+
<TopBar module={module} onMenuClick={() => setIsSidebarOpen(true)} />
|
| 83 |
+
<main className="flex-1 overflow-y-auto bg-transparent relative z-10 w-full p-2 md:p-0">
|
| 84 |
+
{/* Launch guard: the animation covers the workspace; pages load
|
| 85 |
+
(and prefetch their data) behind the opaque overlay. */}
|
| 86 |
+
<div className="relative min-h-full">
|
| 87 |
+
{!isExiting && (
|
| 88 |
+
<React.Suspense fallback={<div className="p-6" />}>
|
| 89 |
+
<Outlet />
|
| 90 |
+
</React.Suspense>
|
| 91 |
+
)}
|
| 92 |
+
<AnimatePresence>
|
| 93 |
+
{!launchDone && !isExiting && (
|
| 94 |
+
<motion.div
|
| 95 |
+
key="launch-overlay"
|
| 96 |
+
className={module === "s" ? "absolute inset-0 z-30 bg-module-s" : "absolute inset-0 z-30 bg-[#05070a]"}
|
| 97 |
+
exit={{ opacity: 0, transition: { duration: 0.45, ease: "easeOut" } }}
|
| 98 |
+
>
|
| 99 |
+
<ModuleLaunchAnimation
|
| 100 |
+
module={module}
|
| 101 |
+
mode="enter"
|
| 102 |
+
seed={seedRef.current}
|
| 103 |
+
onDone={() => setLaunchDone(true)}
|
| 104 |
+
accent={def.theme.accent}
|
| 105 |
+
accentSoft={def.theme.accentText}
|
| 106 |
+
/>
|
| 107 |
+
</motion.div>
|
| 108 |
+
)}
|
| 109 |
+
{isExiting && (
|
| 110 |
+
<motion.div
|
| 111 |
+
key="exit-overlay"
|
| 112 |
+
className={module === "s" ? "absolute inset-0 z-30 bg-module-s" : "absolute inset-0 z-30 bg-[#05070a]"}
|
| 113 |
+
>
|
| 114 |
+
<ModuleLaunchAnimation
|
| 115 |
+
module={module}
|
| 116 |
+
mode="exit"
|
| 117 |
+
seed={Date.now() ^ hashModuleId(module)}
|
| 118 |
+
onDone={() => finishExit()}
|
| 119 |
+
accent={def.theme.accent}
|
| 120 |
+
accentSoft={def.theme.accentText}
|
| 121 |
+
/>
|
| 122 |
+
</motion.div>
|
| 123 |
+
)}
|
| 124 |
+
</AnimatePresence>
|
| 125 |
+
</div>
|
| 126 |
+
</main>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
</div>
|
| 130 |
+
</ModuleThemeProvider>
|
| 131 |
+
);
|
| 132 |
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Link, useLocation, useNavigate } from "react-router-dom";
|
| 2 |
+
import { LayoutDashboard } from "lucide-react";
|
| 3 |
+
import { cn } from "../utils/cn";
|
| 4 |
+
import { useTheme } from "../context/ThemeContext";
|
| 5 |
+
import AnimatedLogo from "./../components/AnimatedLogo";
|
| 6 |
+
import Logo from "./../components/Logo";
|
| 7 |
+
import { useLaunch } from "./LaunchContext";
|
| 8 |
+
import { MODULES, ModuleId, moduleHref } from "./registry";
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Platform sidebar — wires the BRIDGE MODULES direct-launch section plus the
|
| 12 |
+
* active module's navigation registry. Launching a module plays its
|
| 13 |
+
* random-reassembly animation (re-seeded every launch).
|
| 14 |
+
*/
|
| 15 |
+
export default function PlatformSidebar({ module, onClose }: { module: ModuleId; onClose?: () => void }) {
|
| 16 |
+
const location = useLocation();
|
| 17 |
+
const navigate = useNavigate();
|
| 18 |
+
const { config } = useTheme();
|
| 19 |
+
const { startLaunch } = useLaunch();
|
| 20 |
+
const def = MODULES[module];
|
| 21 |
+
|
| 22 |
+
const launch = (target: ModuleId | "hub") => {
|
| 23 |
+
onClose?.();
|
| 24 |
+
startLaunch(target);
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
+
const isActiveModule = (id: ModuleId) => location.pathname.startsWith(MODULES[id].basePath);
|
| 28 |
+
const isActivePath = (path: string) => {
|
| 29 |
+
const full = moduleHref(module, path);
|
| 30 |
+
return path === "" ? location.pathname === full : location.pathname.startsWith(full);
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
return (
|
| 34 |
+
<div className="w-64 border-r border-white/5 bg-zinc-950/90 md:bg-zinc-950/60 backdrop-blur-2xl flex flex-col shrink-0 h-full relative z-20 shadow-[4px_0_24px_-4px_rgba(0,0,0,0.8)]">
|
| 35 |
+
<div className="h-16 flex items-center px-6 border-b border-white/5 shrink-0 gap-3">
|
| 36 |
+
<AnimatedLogo className="w-7 h-7" />
|
| 37 |
+
<Logo wordmark={def.wordmark} />
|
| 38 |
+
</div>
|
| 39 |
+
|
| 40 |
+
<nav className="flex-1 overflow-y-auto py-4 px-3 space-y-1">
|
| 41 |
+
{/* BRIDGE MODULES — direct-launch section (Phase 5) */}
|
| 42 |
+
<div className="mb-4">
|
| 43 |
+
<div className="px-3 pb-2 text-[9px] font-bold tracking-[0.22em] uppercase text-zinc-600 font-mono">
|
| 44 |
+
Bridge Modules
|
| 45 |
+
</div>
|
| 46 |
+
<div className="space-y-1.5">
|
| 47 |
+
{(["e", "s"] as ModuleId[]).map((id) => {
|
| 48 |
+
const m = MODULES[id];
|
| 49 |
+
const active = isActiveModule(id);
|
| 50 |
+
const Icon = m.icon;
|
| 51 |
+
return (
|
| 52 |
+
<button
|
| 53 |
+
key={id}
|
| 54 |
+
type="button"
|
| 55 |
+
onClick={() => launch(id)}
|
| 56 |
+
aria-current={active ? "page" : undefined}
|
| 57 |
+
className={cn(
|
| 58 |
+
"w-full flex items-center gap-3 px-3 py-2.5 text-[13px] font-medium rounded-lg transition-all duration-300 relative group overflow-hidden border text-left",
|
| 59 |
+
active
|
| 60 |
+
? "bg-white/5 border-white/10 shadow-[inset_0_1px_1px_rgba(255,255,255,0.05)]"
|
| 61 |
+
: "text-zinc-400 hover:text-zinc-200 hover:bg-white/5 border-transparent"
|
| 62 |
+
)}
|
| 63 |
+
style={active ? { color: m.theme.accentText } : {}}
|
| 64 |
+
>
|
| 65 |
+
{active && (
|
| 66 |
+
<span
|
| 67 |
+
className="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 rounded-r-full"
|
| 68 |
+
style={{ backgroundColor: m.theme.accent, boxShadow: `0 0 15px ${m.theme.accent}` }}
|
| 69 |
+
/>
|
| 70 |
+
)}
|
| 71 |
+
<span
|
| 72 |
+
className="w-5 h-5 rounded-md flex items-center justify-center shrink-0 border transition-transform duration-300 group-hover:scale-110"
|
| 73 |
+
style={{
|
| 74 |
+
backgroundColor: `${m.theme.accent}14`,
|
| 75 |
+
borderColor: `${m.theme.accent}44`,
|
| 76 |
+
}}
|
| 77 |
+
>
|
| 78 |
+
<Icon className="w-3 h-3" style={{ color: m.theme.accent }} />
|
| 79 |
+
</span>
|
| 80 |
+
<span className="flex-1">{m.label}</span>
|
| 81 |
+
<span
|
| 82 |
+
className="w-1.5 h-1.5 rounded-full shrink-0 transition-opacity"
|
| 83 |
+
style={{
|
| 84 |
+
backgroundColor: m.theme.accent,
|
| 85 |
+
boxShadow: `0 0 8px ${m.theme.accent}`,
|
| 86 |
+
opacity: active ? 1 : 0.35,
|
| 87 |
+
}}
|
| 88 |
+
/>
|
| 89 |
+
</button>
|
| 90 |
+
);
|
| 91 |
+
})}
|
| 92 |
+
</div>
|
| 93 |
+
<button
|
| 94 |
+
type="button"
|
| 95 |
+
onClick={() => launch("hub")}
|
| 96 |
+
className="mt-1.5 w-full flex items-center gap-3 px-3 py-2 text-[11px] font-medium rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-white/5 border border-transparent transition-all duration-300 text-left"
|
| 97 |
+
>
|
| 98 |
+
<LayoutDashboard className="w-3.5 h-3.5" />
|
| 99 |
+
Platform Hub
|
| 100 |
+
</button>
|
| 101 |
+
</div>
|
| 102 |
+
|
| 103 |
+
{/* Active module navigation */}
|
| 104 |
+
<div className="px-3 pb-2 pt-1 text-[9px] font-bold tracking-[0.22em] uppercase text-zinc-600 font-mono">
|
| 105 |
+
{def.label}
|
| 106 |
+
</div>
|
| 107 |
+
{def.nav.map((item) => {
|
| 108 |
+
const isActive = isActivePath(item.path);
|
| 109 |
+
const full = moduleHref(module, item.path);
|
| 110 |
+
return (
|
| 111 |
+
<button
|
| 112 |
+
key={item.name}
|
| 113 |
+
type="button"
|
| 114 |
+
onClick={() => {
|
| 115 |
+
onClose?.();
|
| 116 |
+
if (location.pathname !== full) navigate(full);
|
| 117 |
+
}}
|
| 118 |
+
aria-current={isActive ? "page" : undefined}
|
| 119 |
+
className={cn(
|
| 120 |
+
"w-full flex items-center gap-3 px-3 py-2.5 text-[13px] font-medium rounded-lg transition-all duration-300 relative group overflow-hidden border text-left",
|
| 121 |
+
isActive
|
| 122 |
+
? "bg-white/5 border-white/10 shadow-[inset_0_1px_1px_rgba(255,255,255,0.05)]"
|
| 123 |
+
: "text-zinc-400 hover:text-zinc-200 hover:bg-white/5 border-transparent"
|
| 124 |
+
)}
|
| 125 |
+
style={isActive ? { color: config.accentText } : {}}
|
| 126 |
+
>
|
| 127 |
+
{isActive && (
|
| 128 |
+
<div
|
| 129 |
+
className="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 rounded-r-full"
|
| 130 |
+
style={{
|
| 131 |
+
backgroundColor: config.accent,
|
| 132 |
+
boxShadow: `0 0 15px ${config.accent}`,
|
| 133 |
+
}}
|
| 134 |
+
/>
|
| 135 |
+
)}
|
| 136 |
+
<item.icon
|
| 137 |
+
className={cn("w-4 h-4 transition-transform duration-300 group-hover:scale-110", isActive ? "" : "text-zinc-500")}
|
| 138 |
+
style={isActive ? { color: config.accent, filter: `drop-shadow(0 0 8px ${config.accent})` } : {}}
|
| 139 |
+
/>
|
| 140 |
+
{item.name}
|
| 141 |
+
</button>
|
| 142 |
+
);
|
| 143 |
+
})}
|
| 144 |
+
</nav>
|
| 145 |
+
</div>
|
| 146 |
+
);
|
| 147 |
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { lazy } from "react";
|
| 2 |
+
import { ModuleId } from "./registry";
|
| 3 |
+
|
| 4 |
+
/* ------------------------------------------------------------------ */
|
| 5 |
+
/* Code-split module pages. Chunks are preloaded on hub mount and on */
|
| 6 |
+
/* menu-button hover so the launch animation never janks on fetch. */
|
| 7 |
+
/* ------------------------------------------------------------------ */
|
| 8 |
+
|
| 9 |
+
// Module E pages (mint theme namespace)
|
| 10 |
+
export const EDashboard = lazy(() => import("../pages/Dashboard"));
|
| 11 |
+
export const ECampaigns = lazy(() => import("../pages/Campaigns"));
|
| 12 |
+
export const ECampaignDetail = lazy(() => import("../pages/CampaignDetail"));
|
| 13 |
+
export const ELeads = lazy(() => import("../pages/Leads"));
|
| 14 |
+
export const EEmailAccounts = lazy(() => import("../pages/EmailAccounts"));
|
| 15 |
+
export const EWarmup = lazy(() => import("../pages/Warmup"));
|
| 16 |
+
export const EInbox = lazy(() => import("../pages/Inbox"));
|
| 17 |
+
export const EWebhooks = lazy(() => import("../pages/Webhooks"));
|
| 18 |
+
export const EAnalytics = lazy(() => import("../pages/Analytics"));
|
| 19 |
+
export const EClients = lazy(() => import("../pages/Clients"));
|
| 20 |
+
export const EPricing = lazy(() => import("../pages/Pricing"));
|
| 21 |
+
export const ESettings = lazy(() => import("../pages/Settings"));
|
| 22 |
+
|
| 23 |
+
// Module S pages (prod indigo namespace)
|
| 24 |
+
export const SDashboard = lazy(() => import("./s/pages/Dashboard"));
|
| 25 |
+
export const SCampaigns = lazy(() => import("./s/pages/Campaigns"));
|
| 26 |
+
export const SCampaignDetail = lazy(() => import("./s/pages/CampaignDetail"));
|
| 27 |
+
export const SLeads = lazy(() => import("./s/pages/Leads"));
|
| 28 |
+
export const SEmailAccounts = lazy(() => import("./s/pages/EmailAccounts"));
|
| 29 |
+
export const SWarmup = lazy(() => import("./s/pages/Warmup"));
|
| 30 |
+
export const SInbox = lazy(() => import("./s/pages/Inbox"));
|
| 31 |
+
export const SWebhooks = lazy(() => import("./s/pages/Webhooks"));
|
| 32 |
+
export const SAnalytics = lazy(() => import("./s/pages/Analytics"));
|
| 33 |
+
export const SClients = lazy(() => import("./s/pages/Clients"));
|
| 34 |
+
export const SSettings = lazy(() => import("./s/pages/Settings"));
|
| 35 |
+
|
| 36 |
+
const E_IMPORTS = [
|
| 37 |
+
() => import("../pages/Dashboard"),
|
| 38 |
+
() => import("../pages/Campaigns"),
|
| 39 |
+
() => import("../pages/CampaignDetail"),
|
| 40 |
+
() => import("../pages/Leads"),
|
| 41 |
+
() => import("../pages/EmailAccounts"),
|
| 42 |
+
() => import("../pages/Warmup"),
|
| 43 |
+
() => import("../pages/Inbox"),
|
| 44 |
+
() => import("../pages/Webhooks"),
|
| 45 |
+
() => import("../pages/Analytics"),
|
| 46 |
+
() => import("../pages/Clients"),
|
| 47 |
+
() => import("../pages/Pricing"),
|
| 48 |
+
() => import("../pages/Settings"),
|
| 49 |
+
];
|
| 50 |
+
|
| 51 |
+
const S_IMPORTS = [
|
| 52 |
+
() => import("./s/pages/Dashboard"),
|
| 53 |
+
() => import("./s/pages/Campaigns"),
|
| 54 |
+
() => import("./s/pages/CampaignDetail"),
|
| 55 |
+
() => import("./s/pages/Leads"),
|
| 56 |
+
() => import("./s/pages/EmailAccounts"),
|
| 57 |
+
() => import("./s/pages/Warmup"),
|
| 58 |
+
() => import("./s/pages/Inbox"),
|
| 59 |
+
() => import("./s/pages/Webhooks"),
|
| 60 |
+
() => import("./s/pages/Analytics"),
|
| 61 |
+
() => import("./s/pages/Clients"),
|
| 62 |
+
() => import("./s/pages/Settings"),
|
| 63 |
+
];
|
| 64 |
+
|
| 65 |
+
const preloaded = new Set<string>();
|
| 66 |
+
|
| 67 |
+
/** Warm every chunk of a module before its launch animation starts. */
|
| 68 |
+
export function preloadModulePages(id: ModuleId): void {
|
| 69 |
+
if (preloaded.has(id)) return;
|
| 70 |
+
preloaded.add(id);
|
| 71 |
+
const imports = id === "e" ? E_IMPORTS : S_IMPORTS;
|
| 72 |
+
imports.forEach((fn) => {
|
| 73 |
+
fn().catch(() => {
|
| 74 |
+
// Preload is best-effort; the Suspense boundary handles real failures.
|
| 75 |
+
});
|
| 76 |
+
});
|
| 77 |
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { describe, it, expect } from "vitest";
|
| 2 |
+
import { MODULES, MODULE_IDS, moduleHref, isModuleId } from "./registry";
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Naming migration gate: `modul` → `modules` everywhere, case-aware,
|
| 6 |
+
* zero stragglers (acceptance criterion).
|
| 7 |
+
*/
|
| 8 |
+
describe("modules naming migration", () => {
|
| 9 |
+
it("registers exactly Module E and Module S", () => {
|
| 10 |
+
expect(MODULE_IDS).toEqual(["e", "s"]);
|
| 11 |
+
expect(MODULES.e.label).toBe("Module E");
|
| 12 |
+
expect(MODULES.s.label).toBe("Module S");
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
it("routes live under the /modules namespace", () => {
|
| 16 |
+
expect(MODULES.e.basePath).toBe("/modules/e");
|
| 17 |
+
expect(MODULES.s.basePath).toBe("/modules/s");
|
| 18 |
+
expect(moduleHref("e", "campaigns")).toBe("/modules/e/campaigns");
|
| 19 |
+
expect(moduleHref("s", "campaigns")).toBe("/modules/s/campaigns");
|
| 20 |
+
expect(moduleHref("e")).toBe("/modules/e");
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
it("contains zero `modul` stragglers (case-aware) in labels, wordmarks and routes", () => {
|
| 24 |
+
const strings: string[] = [];
|
| 25 |
+
MODULE_IDS.forEach((id) => {
|
| 26 |
+
const m = MODULES[id];
|
| 27 |
+
strings.push(m.label, m.wordmark, m.basePath, m.engineLabel, m.blurb);
|
| 28 |
+
m.nav.forEach((n) => strings.push(n.name, n.path));
|
| 29 |
+
});
|
| 30 |
+
const stragglers = strings.filter((s) => /modul(?!e)/i.test(s));
|
| 31 |
+
expect(stragglers).toEqual([]);
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
it("wordmarks carry the migrated Module prefix", () => {
|
| 35 |
+
expect(MODULES.e.wordmark).toBe("ModuleE");
|
| 36 |
+
expect(MODULES.s.wordmark).toBe("ModuleS");
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
it("module id guard works", () => {
|
| 40 |
+
expect(isModuleId("e")).toBe(true);
|
| 41 |
+
expect(isModuleId("s")).toBe(true);
|
| 42 |
+
expect(isModuleId("x")).toBe(false);
|
| 43 |
+
expect(isModuleId(undefined)).toBe(false);
|
| 44 |
+
});
|
| 45 |
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { LayoutDashboard, Megaphone, Users, Mail, Flame, Inbox, Webhook, BarChart2, Building2, CreditCard, Settings, Zap, Boxes, LucideIcon } from "lucide-react";
|
| 2 |
+
import { MINT_THEME, PROD_THEME, ThemeConfig } from "../context/ThemeContext";
|
| 3 |
+
|
| 4 |
+
export type ModuleId = "e" | "s";
|
| 5 |
+
|
| 6 |
+
export interface ModuleNavItem {
|
| 7 |
+
name: string;
|
| 8 |
+
path: string; // relative to the module namespace, e.g. "" for index, "campaigns"
|
| 9 |
+
icon: LucideIcon;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
export interface ModuleDefinition {
|
| 13 |
+
id: ModuleId;
|
| 14 |
+
/** Menu label, e.g. "Module E" */
|
| 15 |
+
label: string;
|
| 16 |
+
/** Logo wordmark, e.g. "ModuleE" */
|
| 17 |
+
wordmark: string;
|
| 18 |
+
/** Route namespace: /modules/e */
|
| 19 |
+
basePath: string;
|
| 20 |
+
icon: LucideIcon;
|
| 21 |
+
theme: ThemeConfig;
|
| 22 |
+
/** Short capability line shown on the hub cards */
|
| 23 |
+
blurb: string;
|
| 24 |
+
/** Engine label shown in the TopBar telemetry strip */
|
| 25 |
+
engineLabel: string;
|
| 26 |
+
nav: ModuleNavItem[];
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
const SHARED_NAV: ModuleNavItem[] = [
|
| 30 |
+
{ name: "Campaigns", path: "campaigns", icon: Megaphone },
|
| 31 |
+
{ name: "Leads", path: "leads", icon: Users },
|
| 32 |
+
{ name: "Email Accounts", path: "email-accounts", icon: Mail },
|
| 33 |
+
{ name: "Warmup", path: "warmup", icon: Flame },
|
| 34 |
+
{ name: "Unified Inbox", path: "inbox", icon: Inbox },
|
| 35 |
+
{ name: "Webhooks", path: "webhooks", icon: Webhook },
|
| 36 |
+
{ name: "Analytics", path: "analytics", icon: BarChart2 },
|
| 37 |
+
{ name: "Clients", path: "clients", icon: Building2 },
|
| 38 |
+
{ name: "Settings", path: "settings", icon: Settings },
|
| 39 |
+
];
|
| 40 |
+
|
| 41 |
+
export const MODULES: Record<ModuleId, ModuleDefinition> = {
|
| 42 |
+
e: {
|
| 43 |
+
id: "e",
|
| 44 |
+
label: "Module E",
|
| 45 |
+
wordmark: "ModuleE",
|
| 46 |
+
basePath: "/modules/e",
|
| 47 |
+
icon: Zap,
|
| 48 |
+
theme: MINT_THEME,
|
| 49 |
+
blurb: "Autonomous cold outreach infrastructure, sequence management, unified inbox, email warmup, and deliverability command center.",
|
| 50 |
+
engineLabel: "ModuleE Engine",
|
| 51 |
+
nav: [
|
| 52 |
+
{ name: "Command Center", path: "", icon: LayoutDashboard },
|
| 53 |
+
...SHARED_NAV.slice(0, 8),
|
| 54 |
+
{ name: "Pricing", path: "pricing", icon: CreditCard },
|
| 55 |
+
{ name: "Settings", path: "settings", icon: Settings },
|
| 56 |
+
],
|
| 57 |
+
},
|
| 58 |
+
s: {
|
| 59 |
+
id: "s",
|
| 60 |
+
label: "Module S",
|
| 61 |
+
wordmark: "ModuleS",
|
| 62 |
+
basePath: "/modules/s",
|
| 63 |
+
icon: Boxes,
|
| 64 |
+
theme: PROD_THEME,
|
| 65 |
+
blurb: "Advanced campaign management, sequences, unified inbox, email warmup, lead database, analytics, and webhook automation.",
|
| 66 |
+
engineLabel: "ModuleS Engine",
|
| 67 |
+
nav: [
|
| 68 |
+
{ name: "Dashboard", path: "", icon: LayoutDashboard },
|
| 69 |
+
...SHARED_NAV,
|
| 70 |
+
],
|
| 71 |
+
},
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
export const MODULE_IDS: ModuleId[] = ["e", "s"];
|
| 75 |
+
|
| 76 |
+
export function moduleHref(id: ModuleId, path = ""): string {
|
| 77 |
+
const base = MODULES[id].basePath;
|
| 78 |
+
return path ? `${base}/${path}` : base;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
export function isModuleId(value: string | undefined): value is ModuleId {
|
| 82 |
+
return value === "e" || value === "s";
|
| 83 |
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
| 2 |
+
import { render, screen, waitFor } from "@testing-library/react";
|
| 3 |
+
import userEvent from "@testing-library/user-event";
|
| 4 |
+
import { MemoryRouter, Routes, Route } from "react-router-dom";
|
| 5 |
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
| 6 |
+
import ModuleHub from "./ModuleHub";
|
| 7 |
+
import ModuleShell from "./ModuleShell";
|
| 8 |
+
import { LaunchProvider } from "./LaunchContext";
|
| 9 |
+
import { ThemeProvider } from "../context/ThemeContext";
|
| 10 |
+
import { ApiKeyProvider } from "../context/ApiKeyContext";
|
| 11 |
+
import { EDashboard, SCampaigns } from "./lazyPages";
|
| 12 |
+
import { apiClient } from "../lib/apiClient";
|
| 13 |
+
|
| 14 |
+
vi.mock("recharts", () => ({
|
| 15 |
+
ResponsiveContainer: ({ children }: any) => <div>{children}</div>,
|
| 16 |
+
AreaChart: () => <div>AreaChart</div>,
|
| 17 |
+
Area: () => <div />,
|
| 18 |
+
XAxis: () => <div />,
|
| 19 |
+
YAxis: () => <div />,
|
| 20 |
+
Tooltip: () => <div />,
|
| 21 |
+
LineChart: () => <div>LineChart</div>,
|
| 22 |
+
BarChart: () => <div>BarChart</div>,
|
| 23 |
+
Line: () => <div />,
|
| 24 |
+
Bar: () => <div />,
|
| 25 |
+
CartesianGrid: () => <div />,
|
| 26 |
+
Legend: () => <div />,
|
| 27 |
+
PieChart: () => <div>PieChart</div>,
|
| 28 |
+
Pie: () => <div />,
|
| 29 |
+
Cell: () => <div />,
|
| 30 |
+
}));
|
| 31 |
+
|
| 32 |
+
vi.mock("../lib/apiClient", () => ({
|
| 33 |
+
apiClient: { get: vi.fn().mockResolvedValue({ data: [] }) },
|
| 34 |
+
}));
|
| 35 |
+
|
| 36 |
+
vi.mock("../lib/supabaseClient", () => ({
|
| 37 |
+
supabase: null,
|
| 38 |
+
isSupabaseConfigured: false,
|
| 39 |
+
}));
|
| 40 |
+
|
| 41 |
+
function makeWrapper(initialEntries: string[]) {
|
| 42 |
+
const queryClient = new QueryClient({
|
| 43 |
+
defaultOptions: { queries: { retry: false, gcTime: 0 } },
|
| 44 |
+
});
|
| 45 |
+
return (
|
| 46 |
+
<QueryClientProvider client={queryClient}>
|
| 47 |
+
<ThemeProvider>
|
| 48 |
+
<ApiKeyProvider>
|
| 49 |
+
<MemoryRouter initialEntries={initialEntries}>
|
| 50 |
+
<LaunchProvider>
|
| 51 |
+
<Routes>
|
| 52 |
+
<Route path="/" element={<ModuleHub />} />
|
| 53 |
+
<Route path="/modules/e" element={<ModuleShell module="e" />}>
|
| 54 |
+
<Route index element={<EDashboard />} />
|
| 55 |
+
</Route>
|
| 56 |
+
<Route path="/modules/s" element={<ModuleShell module="s" />}>
|
| 57 |
+
<Route path="campaigns" element={<SCampaigns />} />
|
| 58 |
+
</Route>
|
| 59 |
+
</Routes>
|
| 60 |
+
</LaunchProvider>
|
| 61 |
+
</MemoryRouter>
|
| 62 |
+
</ApiKeyProvider>
|
| 63 |
+
</ThemeProvider>
|
| 64 |
+
</QueryClientProvider>
|
| 65 |
+
);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
describe("BRIDGE platform routing", () => {
|
| 69 |
+
beforeEach(() => {
|
| 70 |
+
vi.clearAllMocks();
|
| 71 |
+
(apiClient.get as any).mockResolvedValue({ data: [] });
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
it("hub renders both module launcher cards with direct-launch buttons", () => {
|
| 75 |
+
render(makeWrapper(["/"]));
|
| 76 |
+
expect(screen.getAllByText(/BRIDGE/).length).toBeGreaterThan(0);
|
| 77 |
+
expect(screen.getByRole("button", { name: /Launch Module E/i })).toBeTruthy();
|
| 78 |
+
expect(screen.getByRole("button", { name: /Launch Module S/i })).toBeTruthy();
|
| 79 |
+
expect(screen.getByText(/Direct URLs/i)).toBeTruthy();
|
| 80 |
+
});
|
| 81 |
+
|
| 82 |
+
it("direct URL load of /modules/e mounts the E shell with its launch guard", async () => {
|
| 83 |
+
render(makeWrapper(["/modules/e"]));
|
| 84 |
+
expect(screen.getByTestId("module-shell-e")).toBeTruthy();
|
| 85 |
+
expect(screen.getByTestId("module-launch-animation")).toBeTruthy();
|
| 86 |
+
// Real dashboard primitives assemble — StatCards carry real titles
|
| 87 |
+
await waitFor(() => {
|
| 88 |
+
expect(screen.getAllByText(/Total Leads/i).length).toBeGreaterThan(0);
|
| 89 |
+
});
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
it("direct URL load of /modules/s mounts the S shell with the S campaign page", async () => {
|
| 93 |
+
render(makeWrapper(["/modules/s/campaigns"]));
|
| 94 |
+
expect(screen.getByTestId("module-shell-s")).toBeTruthy();
|
| 95 |
+
expect(screen.getByTestId("module-launch-animation")).toBeTruthy();
|
| 96 |
+
await waitFor(() => {
|
| 97 |
+
expect(document.querySelector('[data-module="s"]')).toBeTruthy();
|
| 98 |
+
});
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
it("launch animation reveals the workspace when completed", async () => {
|
| 102 |
+
vi.useFakeTimers({ shouldAdvanceTime: true });
|
| 103 |
+
try {
|
| 104 |
+
render(makeWrapper(["/modules/e"]));
|
| 105 |
+
expect(screen.getByTestId("module-launch-animation")).toBeTruthy();
|
| 106 |
+
// Watchdog completes the assembly (slow-motion budget ≈ 3.3s)
|
| 107 |
+
await vi.advanceTimersByTimeAsync(4000);
|
| 108 |
+
await waitFor(() => {
|
| 109 |
+
expect(screen.queryByTestId("module-launch-animation")).toBeNull();
|
| 110 |
+
});
|
| 111 |
+
} finally {
|
| 112 |
+
vi.useRealTimers();
|
| 113 |
+
}
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
it("launching Module S from the hub routes to /modules/s", async () => {
|
| 117 |
+
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
| 118 |
+
vi.useFakeTimers({ shouldAdvanceTime: true });
|
| 119 |
+
try {
|
| 120 |
+
render(makeWrapper(["/"]));
|
| 121 |
+
await user.click(screen.getByRole("button", { name: /Launch Module S/i }));
|
| 122 |
+
await vi.advanceTimersByTimeAsync(4000);
|
| 123 |
+
await waitFor(() => {
|
| 124 |
+
expect(screen.getByTestId("module-shell-s")).toBeTruthy();
|
| 125 |
+
});
|
| 126 |
+
} finally {
|
| 127 |
+
vi.useRealTimers();
|
| 128 |
+
}
|
| 129 |
+
});
|
| 130 |
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { motion } from "motion/react";
|
| 2 |
+
|
| 3 |
+
export default function AnimatedLogo({ className = "w-8 h-8" }: { className?: string }) {
|
| 4 |
+
return (
|
| 5 |
+
<motion.svg
|
| 6 |
+
className={className}
|
| 7 |
+
viewBox="0 0 100 100"
|
| 8 |
+
fill="none"
|
| 9 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 10 |
+
initial={{ opacity: 0, y: 10 }}
|
| 11 |
+
animate={{ opacity: 1, y: 0 }}
|
| 12 |
+
transition={{ duration: 0.8, ease: [0.16, 1, 0.3, 1] }}
|
| 13 |
+
>
|
| 14 |
+
<defs>
|
| 15 |
+
<linearGradient id="crypto-grad-1" x1="0%" y1="0%" x2="100%" y2="100%">
|
| 16 |
+
<stop offset="0%" stopColor="#4f46e5" /> {/* Indigo 600 */}
|
| 17 |
+
<stop offset="100%" stopColor="#0ea5e9" /> {/* Sky 500 */}
|
| 18 |
+
</linearGradient>
|
| 19 |
+
<linearGradient id="crypto-grad-2" x1="100%" y1="0%" x2="0%" y2="100%">
|
| 20 |
+
<stop offset="0%" stopColor="#2dd4bf" /> {/* Teal 400 */}
|
| 21 |
+
<stop offset="100%" stopColor="#3b82f6" /> {/* Blue 500 */}
|
| 22 |
+
</linearGradient>
|
| 23 |
+
<filter id="neon-glow" x="-20%" y="-20%" width="140%" height="140%">
|
| 24 |
+
<feGaussianBlur stdDeviation="4" result="blur" />
|
| 25 |
+
<feComposite in="SourceGraphic" in2="blur" operator="over" />
|
| 26 |
+
</filter>
|
| 27 |
+
</defs>
|
| 28 |
+
|
| 29 |
+
{/* Background glowing element */}
|
| 30 |
+
<motion.polygon
|
| 31 |
+
points="50,5 90,27.5 90,72.5 50,95 10,72.5 10,27.5"
|
| 32 |
+
fill="url(#crypto-grad-1)"
|
| 33 |
+
fillOpacity="0.1"
|
| 34 |
+
stroke="url(#crypto-grad-2)"
|
| 35 |
+
strokeWidth="2"
|
| 36 |
+
filter="url(#neon-glow)"
|
| 37 |
+
initial={{ scale: 0.8, opacity: 0, rotate: -30 }}
|
| 38 |
+
animate={{ scale: 1, opacity: 1, rotate: 0 }}
|
| 39 |
+
transition={{ duration: 1.2, ease: "easeOut" }}
|
| 40 |
+
/>
|
| 41 |
+
|
| 42 |
+
{/* Abstract Sharp 'S' inside */}
|
| 43 |
+
<motion.path
|
| 44 |
+
d="M 65 35 L 35 35 L 35 50 L 65 50 L 65 65 L 35 65"
|
| 45 |
+
stroke="url(#crypto-grad-2)"
|
| 46 |
+
strokeWidth="10"
|
| 47 |
+
strokeLinecap="square"
|
| 48 |
+
strokeLinejoin="miter"
|
| 49 |
+
initial={{ pathLength: 0 }}
|
| 50 |
+
animate={{ pathLength: 1 }}
|
| 51 |
+
transition={{ duration: 1.5, ease: "easeInOut", delay: 0.4 }}
|
| 52 |
+
/>
|
| 53 |
+
|
| 54 |
+
{/* Accent bridging line */}
|
| 55 |
+
<motion.line
|
| 56 |
+
x1="20"
|
| 57 |
+
y1="50"
|
| 58 |
+
x2="80"
|
| 59 |
+
y2="50"
|
| 60 |
+
stroke="url(#crypto-grad-1)"
|
| 61 |
+
strokeWidth="4"
|
| 62 |
+
filter="url(#neon-glow)"
|
| 63 |
+
initial={{ scaleX: 0, opacity: 0 }}
|
| 64 |
+
animate={{ scaleX: 1, opacity: 1 }}
|
| 65 |
+
transition={{ duration: 1, ease: "easeOut", delay: 1 }}
|
| 66 |
+
/>
|
| 67 |
+
</motion.svg>
|
| 68 |
+
);
|
| 69 |
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { ReactNode } from 'react';
|
| 2 |
+
import { cn } from '../../../utils/cn';
|
| 3 |
+
|
| 4 |
+
interface GlassCardProps {
|
| 5 |
+
children: ReactNode;
|
| 6 |
+
className?: string;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export default function GlassCard({ children, className }: GlassCardProps) {
|
| 10 |
+
return (
|
| 11 |
+
<div className={cn("bg-white/5 border border-white/10 backdrop-blur-md rounded-xl shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]", className)}>
|
| 12 |
+
{children}
|
| 13 |
+
</div>
|
| 14 |
+
);
|
| 15 |
+
}
|
|
@@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
+
title: string;
|
| 6 |
+
value: string | number;
|
| 7 |
+
icon: LucideIcon;
|
| 8 |
+
iconColor?: "indigo" | "emerald" | "amber" | "rose" | "teal" | "blue" | "purple";
|
| 9 |
+
change?: {
|
| 10 |
+
value: string;
|
| 11 |
+
isPositive?: boolean | null;
|
| 12 |
+
period?: string;
|
| 13 |
+
};
|
| 14 |
+
subtitle?: string;
|
| 15 |
+
progress?: number; // 0 to 100
|
| 16 |
+
className?: string;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
const colorMap = {
|
| 20 |
+
indigo: {
|
| 21 |
+
bg: "bg-indigo-500/10",
|
| 22 |
+
border: "border-indigo-500/20",
|
| 23 |
+
text: "text-indigo-400",
|
| 24 |
+
glow: "group-hover:border-indigo-500/40",
|
| 25 |
+
},
|
| 26 |
+
emerald: {
|
| 27 |
+
bg: "bg-emerald-500/10",
|
| 28 |
+
border: "border-emerald-500/20",
|
| 29 |
+
text: "text-emerald-400",
|
| 30 |
+
glow: "group-hover:border-emerald-500/40",
|
| 31 |
+
},
|
| 32 |
+
amber: {
|
| 33 |
+
bg: "bg-amber-500/10",
|
| 34 |
+
border: "border-amber-500/20",
|
| 35 |
+
text: "text-amber-400",
|
| 36 |
+
glow: "group-hover:border-amber-500/40",
|
| 37 |
+
},
|
| 38 |
+
rose: {
|
| 39 |
+
bg: "bg-rose-500/10",
|
| 40 |
+
border: "border-rose-500/20",
|
| 41 |
+
text: "text-rose-400",
|
| 42 |
+
glow: "group-hover:border-rose-500/40",
|
| 43 |
+
},
|
| 44 |
+
teal: {
|
| 45 |
+
bg: "bg-teal-500/10",
|
| 46 |
+
border: "border-teal-500/20",
|
| 47 |
+
text: "text-teal-400",
|
| 48 |
+
glow: "group-hover:border-teal-500/40",
|
| 49 |
+
},
|
| 50 |
+
blue: {
|
| 51 |
+
bg: "bg-blue-500/10",
|
| 52 |
+
border: "border-blue-500/20",
|
| 53 |
+
text: "text-blue-400",
|
| 54 |
+
glow: "group-hover:border-blue-500/40",
|
| 55 |
+
},
|
| 56 |
+
purple: {
|
| 57 |
+
bg: "bg-purple-500/10",
|
| 58 |
+
border: "border-purple-500/20",
|
| 59 |
+
text: "text-purple-400",
|
| 60 |
+
glow: "group-hover:border-purple-500/40",
|
| 61 |
+
},
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
export default function StatCard({
|
| 65 |
+
title,
|
| 66 |
+
value,
|
| 67 |
+
icon: Icon,
|
| 68 |
+
iconColor = "indigo",
|
| 69 |
+
change,
|
| 70 |
+
subtitle,
|
| 71 |
+
progress,
|
| 72 |
+
className,
|
| 73 |
+
}: StatCardProps) {
|
| 74 |
+
const c = colorMap[iconColor];
|
| 75 |
+
|
| 76 |
+
return (
|
| 77 |
+
<div
|
| 78 |
+
className={cn(
|
| 79 |
+
"group relative bg-white/5 hover:bg-white/10 backdrop-blur-md border border-white/10 rounded-xl p-5 transition-all duration-300 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)] overflow-hidden",
|
| 80 |
+
className
|
| 81 |
+
)}
|
| 82 |
+
>
|
| 83 |
+
<div className="absolute inset-0 bg-gradient-to-br from-white/[0.03] to-transparent pointer-events-none" />
|
| 84 |
+
<div className="relative z-10 flex justify-between items-start">
|
| 85 |
+
<div>
|
| 86 |
+
<p className="text-xs font-semibold uppercase tracking-wider text-zinc-400 font-sans">
|
| 87 |
+
{title}
|
| 88 |
+
</p>
|
| 89 |
+
<h3 className="text-2xl font-bold text-zinc-100 mt-2 tracking-tight font-mono">
|
| 90 |
+
{value}
|
| 91 |
+
</h3>
|
| 92 |
+
{subtitle && (
|
| 93 |
+
<p className="text-xs text-zinc-500 mt-1 font-sans">{subtitle}</p>
|
| 94 |
+
)}
|
| 95 |
+
</div>
|
| 96 |
+
<div
|
| 97 |
+
className={cn(
|
| 98 |
+
"p-2.5 rounded-xl border transition-transform duration-300 group-hover:scale-110 shadow-[inset_0_1px_1px_rgba(255,255,255,0.1)]",
|
| 99 |
+
c.bg,
|
| 100 |
+
c.border
|
| 101 |
+
)}
|
| 102 |
+
>
|
| 103 |
+
<Icon className={cn("w-5 h-5 drop-shadow-[0_0_8px_currentColor]", c.text)} />
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
{progress !== undefined && (
|
| 108 |
+
<div className="relative z-10 mt-4 space-y-1.5">
|
| 109 |
+
<div className="flex justify-between text-[11px] text-zinc-400 font-sans font-medium">
|
| 110 |
+
<span>Capacity</span>
|
| 111 |
+
<span className="font-mono">{Math.round(progress)}%</span>
|
| 112 |
+
</div>
|
| 113 |
+
<div className="w-full h-1.5 bg-black/50 border border-white/5 rounded-full overflow-hidden">
|
| 114 |
+
<div
|
| 115 |
+
className={cn("h-full rounded-full transition-all duration-500", c.text.replace("text-", "bg-"))}
|
| 116 |
+
style={{ width: `${Math.min(100, Math.max(0, progress))}%`, boxShadow: '0 0 10px currentColor' }}
|
| 117 |
+
/>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
)}
|
| 121 |
+
|
| 122 |
+
{change && (
|
| 123 |
+
<div className="relative z-10 mt-3.5 flex items-center text-xs font-medium font-sans">
|
| 124 |
+
{change.isPositive === true && (
|
| 125 |
+
<span className="flex items-center text-emerald-400 mr-1.5">
|
| 126 |
+
<TrendingUp className="w-3.5 h-3.5 mr-0.5" />
|
| 127 |
+
<span className="font-mono">{change.value}</span>
|
| 128 |
+
</span>
|
| 129 |
+
)}
|
| 130 |
+
{change.isPositive === false && (
|
| 131 |
+
<span className="flex items-center text-rose-400 mr-1.5">
|
| 132 |
+
<TrendingDown className="w-3.5 h-3.5 mr-0.5" />
|
| 133 |
+
<span className="font-mono">{change.value}</span>
|
| 134 |
+
</span>
|
| 135 |
+
)}
|
| 136 |
+
{change.isPositive === null && (
|
| 137 |
+
<span className="flex items-center text-zinc-400 mr-1.5">
|
| 138 |
+
<Minus className="w-3.5 h-3.5 mr-0.5" />
|
| 139 |
+
<span className="font-mono">{change.value}</span>
|
| 140 |
+
</span>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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
BarChart2,
|
| 5 |
+
TrendingUp,
|
| 6 |
+
Download,
|
| 7 |
+
Calendar,
|
| 8 |
+
Mail,
|
| 9 |
+
Inbox,
|
| 10 |
+
Flame,
|
| 11 |
+
ShieldCheck,
|
| 12 |
+
Percent,
|
| 13 |
+
ArrowUpRight
|
| 14 |
+
} from "lucide-react";
|
| 15 |
+
import {
|
| 16 |
+
ResponsiveContainer,
|
| 17 |
+
LineChart,
|
| 18 |
+
Line,
|
| 19 |
+
BarChart,
|
| 20 |
+
Bar,
|
| 21 |
+
XAxis,
|
| 22 |
+
YAxis,
|
| 23 |
+
CartesianGrid,
|
| 24 |
+
Tooltip,
|
| 25 |
+
Legend
|
| 26 |
+
} from "recharts";
|
| 27 |
+
import { useState } from "react";
|
| 28 |
+
import StatCard from "../components/StatCard";
|
| 29 |
+
import CsvExportButton from "../../../components/CsvExportButton";
|
| 30 |
+
|
| 31 |
+
const timelineData = [
|
| 32 |
+
{ date: "Oct 1", sent: 820, opens: 530, replies: 48, bounces: 4 },
|
| 33 |
+
{ date: "Oct 5", sent: 1140, opens: 760, replies: 72, bounces: 8 },
|
| 34 |
+
{ date: "Oct 10", sent: 1650, opens: 1120, replies: 98, bounces: 11 },
|
| 35 |
+
{ date: "Oct 15", sent: 2100, opens: 1450, replies: 134, bounces: 15 },
|
| 36 |
+
{ date: "Oct 20", sent: 2800, opens: 1980, replies: 182, bounces: 21 },
|
| 37 |
+
{ date: "Oct 25", sent: 3400, opens: 2450, replies: 226, bounces: 28 },
|
| 38 |
+
{ date: "Oct 30", sent: 4120, opens: 2980, replies: 280, bounces: 34 },
|
| 39 |
+
];
|
| 40 |
+
|
| 41 |
+
const campaignComparisonData = [
|
| 42 |
+
{ name: "SaaS Enterprise VPs", sent: 4200, opens: 2600, replies: 240 },
|
| 43 |
+
{ name: "Series A Tech Founders", sent: 3100, opens: 2100, replies: 195 },
|
| 44 |
+
{ name: "Agency Owners Q4", sent: 2400, opens: 1400, replies: 120 },
|
| 45 |
+
{ name: "E-commerce Directors", sent: 1800, opens: 980, replies: 84 },
|
| 46 |
+
{ name: "RevOps Decision Makers", sent: 1200, opens: 720, replies: 65 },
|
| 47 |
+
];
|
| 48 |
+
|
| 49 |
+
export default function Analytics() {
|
| 50 |
+
const [dateRange, setDateRange] = useState("30d");
|
| 51 |
+
|
| 52 |
+
const { data: analytics } = useQuery({
|
| 53 |
+
queryKey: ["analytics-campaigns"],
|
| 54 |
+
queryFn: async () => {
|
| 55 |
+
const res = await apiClient.get("/analytics/campaigns");
|
| 56 |
+
return res.data;
|
| 57 |
+
},
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
const { data: emailAccounts = [] } = useQuery({
|
| 61 |
+
queryKey: ["email-accounts"],
|
| 62 |
+
queryFn: async () => {
|
| 63 |
+
const res = await apiClient.get("/email-accounts");
|
| 64 |
+
return res.data;
|
| 65 |
+
},
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
return (
|
| 69 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 70 |
+
{/* Header */}
|
| 71 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 72 |
+
<div>
|
| 73 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 74 |
+
<BarChart2 className="w-6 h-6 text-indigo-400" />
|
| 75 |
+
Outbound Analytics & Intelligence
|
| 76 |
+
</h1>
|
| 77 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 78 |
+
Global deliverability performance, engagement conversion funnels, and mailbox health telemetry.
|
| 79 |
+
</p>
|
| 80 |
+
</div>
|
| 81 |
+
|
| 82 |
+
<div className="flex items-center gap-3">
|
| 83 |
+
<select
|
| 84 |
+
value={dateRange}
|
| 85 |
+
onChange={(e) => setDateRange(e.target.value)}
|
| 86 |
+
className="bg-zinc-900 border border-zinc-800 rounded-lg py-2 px-3 text-xs text-zinc-200 focus:outline-none focus:border-indigo-500"
|
| 87 |
+
>
|
| 88 |
+
<option value="7d">Last 7 Days</option>
|
| 89 |
+
<option value="14d">Last 14 Days</option>
|
| 90 |
+
<option value="30d">Last 30 Days</option>
|
| 91 |
+
<option value="90d">Last 90 Days</option>
|
| 92 |
+
</select>
|
| 93 |
+
<CsvExportButton data={timelineData} filename="smartlead-analytics-export.csv" />
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
{/* KPI Conversion Cards */}
|
| 98 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
| 99 |
+
<StatCard
|
| 100 |
+
title="Open Rate"
|
| 101 |
+
value="64.8%"
|
| 102 |
+
subtitle="4,890 unique opens"
|
| 103 |
+
icon={Mail}
|
| 104 |
+
iconColor="emerald"
|
| 105 |
+
change={{ value: "+3.4%", isPositive: true, period: "vs benchmark" }}
|
| 106 |
+
/>
|
| 107 |
+
<StatCard
|
| 108 |
+
title="Click Rate (CTR)"
|
| 109 |
+
value="18.2%"
|
| 110 |
+
subtitle="1,120 link clicks"
|
| 111 |
+
icon={ArrowUpRight}
|
| 112 |
+
iconColor="blue"
|
| 113 |
+
change={{ value: "+1.1%", isPositive: true, period: "last 30 days" }}
|
| 114 |
+
/>
|
| 115 |
+
<StatCard
|
| 116 |
+
title="Reply Rate"
|
| 117 |
+
value="6.2%"
|
| 118 |
+
subtitle="378 prospect responses"
|
| 119 |
+
icon={Inbox}
|
| 120 |
+
iconColor="purple"
|
| 121 |
+
change={{ value: "+0.8%", isPositive: true, period: "positive intent" }}
|
| 122 |
+
/>
|
| 123 |
+
<StatCard
|
| 124 |
+
title="Bounce Rate"
|
| 125 |
+
value="0.7%"
|
| 126 |
+
subtitle="Deliverability safe"
|
| 127 |
+
icon={ShieldCheck}
|
| 128 |
+
iconColor="teal"
|
| 129 |
+
change={{ value: "-0.2%", isPositive: true, period: "health optimal" }}
|
| 130 |
+
/>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
{/* Timeline Chart */}
|
| 134 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 135 |
+
<div className="flex items-center justify-between mb-6">
|
| 136 |
+
<div>
|
| 137 |
+
<h3 className="text-base font-semibold text-zinc-100">Cumulative Volume & Responses</h3>
|
| 138 |
+
<p className="text-xs text-zinc-400 mt-0.5">
|
| 139 |
+
Daily trajectory of outbound sends, unique opens, and replied prospects.
|
| 140 |
+
</p>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
|
| 144 |
+
<div className="h-[320px] w-full">
|
| 145 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 146 |
+
<LineChart data={timelineData} margin={{ top: 5, right: 20, bottom: 5, left: 0 }}>
|
| 147 |
+
<CartesianGrid strokeDasharray="3 3" stroke="rgba(255,255,255,0.05)" vertical={false} />
|
| 148 |
+
<XAxis dataKey="date" stroke="#a1a1aa" fontSize={12} tickLine={false} axisLine={false} />
|
| 149 |
+
<YAxis stroke="#a1a1aa" fontSize={12} tickLine={false} axisLine={false} tickFormatter={(val) => new Intl.NumberFormat('en-US').format(val)} className="font-mono" />
|
| 150 |
+
<Tooltip
|
| 151 |
+
contentStyle={{
|
| 152 |
+
backgroundColor: "rgba(9, 9, 11, 0.8)",
|
| 153 |
+
backdropFilter: "blur(12px)",
|
| 154 |
+
borderColor: "rgba(255,255,255,0.1)",
|
| 155 |
+
borderRadius: "12px",
|
| 156 |
+
fontSize: "12px",
|
| 157 |
+
color: "#e4e4e7"
|
| 158 |
+
}}
|
| 159 |
+
/>
|
| 160 |
+
<Legend wrapperStyle={{ fontSize: "12px", paddingTop: "10px" }} />
|
| 161 |
+
<Line type="monotone" dataKey="sent" name="Emails Sent" stroke="#3b82f6" strokeWidth={3} dot={{ r: 4, fill: '#3b82f6', strokeWidth: 2, stroke: '#000' }} activeDot={{ r: 6, fill: '#60a5fa' }} animationDuration={1500} />
|
| 162 |
+
<Line type="monotone" dataKey="opens" name="Opens" stroke="#10b981" strokeWidth={3} dot={{ r: 4, fill: '#10b981', strokeWidth: 2, stroke: '#000' }} activeDot={{ r: 6, fill: '#34d399' }} animationDuration={1500} />
|
| 163 |
+
<Line type="monotone" dataKey="replies" name="Replies" stroke="#a855f7" strokeWidth={3} dot={{ r: 4, fill: '#a855f7', strokeWidth: 2, stroke: '#000' }} activeDot={{ r: 6, fill: '#c084fc' }} animationDuration={1500} />
|
| 164 |
+
</LineChart>
|
| 165 |
+
</ResponsiveContainer>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
|
| 169 |
+
{/* Comparison Grid */}
|
| 170 |
+
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
| 171 |
+
{/* Top Campaigns Comparison */}
|
| 172 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 173 |
+
<h3 className="text-base font-semibold text-zinc-100 mb-1">Top Campaign Performance</h3>
|
| 174 |
+
<p className="text-xs text-zinc-400 mb-4">Volume dispatched vs. engaged prospects.</p>
|
| 175 |
+
|
| 176 |
+
<div className="h-[280px] w-full">
|
| 177 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 178 |
+
<BarChart data={campaignComparisonData} layout="vertical" margin={{ top: 5, right: 20, bottom: 5, left: 40 }}>
|
| 179 |
+
<defs>
|
| 180 |
+
<linearGradient id="colorOpens" x1="0" y1="0" x2="1" y2="0">
|
| 181 |
+
<stop offset="0%" stopColor="#10b981" stopOpacity={0.8}/>
|
| 182 |
+
<stop offset="100%" stopColor="#34d399" stopOpacity={1}/>
|
| 183 |
+
</linearGradient>
|
| 184 |
+
<linearGradient id="colorReplies" x1="0" y1="0" x2="1" y2="0">
|
| 185 |
+
<stop offset="0%" stopColor="#a855f7" stopOpacity={0.8}/>
|
| 186 |
+
<stop offset="100%" stopColor="#c084fc" stopOpacity={1}/>
|
| 187 |
+
</linearGradient>
|
| 188 |
+
</defs>
|
| 189 |
+
<CartesianGrid strokeDasharray="3 3" stroke="rgba(255,255,255,0.05)" horizontal={false} />
|
| 190 |
+
<XAxis type="number" stroke="#a1a1aa" fontSize={11} tickLine={false} axisLine={false} className="font-mono" />
|
| 191 |
+
<YAxis dataKey="name" type="category" stroke="#a1a1aa" fontSize={11} tickLine={false} axisLine={false} />
|
| 192 |
+
<Tooltip
|
| 193 |
+
contentStyle={{
|
| 194 |
+
backgroundColor: "rgba(9, 9, 11, 0.8)",
|
| 195 |
+
backdropFilter: "blur(12px)",
|
| 196 |
+
borderColor: "rgba(255,255,255,0.1)",
|
| 197 |
+
borderRadius: "12px",
|
| 198 |
+
fontSize: "12px",
|
| 199 |
+
}}
|
| 200 |
+
/>
|
| 201 |
+
<Bar dataKey="opens" name="Opens" fill="url(#colorOpens)" radius={[0, 4, 4, 0]} animationDuration={1500}>
|
| 202 |
+
</Bar>
|
| 203 |
+
<Bar dataKey="replies" name="Replies" fill="url(#colorReplies)" radius={[0, 4, 4, 0]} animationDuration={1500} />
|
| 204 |
+
</BarChart>
|
| 205 |
+
</ResponsiveContainer>
|
| 206 |
+
</div>
|
| 207 |
+
</div>
|
| 208 |
+
|
| 209 |
+
{/* Mailbox Deliverability Health Matrix */}
|
| 210 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)] flex flex-col justify-between">
|
| 211 |
+
<div>
|
| 212 |
+
<h3 className="text-base font-semibold text-zinc-100 mb-1">Mailbox Deliverability Matrix</h3>
|
| 213 |
+
<p className="text-xs text-zinc-400 mb-4">DNS authentication, warmup status, and health metrics.</p>
|
| 214 |
+
|
| 215 |
+
<div className="space-y-3">
|
| 216 |
+
{emailAccounts.map((acc: any) => (
|
| 217 |
+
<div
|
| 218 |
+
key={acc.id}
|
| 219 |
+
className="flex items-center justify-between p-3 bg-white/5 border border-white/10 rounded-lg text-xs hover:bg-white/10 transition-colors"
|
| 220 |
+
>
|
| 221 |
+
<div>
|
| 222 |
+
<span className="font-semibold text-zinc-200">{acc.from_email}</span>
|
| 223 |
+
<div className="text-[10px] text-zinc-400 mt-0.5">
|
| 224 |
+
SPF: PASS • DKIM: PASS • DMARC: PASS
|
| 225 |
+
</div>
|
| 226 |
+
</div>
|
| 227 |
+
|
| 228 |
+
<div className="flex items-center gap-3 font-mono">
|
| 229 |
+
<span className="text-emerald-400 font-bold drop-shadow-[0_0_8px_rgba(52,211,153,0.5)]">99.4%</span>
|
| 230 |
+
<span className="px-2 py-0.5 bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 rounded text-[10px]">
|
| 231 |
+
Optimal
|
| 232 |
+
</span>
|
| 233 |
+
</div>
|
| 234 |
+
</div>
|
| 235 |
+
))}
|
| 236 |
+
</div>
|
| 237 |
+
</div>
|
| 238 |
+
|
| 239 |
+
<div className="mt-4 pt-3 border-t border-white/10 text-[11px] text-zinc-400 flex items-center justify-between">
|
| 240 |
+
<span>Global Reputation: <span className="font-mono text-zinc-300">98.4 / 100</span></span>
|
| 241 |
+
<span className="text-emerald-400 flex items-center gap-1.5"><ShieldCheck className="w-3.5 h-3.5" /> All Nodes Secure</span>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
</div>
|
| 245 |
+
</div>
|
| 246 |
+
);
|
| 247 |
+
}
|
|
@@ -0,0 +1,709 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import { useParams, Link } from "react-router-dom";
|
| 4 |
+
import {
|
| 5 |
+
ArrowLeft,
|
| 6 |
+
Megaphone,
|
| 7 |
+
Layers,
|
| 8 |
+
Mail,
|
| 9 |
+
Users,
|
| 10 |
+
BarChart2,
|
| 11 |
+
Settings as SettingsIcon,
|
| 12 |
+
Plus,
|
| 13 |
+
Trash2,
|
| 14 |
+
Play,
|
| 15 |
+
Pause,
|
| 16 |
+
Clock,
|
| 17 |
+
CheckCircle2,
|
| 18 |
+
Sparkles,
|
| 19 |
+
Download,
|
| 20 |
+
Send,
|
| 21 |
+
Split
|
| 22 |
+
} from "lucide-react";
|
| 23 |
+
import { useState } from "react";
|
| 24 |
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts";
|
| 25 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 26 |
+
import StatCard from "../components/StatCard";
|
| 27 |
+
import RichTextEditor from "../../../components/RichTextEditor";
|
| 28 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 29 |
+
import CsvExportButton from "../../../components/CsvExportButton";
|
| 30 |
+
import toast from "react-hot-toast";
|
| 31 |
+
|
| 32 |
+
export default function CampaignDetail() {
|
| 33 |
+
const { id } = useParams<{ id: string }>();
|
| 34 |
+
const queryClient = useQueryClient();
|
| 35 |
+
const [activeTab, setActiveTab] = useState<"overview" | "sequences" | "accounts" | "leads" | "analytics" | "settings">("overview");
|
| 36 |
+
const [isAddLeadOpen, setIsAddLeadOpen] = useState(false);
|
| 37 |
+
const [selectedVariantTab, setSelectedVariantTab] = useState<Record<string, number>>({});
|
| 38 |
+
|
| 39 |
+
const { data: campaign, isLoading } = useQuery({
|
| 40 |
+
queryKey: ["campaign", id],
|
| 41 |
+
queryFn: async () => {
|
| 42 |
+
const res = await apiClient.get(`/campaigns/${id}`);
|
| 43 |
+
return res.data;
|
| 44 |
+
},
|
| 45 |
+
enabled: Boolean(id),
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
const { data: sequences = [], refetch: refetchSequences } = useQuery({
|
| 49 |
+
queryKey: ["campaign-sequences", id],
|
| 50 |
+
queryFn: async () => {
|
| 51 |
+
const res = await apiClient.get(`/campaigns/${id}/sequences`);
|
| 52 |
+
return res.data;
|
| 53 |
+
},
|
| 54 |
+
enabled: Boolean(id),
|
| 55 |
+
});
|
| 56 |
+
|
| 57 |
+
const { data: campaignLeads = [], refetch: refetchLeads } = useQuery({
|
| 58 |
+
queryKey: ["campaign-leads", id],
|
| 59 |
+
queryFn: async () => {
|
| 60 |
+
const res = await apiClient.get(`/campaigns/${id}/leads`);
|
| 61 |
+
return res.data;
|
| 62 |
+
},
|
| 63 |
+
enabled: Boolean(id),
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
const { data: assignedAccounts = [], refetch: refetchAccounts } = useQuery({
|
| 67 |
+
queryKey: ["campaign-accounts", id],
|
| 68 |
+
queryFn: async () => {
|
| 69 |
+
const res = await apiClient.get(`/campaigns/${id}/email-accounts`);
|
| 70 |
+
return res.data;
|
| 71 |
+
},
|
| 72 |
+
enabled: Boolean(id),
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
const { data: allEmailAccounts = [] } = useQuery({
|
| 76 |
+
queryKey: ["email-accounts"],
|
| 77 |
+
queryFn: async () => {
|
| 78 |
+
const res = await apiClient.get("/email-accounts");
|
| 79 |
+
return res.data;
|
| 80 |
+
},
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
const { data: analyticsHistory = [] } = useQuery({
|
| 84 |
+
queryKey: ["campaign-analytics-date", id],
|
| 85 |
+
queryFn: async () => {
|
| 86 |
+
const res = await apiClient.get(`/campaigns/${id}/analytics-by-date`);
|
| 87 |
+
return res.data;
|
| 88 |
+
},
|
| 89 |
+
enabled: Boolean(id),
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
// Save sequences mutation
|
| 93 |
+
const saveSequencesMutation = useMutation({
|
| 94 |
+
mutationFn: async (updatedSequences: any[]) => {
|
| 95 |
+
const res = await apiClient.post(`/campaigns/${id}/sequences`, { sequences: updatedSequences });
|
| 96 |
+
return res.data;
|
| 97 |
+
},
|
| 98 |
+
onSuccess: () => {
|
| 99 |
+
toast.success("Sequence saved successfully");
|
| 100 |
+
refetchSequences();
|
| 101 |
+
queryClient.invalidateQueries({ queryKey: ["campaign", id] });
|
| 102 |
+
},
|
| 103 |
+
onError: (err: any) => {
|
| 104 |
+
toast.error(err.response?.data?.error || "Failed to save sequences");
|
| 105 |
+
},
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
const addSequenceStep = () => {
|
| 109 |
+
const nextSeqNum = (sequences.length || 0) + 1;
|
| 110 |
+
const newStep = {
|
| 111 |
+
id: "seq_" + Math.random().toString(36).substring(2, 7),
|
| 112 |
+
seq_number: nextSeqNum,
|
| 113 |
+
delay_days: nextSeqNum === 1 ? 0 : 3,
|
| 114 |
+
subject: `Follow-up #${nextSeqNum - 1}: Re: {{company_name}}`,
|
| 115 |
+
email_body: `<p>Hi {{first_name}},</p><p>Wanted to quickly circle back on my earlier note. Any thoughts?</p>`,
|
| 116 |
+
variant_distribution_percentage: 100,
|
| 117 |
+
variants: [],
|
| 118 |
+
};
|
| 119 |
+
saveSequencesMutation.mutate([...sequences, newStep]);
|
| 120 |
+
};
|
| 121 |
+
|
| 122 |
+
const removeSequenceStep = (stepIndex: number) => {
|
| 123 |
+
const filtered = sequences.filter((_: any, idx: number) => idx !== stepIndex);
|
| 124 |
+
saveSequencesMutation.mutate(filtered);
|
| 125 |
+
};
|
| 126 |
+
|
| 127 |
+
const addVariantToStep = (stepIndex: number) => {
|
| 128 |
+
const updated = [...sequences];
|
| 129 |
+
const target = updated[stepIndex];
|
| 130 |
+
if (!target.variants) target.variants = [];
|
| 131 |
+
target.variant_distribution_percentage = 50;
|
| 132 |
+
target.variants.push({
|
| 133 |
+
id: "var_" + Math.random().toString(36).substring(2, 7),
|
| 134 |
+
variant_label: `Variant ${String.fromCharCode(66 + target.variants.length)}`,
|
| 135 |
+
subject: `Alternative: ${target.subject}`,
|
| 136 |
+
email_body: `<p>Hey {{first_name}}, short follow up regarding {{company_name}}.</p>`,
|
| 137 |
+
});
|
| 138 |
+
saveSequencesMutation.mutate(updated);
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
const addAccountToCampaign = async (accountId: string) => {
|
| 142 |
+
try {
|
| 143 |
+
await apiClient.post(`/campaigns/${id}/email-accounts`, { email_account_id: accountId });
|
| 144 |
+
toast.success("Mailbox assigned to campaign");
|
| 145 |
+
refetchAccounts();
|
| 146 |
+
} catch (err: any) {
|
| 147 |
+
toast.error("Failed to assign account");
|
| 148 |
+
}
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
const removeAccountFromCampaign = async (accountId: string) => {
|
| 152 |
+
try {
|
| 153 |
+
await apiClient.delete(`/campaigns/${id}/email-accounts/${accountId}`);
|
| 154 |
+
toast.success("Mailbox removed from campaign");
|
| 155 |
+
refetchAccounts();
|
| 156 |
+
} catch (err: any) {
|
| 157 |
+
toast.error("Failed to remove account");
|
| 158 |
+
}
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
if (isLoading || !campaign) {
|
| 162 |
+
return (
|
| 163 |
+
<div className="p-12 flex justify-center items-center">
|
| 164 |
+
<div className="w-8 h-8 rounded-full border-2 border-indigo-500 border-t-transparent animate-spin" />
|
| 165 |
+
</div>
|
| 166 |
+
);
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
return (
|
| 170 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 171 |
+
{/* Back Navigation and Header */}
|
| 172 |
+
<div className="space-y-3">
|
| 173 |
+
<Link
|
| 174 |
+
to="/modules/s/campaigns"
|
| 175 |
+
className="inline-flex items-center gap-1.5 text-xs text-zinc-400 hover:text-zinc-200 transition-colors"
|
| 176 |
+
>
|
| 177 |
+
<ArrowLeft className="w-3.5 h-3.5" /> Back to all campaigns
|
| 178 |
+
</Link>
|
| 179 |
+
|
| 180 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 181 |
+
<div>
|
| 182 |
+
<div className="flex items-center gap-3">
|
| 183 |
+
<h1 className="text-2xl font-bold text-zinc-100 tracking-tight">{campaign.name}</h1>
|
| 184 |
+
<StatusBadge status={campaign.status} />
|
| 185 |
+
</div>
|
| 186 |
+
<p className="text-xs text-zinc-400 mt-1">
|
| 187 |
+
Timezone: {campaign.timezone} • Schedule: {campaign.start_schedule} - {campaign.end_schedule}
|
| 188 |
+
</p>
|
| 189 |
+
</div>
|
| 190 |
+
|
| 191 |
+
<div className="flex items-center gap-2">
|
| 192 |
+
<button
|
| 193 |
+
onClick={() => setIsAddLeadOpen(true)}
|
| 194 |
+
className="px-3.5 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5"
|
| 195 |
+
>
|
| 196 |
+
<Plus className="w-3.5 h-3.5" /> Add Leads
|
| 197 |
+
</button>
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
{/* Tabs Bar */}
|
| 203 |
+
<div className="border-b border-zinc-800 flex items-center gap-1 text-sm font-medium overflow-x-auto">
|
| 204 |
+
{[
|
| 205 |
+
{ key: "overview", label: "Overview", icon: BarChart2 },
|
| 206 |
+
{ key: "sequences", label: `Sequences (${sequences.length})`, icon: Layers },
|
| 207 |
+
{ key: "accounts", label: `Email Accounts (${assignedAccounts.length})`, icon: Mail },
|
| 208 |
+
{ key: "leads", label: `Leads (${campaignLeads.length})`, icon: Users },
|
| 209 |
+
{ key: "analytics", label: "Analytics", icon: BarChart2 },
|
| 210 |
+
{ key: "settings", label: "Settings", icon: SettingsIcon },
|
| 211 |
+
].map((tab) => (
|
| 212 |
+
<button
|
| 213 |
+
key={tab.key}
|
| 214 |
+
onClick={() => setActiveTab(tab.key as any)}
|
| 215 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors whitespace-nowrap ${
|
| 216 |
+
activeTab === tab.key
|
| 217 |
+
? "border-indigo-500 text-indigo-400 bg-indigo-500/5"
|
| 218 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200 hover:border-zinc-700"
|
| 219 |
+
}`}
|
| 220 |
+
>
|
| 221 |
+
<tab.icon className="w-4 h-4" />
|
| 222 |
+
{tab.label}
|
| 223 |
+
</button>
|
| 224 |
+
))}
|
| 225 |
+
</div>
|
| 226 |
+
|
| 227 |
+
{/* TAB 1: OVERVIEW */}
|
| 228 |
+
{activeTab === "overview" && (
|
| 229 |
+
<div className="space-y-6">
|
| 230 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
| 231 |
+
<StatCard
|
| 232 |
+
title="Leads in Sequence"
|
| 233 |
+
value={campaign.lead_count || 0}
|
| 234 |
+
icon={Users}
|
| 235 |
+
iconColor="teal"
|
| 236 |
+
/>
|
| 237 |
+
<StatCard
|
| 238 |
+
title="Emails Sent"
|
| 239 |
+
value={campaign.sent_count || 0}
|
| 240 |
+
icon={Send}
|
| 241 |
+
iconColor="blue"
|
| 242 |
+
/>
|
| 243 |
+
<StatCard
|
| 244 |
+
title="Unique Opens"
|
| 245 |
+
value={campaign.open_count || 0}
|
| 246 |
+
subtitle={`${((campaign.open_count / (campaign.sent_count || 1)) * 100).toFixed(1)}% Open Rate`}
|
| 247 |
+
icon={Mail}
|
| 248 |
+
iconColor="emerald"
|
| 249 |
+
/>
|
| 250 |
+
<StatCard
|
| 251 |
+
title="Replies Received"
|
| 252 |
+
value={campaign.reply_count || 0}
|
| 253 |
+
subtitle={`${((campaign.reply_count / (campaign.sent_count || 1)) * 100).toFixed(1)}% Reply Rate`}
|
| 254 |
+
icon={CheckCircle2}
|
| 255 |
+
iconColor="purple"
|
| 256 |
+
/>
|
| 257 |
+
</div>
|
| 258 |
+
|
| 259 |
+
{/* 14-Day Trajectory */}
|
| 260 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-5 shadow-sm">
|
| 261 |
+
<h3 className="text-sm font-semibold text-zinc-100 mb-4">
|
| 262 |
+
Engagement Trajectory (Last 14 Days)
|
| 263 |
+
</h3>
|
| 264 |
+
<div className="h-[260px] w-full">
|
| 265 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 266 |
+
<LineChart data={analyticsHistory} margin={{ top: 5, right: 10, bottom: 5, left: -15 }}>
|
| 267 |
+
<CartesianGrid strokeDasharray="3 3" stroke="#27272a" vertical={false} />
|
| 268 |
+
<XAxis dataKey="date" stroke="#71717a" fontSize={11} tickLine={false} axisLine={false} />
|
| 269 |
+
<YAxis stroke="#71717a" fontSize={11} tickLine={false} axisLine={false} />
|
| 270 |
+
<Tooltip
|
| 271 |
+
contentStyle={{ backgroundColor: "#09090b", borderColor: "#27272a", borderRadius: "8px", fontSize: "12px" }}
|
| 272 |
+
/>
|
| 273 |
+
<Line type="monotone" dataKey="sent" stroke="#3b82f6" strokeWidth={2} name="Sent" dot={false} />
|
| 274 |
+
<Line type="monotone" dataKey="opens" stroke="#10b981" strokeWidth={2} name="Opens" dot={false} />
|
| 275 |
+
<Line type="monotone" dataKey="replies" stroke="#a855f7" strokeWidth={2} name="Replies" dot={false} />
|
| 276 |
+
</LineChart>
|
| 277 |
+
</ResponsiveContainer>
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
)}
|
| 282 |
+
|
| 283 |
+
{/* TAB 2: SEQUENCES WITH A/B VARIANTS */}
|
| 284 |
+
{activeTab === "sequences" && (
|
| 285 |
+
<div className="space-y-6">
|
| 286 |
+
<div className="flex items-center justify-between">
|
| 287 |
+
<div>
|
| 288 |
+
<h3 className="text-base font-semibold text-zinc-100">Multi-Step Sequence Flow</h3>
|
| 289 |
+
<p className="text-xs text-zinc-400 mt-0.5">
|
| 290 |
+
Set delay days, customize subject lines, and configure A/B variants per email step.
|
| 291 |
+
</p>
|
| 292 |
+
</div>
|
| 293 |
+
<button
|
| 294 |
+
onClick={addSequenceStep}
|
| 295 |
+
className="px-3.5 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5"
|
| 296 |
+
>
|
| 297 |
+
<Plus className="w-3.5 h-3.5" /> Add Email Step
|
| 298 |
+
</button>
|
| 299 |
+
</div>
|
| 300 |
+
|
| 301 |
+
<div className="space-y-4">
|
| 302 |
+
{sequences.map((step: any, stepIndex: number) => {
|
| 303 |
+
const currentVariantTab = selectedVariantTab[step.id] || 0;
|
| 304 |
+
const hasVariants = step.variants && step.variants.length > 0;
|
| 305 |
+
|
| 306 |
+
return (
|
| 307 |
+
<div key={step.id || stepIndex} className="bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden shadow-sm">
|
| 308 |
+
{/* Step Header */}
|
| 309 |
+
<div className="px-5 py-3.5 bg-zinc-950 border-b border-zinc-800 flex items-center justify-between">
|
| 310 |
+
<div className="flex items-center gap-3">
|
| 311 |
+
<span className="w-6 h-6 rounded-full bg-indigo-500/20 text-indigo-400 font-bold text-xs flex items-center justify-center border border-indigo-500/30">
|
| 312 |
+
{step.seq_number}
|
| 313 |
+
</span>
|
| 314 |
+
<div>
|
| 315 |
+
<span className="text-xs font-semibold text-zinc-200">
|
| 316 |
+
{step.seq_number === 1 ? "Initial Outreach (Step 1)" : `Follow-up #${step.seq_number - 1}`}
|
| 317 |
+
</span>
|
| 318 |
+
<div className="flex items-center gap-2 text-[11px] text-zinc-400 mt-0.5">
|
| 319 |
+
<Clock className="w-3 h-3 text-zinc-500" />
|
| 320 |
+
<span>Delay:</span>
|
| 321 |
+
<input
|
| 322 |
+
type="number"
|
| 323 |
+
min="0"
|
| 324 |
+
value={step.delay_days}
|
| 325 |
+
onChange={(e) => {
|
| 326 |
+
const updated = [...sequences];
|
| 327 |
+
updated[stepIndex].delay_days = Number(e.target.value);
|
| 328 |
+
saveSequencesMutation.mutate(updated);
|
| 329 |
+
}}
|
| 330 |
+
className="w-12 bg-zinc-900 border border-zinc-700 rounded px-1.5 py-0.5 text-xs text-zinc-100"
|
| 331 |
+
/>
|
| 332 |
+
<span>days after previous email</span>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
</div>
|
| 336 |
+
|
| 337 |
+
<div className="flex items-center gap-2">
|
| 338 |
+
<button
|
| 339 |
+
type="button"
|
| 340 |
+
onClick={() => addVariantToStep(stepIndex)}
|
| 341 |
+
className="px-2.5 py-1 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-xs font-medium rounded-md transition-colors flex items-center gap-1"
|
| 342 |
+
>
|
| 343 |
+
<Split className="w-3.5 h-3.5 text-indigo-400" /> + A/B Variant
|
| 344 |
+
</button>
|
| 345 |
+
<button
|
| 346 |
+
type="button"
|
| 347 |
+
onClick={() => removeSequenceStep(stepIndex)}
|
| 348 |
+
className="p-1.5 text-zinc-500 hover:text-rose-400 hover:bg-rose-500/10 rounded-md transition-colors"
|
| 349 |
+
>
|
| 350 |
+
<Trash2 className="w-4 h-4" />
|
| 351 |
+
</button>
|
| 352 |
+
</div>
|
| 353 |
+
</div>
|
| 354 |
+
|
| 355 |
+
{/* Step Body & Variant Tabs */}
|
| 356 |
+
<div className="p-5 space-y-4">
|
| 357 |
+
{hasVariants && (
|
| 358 |
+
<div className="flex items-center justify-between border-b border-zinc-800 pb-3">
|
| 359 |
+
<div className="flex items-center gap-2">
|
| 360 |
+
<button
|
| 361 |
+
type="button"
|
| 362 |
+
onClick={() => setSelectedVariantTab((prev) => ({ ...prev, [step.id]: 0 }))}
|
| 363 |
+
className={`px-3 py-1 text-xs font-medium rounded-md transition-colors ${
|
| 364 |
+
currentVariantTab === 0 ? "bg-indigo-600 text-white" : "bg-zinc-800 text-zinc-400"
|
| 365 |
+
}`}
|
| 366 |
+
>
|
| 367 |
+
Variant A (Default)
|
| 368 |
+
</button>
|
| 369 |
+
{step.variants.map((v: any, vIdx: number) => (
|
| 370 |
+
<button
|
| 371 |
+
key={v.id || vIdx}
|
| 372 |
+
type="button"
|
| 373 |
+
onClick={() => setSelectedVariantTab((prev) => ({ ...prev, [step.id]: vIdx + 1 }))}
|
| 374 |
+
className={`px-3 py-1 text-xs font-medium rounded-md transition-colors ${
|
| 375 |
+
currentVariantTab === vIdx + 1 ? "bg-indigo-600 text-white" : "bg-zinc-800 text-zinc-400"
|
| 376 |
+
}`}
|
| 377 |
+
>
|
| 378 |
+
{v.variant_label || `Variant ${String.fromCharCode(66 + vIdx)}`}
|
| 379 |
+
</button>
|
| 380 |
+
))}
|
| 381 |
+
</div>
|
| 382 |
+
|
| 383 |
+
<div className="text-xs text-zinc-400 font-mono">
|
| 384 |
+
Split Traffic: 50% / 50%
|
| 385 |
+
</div>
|
| 386 |
+
</div>
|
| 387 |
+
)}
|
| 388 |
+
|
| 389 |
+
{/* Active Variant Editor */}
|
| 390 |
+
{currentVariantTab === 0 ? (
|
| 391 |
+
<div className="space-y-3">
|
| 392 |
+
<div>
|
| 393 |
+
<label className="block text-xs font-medium text-zinc-400 mb-1">
|
| 394 |
+
Subject Line (Variant A)
|
| 395 |
+
</label>
|
| 396 |
+
<input
|
| 397 |
+
type="text"
|
| 398 |
+
value={step.subject}
|
| 399 |
+
onChange={(e) => {
|
| 400 |
+
const updated = [...sequences];
|
| 401 |
+
updated[stepIndex].subject = e.target.value;
|
| 402 |
+
saveSequencesMutation.mutate(updated);
|
| 403 |
+
}}
|
| 404 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2.5 text-xs text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 405 |
+
/>
|
| 406 |
+
</div>
|
| 407 |
+
|
| 408 |
+
<div>
|
| 409 |
+
<label className="block text-xs font-medium text-zinc-400 mb-1">
|
| 410 |
+
Email Body (Variant A)
|
| 411 |
+
</label>
|
| 412 |
+
<RichTextEditor
|
| 413 |
+
content={step.email_body}
|
| 414 |
+
onChange={(html) => {
|
| 415 |
+
const updated = [...sequences];
|
| 416 |
+
updated[stepIndex].email_body = html;
|
| 417 |
+
saveSequencesMutation.mutate(updated);
|
| 418 |
+
}}
|
| 419 |
+
/>
|
| 420 |
+
</div>
|
| 421 |
+
</div>
|
| 422 |
+
) : (
|
| 423 |
+
<div className="space-y-3">
|
| 424 |
+
<div>
|
| 425 |
+
<label className="block text-xs font-medium text-zinc-400 mb-1">
|
| 426 |
+
Subject Line ({step.variants[currentVariantTab - 1]?.variant_label})
|
| 427 |
+
</label>
|
| 428 |
+
<input
|
| 429 |
+
type="text"
|
| 430 |
+
value={step.variants[currentVariantTab - 1]?.subject || ""}
|
| 431 |
+
onChange={(e) => {
|
| 432 |
+
const updated = [...sequences];
|
| 433 |
+
updated[stepIndex].variants[currentVariantTab - 1].subject = e.target.value;
|
| 434 |
+
saveSequencesMutation.mutate(updated);
|
| 435 |
+
}}
|
| 436 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2.5 text-xs text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 437 |
+
/>
|
| 438 |
+
</div>
|
| 439 |
+
|
| 440 |
+
<div>
|
| 441 |
+
<label className="block text-xs font-medium text-zinc-400 mb-1">
|
| 442 |
+
Email Body ({step.variants[currentVariantTab - 1]?.variant_label})
|
| 443 |
+
</label>
|
| 444 |
+
<RichTextEditor
|
| 445 |
+
content={step.variants[currentVariantTab - 1]?.email_body || ""}
|
| 446 |
+
onChange={(html) => {
|
| 447 |
+
const updated = [...sequences];
|
| 448 |
+
updated[stepIndex].variants[currentVariantTab - 1].email_body = html;
|
| 449 |
+
saveSequencesMutation.mutate(updated);
|
| 450 |
+
}}
|
| 451 |
+
/>
|
| 452 |
+
</div>
|
| 453 |
+
</div>
|
| 454 |
+
)}
|
| 455 |
+
</div>
|
| 456 |
+
</div>
|
| 457 |
+
);
|
| 458 |
+
})}
|
| 459 |
+
</div>
|
| 460 |
+
</div>
|
| 461 |
+
)}
|
| 462 |
+
|
| 463 |
+
{/* TAB 3: EMAIL ACCOUNTS ASSIGNMENT */}
|
| 464 |
+
{activeTab === "accounts" && (
|
| 465 |
+
<div className="space-y-6">
|
| 466 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-5">
|
| 467 |
+
<h3 className="text-base font-semibold text-zinc-100 mb-1">Assigned Sending Inboxes</h3>
|
| 468 |
+
<p className="text-xs text-zinc-400 mb-4">
|
| 469 |
+
Emails will be rotated across these connected mailboxes to preserve deliverability.
|
| 470 |
+
</p>
|
| 471 |
+
|
| 472 |
+
<div className="space-y-3">
|
| 473 |
+
{assignedAccounts.map((acc: any) => (
|
| 474 |
+
<div
|
| 475 |
+
key={acc.id}
|
| 476 |
+
className="flex items-center justify-between p-3 bg-zinc-950 border border-zinc-800 rounded-lg"
|
| 477 |
+
>
|
| 478 |
+
<div className="flex items-center gap-3">
|
| 479 |
+
<div className="p-2 bg-indigo-500/10 text-indigo-400 rounded-md">
|
| 480 |
+
<Mail className="w-4 h-4" />
|
| 481 |
+
</div>
|
| 482 |
+
<div>
|
| 483 |
+
<span className="text-xs font-semibold text-zinc-200">{acc.from_name}</span>
|
| 484 |
+
<div className="text-[11px] text-zinc-400">{acc.from_email}</div>
|
| 485 |
+
</div>
|
| 486 |
+
</div>
|
| 487 |
+
|
| 488 |
+
<div className="flex items-center gap-3">
|
| 489 |
+
<StatusBadge status={acc.status} size="sm" />
|
| 490 |
+
<button
|
| 491 |
+
onClick={() => removeAccountFromCampaign(acc.id)}
|
| 492 |
+
className="text-xs text-rose-400 hover:text-rose-300 font-medium"
|
| 493 |
+
>
|
| 494 |
+
Remove
|
| 495 |
+
</button>
|
| 496 |
+
</div>
|
| 497 |
+
</div>
|
| 498 |
+
))}
|
| 499 |
+
|
| 500 |
+
{assignedAccounts.length === 0 && (
|
| 501 |
+
<div className="p-6 text-center text-xs text-zinc-500 bg-zinc-950/60 rounded-lg border border-dashed border-zinc-800">
|
| 502 |
+
No email accounts assigned yet. Select from available mailboxes below.
|
| 503 |
+
</div>
|
| 504 |
+
)}
|
| 505 |
+
</div>
|
| 506 |
+
</div>
|
| 507 |
+
|
| 508 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-5">
|
| 509 |
+
<h4 className="text-xs font-semibold uppercase tracking-wider text-zinc-400 mb-3">
|
| 510 |
+
Available Mailboxes
|
| 511 |
+
</h4>
|
| 512 |
+
<div className="space-y-2">
|
| 513 |
+
{allEmailAccounts
|
| 514 |
+
.filter((a: any) => !assignedAccounts.some((aa: any) => aa.id === a.id))
|
| 515 |
+
.map((acc: any) => (
|
| 516 |
+
<div
|
| 517 |
+
key={acc.id}
|
| 518 |
+
className="flex items-center justify-between p-3 bg-zinc-950/40 border border-zinc-800/80 rounded-lg"
|
| 519 |
+
>
|
| 520 |
+
<div>
|
| 521 |
+
<span className="text-xs font-medium text-zinc-200">{acc.from_email}</span>
|
| 522 |
+
<div className="text-[10px] text-zinc-500">
|
| 523 |
+
Provider: {acc.provider} • Daily limit: {acc.daily_limit} emails
|
| 524 |
+
</div>
|
| 525 |
+
</div>
|
| 526 |
+
<button
|
| 527 |
+
onClick={() => addAccountToCampaign(acc.id)}
|
| 528 |
+
className="px-3 py-1 bg-indigo-600/20 hover:bg-indigo-600 text-indigo-300 hover:text-white rounded text-xs font-medium transition-colors"
|
| 529 |
+
>
|
| 530 |
+
+ Assign to Campaign
|
| 531 |
+
</button>
|
| 532 |
+
</div>
|
| 533 |
+
))}
|
| 534 |
+
</div>
|
| 535 |
+
</div>
|
| 536 |
+
</div>
|
| 537 |
+
)}
|
| 538 |
+
|
| 539 |
+
{/* TAB 4: LEADS */}
|
| 540 |
+
{activeTab === "leads" && (
|
| 541 |
+
<div className="space-y-4">
|
| 542 |
+
<div className="flex items-center justify-between">
|
| 543 |
+
<div className="text-xs text-zinc-400">
|
| 544 |
+
Showing {campaignLeads.length} leads in this campaign.
|
| 545 |
+
</div>
|
| 546 |
+
<div className="flex items-center gap-2">
|
| 547 |
+
<CsvExportButton data={campaignLeads} filename={`campaign-${id}-leads.csv`} />
|
| 548 |
+
<button
|
| 549 |
+
onClick={() => setIsAddLeadOpen(true)}
|
| 550 |
+
className="px-3 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5"
|
| 551 |
+
>
|
| 552 |
+
<Plus className="w-3.5 h-3.5" /> Add Lead
|
| 553 |
+
</button>
|
| 554 |
+
</div>
|
| 555 |
+
</div>
|
| 556 |
+
|
| 557 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden">
|
| 558 |
+
<table className="w-full text-sm text-left">
|
| 559 |
+
<thead className="bg-zinc-950 border-b border-zinc-800 text-zinc-400 text-xs uppercase">
|
| 560 |
+
<tr>
|
| 561 |
+
<th className="px-5 py-3 font-semibold">Lead</th>
|
| 562 |
+
<th className="px-5 py-3 font-semibold">Company</th>
|
| 563 |
+
<th className="px-5 py-3 font-semibold">Status</th>
|
| 564 |
+
<th className="px-5 py-3 font-semibold">Opens</th>
|
| 565 |
+
<th className="px-5 py-3 font-semibold">Clicks</th>
|
| 566 |
+
</tr>
|
| 567 |
+
</thead>
|
| 568 |
+
<tbody className="divide-y divide-zinc-800">
|
| 569 |
+
{campaignLeads.map((lead: any) => (
|
| 570 |
+
<tr key={lead.id} className="hover:bg-zinc-800/30">
|
| 571 |
+
<td className="px-5 py-3.5">
|
| 572 |
+
<div className="font-medium text-zinc-200">
|
| 573 |
+
{lead.first_name} {lead.last_name}
|
| 574 |
+
</div>
|
| 575 |
+
<div className="text-xs text-zinc-400 font-mono">{lead.email}</div>
|
| 576 |
+
</td>
|
| 577 |
+
<td className="px-5 py-3.5 text-zinc-300">{lead.company_name}</td>
|
| 578 |
+
<td className="px-5 py-3.5">
|
| 579 |
+
<StatusBadge status={lead.status} size="sm" />
|
| 580 |
+
</td>
|
| 581 |
+
<td className="px-5 py-3.5 text-zinc-300 font-mono">{lead.open_count || 0}</td>
|
| 582 |
+
<td className="px-5 py-3.5 text-zinc-300 font-mono">{lead.click_count || 0}</td>
|
| 583 |
+
</tr>
|
| 584 |
+
))}
|
| 585 |
+
</tbody>
|
| 586 |
+
</table>
|
| 587 |
+
</div>
|
| 588 |
+
</div>
|
| 589 |
+
)}
|
| 590 |
+
|
| 591 |
+
{/* TAB 5: ANALYTICS */}
|
| 592 |
+
{activeTab === "analytics" && (
|
| 593 |
+
<div className="space-y-6">
|
| 594 |
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
| 595 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 596 |
+
<span className="text-xs text-zinc-400">Open Rate</span>
|
| 597 |
+
<div className="text-2xl font-bold text-emerald-400 mt-1">56.2%</div>
|
| 598 |
+
<span className="text-[11px] text-zinc-500">Above industry avg (28%)</span>
|
| 599 |
+
</div>
|
| 600 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 601 |
+
<span className="text-xs text-zinc-400">Reply Rate</span>
|
| 602 |
+
<div className="text-2xl font-bold text-purple-400 mt-1">6.4%</div>
|
| 603 |
+
<span className="text-[11px] text-zinc-500">Strong positive intent</span>
|
| 604 |
+
</div>
|
| 605 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 606 |
+
<span className="text-xs text-zinc-400">Bounce Rate</span>
|
| 607 |
+
<div className="text-2xl font-bold text-rose-400 mt-1">0.6%</div>
|
| 608 |
+
<span className="text-[11px] text-zinc-500">Safe zone (< 2%)</span>
|
| 609 |
+
</div>
|
| 610 |
+
</div>
|
| 611 |
+
</div>
|
| 612 |
+
)}
|
| 613 |
+
|
| 614 |
+
{/* TAB 6: SETTINGS */}
|
| 615 |
+
{activeTab === "settings" && (
|
| 616 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-6 max-w-2xl">
|
| 617 |
+
<h3 className="text-base font-semibold text-zinc-100 mb-4">Campaign Parameters</h3>
|
| 618 |
+
<div className="space-y-4 text-xs">
|
| 619 |
+
<div>
|
| 620 |
+
<label className="block text-zinc-400 font-medium mb-1">Timezone</label>
|
| 621 |
+
<input
|
| 622 |
+
disabled
|
| 623 |
+
value={campaign.timezone}
|
| 624 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2.5 text-zinc-300"
|
| 625 |
+
/>
|
| 626 |
+
</div>
|
| 627 |
+
<div>
|
| 628 |
+
<label className="block text-zinc-400 font-medium mb-1">Unsubscribe Footer</label>
|
| 629 |
+
<input
|
| 630 |
+
disabled
|
| 631 |
+
value={campaign.unsubscribe_text}
|
| 632 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2.5 text-zinc-300"
|
| 633 |
+
/>
|
| 634 |
+
</div>
|
| 635 |
+
</div>
|
| 636 |
+
</div>
|
| 637 |
+
)}
|
| 638 |
+
|
| 639 |
+
{/* Add Lead Slide-Over */}
|
| 640 |
+
<FormDrawer
|
| 641 |
+
isOpen={isAddLeadOpen}
|
| 642 |
+
onClose={() => setIsAddLeadOpen(false)}
|
| 643 |
+
title="Add Lead to Campaign"
|
| 644 |
+
subtitle="Upload prospect details to be enrolled into this sequence."
|
| 645 |
+
>
|
| 646 |
+
<form
|
| 647 |
+
onSubmit={async (e) => {
|
| 648 |
+
e.preventDefault();
|
| 649 |
+
const form = e.target as HTMLFormElement;
|
| 650 |
+
const newLead = {
|
| 651 |
+
first_name: (form.elements.namedItem("first_name") as HTMLInputElement).value,
|
| 652 |
+
last_name: (form.elements.namedItem("last_name") as HTMLInputElement).value,
|
| 653 |
+
email: (form.elements.namedItem("email") as HTMLInputElement).value,
|
| 654 |
+
company_name: (form.elements.namedItem("company_name") as HTMLInputElement).value,
|
| 655 |
+
website: (form.elements.namedItem("website") as HTMLInputElement).value,
|
| 656 |
+
status: "INTERESTED",
|
| 657 |
+
};
|
| 658 |
+
|
| 659 |
+
try {
|
| 660 |
+
await apiClient.post(`/campaigns/${id}/leads`, newLead);
|
| 661 |
+
toast.success("Lead enrolled in campaign!");
|
| 662 |
+
setIsAddLeadOpen(false);
|
| 663 |
+
refetchLeads();
|
| 664 |
+
} catch (err: any) {
|
| 665 |
+
toast.error("Failed to add lead");
|
| 666 |
+
}
|
| 667 |
+
}}
|
| 668 |
+
className="space-y-4 text-xs"
|
| 669 |
+
>
|
| 670 |
+
<div>
|
| 671 |
+
<label className="block font-medium text-zinc-300 mb-1">First Name *</label>
|
| 672 |
+
<input name="first_name" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 673 |
+
</div>
|
| 674 |
+
<div>
|
| 675 |
+
<label className="block font-medium text-zinc-300 mb-1">Last Name</label>
|
| 676 |
+
<input name="last_name" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 677 |
+
</div>
|
| 678 |
+
<div>
|
| 679 |
+
<label className="block font-medium text-zinc-300 mb-1">Email *</label>
|
| 680 |
+
<input type="email" name="email" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 681 |
+
</div>
|
| 682 |
+
<div>
|
| 683 |
+
<label className="block font-medium text-zinc-300 mb-1">Company Name</label>
|
| 684 |
+
<input name="company_name" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 685 |
+
</div>
|
| 686 |
+
<div>
|
| 687 |
+
<label className="block font-medium text-zinc-300 mb-1">Website</label>
|
| 688 |
+
<input name="website" placeholder="https://" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 689 |
+
</div>
|
| 690 |
+
<div className="pt-4 flex justify-end gap-2">
|
| 691 |
+
<button
|
| 692 |
+
type="button"
|
| 693 |
+
onClick={() => setIsAddLeadOpen(false)}
|
| 694 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 695 |
+
>
|
| 696 |
+
Cancel
|
| 697 |
+
</button>
|
| 698 |
+
<button
|
| 699 |
+
type="submit"
|
| 700 |
+
className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium"
|
| 701 |
+
>
|
| 702 |
+
Enroll Lead
|
| 703 |
+
</button>
|
| 704 |
+
</div>
|
| 705 |
+
</form>
|
| 706 |
+
</FormDrawer>
|
| 707 |
+
</div>
|
| 708 |
+
);
|
| 709 |
+
}
|
|
@@ -0,0 +1,440 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Plus,
|
| 5 |
+
Search,
|
| 6 |
+
Megaphone,
|
| 7 |
+
Play,
|
| 8 |
+
Pause,
|
| 9 |
+
Square,
|
| 10 |
+
Trash2,
|
| 11 |
+
ArrowUpRight,
|
| 12 |
+
Sliders,
|
| 13 |
+
Clock,
|
| 14 |
+
Globe,
|
| 15 |
+
CheckCircle2,
|
| 16 |
+
MailCheck
|
| 17 |
+
} from "lucide-react";
|
| 18 |
+
import { useState } from "react";
|
| 19 |
+
import { Link } from "react-router-dom";
|
| 20 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 21 |
+
import ConfirmModal from "../../../components/ConfirmModal";
|
| 22 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 23 |
+
import toast from "react-hot-toast";
|
| 24 |
+
|
| 25 |
+
export default function Campaigns() {
|
| 26 |
+
const queryClient = useQueryClient();
|
| 27 |
+
const [searchTerm, setSearchTerm] = useState("");
|
| 28 |
+
const [statusFilter, setStatusFilter] = useState("ALL");
|
| 29 |
+
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
| 30 |
+
const [selectedForDelete, setSelectedForDelete] = useState<string | null>(null);
|
| 31 |
+
|
| 32 |
+
const { data: campaigns, isLoading } = useQuery({
|
| 33 |
+
queryKey: ["campaigns"],
|
| 34 |
+
queryFn: async () => {
|
| 35 |
+
const res = await apiClient.get("/campaigns");
|
| 36 |
+
return res.data;
|
| 37 |
+
},
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
+
const updateStatusMutation = useMutation({
|
| 41 |
+
mutationFn: async ({ id, status }: { id: string; status: "START" | "PAUSE" | "STOP" }) => {
|
| 42 |
+
const res = await apiClient.post(`/campaigns/${id}/status`, { status });
|
| 43 |
+
return res.data;
|
| 44 |
+
},
|
| 45 |
+
onSuccess: (_, variables) => {
|
| 46 |
+
toast.success(`Campaign ${variables.status.toLowerCase()}ed`);
|
| 47 |
+
queryClient.invalidateQueries({ queryKey: ["campaigns"] });
|
| 48 |
+
},
|
| 49 |
+
onError: (err: any) => {
|
| 50 |
+
toast.error(err.response?.data?.error || "Failed to update campaign status");
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
const deleteMutation = useMutation({
|
| 55 |
+
mutationFn: async (id: string) => {
|
| 56 |
+
const res = await apiClient.delete(`/campaigns/${id}`);
|
| 57 |
+
return res.data;
|
| 58 |
+
},
|
| 59 |
+
onSuccess: () => {
|
| 60 |
+
toast.success("Campaign removed");
|
| 61 |
+
setSelectedForDelete(null);
|
| 62 |
+
queryClient.invalidateQueries({ queryKey: ["campaigns"] });
|
| 63 |
+
},
|
| 64 |
+
onError: (err: any) => {
|
| 65 |
+
toast.error(err.response?.data?.error || "Failed to delete campaign");
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
const filteredCampaigns = (campaigns || []).filter((c: any) => {
|
| 70 |
+
const matchesSearch = c.name?.toLowerCase().includes(searchTerm.toLowerCase());
|
| 71 |
+
const matchesStatus = statusFilter === "ALL" || c.status === statusFilter;
|
| 72 |
+
return matchesSearch && matchesStatus;
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
return (
|
| 76 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 77 |
+
{/* Header */}
|
| 78 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 79 |
+
<div>
|
| 80 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 81 |
+
<Megaphone className="w-6 h-6 text-indigo-400" />
|
| 82 |
+
Outreach Campaigns
|
| 83 |
+
</h1>
|
| 84 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 85 |
+
Automated multi-step cold email sequences with A/B variant testing.
|
| 86 |
+
</p>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<button
|
| 90 |
+
onClick={() => setIsCreateOpen(true)}
|
| 91 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-2 self-start sm:self-auto"
|
| 92 |
+
>
|
| 93 |
+
<Plus className="w-4 h-4" />
|
| 94 |
+
Create Campaign
|
| 95 |
+
</button>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
{/* Filter and Search Bar */}
|
| 99 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-4 flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 100 |
+
<div className="relative flex-1 max-w-md">
|
| 101 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400" />
|
| 102 |
+
<input
|
| 103 |
+
type="text"
|
| 104 |
+
placeholder="Search campaigns by name..."
|
| 105 |
+
value={searchTerm}
|
| 106 |
+
onChange={(e) => setSearchTerm(e.target.value)}
|
| 107 |
+
className="w-full bg-black/40 border border-white/5 rounded-lg py-2 pl-9 pr-4 text-sm text-zinc-100 placeholder:text-zinc-500 focus:outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 shadow-[inset_0_1px_1px_rgba(255,255,255,0.02)] transition-all"
|
| 108 |
+
/>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
<div className="flex items-center gap-2">
|
| 112 |
+
{["ALL", "ACTIVE", "PAUSED", "STOPPED"].map((status) => (
|
| 113 |
+
<button
|
| 114 |
+
key={status}
|
| 115 |
+
onClick={() => setStatusFilter(status)}
|
| 116 |
+
className={`px-3 py-1.5 rounded-lg text-xs font-medium transition-all duration-300 shadow-[inset_0_1px_1px_rgba(255,255,255,0.02)] ${
|
| 117 |
+
statusFilter === status
|
| 118 |
+
? "bg-indigo-600 text-white shadow-[0_0_12px_rgba(79,70,229,0.5)] border border-indigo-500/50"
|
| 119 |
+
: "bg-black/40 text-zinc-400 hover:text-zinc-200 border border-white/5"
|
| 120 |
+
}`}
|
| 121 |
+
>
|
| 122 |
+
{status}
|
| 123 |
+
</button>
|
| 124 |
+
))}
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
{/* Campaigns Table */}
|
| 129 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl overflow-hidden shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 130 |
+
{isLoading ? (
|
| 131 |
+
<div className="py-20 flex flex-col items-center justify-center gap-3">
|
| 132 |
+
<div className="w-8 h-8 rounded-full border-2 border-indigo-500 border-t-transparent animate-spin drop-shadow-[0_0_8px_rgba(99,102,241,0.5)]" />
|
| 133 |
+
<p className="text-sm text-zinc-400">Loading campaign records...</p>
|
| 134 |
+
</div>
|
| 135 |
+
) : filteredCampaigns.length > 0 ? (
|
| 136 |
+
<div className="overflow-x-auto">
|
| 137 |
+
<table className="w-full text-sm text-left">
|
| 138 |
+
<thead className="bg-black/20 border-b border-white/5 text-zinc-400 text-xs uppercase font-sans tracking-wider">
|
| 139 |
+
<tr>
|
| 140 |
+
<th className="px-6 py-3.5 font-semibold">Campaign Name</th>
|
| 141 |
+
<th className="px-6 py-3.5 font-semibold">Status</th>
|
| 142 |
+
<th className="px-6 py-3.5 font-semibold">Leads</th>
|
| 143 |
+
<th className="px-6 py-3.5 font-semibold">Sent</th>
|
| 144 |
+
<th className="px-6 py-3.5 font-semibold">Opens</th>
|
| 145 |
+
<th className="px-6 py-3.5 font-semibold">Replies</th>
|
| 146 |
+
<th className="px-6 py-3.5 font-semibold">Bounces</th>
|
| 147 |
+
<th className="px-6 py-3.5 font-semibold text-right">Actions</th>
|
| 148 |
+
</tr>
|
| 149 |
+
</thead>
|
| 150 |
+
<tbody className="divide-y divide-white/5">
|
| 151 |
+
{filteredCampaigns.map((camp: any) => (
|
| 152 |
+
<tr key={camp.id} className="hover:bg-white/5 transition-colors">
|
| 153 |
+
<td className="px-6 py-4">
|
| 154 |
+
<Link
|
| 155 |
+
to={`/modules/s/campaigns/${camp.id}`}
|
| 156 |
+
className="font-semibold text-zinc-100 hover:text-indigo-400 transition-colors flex items-center gap-1.5"
|
| 157 |
+
>
|
| 158 |
+
{camp.name}
|
| 159 |
+
<ArrowUpRight className="w-3.5 h-3.5 text-zinc-500" />
|
| 160 |
+
</Link>
|
| 161 |
+
<div className="text-[11px] text-zinc-400 mt-0.5 font-sans">
|
| 162 |
+
Schedule: <span className="font-mono">{camp.start_schedule || "09:00"} - {camp.end_schedule || "17:00"}</span> ({camp.timezone || "America/New_York"})
|
| 163 |
+
</div>
|
| 164 |
+
</td>
|
| 165 |
+
<td className="px-6 py-4">
|
| 166 |
+
<StatusBadge status={camp.status} />
|
| 167 |
+
</td>
|
| 168 |
+
<td className="px-6 py-4 font-mono text-zinc-300">
|
| 169 |
+
{camp.lead_count?.toLocaleString() || 0}
|
| 170 |
+
</td>
|
| 171 |
+
<td className="px-6 py-4 font-mono text-zinc-300">
|
| 172 |
+
{camp.sent_count?.toLocaleString() || 0}
|
| 173 |
+
</td>
|
| 174 |
+
<td className="px-6 py-4 font-mono text-emerald-400 drop-shadow-[0_0_8px_rgba(52,211,153,0.3)]">
|
| 175 |
+
{camp.open_count?.toLocaleString() || 0}
|
| 176 |
+
</td>
|
| 177 |
+
<td className="px-6 py-4 font-mono text-purple-400 font-semibold drop-shadow-[0_0_8px_rgba(168,85,247,0.3)]">
|
| 178 |
+
{camp.reply_count?.toLocaleString() || 0}
|
| 179 |
+
</td>
|
| 180 |
+
<td className="px-6 py-4 font-mono text-rose-400 drop-shadow-[0_0_8px_rgba(244,63,94,0.3)]">
|
| 181 |
+
{camp.bounce_count || 0}
|
| 182 |
+
</td>
|
| 183 |
+
<td className="px-6 py-4 text-right">
|
| 184 |
+
<div className="flex items-center justify-end gap-1.5">
|
| 185 |
+
{camp.status === "ACTIVE" ? (
|
| 186 |
+
<button
|
| 187 |
+
onClick={() => updateStatusMutation.mutate({ id: camp.id, status: "PAUSE" })}
|
| 188 |
+
title="Pause Campaign"
|
| 189 |
+
className="p-1.5 bg-black/40 hover:bg-amber-500/20 text-zinc-400 hover:text-amber-400 rounded-md transition-colors border border-white/5 hover:border-amber-500/30"
|
| 190 |
+
>
|
| 191 |
+
<Pause className="w-3.5 h-3.5" />
|
| 192 |
+
</button>
|
| 193 |
+
) : (
|
| 194 |
+
<button
|
| 195 |
+
onClick={() => updateStatusMutation.mutate({ id: camp.id, status: "START" })}
|
| 196 |
+
title="Start Campaign"
|
| 197 |
+
className="p-1.5 bg-black/40 hover:bg-emerald-500/20 text-zinc-400 hover:text-emerald-400 rounded-md transition-colors border border-white/5 hover:border-emerald-500/30"
|
| 198 |
+
>
|
| 199 |
+
<Play className="w-3.5 h-3.5" />
|
| 200 |
+
</button>
|
| 201 |
+
)}
|
| 202 |
+
<button
|
| 203 |
+
onClick={() => updateStatusMutation.mutate({ id: camp.id, status: "STOP" })}
|
| 204 |
+
title="Stop Campaign"
|
| 205 |
+
className="p-1.5 bg-black/40 hover:bg-rose-500/20 text-zinc-400 hover:text-rose-400 rounded-md transition-colors border border-white/5 hover:border-rose-500/30"
|
| 206 |
+
>
|
| 207 |
+
<Square className="w-3.5 h-3.5" />
|
| 208 |
+
</button>
|
| 209 |
+
<button
|
| 210 |
+
onClick={() => setSelectedForDelete(camp.id)}
|
| 211 |
+
title="Delete Campaign"
|
| 212 |
+
className="p-1.5 bg-black/40 hover:bg-rose-500/20 text-zinc-400 hover:text-rose-400 rounded-md transition-colors border border-white/5 hover:border-rose-500/30"
|
| 213 |
+
>
|
| 214 |
+
<Trash2 className="w-3.5 h-3.5" />
|
| 215 |
+
</button>
|
| 216 |
+
</div>
|
| 217 |
+
</td>
|
| 218 |
+
</tr>
|
| 219 |
+
))}
|
| 220 |
+
</tbody>
|
| 221 |
+
</table>
|
| 222 |
+
</div>
|
| 223 |
+
) : (
|
| 224 |
+
<div className="py-16 text-center">
|
| 225 |
+
<Megaphone className="w-12 h-12 text-zinc-600 mx-auto mb-3" />
|
| 226 |
+
<h3 className="text-base font-medium text-zinc-300">No campaigns found</h3>
|
| 227 |
+
<p className="text-xs text-zinc-500 mt-1 max-w-sm mx-auto font-sans">
|
| 228 |
+
Create your first campaign to begin dispatching automated cold outreach sequences.
|
| 229 |
+
</p>
|
| 230 |
+
<button
|
| 231 |
+
onClick={() => setIsCreateOpen(true)}
|
| 232 |
+
className="mt-4 px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-medium rounded-lg transition-colors shadow-[0_0_12px_rgba(79,70,229,0.5)] border border-indigo-500/50"
|
| 233 |
+
>
|
| 234 |
+
Create Campaign
|
| 235 |
+
</button>
|
| 236 |
+
</div>
|
| 237 |
+
)}
|
| 238 |
+
</div>
|
| 239 |
+
|
| 240 |
+
{/* Delete Campaign Confirmation */}
|
| 241 |
+
<ConfirmModal
|
| 242 |
+
isOpen={Boolean(selectedForDelete)}
|
| 243 |
+
onClose={() => setSelectedForDelete(null)}
|
| 244 |
+
onConfirm={() => selectedForDelete && deleteMutation.mutate(selectedForDelete)}
|
| 245 |
+
title="Delete Campaign"
|
| 246 |
+
description="Are you sure you want to permanently delete this campaign and all associated sequences? This action cannot be undone."
|
| 247 |
+
confirmText="Delete Campaign"
|
| 248 |
+
isDestructive={true}
|
| 249 |
+
isLoading={deleteMutation.isPending}
|
| 250 |
+
/>
|
| 251 |
+
|
| 252 |
+
{/* Full Multi-Step Create Campaign Drawer */}
|
| 253 |
+
<FormDrawer
|
| 254 |
+
isOpen={isCreateOpen}
|
| 255 |
+
onClose={() => setIsCreateOpen(false)}
|
| 256 |
+
title="Launch New Campaign"
|
| 257 |
+
subtitle="Configure schedule parameters, tracking domain, and initial sequence step."
|
| 258 |
+
>
|
| 259 |
+
<form
|
| 260 |
+
onSubmit={async (e) => {
|
| 261 |
+
e.preventDefault();
|
| 262 |
+
const form = e.target as HTMLFormElement;
|
| 263 |
+
const data = {
|
| 264 |
+
name: (form.elements.namedItem("name") as HTMLInputElement).value,
|
| 265 |
+
timezone: (form.elements.namedItem("timezone") as HTMLSelectElement).value,
|
| 266 |
+
start_schedule: (form.elements.namedItem("start_schedule") as HTMLInputElement).value,
|
| 267 |
+
end_schedule: (form.elements.namedItem("end_schedule") as HTMLInputElement).value,
|
| 268 |
+
track_settings: (form.elements.namedItem("track_settings") as HTMLSelectElement).value,
|
| 269 |
+
send_as_plain_text: (form.elements.namedItem("send_as_plain_text") as HTMLInputElement).checked,
|
| 270 |
+
follow_up_percentage: Number((form.elements.namedItem("follow_up_percentage") as HTMLInputElement).value),
|
| 271 |
+
unsubscribe_text: (form.elements.namedItem("unsubscribe_text") as HTMLInputElement).value,
|
| 272 |
+
stop_lead_settings: (form.elements.namedItem("stop_lead_settings") as HTMLSelectElement).value,
|
| 273 |
+
initial_subject: (form.elements.namedItem("subject") as HTMLInputElement).value,
|
| 274 |
+
initial_body: (form.elements.namedItem("body") as HTMLTextAreaElement).value,
|
| 275 |
+
};
|
| 276 |
+
|
| 277 |
+
try {
|
| 278 |
+
await apiClient.post("/campaigns", data);
|
| 279 |
+
toast.success("Campaign launched successfully!");
|
| 280 |
+
setIsCreateOpen(false);
|
| 281 |
+
queryClient.invalidateQueries({ queryKey: ["campaigns"] });
|
| 282 |
+
} catch (err: any) {
|
| 283 |
+
toast.error(err.response?.data?.error || "Failed to create campaign");
|
| 284 |
+
}
|
| 285 |
+
}}
|
| 286 |
+
className="space-y-5 text-sm"
|
| 287 |
+
>
|
| 288 |
+
<div>
|
| 289 |
+
<label className="block font-medium text-zinc-300 mb-1">Campaign Name *</label>
|
| 290 |
+
<input
|
| 291 |
+
name="name"
|
| 292 |
+
required
|
| 293 |
+
placeholder="e.g. Enterprise Founders Outbound"
|
| 294 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 295 |
+
/>
|
| 296 |
+
</div>
|
| 297 |
+
|
| 298 |
+
<div className="grid grid-cols-2 gap-3">
|
| 299 |
+
<div>
|
| 300 |
+
<label className="block font-medium text-zinc-300 mb-1">Start Time</label>
|
| 301 |
+
<input
|
| 302 |
+
type="time"
|
| 303 |
+
name="start_schedule"
|
| 304 |
+
defaultValue="09:00"
|
| 305 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 306 |
+
/>
|
| 307 |
+
</div>
|
| 308 |
+
<div>
|
| 309 |
+
<label className="block font-medium text-zinc-300 mb-1">End Time</label>
|
| 310 |
+
<input
|
| 311 |
+
type="time"
|
| 312 |
+
name="end_schedule"
|
| 313 |
+
defaultValue="17:00"
|
| 314 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 315 |
+
/>
|
| 316 |
+
</div>
|
| 317 |
+
</div>
|
| 318 |
+
|
| 319 |
+
<div>
|
| 320 |
+
<label className="block font-medium text-zinc-300 mb-1">Timezone</label>
|
| 321 |
+
<select
|
| 322 |
+
name="timezone"
|
| 323 |
+
defaultValue="America/New_York"
|
| 324 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 325 |
+
>
|
| 326 |
+
<option value="America/New_York">America/New_York (EST)</option>
|
| 327 |
+
<option value="America/Chicago">America/Chicago (CST)</option>
|
| 328 |
+
<option value="America/Los_Angeles">America/Los_Angeles (PST)</option>
|
| 329 |
+
<option value="Europe/London">Europe/London (GMT)</option>
|
| 330 |
+
<option value="Europe/Paris">Europe/Paris (CET)</option>
|
| 331 |
+
<option value="Asia/Singapore">Asia/Singapore (SGT)</option>
|
| 332 |
+
</select>
|
| 333 |
+
</div>
|
| 334 |
+
|
| 335 |
+
<div>
|
| 336 |
+
<label className="block font-medium text-zinc-300 mb-1">Tracking Settings</label>
|
| 337 |
+
<select
|
| 338 |
+
name="track_settings"
|
| 339 |
+
defaultValue="TRACK_EMAIL_OPEN_AND_CLICK"
|
| 340 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 341 |
+
>
|
| 342 |
+
<option value="TRACK_EMAIL_OPEN_AND_CLICK">Track Opens and Clicks</option>
|
| 343 |
+
<option value="TRACK_EMAIL_OPEN">Track Email Opens Only</option>
|
| 344 |
+
<option value="TRACK_EMAIL_CLICK">Track Email Clicks Only</option>
|
| 345 |
+
<option value="DONT_TRACK_EMAIL_OPEN">Do Not Track Opens or Clicks</option>
|
| 346 |
+
</select>
|
| 347 |
+
</div>
|
| 348 |
+
|
| 349 |
+
<div className="flex items-center justify-between p-3 bg-zinc-900 border border-zinc-800 rounded-lg">
|
| 350 |
+
<div>
|
| 351 |
+
<span className="font-medium text-zinc-200 block text-xs">Send as Plain Text</span>
|
| 352 |
+
<span className="text-[11px] text-zinc-500">Improves deliverability in strict enterprise inboxes</span>
|
| 353 |
+
</div>
|
| 354 |
+
<input
|
| 355 |
+
type="checkbox"
|
| 356 |
+
name="send_as_plain_text"
|
| 357 |
+
className="w-4 h-4 rounded text-indigo-600 focus:ring-indigo-500 bg-zinc-950 border-zinc-700"
|
| 358 |
+
/>
|
| 359 |
+
</div>
|
| 360 |
+
|
| 361 |
+
<div>
|
| 362 |
+
<div className="flex justify-between text-xs font-medium text-zinc-300 mb-1">
|
| 363 |
+
<span>Follow-up Distribution %</span>
|
| 364 |
+
<span>85%</span>
|
| 365 |
+
</div>
|
| 366 |
+
<input
|
| 367 |
+
type="range"
|
| 368 |
+
name="follow_up_percentage"
|
| 369 |
+
min="10"
|
| 370 |
+
max="100"
|
| 371 |
+
defaultValue="85"
|
| 372 |
+
className="w-full accent-indigo-500"
|
| 373 |
+
/>
|
| 374 |
+
</div>
|
| 375 |
+
|
| 376 |
+
<div>
|
| 377 |
+
<label className="block font-medium text-zinc-300 mb-1">Unsubscribe Message</label>
|
| 378 |
+
<input
|
| 379 |
+
name="unsubscribe_text"
|
| 380 |
+
defaultValue="Reply unsubscribe if you prefer not to receive updates."
|
| 381 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500 text-xs"
|
| 382 |
+
/>
|
| 383 |
+
</div>
|
| 384 |
+
|
| 385 |
+
<div>
|
| 386 |
+
<label className="block font-medium text-zinc-300 mb-1">Stop Lead Condition</label>
|
| 387 |
+
<select
|
| 388 |
+
name="stop_lead_settings"
|
| 389 |
+
defaultValue="REPLIED"
|
| 390 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500 text-xs"
|
| 391 |
+
>
|
| 392 |
+
<option value="REPLIED">Stop sequence once lead replies</option>
|
| 393 |
+
<option value="OPENED">Stop sequence once lead opens email</option>
|
| 394 |
+
<option value="CLICKED">Stop sequence once lead clicks a link</option>
|
| 395 |
+
</select>
|
| 396 |
+
</div>
|
| 397 |
+
|
| 398 |
+
<div className="pt-2 border-t border-zinc-800 space-y-3">
|
| 399 |
+
<h4 className="text-xs font-semibold uppercase text-zinc-400">Step 1 Sequence Setup</h4>
|
| 400 |
+
<div>
|
| 401 |
+
<label className="block font-medium text-zinc-300 mb-1">Subject Line</label>
|
| 402 |
+
<input
|
| 403 |
+
name="subject"
|
| 404 |
+
required
|
| 405 |
+
defaultValue="Quick sync for {{first_name}}"
|
| 406 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500 text-xs"
|
| 407 |
+
/>
|
| 408 |
+
</div>
|
| 409 |
+
<div>
|
| 410 |
+
<label className="block font-medium text-zinc-300 mb-1">Email Body</label>
|
| 411 |
+
<textarea
|
| 412 |
+
name="body"
|
| 413 |
+
rows={3}
|
| 414 |
+
required
|
| 415 |
+
defaultValue="<p>Hi {{first_name}},</p><p>Wanted to see how {{company_name}} is optimizing outbound deliverability?</p>"
|
| 416 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500 font-mono text-xs"
|
| 417 |
+
/>
|
| 418 |
+
</div>
|
| 419 |
+
</div>
|
| 420 |
+
|
| 421 |
+
<div className="pt-4 flex justify-end gap-3 border-t border-zinc-800">
|
| 422 |
+
<button
|
| 423 |
+
type="button"
|
| 424 |
+
onClick={() => setIsCreateOpen(false)}
|
| 425 |
+
className="px-4 py-2 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 rounded-lg text-xs"
|
| 426 |
+
>
|
| 427 |
+
Cancel
|
| 428 |
+
</button>
|
| 429 |
+
<button
|
| 430 |
+
type="submit"
|
| 431 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white font-medium rounded-lg text-xs shadow-md"
|
| 432 |
+
>
|
| 433 |
+
Launch Campaign
|
| 434 |
+
</button>
|
| 435 |
+
</div>
|
| 436 |
+
</form>
|
| 437 |
+
</FormDrawer>
|
| 438 |
+
</div>
|
| 439 |
+
);
|
| 440 |
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Building2,
|
| 5 |
+
Plus,
|
| 6 |
+
Trash2,
|
| 7 |
+
ExternalLink,
|
| 8 |
+
Users,
|
| 9 |
+
Megaphone,
|
| 10 |
+
Mail,
|
| 11 |
+
ArrowUpRight,
|
| 12 |
+
ShieldCheck
|
| 13 |
+
} from "lucide-react";
|
| 14 |
+
import { useState } from "react";
|
| 15 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 16 |
+
import ConfirmModal from "../../../components/ConfirmModal";
|
| 17 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 18 |
+
import toast from "react-hot-toast";
|
| 19 |
+
|
| 20 |
+
export default function Clients() {
|
| 21 |
+
const queryClient = useQueryClient();
|
| 22 |
+
const [isAddOpen, setIsAddOpen] = useState(false);
|
| 23 |
+
const [selectedForDelete, setSelectedForDelete] = useState<string | null>(null);
|
| 24 |
+
|
| 25 |
+
const { data: clients = [], isLoading, refetch } = useQuery({
|
| 26 |
+
queryKey: ["clients"],
|
| 27 |
+
queryFn: async () => {
|
| 28 |
+
const res = await apiClient.get("/clients");
|
| 29 |
+
return res.data;
|
| 30 |
+
},
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
const deleteMutation = useMutation({
|
| 34 |
+
mutationFn: async (id: string) => {
|
| 35 |
+
const res = await apiClient.delete(`/clients/${id}`);
|
| 36 |
+
return res.data;
|
| 37 |
+
},
|
| 38 |
+
onSuccess: () => {
|
| 39 |
+
toast.success("Client account removed");
|
| 40 |
+
setSelectedForDelete(null);
|
| 41 |
+
refetch();
|
| 42 |
+
},
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
return (
|
| 46 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 47 |
+
{/* Header */}
|
| 48 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 49 |
+
<div>
|
| 50 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 51 |
+
<Building2 className="w-6 h-6 text-indigo-400" />
|
| 52 |
+
Agency Client Sub-Accounts
|
| 53 |
+
</h1>
|
| 54 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 55 |
+
Isolate campaigns, custom domains, leads, and analytics across distinct client sub-portals.
|
| 56 |
+
</p>
|
| 57 |
+
</div>
|
| 58 |
+
|
| 59 |
+
<button
|
| 60 |
+
onClick={() => setIsAddOpen(true)}
|
| 61 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-2"
|
| 62 |
+
>
|
| 63 |
+
<Plus className="w-4 h-4" /> Add Client Portal
|
| 64 |
+
</button>
|
| 65 |
+
</div>
|
| 66 |
+
|
| 67 |
+
{/* Client Cards Grid */}
|
| 68 |
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
|
| 69 |
+
{clients.map((client: any) => (
|
| 70 |
+
<div
|
| 71 |
+
key={client.id}
|
| 72 |
+
className="bg-zinc-900 border border-zinc-800 rounded-xl p-5 shadow-sm hover:border-zinc-700 transition-all flex flex-col justify-between"
|
| 73 |
+
>
|
| 74 |
+
<div>
|
| 75 |
+
<div className="flex items-start justify-between">
|
| 76 |
+
<div className="flex items-center gap-3">
|
| 77 |
+
<div className="w-10 h-10 rounded-lg bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 flex items-center justify-center font-bold text-base">
|
| 78 |
+
{client.name ? client.name[0] : "C"}
|
| 79 |
+
</div>
|
| 80 |
+
<div>
|
| 81 |
+
<h3 className="font-semibold text-zinc-100 text-sm">{client.name}</h3>
|
| 82 |
+
<span className="text-xs text-zinc-500 font-mono">{client.email}</span>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
|
| 86 |
+
<StatusBadge status={client.status || "ACTIVE"} size="sm" />
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
{client.website && (
|
| 90 |
+
<div className="mt-3 text-xs text-zinc-400 flex items-center gap-1.5 font-mono">
|
| 91 |
+
<ExternalLink className="w-3.5 h-3.5 text-zinc-500" />
|
| 92 |
+
<a
|
| 93 |
+
href={client.website}
|
| 94 |
+
target="_blank"
|
| 95 |
+
rel="noreferrer"
|
| 96 |
+
className="hover:text-indigo-400 transition-colors truncate"
|
| 97 |
+
>
|
| 98 |
+
{client.website.replace("https://", "")}
|
| 99 |
+
</a>
|
| 100 |
+
</div>
|
| 101 |
+
)}
|
| 102 |
+
|
| 103 |
+
{/* Metrics */}
|
| 104 |
+
<div className="grid grid-cols-2 gap-3 mt-5 pt-4 border-t border-zinc-800/80 text-xs">
|
| 105 |
+
<div className="p-2.5 bg-zinc-950 rounded-lg border border-zinc-800/60">
|
| 106 |
+
<span className="text-zinc-500 flex items-center gap-1 text-[11px]">
|
| 107 |
+
<Megaphone className="w-3 h-3 text-indigo-400" /> Campaigns
|
| 108 |
+
</span>
|
| 109 |
+
<span className="text-base font-bold text-zinc-200 mt-1 block font-mono">
|
| 110 |
+
{client.campaigns_count || 3}
|
| 111 |
+
</span>
|
| 112 |
+
</div>
|
| 113 |
+
<div className="p-2.5 bg-zinc-950 rounded-lg border border-zinc-800/60">
|
| 114 |
+
<span className="text-zinc-500 flex items-center gap-1 text-[11px]">
|
| 115 |
+
<Users className="w-3 h-3 text-teal-400" /> Leads
|
| 116 |
+
</span>
|
| 117 |
+
<span className="text-base font-bold text-zinc-200 mt-1 block font-mono">
|
| 118 |
+
{client.leads_count?.toLocaleString() || "1,420"}
|
| 119 |
+
</span>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
<div className="mt-5 pt-3 border-t border-zinc-800/80 flex items-center justify-between">
|
| 125 |
+
<span className="text-[11px] text-zinc-500 font-mono">ID: {client.id}</span>
|
| 126 |
+
<div className="flex items-center gap-2">
|
| 127 |
+
<button
|
| 128 |
+
onClick={() => setSelectedForDelete(client.id)}
|
| 129 |
+
className="p-1.5 text-zinc-500 hover:text-rose-400 hover:bg-rose-500/10 rounded-md transition-colors"
|
| 130 |
+
>
|
| 131 |
+
<Trash2 className="w-3.5 h-3.5" />
|
| 132 |
+
</button>
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
))}
|
| 137 |
+
|
| 138 |
+
{clients.length === 0 && (
|
| 139 |
+
<div className="col-span-full py-16 text-center text-xs text-zinc-500 bg-zinc-900 border border-zinc-800 rounded-xl">
|
| 140 |
+
No client portals created yet. Add your first agency sub-account above.
|
| 141 |
+
</div>
|
| 142 |
+
)}
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
{/* Delete Confirmation */}
|
| 146 |
+
<ConfirmModal
|
| 147 |
+
isOpen={Boolean(selectedForDelete)}
|
| 148 |
+
onClose={() => setSelectedForDelete(null)}
|
| 149 |
+
onConfirm={() => selectedForDelete && deleteMutation.mutate(selectedForDelete)}
|
| 150 |
+
title="Delete Client Sub-Account"
|
| 151 |
+
description="Are you sure you want to remove this client sub-account? All associated campaigns and isolated settings will be detached."
|
| 152 |
+
/>
|
| 153 |
+
|
| 154 |
+
{/* Add Client Drawer */}
|
| 155 |
+
<FormDrawer
|
| 156 |
+
isOpen={isAddOpen}
|
| 157 |
+
onClose={() => setIsAddOpen(false)}
|
| 158 |
+
title="Create Agency Client Sub-Account"
|
| 159 |
+
subtitle="Provision dedicated workspaces for client stakeholders."
|
| 160 |
+
>
|
| 161 |
+
<form
|
| 162 |
+
onSubmit={async (e) => {
|
| 163 |
+
e.preventDefault();
|
| 164 |
+
const form = e.target as HTMLFormElement;
|
| 165 |
+
const data = {
|
| 166 |
+
name: (form.elements.namedItem("name") as HTMLInputElement).value,
|
| 167 |
+
email: (form.elements.namedItem("email") as HTMLInputElement).value,
|
| 168 |
+
website: (form.elements.namedItem("website") as HTMLInputElement).value,
|
| 169 |
+
};
|
| 170 |
+
|
| 171 |
+
try {
|
| 172 |
+
await apiClient.post("/clients", data);
|
| 173 |
+
toast.success("Client account created!");
|
| 174 |
+
setIsAddOpen(false);
|
| 175 |
+
refetch();
|
| 176 |
+
} catch (err: any) {
|
| 177 |
+
toast.error("Failed to create client");
|
| 178 |
+
}
|
| 179 |
+
}}
|
| 180 |
+
className="space-y-4 text-xs"
|
| 181 |
+
>
|
| 182 |
+
<div>
|
| 183 |
+
<label className="block font-medium text-zinc-300 mb-1">Client Company Name *</label>
|
| 184 |
+
<input name="name" required placeholder="e.g. Acme Ventures" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 185 |
+
</div>
|
| 186 |
+
<div>
|
| 187 |
+
<label className="block font-medium text-zinc-300 mb-1">Primary Contact Email *</label>
|
| 188 |
+
<input type="email" name="email" required placeholder="contact@acme.com" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 189 |
+
</div>
|
| 190 |
+
<div>
|
| 191 |
+
<label className="block font-medium text-zinc-300 mb-1">Website URL</label>
|
| 192 |
+
<input name="website" placeholder="https://acme.com" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 193 |
+
</div>
|
| 194 |
+
|
| 195 |
+
<div className="pt-4 flex justify-end gap-2 border-t border-zinc-800">
|
| 196 |
+
<button
|
| 197 |
+
type="button"
|
| 198 |
+
onClick={() => setIsAddOpen(false)}
|
| 199 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 200 |
+
>
|
| 201 |
+
Cancel
|
| 202 |
+
</button>
|
| 203 |
+
<button
|
| 204 |
+
type="submit"
|
| 205 |
+
className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium shadow"
|
| 206 |
+
>
|
| 207 |
+
Provision Account
|
| 208 |
+
</button>
|
| 209 |
+
</div>
|
| 210 |
+
</form>
|
| 211 |
+
</FormDrawer>
|
| 212 |
+
</div>
|
| 213 |
+
);
|
| 214 |
+
}
|
|
@@ -0,0 +1,543 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Megaphone,
|
| 5 |
+
Users,
|
| 6 |
+
Mail,
|
| 7 |
+
Inbox,
|
| 8 |
+
Flame,
|
| 9 |
+
TrendingUp,
|
| 10 |
+
Sparkles,
|
| 11 |
+
Activity,
|
| 12 |
+
Plus,
|
| 13 |
+
ArrowUpRight,
|
| 14 |
+
CheckCircle2,
|
| 15 |
+
ShieldCheck,
|
| 16 |
+
Radio,
|
| 17 |
+
Zap
|
| 18 |
+
} from "lucide-react";
|
| 19 |
+
import {
|
| 20 |
+
LineChart,
|
| 21 |
+
Line,
|
| 22 |
+
XAxis,
|
| 23 |
+
YAxis,
|
| 24 |
+
CartesianGrid,
|
| 25 |
+
Tooltip,
|
| 26 |
+
ResponsiveContainer,
|
| 27 |
+
PieChart,
|
| 28 |
+
Pie,
|
| 29 |
+
Cell
|
| 30 |
+
} from "recharts";
|
| 31 |
+
import { useState } from "react";
|
| 32 |
+
import { Link } from "react-router-dom";
|
| 33 |
+
import StatCard from "../components/StatCard";
|
| 34 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 35 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 36 |
+
import toast from "react-hot-toast";
|
| 37 |
+
|
| 38 |
+
const lineData = [
|
| 39 |
+
{ date: "Day 1", sent: 480, open: 310, reply: 28, bounce: 6 },
|
| 40 |
+
{ date: "Day 4", sent: 820, open: 530, reply: 46, bounce: 10 },
|
| 41 |
+
{ date: "Day 7", sent: 1250, open: 820, reply: 74, bounce: 14 },
|
| 42 |
+
{ date: "Day 10", sent: 1780, open: 1190, reply: 105, bounce: 19 },
|
| 43 |
+
{ date: "Day 14", sent: 2420, open: 1650, reply: 148, bounce: 23 },
|
| 44 |
+
{ date: "Day 18", sent: 3150, open: 2190, reply: 196, bounce: 31 },
|
| 45 |
+
{ date: "Day 22", sent: 4020, open: 2840, reply: 254, bounce: 38 },
|
| 46 |
+
{ date: "Day 26", sent: 4980, open: 3510, reply: 312, bounce: 46 },
|
| 47 |
+
{ date: "Day 30", sent: 5890, open: 4120, reply: 378, bounce: 52 },
|
| 48 |
+
];
|
| 49 |
+
|
| 50 |
+
const pieData = [
|
| 51 |
+
{ name: "Interested", value: 340, color: "#10b981" },
|
| 52 |
+
{ name: "Meeting Booked", value: 160, color: "#6366f1" },
|
| 53 |
+
{ name: "Replied", value: 290, color: "#f59e0b" },
|
| 54 |
+
{ name: "Not Interested", value: 180, color: "#f43f5e" },
|
| 55 |
+
{ name: "Bounced", value: 45, color: "#71717a" },
|
| 56 |
+
];
|
| 57 |
+
|
| 58 |
+
export default function Dashboard() {
|
| 59 |
+
const [isCreateCampaignOpen, setIsCreateCampaignOpen] = useState(false);
|
| 60 |
+
const [isAddLeadOpen, setIsAddLeadOpen] = useState(false);
|
| 61 |
+
const [activeMetric, setActiveMetric] = useState<"all" | "open" | "reply">("all");
|
| 62 |
+
|
| 63 |
+
const { data: analytics } = useQuery({
|
| 64 |
+
queryKey: ["analytics-summary"],
|
| 65 |
+
queryFn: async () => {
|
| 66 |
+
const res = await apiClient.get("/analytics/campaigns");
|
| 67 |
+
return res.data;
|
| 68 |
+
},
|
| 69 |
+
});
|
| 70 |
+
|
| 71 |
+
const { data: campaigns } = useQuery({
|
| 72 |
+
queryKey: ["campaigns"],
|
| 73 |
+
queryFn: async () => {
|
| 74 |
+
const res = await apiClient.get("/campaigns");
|
| 75 |
+
return res.data;
|
| 76 |
+
},
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
const { data: emailAccounts } = useQuery({
|
| 80 |
+
queryKey: ["email-accounts"],
|
| 81 |
+
queryFn: async () => {
|
| 82 |
+
const res = await apiClient.get("/email-accounts");
|
| 83 |
+
return res.data;
|
| 84 |
+
},
|
| 85 |
+
});
|
| 86 |
+
|
| 87 |
+
return (
|
| 88 |
+
<div className="p-6 max-w-7xl mx-auto space-y-7">
|
| 89 |
+
{/* Header with Live Status & Quick Action Buttons */}
|
| 90 |
+
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
| 91 |
+
<div>
|
| 92 |
+
<div className="flex items-center gap-2">
|
| 93 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 94 |
+
Command Center
|
| 95 |
+
</h1>
|
| 96 |
+
<span className="flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2.5 py-0.5 rounded-full">
|
| 97 |
+
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400 animate-ping" />
|
| 98 |
+
Live Engine
|
| 99 |
+
</span>
|
| 100 |
+
</div>
|
| 101 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 102 |
+
Real-time deliverability radar, campaign sequencing, and cold outreach throughput.
|
| 103 |
+
</p>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<div className="flex items-center gap-3">
|
| 107 |
+
<button
|
| 108 |
+
onClick={() => setIsCreateCampaignOpen(true)}
|
| 109 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-2"
|
| 110 |
+
>
|
| 111 |
+
<Plus className="w-4 h-4" />
|
| 112 |
+
Create Campaign
|
| 113 |
+
</button>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
|
| 117 |
+
{/* High-Impact Stat Cards */}
|
| 118 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
| 119 |
+
<StatCard
|
| 120 |
+
title="Total Campaigns"
|
| 121 |
+
value={campaigns?.length || 3}
|
| 122 |
+
subtitle="Outbound Sequences"
|
| 123 |
+
icon={Megaphone}
|
| 124 |
+
iconColor="indigo"
|
| 125 |
+
change={{ value: "+2 new", isPositive: true, period: "this week" }}
|
| 126 |
+
/>
|
| 127 |
+
<StatCard
|
| 128 |
+
title="Total Leads"
|
| 129 |
+
value={analytics?.total_leads ? analytics.total_leads.toLocaleString() : "4,670"}
|
| 130 |
+
subtitle="Prospects Targeted"
|
| 131 |
+
icon={Users}
|
| 132 |
+
iconColor="teal"
|
| 133 |
+
change={{ value: "+380", isPositive: true, period: "last 7 days" }}
|
| 134 |
+
/>
|
| 135 |
+
<StatCard
|
| 136 |
+
title="Emails Sent"
|
| 137 |
+
value={analytics?.total_sent ? analytics.total_sent.toLocaleString() : "11,140"}
|
| 138 |
+
subtitle="Across All Mailboxes"
|
| 139 |
+
icon={Mail}
|
| 140 |
+
iconColor="blue"
|
| 141 |
+
change={{ value: "+14.8%", isPositive: true, period: "month-over-month" }}
|
| 142 |
+
/>
|
| 143 |
+
<StatCard
|
| 144 |
+
title="Avg Reply Rate"
|
| 145 |
+
value={analytics?.reply_rate ? `${analytics.reply_rate}%` : "5.8%"}
|
| 146 |
+
subtitle="Deliverability High"
|
| 147 |
+
icon={Inbox}
|
| 148 |
+
iconColor="emerald"
|
| 149 |
+
change={{ value: "+1.2%", isPositive: true, period: "vs benchmark" }}
|
| 150 |
+
/>
|
| 151 |
+
</div>
|
| 152 |
+
|
| 153 |
+
{/* Deliverability & Mailbox Health Ribbon */}
|
| 154 |
+
<div className="bg-gradient-to-r from-white/5 via-indigo-900/20 to-white/5 border border-white/10 backdrop-blur-md rounded-xl p-4 flex flex-col md:flex-row items-center justify-between gap-4 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 155 |
+
<div className="flex items-center gap-3">
|
| 156 |
+
<div className="p-2.5 bg-emerald-500/20 border border-emerald-500/30 rounded-xl text-emerald-300 shadow-[inset_0_1px_1px_rgba(255,255,255,0.1)]">
|
| 157 |
+
<ShieldCheck className="w-5 h-5 drop-shadow-[0_0_8px_rgba(52,211,153,0.5)]" />
|
| 158 |
+
</div>
|
| 159 |
+
<div>
|
| 160 |
+
<h4 className="text-sm font-semibold text-zinc-100 flex items-center gap-2">
|
| 161 |
+
Deliverability & Reputation Guard
|
| 162 |
+
<span className="text-[10px] font-bold uppercase tracking-wider bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 px-2 py-0.5 rounded-full drop-shadow-[0_0_8px_rgba(52,211,153,0.3)]">
|
| 163 |
+
98.4% Score
|
| 164 |
+
</span>
|
| 165 |
+
</h4>
|
| 166 |
+
<p className="text-xs text-zinc-400 mt-0.5">
|
| 167 |
+
4 active mailboxes in automatic ramp-up. Spam rescue active across Google & Outlook nodes.
|
| 168 |
+
</p>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
+
|
| 172 |
+
<div className="flex items-center gap-4 text-xs">
|
| 173 |
+
<div className="flex items-center gap-2 bg-black/40 border border-white/5 px-3 py-1.5 rounded-lg shadow-[inset_0_1px_1px_rgba(255,255,255,0.02)]">
|
| 174 |
+
<Flame className="w-4 h-4 text-amber-400 drop-shadow-[0_0_8px_rgba(251,191,36,0.5)]" />
|
| 175 |
+
<span className="text-zinc-300 font-medium font-sans">Warmup:</span>
|
| 176 |
+
<span className="text-amber-400 font-bold font-mono drop-shadow-[0_0_8px_rgba(251,191,36,0.3)]">120 daily / 4 inboxes</span>
|
| 177 |
+
</div>
|
| 178 |
+
<Link
|
| 179 |
+
to="/modules/s/warmup"
|
| 180 |
+
className="text-indigo-400 hover:text-indigo-300 font-medium flex items-center gap-1 transition-colors"
|
| 181 |
+
>
|
| 182 |
+
Warmup Center <ArrowUpRight className="w-3.5 h-3.5" />
|
| 183 |
+
</Link>
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
{/* Main Visualizations Grid */}
|
| 188 |
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
| 189 |
+
{/* 30-Day Performance Multi-Line Chart */}
|
| 190 |
+
<div className="lg:col-span-2 bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)] flex flex-col">
|
| 191 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6">
|
| 192 |
+
<div>
|
| 193 |
+
<h3 className="text-base font-semibold text-zinc-100 flex items-center gap-2">
|
| 194 |
+
<Activity className="w-4 h-4 text-indigo-400 drop-shadow-[0_0_8px_rgba(99,102,241,0.5)]" />
|
| 195 |
+
Performance Trajectory (30 Days)
|
| 196 |
+
</h3>
|
| 197 |
+
<p className="text-xs text-zinc-400 mt-0.5">
|
| 198 |
+
Sent volume, open rate, and reply convergence.
|
| 199 |
+
</p>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
{/* Metric toggles */}
|
| 203 |
+
<div className="flex items-center bg-black/40 p-1 rounded-lg border border-white/5 text-xs shadow-[inset_0_1px_1px_rgba(255,255,255,0.02)]">
|
| 204 |
+
<button
|
| 205 |
+
onClick={() => setActiveMetric("all")}
|
| 206 |
+
className={`px-3 py-1 rounded-md font-medium transition-all duration-300 ${
|
| 207 |
+
activeMetric === "all" ? "bg-indigo-600 text-white shadow-[0_0_12px_rgba(79,70,229,0.5)]" : "text-zinc-400 hover:text-zinc-200"
|
| 208 |
+
}`}
|
| 209 |
+
>
|
| 210 |
+
All Metrics
|
| 211 |
+
</button>
|
| 212 |
+
<button
|
| 213 |
+
onClick={() => setActiveMetric("open")}
|
| 214 |
+
className={`px-3 py-1 rounded-md font-medium transition-all duration-300 ${
|
| 215 |
+
activeMetric === "open" ? "bg-emerald-600 text-white shadow-[0_0_12px_rgba(5,150,105,0.5)]" : "text-zinc-400 hover:text-zinc-200"
|
| 216 |
+
}`}
|
| 217 |
+
>
|
| 218 |
+
Opens
|
| 219 |
+
</button>
|
| 220 |
+
<button
|
| 221 |
+
onClick={() => setActiveMetric("reply")}
|
| 222 |
+
className={`px-3 py-1 rounded-md font-medium transition-all duration-300 ${
|
| 223 |
+
activeMetric === "reply" ? "bg-purple-600 text-white shadow-[0_0_12px_rgba(147,51,234,0.5)]" : "text-zinc-400 hover:text-zinc-200"
|
| 224 |
+
}`}
|
| 225 |
+
>
|
| 226 |
+
Replies
|
| 227 |
+
</button>
|
| 228 |
+
</div>
|
| 229 |
+
</div>
|
| 230 |
+
|
| 231 |
+
<div className="h-[300px] w-full">
|
| 232 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 233 |
+
<LineChart data={lineData} margin={{ top: 5, right: 10, bottom: 5, left: -10 }}>
|
| 234 |
+
<CartesianGrid strokeDasharray="3 3" stroke="rgba(255,255,255,0.05)" vertical={false} />
|
| 235 |
+
<XAxis dataKey="date" stroke="#a1a1aa" fontSize={12} tickLine={false} axisLine={false} />
|
| 236 |
+
<YAxis stroke="#a1a1aa" fontSize={12} tickLine={false} axisLine={false} className="font-mono" />
|
| 237 |
+
<Tooltip
|
| 238 |
+
contentStyle={{
|
| 239 |
+
backgroundColor: "rgba(9, 9, 11, 0.8)",
|
| 240 |
+
backdropFilter: "blur(12px)",
|
| 241 |
+
borderColor: "rgba(255,255,255,0.1)",
|
| 242 |
+
borderRadius: "12px",
|
| 243 |
+
color: "#f4f4f5",
|
| 244 |
+
fontSize: "12px",
|
| 245 |
+
}}
|
| 246 |
+
/>
|
| 247 |
+
{(activeMetric === "all" || activeMetric === "open") && (
|
| 248 |
+
<Line
|
| 249 |
+
type="monotone"
|
| 250 |
+
dataKey="sent"
|
| 251 |
+
name="Sent"
|
| 252 |
+
stroke="#3b82f6"
|
| 253 |
+
strokeWidth={3}
|
| 254 |
+
dot={{ r: 4, fill: "#3b82f6", strokeWidth: 2, stroke: "#000" }}
|
| 255 |
+
activeDot={{ r: 6, fill: "#60a5fa" }}
|
| 256 |
+
animationDuration={1500}
|
| 257 |
+
/>
|
| 258 |
+
)}
|
| 259 |
+
{(activeMetric === "all" || activeMetric === "open") && (
|
| 260 |
+
<Line
|
| 261 |
+
type="monotone"
|
| 262 |
+
dataKey="open"
|
| 263 |
+
name="Opens"
|
| 264 |
+
stroke="#10b981"
|
| 265 |
+
strokeWidth={3}
|
| 266 |
+
dot={{ r: 4, fill: "#10b981", strokeWidth: 2, stroke: "#000" }}
|
| 267 |
+
activeDot={{ r: 6, fill: "#34d399" }}
|
| 268 |
+
animationDuration={1500}
|
| 269 |
+
/>
|
| 270 |
+
)}
|
| 271 |
+
{(activeMetric === "all" || activeMetric === "reply") && (
|
| 272 |
+
<Line
|
| 273 |
+
type="monotone"
|
| 274 |
+
dataKey="reply"
|
| 275 |
+
name="Replies"
|
| 276 |
+
stroke="#a855f7"
|
| 277 |
+
strokeWidth={3}
|
| 278 |
+
dot={{ r: 4, fill: "#a855f7", strokeWidth: 2, stroke: "#000" }}
|
| 279 |
+
activeDot={{ r: 6, fill: "#c084fc" }}
|
| 280 |
+
animationDuration={1500}
|
| 281 |
+
/>
|
| 282 |
+
)}
|
| 283 |
+
{activeMetric === "all" && (
|
| 284 |
+
<Line
|
| 285 |
+
type="monotone"
|
| 286 |
+
dataKey="bounce"
|
| 287 |
+
name="Bounces"
|
| 288 |
+
stroke="#f43f5e"
|
| 289 |
+
strokeWidth={2}
|
| 290 |
+
strokeDasharray="4 4"
|
| 291 |
+
dot={false}
|
| 292 |
+
animationDuration={1500}
|
| 293 |
+
/>
|
| 294 |
+
)}
|
| 295 |
+
</LineChart>
|
| 296 |
+
</ResponsiveContainer>
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<div className="mt-4 pt-3 border-t border-white/5 flex items-center justify-between text-xs text-zinc-400">
|
| 300 |
+
<div className="flex items-center gap-4 font-sans">
|
| 301 |
+
<span className="flex items-center gap-1.5">
|
| 302 |
+
<span className="w-2.5 h-2.5 rounded-full bg-blue-500 shadow-[0_0_8px_rgba(59,130,246,0.8)]" /> Sent
|
| 303 |
+
</span>
|
| 304 |
+
<span className="flex items-center gap-1.5">
|
| 305 |
+
<span className="w-2.5 h-2.5 rounded-full bg-emerald-500 shadow-[0_0_8px_rgba(16,185,129,0.8)]" /> Opens
|
| 306 |
+
</span>
|
| 307 |
+
<span className="flex items-center gap-1.5">
|
| 308 |
+
<span className="w-2.5 h-2.5 rounded-full bg-purple-500 shadow-[0_0_8px_rgba(168,85,247,0.8)]" /> Replies
|
| 309 |
+
</span>
|
| 310 |
+
<span className="flex items-center gap-1.5">
|
| 311 |
+
<span className="w-2.5 h-2.5 rounded-full bg-rose-500 shadow-[0_0_8px_rgba(244,63,94,0.8)]" /> Bounces
|
| 312 |
+
</span>
|
| 313 |
+
</div>
|
| 314 |
+
<Link to="/modules/s/analytics" className="text-indigo-400 hover:text-indigo-300 font-medium">
|
| 315 |
+
View Detailed Analytics →
|
| 316 |
+
</Link>
|
| 317 |
+
</div>
|
| 318 |
+
</div>
|
| 319 |
+
|
| 320 |
+
{/* Lead Status Distribution Donut */}
|
| 321 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)] flex flex-col justify-between">
|
| 322 |
+
<div>
|
| 323 |
+
<h3 className="text-base font-semibold text-zinc-100 flex items-center gap-2">
|
| 324 |
+
<Zap className="w-4 h-4 text-amber-400 drop-shadow-[0_0_8px_rgba(251,191,36,0.5)]" />
|
| 325 |
+
Lead Intent Distribution
|
| 326 |
+
</h3>
|
| 327 |
+
<p className="text-xs text-zinc-400 mt-0.5">Classification of prospect responses.</p>
|
| 328 |
+
</div>
|
| 329 |
+
|
| 330 |
+
<div className="relative h-[220px] w-full flex items-center justify-center my-2">
|
| 331 |
+
<ResponsiveContainer width="100%" height="100%">
|
| 332 |
+
<PieChart>
|
| 333 |
+
<Pie
|
| 334 |
+
data={pieData}
|
| 335 |
+
innerRadius={65}
|
| 336 |
+
outerRadius={95}
|
| 337 |
+
paddingAngle={4}
|
| 338 |
+
dataKey="value"
|
| 339 |
+
stroke="none"
|
| 340 |
+
animationDuration={1500}
|
| 341 |
+
>
|
| 342 |
+
{pieData.map((entry, index) => (
|
| 343 |
+
<Cell key={`cell-${index}`} fill={entry.color} />
|
| 344 |
+
))}
|
| 345 |
+
</Pie>
|
| 346 |
+
<Tooltip
|
| 347 |
+
contentStyle={{
|
| 348 |
+
backgroundColor: "rgba(9, 9, 11, 0.8)",
|
| 349 |
+
backdropFilter: "blur(12px)",
|
| 350 |
+
borderColor: "rgba(255,255,255,0.1)",
|
| 351 |
+
borderRadius: "12px",
|
| 352 |
+
fontSize: "12px",
|
| 353 |
+
}}
|
| 354 |
+
/>
|
| 355 |
+
</PieChart>
|
| 356 |
+
</ResponsiveContainer>
|
| 357 |
+
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none drop-shadow-[0_0_12px_rgba(255,255,255,0.3)]">
|
| 358 |
+
<span className="text-2xl font-bold text-white font-mono">1,015</span>
|
| 359 |
+
<span className="text-[10px] uppercase tracking-wider text-zinc-400 font-medium font-sans">
|
| 360 |
+
Classified
|
| 361 |
+
</span>
|
| 362 |
+
</div>
|
| 363 |
+
</div>
|
| 364 |
+
|
| 365 |
+
<div className="space-y-1.5 pt-3 border-t border-white/5 text-xs font-sans">
|
| 366 |
+
{pieData.map((item) => (
|
| 367 |
+
<div key={item.name} className="flex items-center justify-between text-zinc-300">
|
| 368 |
+
<span className="flex items-center gap-2">
|
| 369 |
+
<span className="w-2.5 h-2.5 rounded-full" style={{ backgroundColor: item.color, boxShadow: `0 0 8px ${item.color}` }} />
|
| 370 |
+
{item.name}
|
| 371 |
+
</span>
|
| 372 |
+
<span className="font-semibold text-zinc-200 font-mono">{item.value}</span>
|
| 373 |
+
</div>
|
| 374 |
+
))}
|
| 375 |
+
</div>
|
| 376 |
+
</div>
|
| 377 |
+
</div>
|
| 378 |
+
|
| 379 |
+
{/* Active Campaigns Overview Table */}
|
| 380 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl overflow-hidden shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 381 |
+
<div className="px-6 py-4 border-b border-white/5 flex items-center justify-between bg-white/[0.02]">
|
| 382 |
+
<div>
|
| 383 |
+
<h3 className="text-base font-semibold text-zinc-100 flex items-center gap-2">
|
| 384 |
+
<Radio className="w-4 h-4 text-indigo-400 drop-shadow-[0_0_8px_rgba(99,102,241,0.5)]" />
|
| 385 |
+
Active Outreach Sequences
|
| 386 |
+
</h3>
|
| 387 |
+
<p className="text-xs text-zinc-400 mt-0.5">
|
| 388 |
+
Live status, recipient quotas, and response metrics.
|
| 389 |
+
</p>
|
| 390 |
+
</div>
|
| 391 |
+
<Link
|
| 392 |
+
to="/modules/s/campaigns"
|
| 393 |
+
className="text-xs font-semibold text-indigo-400 hover:text-indigo-300 transition-colors"
|
| 394 |
+
>
|
| 395 |
+
Manage Campaigns →
|
| 396 |
+
</Link>
|
| 397 |
+
</div>
|
| 398 |
+
|
| 399 |
+
<div className="overflow-x-auto">
|
| 400 |
+
<table className="w-full text-sm text-left">
|
| 401 |
+
<thead className="bg-black/20 border-b border-white/5 text-zinc-400 text-xs uppercase">
|
| 402 |
+
<tr>
|
| 403 |
+
<th className="px-6 py-3 font-medium">Campaign</th>
|
| 404 |
+
<th className="px-6 py-3 font-medium">Status</th>
|
| 405 |
+
<th className="px-6 py-3 font-medium">Leads</th>
|
| 406 |
+
<th className="px-6 py-3 font-medium">Sent</th>
|
| 407 |
+
<th className="px-6 py-3 font-medium">Opens</th>
|
| 408 |
+
<th className="px-6 py-3 font-medium">Replies</th>
|
| 409 |
+
<th className="px-6 py-3 font-medium text-right">Action</th>
|
| 410 |
+
</tr>
|
| 411 |
+
</thead>
|
| 412 |
+
<tbody className="divide-y divide-white/5">
|
| 413 |
+
{(Array.isArray(campaigns) ? campaigns : []).map((camp: any) => (
|
| 414 |
+
<tr key={camp.id} className="hover:bg-white/5 transition-colors">
|
| 415 |
+
<td className="px-6 py-4 font-semibold text-zinc-100">
|
| 416 |
+
<Link to={`/modules/s/campaigns/${camp.id}`} className="hover:text-indigo-400 transition-colors">
|
| 417 |
+
{camp.name}
|
| 418 |
+
</Link>
|
| 419 |
+
<div className="text-[11px] text-zinc-400 font-normal mt-0.5 font-sans">
|
| 420 |
+
{camp.timezone} • {camp.sequences?.length || 1} step sequence
|
| 421 |
+
</div>
|
| 422 |
+
</td>
|
| 423 |
+
<td className="px-6 py-4">
|
| 424 |
+
<StatusBadge status={camp.status} />
|
| 425 |
+
</td>
|
| 426 |
+
<td className="px-6 py-4 text-zinc-300 font-mono">{camp.lead_count || 0}</td>
|
| 427 |
+
<td className="px-6 py-4 text-zinc-300 font-mono">{camp.sent_count || 0}</td>
|
| 428 |
+
<td className="px-6 py-4 text-emerald-400 font-mono drop-shadow-[0_0_8px_rgba(52,211,153,0.3)]">{camp.open_count || 0}</td>
|
| 429 |
+
<td className="px-6 py-4 text-purple-400 font-mono font-semibold drop-shadow-[0_0_8px_rgba(168,85,247,0.3)]">{camp.reply_count || 0}</td>
|
| 430 |
+
<td className="px-6 py-4 text-right">
|
| 431 |
+
<Link
|
| 432 |
+
to={`/modules/s/campaigns/${camp.id}`}
|
| 433 |
+
className="px-3 py-1.5 bg-white/5 hover:bg-white/10 text-zinc-200 text-xs font-medium rounded-lg border border-white/5 transition-all inline-flex items-center gap-1 shadow-[inset_0_1px_1px_rgba(255,255,255,0.05)]"
|
| 434 |
+
>
|
| 435 |
+
Inspect <ArrowUpRight className="w-3 h-3" />
|
| 436 |
+
</Link>
|
| 437 |
+
</td>
|
| 438 |
+
</tr>
|
| 439 |
+
))}
|
| 440 |
+
</tbody>
|
| 441 |
+
</table>
|
| 442 |
+
</div>
|
| 443 |
+
</div>
|
| 444 |
+
|
| 445 |
+
{/* Quick Campaign Creator Slide-Over Drawer */}
|
| 446 |
+
<FormDrawer
|
| 447 |
+
isOpen={isCreateCampaignOpen}
|
| 448 |
+
onClose={() => setIsCreateCampaignOpen(false)}
|
| 449 |
+
title="Create New Campaign"
|
| 450 |
+
subtitle="Configure schedule, tracking domains, and email sequence steps."
|
| 451 |
+
>
|
| 452 |
+
<form
|
| 453 |
+
onSubmit={async (e) => {
|
| 454 |
+
e.preventDefault();
|
| 455 |
+
const form = e.target as HTMLFormElement;
|
| 456 |
+
const name = (form.elements.namedItem("name") as HTMLInputElement).value;
|
| 457 |
+
const timezone = (form.elements.namedItem("timezone") as HTMLSelectElement).value;
|
| 458 |
+
const initial_subject = (form.elements.namedItem("subject") as HTMLInputElement).value;
|
| 459 |
+
const initial_body = (form.elements.namedItem("body") as HTMLTextAreaElement).value;
|
| 460 |
+
|
| 461 |
+
try {
|
| 462 |
+
await apiClient.post("/campaigns", {
|
| 463 |
+
name,
|
| 464 |
+
timezone,
|
| 465 |
+
initial_subject,
|
| 466 |
+
initial_body,
|
| 467 |
+
track_settings: "TRACK_EMAIL_OPEN_AND_CLICK",
|
| 468 |
+
});
|
| 469 |
+
toast.success("Campaign created successfully!");
|
| 470 |
+
setIsCreateCampaignOpen(false);
|
| 471 |
+
} catch (err: any) {
|
| 472 |
+
toast.error(err.message || "Failed to create campaign");
|
| 473 |
+
}
|
| 474 |
+
}}
|
| 475 |
+
className="space-y-4 text-sm"
|
| 476 |
+
>
|
| 477 |
+
<div>
|
| 478 |
+
<label className="block font-medium text-zinc-300 mb-1">Campaign Name</label>
|
| 479 |
+
<input
|
| 480 |
+
name="name"
|
| 481 |
+
required
|
| 482 |
+
placeholder="e.g. Q4 Tech VP Outreach"
|
| 483 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 484 |
+
/>
|
| 485 |
+
</div>
|
| 486 |
+
|
| 487 |
+
<div>
|
| 488 |
+
<label className="block font-medium text-zinc-300 mb-1">Timezone</label>
|
| 489 |
+
<select
|
| 490 |
+
name="timezone"
|
| 491 |
+
defaultValue="America/New_York"
|
| 492 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 493 |
+
>
|
| 494 |
+
<option value="America/New_York">Eastern Time (US & Canada)</option>
|
| 495 |
+
<option value="America/Chicago">Central Time (US & Canada)</option>
|
| 496 |
+
<option value="America/Los_Angeles">Pacific Time (US & Canada)</option>
|
| 497 |
+
<option value="Europe/London">London (GMT)</option>
|
| 498 |
+
<option value="Europe/Paris">Central European Time (CET)</option>
|
| 499 |
+
<option value="Asia/Singapore">Singapore (SGT)</option>
|
| 500 |
+
</select>
|
| 501 |
+
</div>
|
| 502 |
+
|
| 503 |
+
<div>
|
| 504 |
+
<label className="block font-medium text-zinc-300 mb-1">Step 1: Subject Line</label>
|
| 505 |
+
<input
|
| 506 |
+
name="subject"
|
| 507 |
+
required
|
| 508 |
+
defaultValue="Question about {{company_name}}'s pipeline"
|
| 509 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500"
|
| 510 |
+
/>
|
| 511 |
+
</div>
|
| 512 |
+
|
| 513 |
+
<div>
|
| 514 |
+
<label className="block font-medium text-zinc-300 mb-1">Step 1: Email Body</label>
|
| 515 |
+
<textarea
|
| 516 |
+
name="body"
|
| 517 |
+
rows={4}
|
| 518 |
+
required
|
| 519 |
+
defaultValue="Hi {{first_name}},\n\nWanted to reach out and see if you are exploring new outbound channels this quarter?\n\nBest,\nAlex"
|
| 520 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 focus:outline-none focus:border-indigo-500 font-mono text-xs"
|
| 521 |
+
/>
|
| 522 |
+
</div>
|
| 523 |
+
|
| 524 |
+
<div className="pt-4 flex justify-end gap-3">
|
| 525 |
+
<button
|
| 526 |
+
type="button"
|
| 527 |
+
onClick={() => setIsCreateCampaignOpen(false)}
|
| 528 |
+
className="px-4 py-2 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 rounded-lg"
|
| 529 |
+
>
|
| 530 |
+
Cancel
|
| 531 |
+
</button>
|
| 532 |
+
<button
|
| 533 |
+
type="submit"
|
| 534 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white font-medium rounded-lg shadow-md"
|
| 535 |
+
>
|
| 536 |
+
Create Campaign
|
| 537 |
+
</button>
|
| 538 |
+
</div>
|
| 539 |
+
</form>
|
| 540 |
+
</FormDrawer>
|
| 541 |
+
</div>
|
| 542 |
+
);
|
| 543 |
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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2,
|
| 9 |
+
AlertCircle,
|
| 10 |
+
Server,
|
| 11 |
+
Flame,
|
| 12 |
+
Sliders,
|
| 13 |
+
ShieldCheck
|
| 14 |
+
} from "lucide-react";
|
| 15 |
+
import { useState } from "react";
|
| 16 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 17 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 18 |
+
import ConfirmModal from "../../../components/ConfirmModal";
|
| 19 |
+
import toast from "react-hot-toast";
|
| 20 |
+
|
| 21 |
+
export default function EmailAccounts() {
|
| 22 |
+
const queryClient = useQueryClient();
|
| 23 |
+
const [isAddOpen, setIsAddOpen] = useState(false);
|
| 24 |
+
const [activeSetupTab, setActiveSetupTab] = useState<"smtp" | "google" | "outlook">("smtp");
|
| 25 |
+
const [selectedForDelete, setSelectedForDelete] = useState<string | null>(null);
|
| 26 |
+
|
| 27 |
+
const { data: accounts = [], isLoading, refetch } = useQuery({
|
| 28 |
+
queryKey: ["email-accounts"],
|
| 29 |
+
queryFn: async () => {
|
| 30 |
+
const res = await apiClient.get("/email-accounts");
|
| 31 |
+
return res.data;
|
| 32 |
+
},
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
const reconnectMutation = useMutation({
|
| 36 |
+
mutationFn: async (id: string) => {
|
| 37 |
+
const res = await apiClient.post(`/email-accounts/${id}/reconnect`);
|
| 38 |
+
return res.data;
|
| 39 |
+
},
|
| 40 |
+
onSuccess: () => {
|
| 41 |
+
toast.success("Mailbox connection verified and active!");
|
| 42 |
+
refetch();
|
| 43 |
+
},
|
| 44 |
+
onError: () => {
|
| 45 |
+
toast.error("Failed to verify mailbox connection");
|
| 46 |
+
}
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
const deleteMutation = useMutation({
|
| 50 |
+
mutationFn: async (id: string) => {
|
| 51 |
+
const res = await apiClient.delete(`/email-accounts/${id}`);
|
| 52 |
+
return res.data;
|
| 53 |
+
},
|
| 54 |
+
onSuccess: () => {
|
| 55 |
+
toast.success("Email account disconnected");
|
| 56 |
+
setSelectedForDelete(null);
|
| 57 |
+
refetch();
|
| 58 |
+
},
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
const getProviderIcon = (provider: string) => {
|
| 62 |
+
switch (provider?.toLowerCase()) {
|
| 63 |
+
case "google":
|
| 64 |
+
case "gmail":
|
| 65 |
+
return <span className="text-red-400 font-bold">G</span>;
|
| 66 |
+
case "microsoft":
|
| 67 |
+
case "outlook":
|
| 68 |
+
return <span className="text-blue-400 font-bold">M</span>;
|
| 69 |
+
default:
|
| 70 |
+
return <Server className="w-3.5 h-3.5 text-zinc-400" />;
|
| 71 |
+
}
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
return (
|
| 75 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 76 |
+
{/* Header */}
|
| 77 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 78 |
+
<div>
|
| 79 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 80 |
+
<Mail className="w-6 h-6 text-blue-400" />
|
| 81 |
+
Sending Inboxes & Mailboxes
|
| 82 |
+
</h1>
|
| 83 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 84 |
+
Connect and manage sending infrastructure across Google Workspace, Microsoft 365, and custom SMTP/IMAP.
|
| 85 |
+
</p>
|
| 86 |
+
</div>
|
| 87 |
+
|
| 88 |
+
<button
|
| 89 |
+
onClick={() => setIsAddOpen(true)}
|
| 90 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-2"
|
| 91 |
+
>
|
| 92 |
+
<Plus className="w-4 h-4" /> Add Mailbox
|
| 93 |
+
</button>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
{/* Overview Cards */}
|
| 97 |
+
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
| 98 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 99 |
+
<span className="text-xs text-zinc-400">Total Sending Capacity</span>
|
| 100 |
+
<div className="text-2xl font-bold text-zinc-100 mt-1">
|
| 101 |
+
{accounts.reduce((sum: number, a: any) => sum + (a.daily_limit || 0), 0)} / day
|
| 102 |
+
</div>
|
| 103 |
+
<span className="text-[11px] text-zinc-500">{accounts.length} connected mailboxes</span>
|
| 104 |
+
</div>
|
| 105 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 106 |
+
<span className="text-xs text-zinc-400">Active in Warmup</span>
|
| 107 |
+
<div className="text-2xl font-bold text-amber-400 mt-1">
|
| 108 |
+
{accounts.filter((a: any) => a.warmup_status === "ACTIVE").length} of {accounts.length}
|
| 109 |
+
</div>
|
| 110 |
+
<span className="text-[11px] text-zinc-500">Autonomous ramp-up active</span>
|
| 111 |
+
</div>
|
| 112 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 113 |
+
<span className="text-xs text-zinc-400">Network Deliverability</span>
|
| 114 |
+
<div className="text-2xl font-bold text-emerald-400 mt-1">99.1%</div>
|
| 115 |
+
<span className="text-[11px] text-zinc-500">All DNS / SPF / DKIM valid</span>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
|
| 119 |
+
{/* Accounts Table */}
|
| 120 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden shadow-sm">
|
| 121 |
+
<div className="overflow-x-auto">
|
| 122 |
+
<table className="w-full text-sm text-left">
|
| 123 |
+
<thead className="bg-zinc-950 border-b border-zinc-800 text-zinc-400 text-xs uppercase">
|
| 124 |
+
<tr>
|
| 125 |
+
<th className="px-6 py-3.5 font-semibold">Account / Sender</th>
|
| 126 |
+
<th className="px-6 py-3.5 font-semibold">Provider</th>
|
| 127 |
+
<th className="px-6 py-3.5 font-semibold">Status</th>
|
| 128 |
+
<th className="px-6 py-3.5 font-semibold">Daily Limit & Usage</th>
|
| 129 |
+
<th className="px-6 py-3.5 font-semibold">Warmup</th>
|
| 130 |
+
<th className="px-6 py-3.5 font-semibold text-right">Actions</th>
|
| 131 |
+
</tr>
|
| 132 |
+
</thead>
|
| 133 |
+
<tbody className="divide-y divide-zinc-800/80">
|
| 134 |
+
{accounts.map((acc: any) => {
|
| 135 |
+
const usage = acc.sent_count || 12;
|
| 136 |
+
const limit = acc.daily_limit || 40;
|
| 137 |
+
const percentage = Math.min(100, Math.round((usage / limit) * 100));
|
| 138 |
+
|
| 139 |
+
return (
|
| 140 |
+
<tr key={acc.id} className="hover:bg-zinc-800/30 transition-colors">
|
| 141 |
+
<td className="px-6 py-4">
|
| 142 |
+
<div className="font-semibold text-zinc-100">{acc.from_name}</div>
|
| 143 |
+
<div className="text-xs text-zinc-400 font-mono mt-0.5">{acc.from_email}</div>
|
| 144 |
+
</td>
|
| 145 |
+
<td className="px-6 py-4">
|
| 146 |
+
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 bg-zinc-950 border border-zinc-800 rounded-md text-xs text-zinc-300 font-medium capitalize">
|
| 147 |
+
{getProviderIcon(acc.provider)}
|
| 148 |
+
{acc.provider}
|
| 149 |
+
</span>
|
| 150 |
+
</td>
|
| 151 |
+
<td className="px-6 py-4">
|
| 152 |
+
<StatusBadge status={acc.status} size="sm" />
|
| 153 |
+
</td>
|
| 154 |
+
<td className="px-6 py-4">
|
| 155 |
+
<div className="w-40 space-y-1">
|
| 156 |
+
<div className="flex justify-between text-[11px] font-mono text-zinc-400">
|
| 157 |
+
<span>{usage} sent</span>
|
| 158 |
+
<span>{limit} limit</span>
|
| 159 |
+
</div>
|
| 160 |
+
<div className="w-full h-1.5 bg-zinc-950 rounded-full overflow-hidden border border-zinc-800">
|
| 161 |
+
<div
|
| 162 |
+
className={`h-full rounded-full ${
|
| 163 |
+
percentage > 90 ? "bg-amber-500" : "bg-indigo-500"
|
| 164 |
+
}`}
|
| 165 |
+
style={{ width: `${percentage}%` }}
|
| 166 |
+
/>
|
| 167 |
+
</div>
|
| 168 |
+
</div>
|
| 169 |
+
</td>
|
| 170 |
+
<td className="px-6 py-4">
|
| 171 |
+
<div className="flex items-center gap-2">
|
| 172 |
+
<Flame className={`w-4 h-4 ${acc.warmup_status === "ACTIVE" ? "text-amber-400 animate-pulse" : "text-zinc-600"}`} />
|
| 173 |
+
<span className="text-xs font-medium text-zinc-300">
|
| 174 |
+
{acc.warmup_status === "ACTIVE" ? "Ramping Up" : "Disabled"}
|
| 175 |
+
</span>
|
| 176 |
+
</div>
|
| 177 |
+
</td>
|
| 178 |
+
<td className="px-6 py-4 text-right">
|
| 179 |
+
<div className="flex items-center justify-end gap-2">
|
| 180 |
+
<button
|
| 181 |
+
onClick={() => reconnectMutation.mutate(acc.id)}
|
| 182 |
+
title="Verify Connection"
|
| 183 |
+
className="p-1.5 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 rounded-md transition-colors"
|
| 184 |
+
>
|
| 185 |
+
<RefreshCw className="w-3.5 h-3.5" />
|
| 186 |
+
</button>
|
| 187 |
+
<button
|
| 188 |
+
onClick={() => setSelectedForDelete(acc.id)}
|
| 189 |
+
title="Disconnect Mailbox"
|
| 190 |
+
className="p-1.5 bg-zinc-800 hover:bg-rose-500/20 text-zinc-400 hover:text-rose-400 rounded-md transition-colors"
|
| 191 |
+
>
|
| 192 |
+
<Trash2 className="w-3.5 h-3.5" />
|
| 193 |
+
</button>
|
| 194 |
+
</div>
|
| 195 |
+
</td>
|
| 196 |
+
</tr>
|
| 197 |
+
);
|
| 198 |
+
})}
|
| 199 |
+
</tbody>
|
| 200 |
+
</table>
|
| 201 |
+
</div>
|
| 202 |
+
</div>
|
| 203 |
+
|
| 204 |
+
{/* Delete Confirmation */}
|
| 205 |
+
<ConfirmModal
|
| 206 |
+
isOpen={Boolean(selectedForDelete)}
|
| 207 |
+
onClose={() => setSelectedForDelete(null)}
|
| 208 |
+
onConfirm={() => selectedForDelete && deleteMutation.mutate(selectedForDelete)}
|
| 209 |
+
title="Disconnect Mailbox"
|
| 210 |
+
description="Are you sure you want to disconnect this email account? Active campaigns using this mailbox will cease dispatching from it."
|
| 211 |
+
confirmText="Disconnect"
|
| 212 |
+
/>
|
| 213 |
+
|
| 214 |
+
{/* Add Mailbox Drawer */}
|
| 215 |
+
<FormDrawer
|
| 216 |
+
isOpen={isAddOpen}
|
| 217 |
+
onClose={() => setIsAddOpen(false)}
|
| 218 |
+
title="Connect Sending Mailbox"
|
| 219 |
+
subtitle="Add Google Workspace, Microsoft 365, or Custom SMTP/IMAP credentials."
|
| 220 |
+
>
|
| 221 |
+
<div className="space-y-5 text-xs">
|
| 222 |
+
{/* Provider Selector Tabs */}
|
| 223 |
+
<div className="grid grid-cols-3 gap-2 p-1 bg-zinc-900 border border-zinc-800 rounded-xl">
|
| 224 |
+
<button
|
| 225 |
+
type="button"
|
| 226 |
+
onClick={() => setActiveSetupTab("smtp")}
|
| 227 |
+
className={`py-2 rounded-lg font-medium transition-colors ${
|
| 228 |
+
activeSetupTab === "smtp" ? "bg-indigo-600 text-white" : "text-zinc-400 hover:text-zinc-200"
|
| 229 |
+
}`}
|
| 230 |
+
>
|
| 231 |
+
SMTP / IMAP
|
| 232 |
+
</button>
|
| 233 |
+
<button
|
| 234 |
+
type="button"
|
| 235 |
+
onClick={() => setActiveSetupTab("google")}
|
| 236 |
+
className={`py-2 rounded-lg font-medium transition-colors ${
|
| 237 |
+
activeSetupTab === "google" ? "bg-indigo-600 text-white" : "text-zinc-400 hover:text-zinc-200"
|
| 238 |
+
}`}
|
| 239 |
+
>
|
| 240 |
+
Google OAuth
|
| 241 |
+
</button>
|
| 242 |
+
<button
|
| 243 |
+
type="button"
|
| 244 |
+
onClick={() => setActiveSetupTab("outlook")}
|
| 245 |
+
className={`py-2 rounded-lg font-medium transition-colors ${
|
| 246 |
+
activeSetupTab === "outlook" ? "bg-indigo-600 text-white" : "text-zinc-400 hover:text-zinc-200"
|
| 247 |
+
}`}
|
| 248 |
+
>
|
| 249 |
+
Microsoft 365
|
| 250 |
+
</button>
|
| 251 |
+
</div>
|
| 252 |
+
|
| 253 |
+
{activeSetupTab === "smtp" && (
|
| 254 |
+
<form
|
| 255 |
+
onSubmit={async (e) => {
|
| 256 |
+
e.preventDefault();
|
| 257 |
+
const form = e.target as HTMLFormElement;
|
| 258 |
+
const data = {
|
| 259 |
+
from_name: (form.elements.namedItem("from_name") as HTMLInputElement).value,
|
| 260 |
+
from_email: (form.elements.namedItem("from_email") as HTMLInputElement).value,
|
| 261 |
+
smtp_host: (form.elements.namedItem("smtp_host") as HTMLInputElement).value,
|
| 262 |
+
smtp_port: Number((form.elements.namedItem("smtp_port") as HTMLInputElement).value),
|
| 263 |
+
smtp_username: (form.elements.namedItem("smtp_username") as HTMLInputElement).value,
|
| 264 |
+
smtp_password: (form.elements.namedItem("smtp_password") as HTMLInputElement).value,
|
| 265 |
+
imap_host: (form.elements.namedItem("imap_host") as HTMLInputElement).value,
|
| 266 |
+
imap_port: Number((form.elements.namedItem("imap_port") as HTMLInputElement).value),
|
| 267 |
+
imap_username: (form.elements.namedItem("imap_username") as HTMLInputElement).value,
|
| 268 |
+
imap_password: (form.elements.namedItem("imap_password") as HTMLInputElement).value,
|
| 269 |
+
daily_limit: Number((form.elements.namedItem("daily_limit") as HTMLInputElement).value),
|
| 270 |
+
provider: "smtp",
|
| 271 |
+
};
|
| 272 |
+
|
| 273 |
+
try {
|
| 274 |
+
await apiClient.post("/email-accounts/smtp", data);
|
| 275 |
+
toast.success("SMTP Mailbox connected successfully!");
|
| 276 |
+
setIsAddOpen(false);
|
| 277 |
+
refetch();
|
| 278 |
+
} catch (err: any) {
|
| 279 |
+
toast.error(err.response?.data?.error || "Failed to connect SMTP account");
|
| 280 |
+
}
|
| 281 |
+
}}
|
| 282 |
+
className="space-y-4"
|
| 283 |
+
>
|
| 284 |
+
<div className="grid grid-cols-2 gap-3">
|
| 285 |
+
<div>
|
| 286 |
+
<label className="block font-medium text-zinc-300 mb-1">Sender Name *</label>
|
| 287 |
+
<input name="from_name" required placeholder="Alex Turner" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 288 |
+
</div>
|
| 289 |
+
<div>
|
| 290 |
+
<label className="block font-medium text-zinc-300 mb-1">Email Address *</label>
|
| 291 |
+
<input name="from_email" type="email" required placeholder="alex@company.com" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
|
| 295 |
+
<div className="pt-2 border-t border-zinc-800 space-y-3">
|
| 296 |
+
<h4 className="font-semibold text-zinc-400 uppercase tracking-wider text-[10px]">SMTP Configuration (Outbound)</h4>
|
| 297 |
+
<div className="grid grid-cols-3 gap-2">
|
| 298 |
+
<div className="col-span-2">
|
| 299 |
+
<label className="block font-medium text-zinc-400 mb-1">Host</label>
|
| 300 |
+
<input name="smtp_host" defaultValue="smtp.mailgun.org" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 301 |
+
</div>
|
| 302 |
+
<div>
|
| 303 |
+
<label className="block font-medium text-zinc-400 mb-1">Port</label>
|
| 304 |
+
<input name="smtp_port" defaultValue="587" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
<div className="grid grid-cols-2 gap-2">
|
| 308 |
+
<div>
|
| 309 |
+
<label className="block font-medium text-zinc-400 mb-1">Username</label>
|
| 310 |
+
<input name="smtp_username" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 311 |
+
</div>
|
| 312 |
+
<div>
|
| 313 |
+
<label className="block font-medium text-zinc-400 mb-1">Password</label>
|
| 314 |
+
<input name="smtp_password" type="password" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 315 |
+
</div>
|
| 316 |
+
</div>
|
| 317 |
+
</div>
|
| 318 |
+
|
| 319 |
+
<div className="pt-2 border-t border-zinc-800 space-y-3">
|
| 320 |
+
<h4 className="font-semibold text-zinc-400 uppercase tracking-wider text-[10px]">IMAP Configuration (Inbox & Replies)</h4>
|
| 321 |
+
<div className="grid grid-cols-3 gap-2">
|
| 322 |
+
<div className="col-span-2">
|
| 323 |
+
<label className="block font-medium text-zinc-400 mb-1">Host</label>
|
| 324 |
+
<input name="imap_host" defaultValue="imap.mailgun.org" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 325 |
+
</div>
|
| 326 |
+
<div>
|
| 327 |
+
<label className="block font-medium text-zinc-400 mb-1">Port</label>
|
| 328 |
+
<input name="imap_port" defaultValue="993" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 329 |
+
</div>
|
| 330 |
+
</div>
|
| 331 |
+
<div className="grid grid-cols-2 gap-2">
|
| 332 |
+
<div>
|
| 333 |
+
<label className="block font-medium text-zinc-400 mb-1">Username</label>
|
| 334 |
+
<input name="imap_username" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 335 |
+
</div>
|
| 336 |
+
<div>
|
| 337 |
+
<label className="block font-medium text-zinc-400 mb-1">Password</label>
|
| 338 |
+
<input name="imap_password" type="password" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 339 |
+
</div>
|
| 340 |
+
</div>
|
| 341 |
+
</div>
|
| 342 |
+
|
| 343 |
+
<div>
|
| 344 |
+
<label className="block font-medium text-zinc-300 mb-1">Max Daily Send Limit</label>
|
| 345 |
+
<input name="daily_limit" type="number" defaultValue="50" min="1" max="2000" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 346 |
+
</div>
|
| 347 |
+
|
| 348 |
+
<div className="pt-4 flex justify-end gap-2 border-t border-zinc-800">
|
| 349 |
+
<button
|
| 350 |
+
type="button"
|
| 351 |
+
onClick={() => setIsAddOpen(false)}
|
| 352 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 353 |
+
>
|
| 354 |
+
Cancel
|
| 355 |
+
</button>
|
| 356 |
+
<button
|
| 357 |
+
type="submit"
|
| 358 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white font-medium rounded-lg"
|
| 359 |
+
>
|
| 360 |
+
Connect Mailbox
|
| 361 |
+
</button>
|
| 362 |
+
</div>
|
| 363 |
+
</form>
|
| 364 |
+
)}
|
| 365 |
+
|
| 366 |
+
{(activeSetupTab === "google" || activeSetupTab === "outlook") && (
|
| 367 |
+
<div className="py-8 text-center space-y-4">
|
| 368 |
+
<div className="p-4 bg-zinc-900 rounded-xl border border-zinc-800 max-w-sm mx-auto">
|
| 369 |
+
<div className="text-2xl mb-2 font-bold">{activeSetupTab === "google" ? "Google Workspace" : "Microsoft 365"}</div>
|
| 370 |
+
<p className="text-zinc-400 text-xs">
|
| 371 |
+
Authorize direct OAuth access to dispatch outbound sequences with verified sender tokens.
|
| 372 |
+
</p>
|
| 373 |
+
<button
|
| 374 |
+
type="button"
|
| 375 |
+
onClick={() => {
|
| 376 |
+
toast.success(`Connected ${activeSetupTab} account!`);
|
| 377 |
+
setIsAddOpen(false);
|
| 378 |
+
refetch();
|
| 379 |
+
}}
|
| 380 |
+
className="mt-4 w-full py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white font-semibold rounded-lg shadow-md"
|
| 381 |
+
>
|
| 382 |
+
Authorize with {activeSetupTab === "google" ? "Google" : "Microsoft"}
|
| 383 |
+
</button>
|
| 384 |
+
</div>
|
| 385 |
+
</div>
|
| 386 |
+
)}
|
| 387 |
+
</div>
|
| 388 |
+
</FormDrawer>
|
| 389 |
+
</div>
|
| 390 |
+
);
|
| 391 |
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Inbox as InboxIcon,
|
| 5 |
+
Search,
|
| 6 |
+
Send,
|
| 7 |
+
Sparkles,
|
| 8 |
+
CheckCircle2,
|
| 9 |
+
AlertCircle,
|
| 10 |
+
Clock,
|
| 11 |
+
Mail,
|
| 12 |
+
Calendar,
|
| 13 |
+
User,
|
| 14 |
+
Building,
|
| 15 |
+
ChevronRight,
|
| 16 |
+
Paperclip,
|
| 17 |
+
Smile,
|
| 18 |
+
RefreshCw
|
| 19 |
+
} from "lucide-react";
|
| 20 |
+
import { useState } from "react";
|
| 21 |
+
import DOMPurify from "dompurify";
|
| 22 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 23 |
+
import RichTextEditor from "../../../components/RichTextEditor";
|
| 24 |
+
import toast from "react-hot-toast";
|
| 25 |
+
|
| 26 |
+
const CATEGORIES = [
|
| 27 |
+
{ key: "ALL", label: "All Messages" },
|
| 28 |
+
{ key: "INTERESTED", label: "Interested" },
|
| 29 |
+
{ key: "MEETING_BOOKED", label: "Meeting Booked" },
|
| 30 |
+
{ key: "REPLIED", label: "Replied" },
|
| 31 |
+
{ key: "NOT_INTERESTED", label: "Not Interested" },
|
| 32 |
+
];
|
| 33 |
+
|
| 34 |
+
export default function Inbox() {
|
| 35 |
+
const queryClient = useQueryClient();
|
| 36 |
+
const [selectedCategory, setSelectedCategory] = useState("ALL");
|
| 37 |
+
const [selectedMessageId, setSelectedMessageId] = useState<string | null>("msg_001");
|
| 38 |
+
const [replyBody, setReplyBody] = useState("");
|
| 39 |
+
|
| 40 |
+
const { data: messages = [], isLoading, refetch } = useQuery({
|
| 41 |
+
queryKey: ["inbox-messages", selectedCategory],
|
| 42 |
+
queryFn: async () => {
|
| 43 |
+
const res = await apiClient.get("/inbox", {
|
| 44 |
+
params: selectedCategory !== "ALL" ? { category: selectedCategory } : {},
|
| 45 |
+
});
|
| 46 |
+
return res.data;
|
| 47 |
+
},
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
const selectedMessage = (Array.isArray(messages) ? messages : []).find((m: any) => m.id === selectedMessageId) || (Array.isArray(messages) ? messages[0] : null);
|
| 51 |
+
|
| 52 |
+
const updateCategoryMutation = useMutation({
|
| 53 |
+
mutationFn: async ({ messageId, category }: { messageId: string; category: string }) => {
|
| 54 |
+
const res = await apiClient.post(`/inbox/${messageId}/category`, { category });
|
| 55 |
+
return res.data;
|
| 56 |
+
},
|
| 57 |
+
onSuccess: () => {
|
| 58 |
+
toast.success("Lead categorization updated");
|
| 59 |
+
refetch();
|
| 60 |
+
},
|
| 61 |
+
});
|
| 62 |
+
|
| 63 |
+
const sendReplyMutation = useMutation({
|
| 64 |
+
mutationFn: async ({ messageId, body }: { messageId: string; body: string }) => {
|
| 65 |
+
const res = await apiClient.post(`/inbox/${messageId}/reply`, { reply_body: body });
|
| 66 |
+
return res.data;
|
| 67 |
+
},
|
| 68 |
+
onSuccess: () => {
|
| 69 |
+
toast.success("Reply dispatched to lead!");
|
| 70 |
+
setReplyBody("");
|
| 71 |
+
refetch();
|
| 72 |
+
},
|
| 73 |
+
onError: () => {
|
| 74 |
+
toast.error("Failed to send reply");
|
| 75 |
+
}
|
| 76 |
+
});
|
| 77 |
+
|
| 78 |
+
return (
|
| 79 |
+
<div className="h-[calc(100vh-4rem)] flex flex-col overflow-hidden">
|
| 80 |
+
{/* Top Controls */}
|
| 81 |
+
<div className="h-14 border-b border-zinc-800 bg-zinc-950 px-6 flex items-center justify-between shrink-0">
|
| 82 |
+
<div className="flex items-center gap-3">
|
| 83 |
+
<div className="p-1.5 bg-indigo-500/10 text-indigo-400 rounded-lg">
|
| 84 |
+
<InboxIcon className="w-5 h-5" />
|
| 85 |
+
</div>
|
| 86 |
+
<div>
|
| 87 |
+
<h1 className="text-base font-bold text-zinc-100 flex items-center gap-2">
|
| 88 |
+
Unified Master Inbox
|
| 89 |
+
<span className="text-[10px] font-bold uppercase tracking-wider bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-2 py-0.5 rounded-full">
|
| 90 |
+
AI Sentiment Active
|
| 91 |
+
</span>
|
| 92 |
+
</h1>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<div className="flex items-center gap-2">
|
| 97 |
+
<button
|
| 98 |
+
onClick={() => refetch()}
|
| 99 |
+
className="p-1.5 text-zinc-400 hover:text-zinc-200 hover:bg-zinc-900 rounded-lg transition-colors"
|
| 100 |
+
title="Refresh Inboxes"
|
| 101 |
+
>
|
| 102 |
+
<RefreshCw className="w-4 h-4" />
|
| 103 |
+
</button>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
{/* 2-Pane Inbox Workspace */}
|
| 108 |
+
<div className="flex-1 flex overflow-hidden">
|
| 109 |
+
{/* Left Pane: Message List */}
|
| 110 |
+
<div className="w-80 md:w-96 border-r border-zinc-800 flex flex-col bg-zinc-950/60 shrink-0">
|
| 111 |
+
{/* Categories Filter Tabs */}
|
| 112 |
+
<div className="p-3 border-b border-zinc-800 flex gap-1 overflow-x-auto">
|
| 113 |
+
{CATEGORIES.map((cat) => (
|
| 114 |
+
<button
|
| 115 |
+
key={cat.key}
|
| 116 |
+
onClick={() => setSelectedCategory(cat.key)}
|
| 117 |
+
className={`px-2.5 py-1 rounded-md text-xs font-medium whitespace-nowrap transition-colors ${
|
| 118 |
+
selectedCategory === cat.key
|
| 119 |
+
? "bg-indigo-600 text-white"
|
| 120 |
+
: "bg-zinc-900 text-zinc-400 hover:text-zinc-200"
|
| 121 |
+
}`}
|
| 122 |
+
>
|
| 123 |
+
{cat.label}
|
| 124 |
+
</button>
|
| 125 |
+
))}
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
{/* Messages Scroll Area */}
|
| 129 |
+
<div className="flex-1 overflow-y-auto divide-y divide-zinc-800/60">
|
| 130 |
+
{messages.map((msg: any) => {
|
| 131 |
+
const isSelected = msg.id === selectedMessage?.id;
|
| 132 |
+
return (
|
| 133 |
+
<div
|
| 134 |
+
key={msg.id}
|
| 135 |
+
onClick={() => setSelectedMessageId(msg.id)}
|
| 136 |
+
className={`p-4 transition-colors cursor-pointer ${
|
| 137 |
+
isSelected ? "bg-indigo-950/30 border-l-2 border-indigo-500" : "hover:bg-zinc-900/40"
|
| 138 |
+
}`}
|
| 139 |
+
>
|
| 140 |
+
<div className="flex items-start justify-between gap-2">
|
| 141 |
+
<span className="font-semibold text-xs text-zinc-100 truncate">
|
| 142 |
+
{msg.from_name || msg.from_email}
|
| 143 |
+
</span>
|
| 144 |
+
<span className="text-[10px] text-zinc-500 shrink-0">
|
| 145 |
+
{new Date(msg.created_at || Date.now()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}
|
| 146 |
+
</span>
|
| 147 |
+
</div>
|
| 148 |
+
|
| 149 |
+
<h4 className="text-xs font-medium text-zinc-300 mt-1 truncate">
|
| 150 |
+
{msg.subject}
|
| 151 |
+
</h4>
|
| 152 |
+
|
| 153 |
+
<p className="text-[11px] text-zinc-500 mt-1 line-clamp-2 leading-relaxed">
|
| 154 |
+
{msg.preview_body || msg.body?.replace(/<[^>]*>?/gm, "")}
|
| 155 |
+
</p>
|
| 156 |
+
|
| 157 |
+
<div className="mt-2.5 flex items-center justify-between">
|
| 158 |
+
<StatusBadge status={msg.lead_category || "INTERESTED"} size="sm" />
|
| 159 |
+
<span className="text-[10px] text-zinc-400 font-mono">
|
| 160 |
+
{msg.company_name}
|
| 161 |
+
</span>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
);
|
| 165 |
+
})}
|
| 166 |
+
|
| 167 |
+
{messages.length === 0 && (
|
| 168 |
+
<div className="p-8 text-center text-xs text-zinc-500">
|
| 169 |
+
No replies found for this category filter.
|
| 170 |
+
</div>
|
| 171 |
+
)}
|
| 172 |
+
</div>
|
| 173 |
+
</div>
|
| 174 |
+
|
| 175 |
+
{/* Right Pane: Thread View & Response Composer */}
|
| 176 |
+
{selectedMessage ? (
|
| 177 |
+
<div className="flex-1 flex flex-col bg-zinc-950 overflow-hidden">
|
| 178 |
+
{/* Thread Header */}
|
| 179 |
+
<div className="p-5 border-b border-zinc-800 bg-zinc-900/30 flex items-center justify-between shrink-0">
|
| 180 |
+
<div className="flex items-center gap-3">
|
| 181 |
+
<div className="w-9 h-9 rounded-full bg-indigo-600/20 text-indigo-400 flex items-center justify-center font-bold text-sm border border-indigo-500/30">
|
| 182 |
+
{selectedMessage.from_name ? selectedMessage.from_name[0] : "L"}
|
| 183 |
+
</div>
|
| 184 |
+
<div>
|
| 185 |
+
<h3 className="text-sm font-bold text-zinc-100 flex items-center gap-2">
|
| 186 |
+
{selectedMessage.subject}
|
| 187 |
+
</h3>
|
| 188 |
+
<div className="text-xs text-zinc-400 flex items-center gap-2 mt-0.5">
|
| 189 |
+
<span>{selectedMessage.from_name} <{selectedMessage.from_email}></span>
|
| 190 |
+
<span>•</span>
|
| 191 |
+
<span className="font-mono text-zinc-500">{selectedMessage.company_name}</span>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
</div>
|
| 195 |
+
|
| 196 |
+
{/* Categorization Dropdown */}
|
| 197 |
+
<div className="flex items-center gap-2">
|
| 198 |
+
<span className="text-xs text-zinc-500">AI Intent:</span>
|
| 199 |
+
<select
|
| 200 |
+
value={selectedMessage.lead_category || "INTERESTED"}
|
| 201 |
+
onChange={(e) =>
|
| 202 |
+
updateCategoryMutation.mutate({
|
| 203 |
+
messageId: selectedMessage.id,
|
| 204 |
+
category: e.target.value,
|
| 205 |
+
})
|
| 206 |
+
}
|
| 207 |
+
className="bg-zinc-900 border border-zinc-800 rounded-lg py-1.5 px-3 text-xs text-zinc-200 focus:outline-none focus:border-indigo-500"
|
| 208 |
+
>
|
| 209 |
+
<option value="INTERESTED">Interested</option>
|
| 210 |
+
<option value="MEETING_BOOKED">Meeting Booked</option>
|
| 211 |
+
<option value="REPLIED">Replied</option>
|
| 212 |
+
<option value="NOT_INTERESTED">Not Interested</option>
|
| 213 |
+
</select>
|
| 214 |
+
</div>
|
| 215 |
+
</div>
|
| 216 |
+
|
| 217 |
+
{/* Conversation Messages */}
|
| 218 |
+
<div className="flex-1 overflow-y-auto p-6 space-y-4">
|
| 219 |
+
{/* Outbound Sent Message */}
|
| 220 |
+
<div className="max-w-2xl bg-zinc-900 border border-zinc-800 rounded-xl p-4 text-xs space-y-2">
|
| 221 |
+
<div className="flex items-center justify-between text-zinc-400 pb-2 border-b border-zinc-800">
|
| 222 |
+
<span className="font-medium text-zinc-300">Outbound Step #1 (Sent by Sequence)</span>
|
| 223 |
+
<span className="text-[10px]">Yesterday</span>
|
| 224 |
+
</div>
|
| 225 |
+
<div className="text-zinc-300 leading-relaxed">
|
| 226 |
+
Hi {selectedMessage.from_name?.split(" ")[0] || "there"},<br /><br />
|
| 227 |
+
Wanted to see how your team is managing deliverability and scale this quarter?<br /><br />
|
| 228 |
+
Best regards,<br />
|
| 229 |
+
Alex
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
|
| 233 |
+
{/* Inbound Prospect Reply */}
|
| 234 |
+
<div className="max-w-2xl ml-auto bg-indigo-950/40 border border-indigo-500/30 rounded-xl p-4 text-xs space-y-2">
|
| 235 |
+
<div className="flex items-center justify-between text-indigo-300 pb-2 border-b border-indigo-500/20">
|
| 236 |
+
<span className="font-semibold text-indigo-200">
|
| 237 |
+
{selectedMessage.from_name} (Prospect Reply)
|
| 238 |
+
</span>
|
| 239 |
+
<span className="text-[10px] text-zinc-400">Today</span>
|
| 240 |
+
</div>
|
| 241 |
+
<div
|
| 242 |
+
className="text-zinc-200 leading-relaxed prose prose-invert max-w-none text-xs"
|
| 243 |
+
dangerouslySetInnerHTML={{
|
| 244 |
+
__html: DOMPurify.sanitize(selectedMessage.body || "Thanks for reaching out! Let's schedule 15 minutes."),
|
| 245 |
+
}}
|
| 246 |
+
/>
|
| 247 |
+
</div>
|
| 248 |
+
</div>
|
| 249 |
+
|
| 250 |
+
{/* Reply Composer Bottom Section */}
|
| 251 |
+
<div className="p-4 border-t border-zinc-800 bg-zinc-950 shrink-0 space-y-3">
|
| 252 |
+
<RichTextEditor
|
| 253 |
+
content={replyBody}
|
| 254 |
+
onChange={setReplyBody}
|
| 255 |
+
placeholder="Compose your reply or insert calendar meeting booking link..."
|
| 256 |
+
/>
|
| 257 |
+
|
| 258 |
+
<div className="flex items-center justify-between">
|
| 259 |
+
<div className="flex items-center gap-2">
|
| 260 |
+
<button
|
| 261 |
+
type="button"
|
| 262 |
+
onClick={() => setReplyBody("<p>Hi, how does Tuesday at 2 PM EST work for a quick 15-min call? Here is my calendar: https://cal.com/alex/15min</p>")}
|
| 263 |
+
className="px-2.5 py-1 bg-zinc-900 hover:bg-zinc-800 text-zinc-400 hover:text-zinc-200 border border-zinc-800 rounded-md text-[11px] transition-colors"
|
| 264 |
+
>
|
| 265 |
+
+ Insert Booking Link
|
| 266 |
+
</button>
|
| 267 |
+
<button
|
| 268 |
+
type="button"
|
| 269 |
+
onClick={() => setReplyBody("<p>Thanks for getting back to me! I have attached our case study PDF here.</p>")}
|
| 270 |
+
className="px-2.5 py-1 bg-zinc-900 hover:bg-zinc-800 text-zinc-400 hover:text-zinc-200 border border-zinc-800 rounded-md text-[11px] transition-colors"
|
| 271 |
+
>
|
| 272 |
+
+ Insert Case Study
|
| 273 |
+
</button>
|
| 274 |
+
</div>
|
| 275 |
+
|
| 276 |
+
<button
|
| 277 |
+
type="button"
|
| 278 |
+
onClick={() => {
|
| 279 |
+
if (!replyBody) {
|
| 280 |
+
toast.error("Please write a reply message");
|
| 281 |
+
return;
|
| 282 |
+
}
|
| 283 |
+
sendReplyMutation.mutate({
|
| 284 |
+
messageId: selectedMessage.id,
|
| 285 |
+
body: replyBody,
|
| 286 |
+
});
|
| 287 |
+
}}
|
| 288 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white font-medium text-xs rounded-lg transition-colors flex items-center gap-2 shadow-md"
|
| 289 |
+
>
|
| 290 |
+
<Send className="w-3.5 h-3.5" /> Send Reply
|
| 291 |
+
</button>
|
| 292 |
+
</div>
|
| 293 |
+
</div>
|
| 294 |
+
</div>
|
| 295 |
+
) : (
|
| 296 |
+
<div className="flex-1 flex items-center justify-center text-xs text-zinc-500">
|
| 297 |
+
Select a message thread from the left pane to view conversation.
|
| 298 |
+
</div>
|
| 299 |
+
)}
|
| 300 |
+
</div>
|
| 301 |
+
</div>
|
| 302 |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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Users,
|
| 5 |
+
Search,
|
| 6 |
+
Plus,
|
| 7 |
+
ShieldAlert,
|
| 8 |
+
Trash2,
|
| 9 |
+
Mail,
|
| 10 |
+
Building,
|
| 11 |
+
Globe,
|
| 12 |
+
MapPin,
|
| 13 |
+
Linkedin,
|
| 14 |
+
Phone,
|
| 15 |
+
Filter,
|
| 16 |
+
Clock,
|
| 17 |
+
CheckCircle2,
|
| 18 |
+
Ban,
|
| 19 |
+
ArrowUpRight
|
| 20 |
+
} from "lucide-react";
|
| 21 |
+
import { useState } from "react";
|
| 22 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 23 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 24 |
+
import CsvExportButton from "../../../components/CsvExportButton";
|
| 25 |
+
import ConfirmModal from "../../../components/ConfirmModal";
|
| 26 |
+
import toast from "react-hot-toast";
|
| 27 |
+
|
| 28 |
+
const STATUSES = [
|
| 29 |
+
"ALL",
|
| 30 |
+
"INTERESTED",
|
| 31 |
+
"MEETING_BOOKED",
|
| 32 |
+
"MEETING_DONE",
|
| 33 |
+
"REPLIED",
|
| 34 |
+
"NOT_INTERESTED",
|
| 35 |
+
"UNSUBSCRIBED",
|
| 36 |
+
"BOUNCED",
|
| 37 |
+
"DO_NOT_CONTACT"
|
| 38 |
+
];
|
| 39 |
+
|
| 40 |
+
export default function Leads() {
|
| 41 |
+
const queryClient = useQueryClient();
|
| 42 |
+
const [activeTab, setActiveTab] = useState<"leads" | "blocklist">("leads");
|
| 43 |
+
const [searchQuery, setSearchQuery] = useState("");
|
| 44 |
+
const [selectedStatus, setSelectedStatus] = useState("ALL");
|
| 45 |
+
const [selectedLead, setSelectedLead] = useState<any | null>(null);
|
| 46 |
+
const [isAddLeadOpen, setIsAddLeadOpen] = useState(false);
|
| 47 |
+
const [isAddBlocklistOpen, setIsAddBlocklistOpen] = useState(false);
|
| 48 |
+
const [blocklistType, setBlocklistType] = useState<"email" | "domain">("email");
|
| 49 |
+
|
| 50 |
+
const { data: leads = [], isLoading } = useQuery({
|
| 51 |
+
queryKey: ["leads-search", searchQuery, selectedStatus],
|
| 52 |
+
queryFn: async () => {
|
| 53 |
+
const res = await apiClient.get("/leads/search", {
|
| 54 |
+
params: { q: searchQuery, status: selectedStatus },
|
| 55 |
+
});
|
| 56 |
+
return res.data;
|
| 57 |
+
},
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
const { data: emailBlockList = [], refetch: refetchEmailBlockList } = useQuery({
|
| 61 |
+
queryKey: ["blocklist-emails"],
|
| 62 |
+
queryFn: async () => {
|
| 63 |
+
const res = await apiClient.get("/leads/block-list");
|
| 64 |
+
return res.data;
|
| 65 |
+
},
|
| 66 |
+
});
|
| 67 |
+
|
| 68 |
+
const { data: domainBlockList = [], refetch: refetchDomainBlockList } = useQuery({
|
| 69 |
+
queryKey: ["blocklist-domains"],
|
| 70 |
+
queryFn: async () => {
|
| 71 |
+
const res = await apiClient.get("/leads/domain-block-list");
|
| 72 |
+
return res.data;
|
| 73 |
+
},
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
const updateLeadStatusMutation = useMutation({
|
| 77 |
+
mutationFn: async ({ campaignId, leadId, status }: { campaignId: string; leadId: string; status: string }) => {
|
| 78 |
+
const res = await apiClient.post(`/campaigns/${campaignId}/leads/status`, { lead_id: leadId, status });
|
| 79 |
+
return res.data;
|
| 80 |
+
},
|
| 81 |
+
onSuccess: () => {
|
| 82 |
+
toast.success("Lead status updated");
|
| 83 |
+
queryClient.invalidateQueries({ queryKey: ["leads-search"] });
|
| 84 |
+
},
|
| 85 |
+
});
|
| 86 |
+
|
| 87 |
+
const deleteLeadMutation = useMutation({
|
| 88 |
+
mutationFn: async ({ campaignId, leadId }: { campaignId: string; leadId: string }) => {
|
| 89 |
+
const res = await apiClient.delete(`/campaigns/${campaignId}/leads/${leadId}`);
|
| 90 |
+
return res.data;
|
| 91 |
+
},
|
| 92 |
+
onSuccess: () => {
|
| 93 |
+
toast.success("Lead removed");
|
| 94 |
+
setSelectedLead(null);
|
| 95 |
+
queryClient.invalidateQueries({ queryKey: ["leads-search"] });
|
| 96 |
+
},
|
| 97 |
+
});
|
| 98 |
+
|
| 99 |
+
return (
|
| 100 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 101 |
+
{/* Header */}
|
| 102 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 103 |
+
<div>
|
| 104 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 105 |
+
<Users className="w-6 h-6 text-teal-400" />
|
| 106 |
+
Lead Intelligence Database
|
| 107 |
+
</h1>
|
| 108 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 109 |
+
Global repository of targeted prospects, responses, and suppression blocklists.
|
| 110 |
+
</p>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<div className="flex items-center gap-3">
|
| 114 |
+
<button
|
| 115 |
+
onClick={() => setIsAddLeadOpen(true)}
|
| 116 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-2"
|
| 117 |
+
>
|
| 118 |
+
<Plus className="w-4 h-4" /> Add Prospect
|
| 119 |
+
</button>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
|
| 123 |
+
{/* Main Tabs */}
|
| 124 |
+
<div className="border-b border-zinc-800 flex items-center gap-2 text-sm font-medium">
|
| 125 |
+
<button
|
| 126 |
+
onClick={() => setActiveTab("leads")}
|
| 127 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors ${
|
| 128 |
+
activeTab === "leads"
|
| 129 |
+
? "border-indigo-500 text-indigo-400 bg-indigo-500/5"
|
| 130 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200"
|
| 131 |
+
}`}
|
| 132 |
+
>
|
| 133 |
+
<Users className="w-4 h-4" /> Global Leads ({leads.length})
|
| 134 |
+
</button>
|
| 135 |
+
<button
|
| 136 |
+
onClick={() => setActiveTab("blocklist")}
|
| 137 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors ${
|
| 138 |
+
activeTab === "blocklist"
|
| 139 |
+
? "border-indigo-500 text-indigo-400 bg-indigo-500/5"
|
| 140 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200"
|
| 141 |
+
}`}
|
| 142 |
+
>
|
| 143 |
+
<ShieldAlert className="w-4 h-4" /> Suppression Blocklists
|
| 144 |
+
</button>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
{activeTab === "leads" && (
|
| 148 |
+
<div className="space-y-4">
|
| 149 |
+
{/* Filter Bar */}
|
| 150 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-4 flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 151 |
+
<div className="relative flex-1 max-w-md">
|
| 152 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400" />
|
| 153 |
+
<input
|
| 154 |
+
type="text"
|
| 155 |
+
placeholder="Search by name, email, or company..."
|
| 156 |
+
value={searchQuery}
|
| 157 |
+
onChange={(e) => setSearchQuery(e.target.value)}
|
| 158 |
+
className="w-full bg-black/40 border border-white/5 rounded-lg py-2 pl-9 pr-4 text-xs text-zinc-100 placeholder:text-zinc-500 focus:outline-none focus:border-indigo-500 shadow-[inset_0_1px_1px_rgba(255,255,255,0.02)] transition-all"
|
| 159 |
+
/>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
+
<div className="flex items-center gap-3">
|
| 163 |
+
<select
|
| 164 |
+
value={selectedStatus}
|
| 165 |
+
onChange={(e) => setSelectedStatus(e.target.value)}
|
| 166 |
+
className="bg-black/40 border border-white/5 rounded-lg py-2 px-3 text-xs text-zinc-300 focus:outline-none focus:border-indigo-500 shadow-[inset_0_1px_1px_rgba(255,255,255,0.02)] transition-all"
|
| 167 |
+
>
|
| 168 |
+
{STATUSES.map((st) => (
|
| 169 |
+
<option key={st} value={st} className="bg-zinc-900">
|
| 170 |
+
Status: {st.replace(/_/g, " ")}
|
| 171 |
+
</option>
|
| 172 |
+
))}
|
| 173 |
+
</select>
|
| 174 |
+
<CsvExportButton data={leads} filename="smartlead-global-leads.csv" />
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
|
| 178 |
+
{/* Leads Table */}
|
| 179 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl overflow-hidden shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)]">
|
| 180 |
+
<div className="overflow-x-auto">
|
| 181 |
+
<table className="w-full text-sm text-left">
|
| 182 |
+
<thead className="bg-black/20 border-b border-white/5 text-zinc-400 text-xs uppercase font-sans tracking-wider">
|
| 183 |
+
<tr>
|
| 184 |
+
<th className="px-6 py-3.5 font-semibold">Prospect</th>
|
| 185 |
+
<th className="px-6 py-3.5 font-semibold">Company</th>
|
| 186 |
+
<th className="px-6 py-3.5 font-semibold">Status</th>
|
| 187 |
+
<th className="px-6 py-3.5 font-semibold">Engagement</th>
|
| 188 |
+
<th className="px-6 py-3.5 font-semibold">Location</th>
|
| 189 |
+
<th className="px-6 py-3.5 font-semibold text-right">Actions</th>
|
| 190 |
+
</tr>
|
| 191 |
+
</thead>
|
| 192 |
+
<tbody className="divide-y divide-white/5">
|
| 193 |
+
{leads.map((lead: any) => (
|
| 194 |
+
<tr
|
| 195 |
+
key={lead.id}
|
| 196 |
+
onClick={() => setSelectedLead(lead)}
|
| 197 |
+
className="hover:bg-white/5 transition-colors cursor-pointer"
|
| 198 |
+
>
|
| 199 |
+
<td className="px-6 py-4">
|
| 200 |
+
<div className="font-semibold text-zinc-100 flex items-center gap-2">
|
| 201 |
+
{lead.first_name} {lead.last_name}
|
| 202 |
+
</div>
|
| 203 |
+
<div className="text-xs text-zinc-400 font-mono flex items-center gap-1 mt-0.5">
|
| 204 |
+
<Mail className="w-3 h-3 text-zinc-500" /> {lead.email}
|
| 205 |
+
</div>
|
| 206 |
+
</td>
|
| 207 |
+
<td className="px-6 py-4 text-zinc-300">
|
| 208 |
+
<div className="font-medium text-zinc-200">{lead.company_name}</div>
|
| 209 |
+
{lead.website && (
|
| 210 |
+
<div className="text-[11px] text-zinc-500 font-mono truncate max-w-[150px]">
|
| 211 |
+
{lead.website.replace("https://", "")}
|
| 212 |
+
</div>
|
| 213 |
+
)}
|
| 214 |
+
</td>
|
| 215 |
+
<td className="px-6 py-4">
|
| 216 |
+
<StatusBadge status={lead.status} size="sm" />
|
| 217 |
+
</td>
|
| 218 |
+
<td className="px-6 py-4">
|
| 219 |
+
<div className="text-xs text-zinc-300 font-mono">
|
| 220 |
+
<span className="text-emerald-400 drop-shadow-[0_0_8px_rgba(52,211,153,0.3)]">{lead.open_count || 0}</span> opens •{" "}
|
| 221 |
+
<span className="text-indigo-400 drop-shadow-[0_0_8px_rgba(99,102,241,0.3)]">{lead.click_count || 0}</span> clicks
|
| 222 |
+
</div>
|
| 223 |
+
</td>
|
| 224 |
+
<td className="px-6 py-4 text-xs text-zinc-400 font-sans">
|
| 225 |
+
{lead.location || "United States"}
|
| 226 |
+
</td>
|
| 227 |
+
<td className="px-6 py-4 text-right">
|
| 228 |
+
<button
|
| 229 |
+
onClick={(e) => {
|
| 230 |
+
e.stopPropagation();
|
| 231 |
+
setSelectedLead(lead);
|
| 232 |
+
}}
|
| 233 |
+
className="px-3 py-1.5 bg-white/5 hover:bg-white/10 text-zinc-300 text-xs font-medium rounded-lg border border-white/5 transition-all shadow-[inset_0_1px_1px_rgba(255,255,255,0.05)]"
|
| 234 |
+
>
|
| 235 |
+
View Profile
|
| 236 |
+
</button>
|
| 237 |
+
</td>
|
| 238 |
+
</tr>
|
| 239 |
+
))}
|
| 240 |
+
|
| 241 |
+
{leads.length === 0 && !isLoading && (
|
| 242 |
+
<tr>
|
| 243 |
+
<td colSpan={6} className="py-16 text-center text-xs text-zinc-500">
|
| 244 |
+
No prospect leads matching current filters.
|
| 245 |
+
</td>
|
| 246 |
+
</tr>
|
| 247 |
+
)}
|
| 248 |
+
</tbody>
|
| 249 |
+
</table>
|
| 250 |
+
</div>
|
| 251 |
+
</div>
|
| 252 |
+
</div>
|
| 253 |
+
)}
|
| 254 |
+
|
| 255 |
+
{/* SUB-TAB: BLOCKLIST MANAGER */}
|
| 256 |
+
{activeTab === "blocklist" && (
|
| 257 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 258 |
+
{/* Email Blocklist */}
|
| 259 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)] space-y-4">
|
| 260 |
+
<div className="flex items-center justify-between">
|
| 261 |
+
<div>
|
| 262 |
+
<h3 className="text-sm font-semibold text-zinc-100 flex items-center gap-2">
|
| 263 |
+
<Mail className="w-4 h-4 text-rose-400 drop-shadow-[0_0_8px_rgba(244,63,94,0.5)]" />
|
| 264 |
+
Email Address Blocklist
|
| 265 |
+
</h3>
|
| 266 |
+
<p className="text-xs text-zinc-400 mt-0.5">Suppressed emails never receive outreach.</p>
|
| 267 |
+
</div>
|
| 268 |
+
<button
|
| 269 |
+
onClick={() => {
|
| 270 |
+
setBlocklistType("email");
|
| 271 |
+
setIsAddBlocklistOpen(true);
|
| 272 |
+
}}
|
| 273 |
+
className="px-2.5 py-1.5 bg-white/5 hover:bg-white/10 text-zinc-200 text-xs font-medium rounded-md border border-white/5 transition-all shadow-[inset_0_1px_1px_rgba(255,255,255,0.05)]"
|
| 274 |
+
>
|
| 275 |
+
+ Add Email
|
| 276 |
+
</button>
|
| 277 |
+
</div>
|
| 278 |
+
|
| 279 |
+
<div className="space-y-2">
|
| 280 |
+
{emailBlockList.map((item: any) => (
|
| 281 |
+
<div
|
| 282 |
+
key={item.id}
|
| 283 |
+
className="flex items-center justify-between p-3 bg-black/40 border border-white/5 rounded-lg text-xs hover:bg-white/5 transition-colors"
|
| 284 |
+
>
|
| 285 |
+
<div>
|
| 286 |
+
<span className="font-mono text-zinc-200 font-medium">{item.email}</span>
|
| 287 |
+
<div className="text-[10px] text-zinc-500 font-sans mt-0.5">{item.reason}</div>
|
| 288 |
+
</div>
|
| 289 |
+
<button
|
| 290 |
+
onClick={async () => {
|
| 291 |
+
await apiClient.delete(`/leads/block-list/${item.id}`);
|
| 292 |
+
toast.success("Removed from blocklist");
|
| 293 |
+
refetchEmailBlockList();
|
| 294 |
+
}}
|
| 295 |
+
className="text-zinc-500 hover:text-rose-400 p-1.5 rounded-md hover:bg-rose-500/10 transition-colors"
|
| 296 |
+
>
|
| 297 |
+
<Trash2 className="w-3.5 h-3.5" />
|
| 298 |
+
</button>
|
| 299 |
+
</div>
|
| 300 |
+
))}
|
| 301 |
+
</div>
|
| 302 |
+
</div>
|
| 303 |
+
|
| 304 |
+
{/* Domain Blocklist */}
|
| 305 |
+
<div className="bg-white/5 border border-white/10 backdrop-blur-md rounded-xl p-5 shadow-[0_8px_32px_-8px_rgba(0,0,0,0.5)] space-y-4">
|
| 306 |
+
<div className="flex items-center justify-between">
|
| 307 |
+
<div>
|
| 308 |
+
<h3 className="text-sm font-semibold text-zinc-100 flex items-center gap-2">
|
| 309 |
+
<Globe className="w-4 h-4 text-amber-400 drop-shadow-[0_0_8px_rgba(251,191,36,0.5)]" />
|
| 310 |
+
Domain Suppression List
|
| 311 |
+
</h3>
|
| 312 |
+
<p className="text-xs text-zinc-400 mt-0.5">Blocks all emails under specified root domains.</p>
|
| 313 |
+
</div>
|
| 314 |
+
<button
|
| 315 |
+
onClick={() => {
|
| 316 |
+
setBlocklistType("domain");
|
| 317 |
+
setIsAddBlocklistOpen(true);
|
| 318 |
+
}}
|
| 319 |
+
className="px-2.5 py-1.5 bg-white/5 hover:bg-white/10 text-zinc-200 text-xs font-medium rounded-md border border-white/5 transition-all shadow-[inset_0_1px_1px_rgba(255,255,255,0.05)]"
|
| 320 |
+
>
|
| 321 |
+
+ Add Domain
|
| 322 |
+
</button>
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
+
<div className="space-y-2">
|
| 326 |
+
{domainBlockList.map((item: any) => (
|
| 327 |
+
<div
|
| 328 |
+
key={item.id}
|
| 329 |
+
className="flex items-center justify-between p-3 bg-black/40 border border-white/5 rounded-lg text-xs hover:bg-white/5 transition-colors"
|
| 330 |
+
>
|
| 331 |
+
<div>
|
| 332 |
+
<span className="font-mono text-zinc-200 font-medium">@{item.domain}</span>
|
| 333 |
+
<div className="text-[10px] text-zinc-500 font-sans mt-0.5">{item.reason}</div>
|
| 334 |
+
</div>
|
| 335 |
+
<button
|
| 336 |
+
onClick={async () => {
|
| 337 |
+
await apiClient.delete(`/leads/domain-block-list/${item.id}`);
|
| 338 |
+
toast.success("Domain removed from blocklist");
|
| 339 |
+
refetchDomainBlockList();
|
| 340 |
+
}}
|
| 341 |
+
className="text-zinc-500 hover:text-rose-400 p-1.5 rounded-md hover:bg-rose-500/10 transition-colors"
|
| 342 |
+
>
|
| 343 |
+
<Trash2 className="w-3.5 h-3.5" />
|
| 344 |
+
</button>
|
| 345 |
+
</div>
|
| 346 |
+
))}
|
| 347 |
+
</div>
|
| 348 |
+
</div>
|
| 349 |
+
</div>
|
| 350 |
+
)}
|
| 351 |
+
|
| 352 |
+
{/* Lead Detail Slide-Over Drawer */}
|
| 353 |
+
<FormDrawer
|
| 354 |
+
isOpen={Boolean(selectedLead)}
|
| 355 |
+
onClose={() => setSelectedLead(null)}
|
| 356 |
+
title="Prospect Dossier"
|
| 357 |
+
subtitle={selectedLead ? `${selectedLead.first_name} ${selectedLead.last_name} (${selectedLead.email})` : ""}
|
| 358 |
+
>
|
| 359 |
+
{selectedLead && (
|
| 360 |
+
<div className="space-y-6 text-xs">
|
| 361 |
+
{/* Status Change Card */}
|
| 362 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 363 |
+
<label className="block font-medium text-zinc-400 mb-2">Lead Outreach Status</label>
|
| 364 |
+
<select
|
| 365 |
+
value={selectedLead.status}
|
| 366 |
+
onChange={(e) => {
|
| 367 |
+
updateLeadStatusMutation.mutate({
|
| 368 |
+
campaignId: selectedLead.campaign_id,
|
| 369 |
+
leadId: selectedLead.id,
|
| 370 |
+
status: e.target.value,
|
| 371 |
+
});
|
| 372 |
+
setSelectedLead({ ...selectedLead, status: e.target.value });
|
| 373 |
+
}}
|
| 374 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2 text-zinc-100 font-medium"
|
| 375 |
+
>
|
| 376 |
+
{STATUSES.filter((s) => s !== "ALL").map((st) => (
|
| 377 |
+
<option key={st} value={st}>
|
| 378 |
+
{st.replace(/_/g, " ")}
|
| 379 |
+
</option>
|
| 380 |
+
))}
|
| 381 |
+
</select>
|
| 382 |
+
</div>
|
| 383 |
+
|
| 384 |
+
{/* Profile Fields */}
|
| 385 |
+
<div className="space-y-3 bg-zinc-900/60 border border-zinc-800 rounded-xl p-4">
|
| 386 |
+
<h4 className="font-semibold text-zinc-300 uppercase tracking-wider text-[10px]">Contact Info</h4>
|
| 387 |
+
<div className="grid grid-cols-2 gap-3">
|
| 388 |
+
<div>
|
| 389 |
+
<span className="text-zinc-500 block">Company</span>
|
| 390 |
+
<span className="text-zinc-200 font-medium">{selectedLead.company_name}</span>
|
| 391 |
+
</div>
|
| 392 |
+
<div>
|
| 393 |
+
<span className="text-zinc-500 block">Location</span>
|
| 394 |
+
<span className="text-zinc-200 font-medium">{selectedLead.location || "N/A"}</span>
|
| 395 |
+
</div>
|
| 396 |
+
<div>
|
| 397 |
+
<span className="text-zinc-500 block">Phone</span>
|
| 398 |
+
<span className="text-zinc-200 font-medium">{selectedLead.phone_number || "N/A"}</span>
|
| 399 |
+
</div>
|
| 400 |
+
<div>
|
| 401 |
+
<span className="text-zinc-500 block">LinkedIn</span>
|
| 402 |
+
<a
|
| 403 |
+
href={selectedLead.linkedin_profile || "#"}
|
| 404 |
+
target="_blank"
|
| 405 |
+
rel="noreferrer"
|
| 406 |
+
className="text-indigo-400 hover:underline"
|
| 407 |
+
>
|
| 408 |
+
View LinkedIn Profile
|
| 409 |
+
</a>
|
| 410 |
+
</div>
|
| 411 |
+
</div>
|
| 412 |
+
</div>
|
| 413 |
+
|
| 414 |
+
{/* Custom Fields */}
|
| 415 |
+
{selectedLead.custom_fields && Object.keys(selectedLead.custom_fields).length > 0 && (
|
| 416 |
+
<div className="space-y-2 bg-zinc-900/60 border border-zinc-800 rounded-xl p-4">
|
| 417 |
+
<h4 className="font-semibold text-zinc-300 uppercase tracking-wider text-[10px]">Custom Attributes</h4>
|
| 418 |
+
<div className="grid grid-cols-2 gap-2 font-mono text-[11px]">
|
| 419 |
+
{Object.entries(selectedLead.custom_fields).map(([key, val]) => (
|
| 420 |
+
<div key={key} className="bg-zinc-950 p-2 rounded border border-zinc-800">
|
| 421 |
+
<span className="text-zinc-500 block text-[10px]">{key}</span>
|
| 422 |
+
<span className="text-zinc-200 font-semibold">{String(val)}</span>
|
| 423 |
+
</div>
|
| 424 |
+
))}
|
| 425 |
+
</div>
|
| 426 |
+
</div>
|
| 427 |
+
)}
|
| 428 |
+
|
| 429 |
+
{/* Timeline */}
|
| 430 |
+
<div className="space-y-3 bg-zinc-900/60 border border-zinc-800 rounded-xl p-4">
|
| 431 |
+
<h4 className="font-semibold text-zinc-300 uppercase tracking-wider text-[10px]">Activity Timeline</h4>
|
| 432 |
+
<div className="space-y-3">
|
| 433 |
+
<div className="flex items-start gap-2.5">
|
| 434 |
+
<div className="w-2 h-2 rounded-full bg-emerald-400 mt-1" />
|
| 435 |
+
<div>
|
| 436 |
+
<span className="text-zinc-300 font-medium">Email Delivered & Opened</span>
|
| 437 |
+
<div className="text-[10px] text-zinc-500">2 hours ago</div>
|
| 438 |
+
</div>
|
| 439 |
+
</div>
|
| 440 |
+
<div className="flex items-start gap-2.5">
|
| 441 |
+
<div className="w-2 h-2 rounded-full bg-indigo-400 mt-1" />
|
| 442 |
+
<div>
|
| 443 |
+
<span className="text-zinc-300 font-medium">Enrolled in Enterprise SaaS Sequence</span>
|
| 444 |
+
<div className="text-[10px] text-zinc-500">3 days ago</div>
|
| 445 |
+
</div>
|
| 446 |
+
</div>
|
| 447 |
+
</div>
|
| 448 |
+
</div>
|
| 449 |
+
|
| 450 |
+
{/* Delete Lead Button */}
|
| 451 |
+
<div className="pt-2 flex justify-end">
|
| 452 |
+
<button
|
| 453 |
+
onClick={() => {
|
| 454 |
+
deleteLeadMutation.mutate({
|
| 455 |
+
campaignId: selectedLead.campaign_id,
|
| 456 |
+
leadId: selectedLead.id,
|
| 457 |
+
});
|
| 458 |
+
}}
|
| 459 |
+
className="px-3 py-1.5 bg-rose-600/20 hover:bg-rose-600 text-rose-300 hover:text-white rounded-lg text-xs font-medium transition-colors flex items-center gap-1.5"
|
| 460 |
+
>
|
| 461 |
+
<Trash2 className="w-3.5 h-3.5" /> Remove Lead
|
| 462 |
+
</button>
|
| 463 |
+
</div>
|
| 464 |
+
</div>
|
| 465 |
+
)}
|
| 466 |
+
</FormDrawer>
|
| 467 |
+
|
| 468 |
+
{/* Add Lead Slide-Over */}
|
| 469 |
+
<FormDrawer
|
| 470 |
+
isOpen={isAddLeadOpen}
|
| 471 |
+
onClose={() => setIsAddLeadOpen(false)}
|
| 472 |
+
title="Add Global Prospect Lead"
|
| 473 |
+
subtitle="Input contact info, company details, and custom variables for personalization."
|
| 474 |
+
>
|
| 475 |
+
<form
|
| 476 |
+
onSubmit={async (e) => {
|
| 477 |
+
e.preventDefault();
|
| 478 |
+
const form = e.target as HTMLFormElement;
|
| 479 |
+
const newLead = {
|
| 480 |
+
first_name: (form.elements.namedItem("first_name") as HTMLInputElement).value,
|
| 481 |
+
last_name: (form.elements.namedItem("last_name") as HTMLInputElement).value,
|
| 482 |
+
email: (form.elements.namedItem("email") as HTMLInputElement).value,
|
| 483 |
+
phone_number: (form.elements.namedItem("phone_number") as HTMLInputElement).value,
|
| 484 |
+
company_name: (form.elements.namedItem("company_name") as HTMLInputElement).value,
|
| 485 |
+
website: (form.elements.namedItem("website") as HTMLInputElement).value,
|
| 486 |
+
location: (form.elements.namedItem("location") as HTMLInputElement).value,
|
| 487 |
+
linkedin_profile: (form.elements.namedItem("linkedin_profile") as HTMLInputElement).value,
|
| 488 |
+
status: "INTERESTED",
|
| 489 |
+
};
|
| 490 |
+
|
| 491 |
+
try {
|
| 492 |
+
await apiClient.post("/campaigns/camp_9901/leads", newLead);
|
| 493 |
+
toast.success("Prospect added to database!");
|
| 494 |
+
setIsAddLeadOpen(false);
|
| 495 |
+
queryClient.invalidateQueries({ queryKey: ["leads-search"] });
|
| 496 |
+
} catch (err: any) {
|
| 497 |
+
toast.error("Failed to add prospect");
|
| 498 |
+
}
|
| 499 |
+
}}
|
| 500 |
+
className="space-y-3.5 text-xs"
|
| 501 |
+
>
|
| 502 |
+
<div className="grid grid-cols-2 gap-3">
|
| 503 |
+
<div>
|
| 504 |
+
<label className="block font-medium text-zinc-300 mb-1">First Name *</label>
|
| 505 |
+
<input name="first_name" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 506 |
+
</div>
|
| 507 |
+
<div>
|
| 508 |
+
<label className="block font-medium text-zinc-300 mb-1">Last Name</label>
|
| 509 |
+
<input name="last_name" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 510 |
+
</div>
|
| 511 |
+
</div>
|
| 512 |
+
<div>
|
| 513 |
+
<label className="block font-medium text-zinc-300 mb-1">Email Address *</label>
|
| 514 |
+
<input type="email" name="email" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 515 |
+
</div>
|
| 516 |
+
<div className="grid grid-cols-2 gap-3">
|
| 517 |
+
<div>
|
| 518 |
+
<label className="block font-medium text-zinc-300 mb-1">Company Name</label>
|
| 519 |
+
<input name="company_name" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 520 |
+
</div>
|
| 521 |
+
<div>
|
| 522 |
+
<label className="block font-medium text-zinc-300 mb-1">Phone Number</label>
|
| 523 |
+
<input name="phone_number" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 524 |
+
</div>
|
| 525 |
+
</div>
|
| 526 |
+
<div>
|
| 527 |
+
<label className="block font-medium text-zinc-300 mb-1">Website URL</label>
|
| 528 |
+
<input name="website" placeholder="https://" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 529 |
+
</div>
|
| 530 |
+
<div className="grid grid-cols-2 gap-3">
|
| 531 |
+
<div>
|
| 532 |
+
<label className="block font-medium text-zinc-300 mb-1">Location</label>
|
| 533 |
+
<input name="location" placeholder="e.g. San Francisco, CA" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 534 |
+
</div>
|
| 535 |
+
<div>
|
| 536 |
+
<label className="block font-medium text-zinc-300 mb-1">LinkedIn URL</label>
|
| 537 |
+
<input name="linkedin_profile" placeholder="https://linkedin.com/in/..." className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2 text-zinc-100" />
|
| 538 |
+
</div>
|
| 539 |
+
</div>
|
| 540 |
+
|
| 541 |
+
<div className="pt-4 flex justify-end gap-2">
|
| 542 |
+
<button
|
| 543 |
+
type="button"
|
| 544 |
+
onClick={() => setIsAddLeadOpen(false)}
|
| 545 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 546 |
+
>
|
| 547 |
+
Cancel
|
| 548 |
+
</button>
|
| 549 |
+
<button
|
| 550 |
+
type="submit"
|
| 551 |
+
className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium shadow"
|
| 552 |
+
>
|
| 553 |
+
Save Prospect
|
| 554 |
+
</button>
|
| 555 |
+
</div>
|
| 556 |
+
</form>
|
| 557 |
+
</FormDrawer>
|
| 558 |
+
|
| 559 |
+
{/* Add Blocklist Modal */}
|
| 560 |
+
<FormDrawer
|
| 561 |
+
isOpen={isAddBlocklistOpen}
|
| 562 |
+
onClose={() => setIsAddBlocklistOpen(false)}
|
| 563 |
+
title={blocklistType === "email" ? "Add Email to Suppression Blocklist" : "Add Domain to Suppression Blocklist"}
|
| 564 |
+
subtitle="Blocked records will never receive any emails from any campaign."
|
| 565 |
+
>
|
| 566 |
+
<form
|
| 567 |
+
onSubmit={async (e) => {
|
| 568 |
+
e.preventDefault();
|
| 569 |
+
const form = e.target as HTMLFormElement;
|
| 570 |
+
const val = (form.elements.namedItem("val") as HTMLInputElement).value;
|
| 571 |
+
const reason = (form.elements.namedItem("reason") as HTMLInputElement).value;
|
| 572 |
+
|
| 573 |
+
try {
|
| 574 |
+
if (blocklistType === "email") {
|
| 575 |
+
await apiClient.post("/leads/block-list", { email: val, reason });
|
| 576 |
+
refetchEmailBlockList();
|
| 577 |
+
} else {
|
| 578 |
+
await apiClient.post("/leads/domain-block-list", { domain: val, reason });
|
| 579 |
+
refetchDomainBlockList();
|
| 580 |
+
}
|
| 581 |
+
toast.success("Suppression entry saved");
|
| 582 |
+
setIsAddBlocklistOpen(false);
|
| 583 |
+
} catch (err: any) {
|
| 584 |
+
toast.error("Failed to add entry");
|
| 585 |
+
}
|
| 586 |
+
}}
|
| 587 |
+
className="space-y-4 text-xs"
|
| 588 |
+
>
|
| 589 |
+
<div>
|
| 590 |
+
<label className="block font-medium text-zinc-300 mb-1">
|
| 591 |
+
{blocklistType === "email" ? "Email Address" : "Domain (e.g. competitor.com)"}
|
| 592 |
+
</label>
|
| 593 |
+
<input name="val" required className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 594 |
+
</div>
|
| 595 |
+
<div>
|
| 596 |
+
<label className="block font-medium text-zinc-300 mb-1">Reason for Suppression</label>
|
| 597 |
+
<input name="reason" placeholder="e.g. Legal opt-out, Competitor" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 598 |
+
</div>
|
| 599 |
+
<div className="pt-4 flex justify-end gap-2">
|
| 600 |
+
<button
|
| 601 |
+
type="button"
|
| 602 |
+
onClick={() => setIsAddBlocklistOpen(false)}
|
| 603 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 604 |
+
>
|
| 605 |
+
Cancel
|
| 606 |
+
</button>
|
| 607 |
+
<button
|
| 608 |
+
type="submit"
|
| 609 |
+
className="px-4 py-2 bg-rose-600 text-white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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {
|
| 2 |
+
KeyRound,
|
| 3 |
+
Plus,
|
| 4 |
+
Trash2,
|
| 5 |
+
Copy,
|
| 6 |
+
CheckCircle2,
|
| 7 |
+
AlertCircle,
|
| 8 |
+
ShieldCheck,
|
| 9 |
+
Sparkles,
|
| 10 |
+
Globe,
|
| 11 |
+
Clock,
|
| 12 |
+
Sliders,
|
| 13 |
+
Terminal,
|
| 14 |
+
Activity,
|
| 15 |
+
Database
|
| 16 |
+
} from "lucide-react";
|
| 17 |
+
import { useState, useEffect } from "react";
|
| 18 |
+
import { useApiKey } from "../../../context/ApiKeyContext";
|
| 19 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 20 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 21 |
+
import ConfirmModal from "../../../components/ConfirmModal";
|
| 22 |
+
import toast from "react-hot-toast";
|
| 23 |
+
import { supabase, isSupabaseConfigured } from "../../../lib/supabaseClient";
|
| 24 |
+
|
| 25 |
+
export default function Settings() {
|
| 26 |
+
const { apiKeys, activeKeyId, setActiveKeyId, addApiKey, removeApiKey, renameApiKey } = useApiKey();
|
| 27 |
+
const [activeTab, setActiveTab] = useState<"keys" | "preferences" | "sandbox" | "database">("keys");
|
| 28 |
+
const [isAddKeyOpen, setIsAddKeyOpen] = useState(false);
|
| 29 |
+
const [keyToDelete, setKeyToDelete] = useState<string | null>(null);
|
| 30 |
+
const [testResult, setTestResult] = useState<{ status: "idle" | "testing" | "success" | "error"; message?: string; latency?: number }>({ status: "idle" });
|
| 31 |
+
const [supabaseStatus, setSupabaseStatus] = useState<"testing" | "connected" | "error" | "unconfigured">("testing");
|
| 32 |
+
|
| 33 |
+
useEffect(() => {
|
| 34 |
+
async function checkSupabase() {
|
| 35 |
+
if (!isSupabaseConfigured() || !supabase) {
|
| 36 |
+
setSupabaseStatus("unconfigured");
|
| 37 |
+
return;
|
| 38 |
+
}
|
| 39 |
+
try {
|
| 40 |
+
// Simple ping to check if credentials are valid
|
| 41 |
+
// Using auth.getSession() as a lightweight check
|
| 42 |
+
const { error } = await supabase.auth.getSession();
|
| 43 |
+
if (error) throw error;
|
| 44 |
+
setSupabaseStatus("connected");
|
| 45 |
+
} catch (err) {
|
| 46 |
+
console.error("Supabase connection error:", err);
|
| 47 |
+
setSupabaseStatus("error");
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if (activeTab === "database") {
|
| 52 |
+
checkSupabase();
|
| 53 |
+
}
|
| 54 |
+
}, [activeTab]);
|
| 55 |
+
|
| 56 |
+
const testActiveConnection = async () => {
|
| 57 |
+
setTestResult({ status: "testing" });
|
| 58 |
+
const startTime = Date.now();
|
| 59 |
+
|
| 60 |
+
try {
|
| 61 |
+
const res = await apiClient.get("/campaigns");
|
| 62 |
+
const latency = Date.now() - startTime;
|
| 63 |
+
setTestResult({
|
| 64 |
+
status: "success",
|
| 65 |
+
message: `Connected successfully. Response latency: ${latency}ms. Found ${res.data?.length || 0} campaigns.`,
|
| 66 |
+
latency,
|
| 67 |
+
});
|
| 68 |
+
toast.success("API Key verified successfully!");
|
| 69 |
+
} catch (err: any) {
|
| 70 |
+
setTestResult({
|
| 71 |
+
status: "error",
|
| 72 |
+
message: err.response?.data?.error || "Failed to reach BRIDGE ModulS API gateway",
|
| 73 |
+
});
|
| 74 |
+
toast.error("API connection test failed");
|
| 75 |
+
}
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
return (
|
| 79 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 80 |
+
{/* Header */}
|
| 81 |
+
<div>
|
| 82 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 83 |
+
<KeyRound className="w-6 h-6 text-indigo-400" />
|
| 84 |
+
Settings & API Credentials
|
| 85 |
+
</h1>
|
| 86 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 87 |
+
Manage BRIDGE ModulS API keys, system preferences, and test live gateway endpoints.
|
| 88 |
+
</p>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
{/* Tabs */}
|
| 92 |
+
<div className="border-b border-zinc-800 flex items-center gap-2 text-sm font-medium">
|
| 93 |
+
<button
|
| 94 |
+
onClick={() => setActiveTab("keys")}
|
| 95 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors ${
|
| 96 |
+
activeTab === "keys"
|
| 97 |
+
? "border-indigo-500 text-indigo-400 bg-indigo-500/5"
|
| 98 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200"
|
| 99 |
+
}`}
|
| 100 |
+
>
|
| 101 |
+
<KeyRound className="w-4 h-4" /> API Key Manager ({apiKeys.length})
|
| 102 |
+
</button>
|
| 103 |
+
<button
|
| 104 |
+
onClick={() => setActiveTab("preferences")}
|
| 105 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors ${
|
| 106 |
+
activeTab === "preferences"
|
| 107 |
+
? "border-indigo-500 text-indigo-400 bg-indigo-500/5"
|
| 108 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200"
|
| 109 |
+
}`}
|
| 110 |
+
>
|
| 111 |
+
<Sliders className="w-4 h-4" /> System Preferences
|
| 112 |
+
</button>
|
| 113 |
+
<button
|
| 114 |
+
onClick={() => setActiveTab("sandbox")}
|
| 115 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors ${
|
| 116 |
+
activeTab === "sandbox"
|
| 117 |
+
? "border-indigo-500 text-indigo-400 bg-indigo-500/5"
|
| 118 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200"
|
| 119 |
+
}`}
|
| 120 |
+
>
|
| 121 |
+
<Terminal className="w-4 h-4" /> API Sandbox & Architecture
|
| 122 |
+
</button>
|
| 123 |
+
<button
|
| 124 |
+
onClick={() => setActiveTab("database")}
|
| 125 |
+
className={`px-4 py-2.5 border-b-2 font-medium text-xs flex items-center gap-2 transition-colors ${
|
| 126 |
+
activeTab === "database"
|
| 127 |
+
? "border-emerald-500 text-emerald-400 bg-emerald-500/5"
|
| 128 |
+
: "border-transparent text-zinc-400 hover:text-zinc-200"
|
| 129 |
+
}`}
|
| 130 |
+
>
|
| 131 |
+
<Database className="w-4 h-4" /> Supabase Connection
|
| 132 |
+
</button>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
{/* TAB 1: API KEYS */}
|
| 136 |
+
{activeTab === "keys" && (
|
| 137 |
+
<div className="space-y-6 max-w-4xl">
|
| 138 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-5 shadow-sm space-y-4">
|
| 139 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
|
| 140 |
+
<div>
|
| 141 |
+
<h3 className="text-base font-semibold text-zinc-100">Configured BRIDGE ModulS API Keys</h3>
|
| 142 |
+
<p className="text-xs text-zinc-400 mt-0.5">
|
| 143 |
+
Store multiple keys for distinct environments or client workspaces.
|
| 144 |
+
</p>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<div className="flex items-center gap-2">
|
| 148 |
+
<button
|
| 149 |
+
onClick={testActiveConnection}
|
| 150 |
+
disabled={testResult.status === "testing"}
|
| 151 |
+
className="px-3 py-1.5 bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5 border border-zinc-700"
|
| 152 |
+
>
|
| 153 |
+
<Activity className="w-3.5 h-3.5 text-emerald-400" />
|
| 154 |
+
{testResult.status === "testing" ? "Testing..." : "Test Connection"}
|
| 155 |
+
</button>
|
| 156 |
+
<button
|
| 157 |
+
onClick={() => setIsAddKeyOpen(true)}
|
| 158 |
+
className="px-3.5 py-1.5 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5"
|
| 159 |
+
>
|
| 160 |
+
<Plus className="w-3.5 h-3.5" /> Add API Key
|
| 161 |
+
</button>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
{/* Test Connection Banner */}
|
| 166 |
+
{testResult.status === "success" && (
|
| 167 |
+
<div className="p-3 bg-emerald-500/10 border border-emerald-500/20 rounded-lg flex items-center gap-2.5 text-xs text-emerald-400">
|
| 168 |
+
<CheckCircle2 className="w-4 h-4 shrink-0" />
|
| 169 |
+
<span>{testResult.message}</span>
|
| 170 |
+
</div>
|
| 171 |
+
)}
|
| 172 |
+
{testResult.status === "error" && (
|
| 173 |
+
<div className="p-3 bg-rose-500/10 border border-rose-500/20 rounded-lg flex items-center gap-2.5 text-xs text-rose-400">
|
| 174 |
+
<AlertCircle className="w-4 h-4 shrink-0" />
|
| 175 |
+
<span>{testResult.message}</span>
|
| 176 |
+
</div>
|
| 177 |
+
)}
|
| 178 |
+
|
| 179 |
+
{/* Keys List */}
|
| 180 |
+
<div className="space-y-3 pt-2">
|
| 181 |
+
{apiKeys.map((k) => {
|
| 182 |
+
const isActive = k.id === activeKeyId;
|
| 183 |
+
const maskedKey = k.key.length > 8
|
| 184 |
+
? `${k.key.substring(0, 4)}••••••••••••••••${k.key.substring(k.key.length - 4)}`
|
| 185 |
+
: "••••••••••••";
|
| 186 |
+
|
| 187 |
+
return (
|
| 188 |
+
<div
|
| 189 |
+
key={k.id}
|
| 190 |
+
className={`p-4 rounded-xl border transition-all flex flex-col sm:flex-row sm:items-center justify-between gap-4 ${
|
| 191 |
+
isActive
|
| 192 |
+
? "bg-indigo-950/20 border-indigo-500/40 shadow-sm"
|
| 193 |
+
: "bg-zinc-950/60 border-zinc-800/80 hover:border-zinc-700"
|
| 194 |
+
}`}
|
| 195 |
+
>
|
| 196 |
+
<div>
|
| 197 |
+
<div className="flex items-center gap-2">
|
| 198 |
+
<span className="font-semibold text-xs text-zinc-100">{k.name}</span>
|
| 199 |
+
{isActive && (
|
| 200 |
+
<span className="text-[10px] font-bold uppercase tracking-wider bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 px-2 py-0.5 rounded-full">
|
| 201 |
+
Active Key
|
| 202 |
+
</span>
|
| 203 |
+
)}
|
| 204 |
+
</div>
|
| 205 |
+
<div className="font-mono text-xs text-zinc-400 mt-1 flex items-center gap-2">
|
| 206 |
+
<span>{maskedKey}</span>
|
| 207 |
+
<button
|
| 208 |
+
onClick={() => {
|
| 209 |
+
navigator.clipboard.writeText(k.key);
|
| 210 |
+
toast.success("API key copied to clipboard");
|
| 211 |
+
}}
|
| 212 |
+
className="text-zinc-500 hover:text-zinc-300 p-1"
|
| 213 |
+
>
|
| 214 |
+
<Copy className="w-3.5 h-3.5" />
|
| 215 |
+
</button>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
|
| 219 |
+
<div className="flex items-center gap-2">
|
| 220 |
+
{!isActive && (
|
| 221 |
+
<button
|
| 222 |
+
onClick={() => {
|
| 223 |
+
setActiveKeyId(k.id);
|
| 224 |
+
toast.success(`Switched active key to "${k.name}"`);
|
| 225 |
+
}}
|
| 226 |
+
className="px-3 py-1 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-xs font-medium rounded-md transition-colors"
|
| 227 |
+
>
|
| 228 |
+
Set as Active
|
| 229 |
+
</button>
|
| 230 |
+
)}
|
| 231 |
+
<button
|
| 232 |
+
onClick={() => setKeyToDelete(k.id)}
|
| 233 |
+
className="p-1.5 text-zinc-500 hover:text-rose-400 hover:bg-rose-500/10 rounded-md transition-colors"
|
| 234 |
+
>
|
| 235 |
+
<Trash2 className="w-4 h-4" />
|
| 236 |
+
</button>
|
| 237 |
+
</div>
|
| 238 |
+
</div>
|
| 239 |
+
);
|
| 240 |
+
})}
|
| 241 |
+
|
| 242 |
+
{apiKeys.length === 0 && (
|
| 243 |
+
<div className="p-8 text-center text-xs text-zinc-500 bg-zinc-950/40 rounded-xl border border-dashed border-zinc-800">
|
| 244 |
+
No custom API keys saved. The app is currently operating in high-fidelity mock database mode.
|
| 245 |
+
</div>
|
| 246 |
+
)}
|
| 247 |
+
</div>
|
| 248 |
+
</div>
|
| 249 |
+
</div>
|
| 250 |
+
)}
|
| 251 |
+
|
| 252 |
+
{/* TAB 2: PREFERENCES */}
|
| 253 |
+
{activeTab === "preferences" && (
|
| 254 |
+
<div className="space-y-6 max-w-2xl bg-zinc-900 border border-zinc-800 rounded-xl p-6">
|
| 255 |
+
<h3 className="text-base font-semibold text-zinc-100 mb-4">Workspace Outreach Defaults</h3>
|
| 256 |
+
<div className="space-y-4 text-xs">
|
| 257 |
+
<div>
|
| 258 |
+
<label className="block font-medium text-zinc-300 mb-1">Default Sending Timezone</label>
|
| 259 |
+
<select
|
| 260 |
+
defaultValue="America/New_York"
|
| 261 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2.5 text-zinc-100"
|
| 262 |
+
>
|
| 263 |
+
<option value="America/New_York">America/New_York (EST)</option>
|
| 264 |
+
<option value="America/Chicago">America/Chicago (CST)</option>
|
| 265 |
+
<option value="America/Los_Angeles">America/Los_Angeles (PST)</option>
|
| 266 |
+
<option value="Europe/London">Europe/London (GMT)</option>
|
| 267 |
+
</select>
|
| 268 |
+
</div>
|
| 269 |
+
|
| 270 |
+
<div>
|
| 271 |
+
<label className="block font-medium text-zinc-300 mb-1">Global Mailbox Rate Limiting</label>
|
| 272 |
+
<input
|
| 273 |
+
type="number"
|
| 274 |
+
defaultValue="50"
|
| 275 |
+
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg p-2.5 text-zinc-100"
|
| 276 |
+
/>
|
| 277 |
+
<span className="text-[11px] text-zinc-500 mt-1 block">Maximum outbound emails per mailbox / 24 hours</span>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<div className="pt-4 flex justify-end">
|
| 281 |
+
<button
|
| 282 |
+
type="button"
|
| 283 |
+
onClick={() => toast.success("Preferences updated")}
|
| 284 |
+
className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium"
|
| 285 |
+
>
|
| 286 |
+
Save Preferences
|
| 287 |
+
</button>
|
| 288 |
+
</div>
|
| 289 |
+
</div>
|
| 290 |
+
</div>
|
| 291 |
+
)}
|
| 292 |
+
|
| 293 |
+
{/* TAB 3: SANDBOX */}
|
| 294 |
+
{activeTab === "sandbox" && (
|
| 295 |
+
<div className="space-y-4 max-w-4xl bg-zinc-900 border border-zinc-800 rounded-xl p-6">
|
| 296 |
+
<h3 className="text-base font-semibold text-zinc-100 flex items-center gap-2">
|
| 297 |
+
<Terminal className="w-5 h-5 text-indigo-400" /> Backend Gateway Architecture
|
| 298 |
+
</h3>
|
| 299 |
+
<p className="text-xs text-zinc-400 leading-relaxed">
|
| 300 |
+
All requests from the frontend client route securely through the Node.js/Express proxy (`/api/*`).
|
| 301 |
+
The proxy attaches the active API key as a query parameter (`?api_key=...`) to the core REST API endpoint (`https://server.smartlead.ai/api/v1`).
|
| 302 |
+
</p>
|
| 303 |
+
|
| 304 |
+
<div className="p-4 bg-zinc-950 border border-zinc-800 rounded-lg font-mono text-xs text-zinc-300 space-y-2">
|
| 305 |
+
<span className="text-emerald-400"># Example Proxy Request</span><br />
|
| 306 |
+
GET /api/campaigns → https://server.smartlead.ai/api/v1/campaigns?api_key={KEY}<br />
|
| 307 |
+
POST /api/leads/search → https://server.smartlead.ai/api/v1/leads/?api_key={KEY}
|
| 308 |
+
</div>
|
| 309 |
+
</div>
|
| 310 |
+
)}
|
| 311 |
+
|
| 312 |
+
{/* TAB 4: DATABASE / SUPABASE */}
|
| 313 |
+
{activeTab === "database" && (
|
| 314 |
+
<div className="space-y-6 max-w-4xl">
|
| 315 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-6 shadow-sm space-y-6">
|
| 316 |
+
<div>
|
| 317 |
+
<h3 className="text-base font-semibold text-zinc-100 flex items-center gap-2">
|
| 318 |
+
<Database className="w-5 h-5 text-emerald-400" /> Supabase Integration Status
|
| 319 |
+
</h3>
|
| 320 |
+
<p className="text-xs text-zinc-400 mt-1">
|
| 321 |
+
Check the connection to your Supabase project instance (xxpwunwppyassyvjgfxa).
|
| 322 |
+
To configure, provide your URL and Anon Key in your environment variables.
|
| 323 |
+
</p>
|
| 324 |
+
</div>
|
| 325 |
+
|
| 326 |
+
<div className={`p-4 rounded-xl border flex items-start gap-4 transition-colors ${
|
| 327 |
+
supabaseStatus === "connected" ? "bg-emerald-500/10 border-emerald-500/30" :
|
| 328 |
+
supabaseStatus === "unconfigured" ? "bg-amber-500/10 border-amber-500/30" :
|
| 329 |
+
supabaseStatus === "error" ? "bg-rose-500/10 border-rose-500/30" :
|
| 330 |
+
"bg-zinc-950/60 border-zinc-800"
|
| 331 |
+
}`}>
|
| 332 |
+
{supabaseStatus === "connected" && <CheckCircle2 className="w-6 h-6 text-emerald-400 shrink-0" />}
|
| 333 |
+
{supabaseStatus === "unconfigured" && <AlertCircle className="w-6 h-6 text-amber-400 shrink-0" />}
|
| 334 |
+
{supabaseStatus === "error" && <AlertCircle className="w-6 h-6 text-rose-400 shrink-0" />}
|
| 335 |
+
{supabaseStatus === "testing" && <Activity className="w-6 h-6 text-zinc-400 shrink-0 animate-pulse" />}
|
| 336 |
+
|
| 337 |
+
<div className="space-y-1">
|
| 338 |
+
<h4 className={`text-sm font-semibold ${
|
| 339 |
+
supabaseStatus === "connected" ? "text-emerald-400" :
|
| 340 |
+
supabaseStatus === "unconfigured" ? "text-amber-400" :
|
| 341 |
+
supabaseStatus === "error" ? "text-rose-400" :
|
| 342 |
+
"text-zinc-300"
|
| 343 |
+
}`}>
|
| 344 |
+
{supabaseStatus === "connected" ? "Connection Established" :
|
| 345 |
+
supabaseStatus === "unconfigured" ? "Missing Credentials" :
|
| 346 |
+
supabaseStatus === "error" ? "Connection Failed" :
|
| 347 |
+
"Testing Connection..."}
|
| 348 |
+
</h4>
|
| 349 |
+
<p className="text-xs text-zinc-400 leading-relaxed">
|
| 350 |
+
{supabaseStatus === "connected" ? "Successfully communicating with Supabase Project xxpwunwppyassyvjgfxa." :
|
| 351 |
+
supabaseStatus === "unconfigured" ? "Cannot connect to Supabase. Please ensure VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY are set in your environment variables (.env file)." :
|
| 352 |
+
supabaseStatus === "error" ? "Failed to establish a connection with the provided credentials. Please verify your Project URL and Anon Key." :
|
| 353 |
+
"Pinging Supabase endpoints..."}
|
| 354 |
+
</p>
|
| 355 |
+
</div>
|
| 356 |
+
</div>
|
| 357 |
+
|
| 358 |
+
<div className="space-y-3 pt-2">
|
| 359 |
+
<h4 className="text-sm font-semibold text-zinc-200">Configuration Guide</h4>
|
| 360 |
+
<ol className="list-decimal list-inside space-y-2 text-xs text-zinc-400">
|
| 361 |
+
<li>Go to your Supabase Dashboard: <a href="https://supabase.com/dashboard/project/xxpwunwppyassyvjgfxa" target="_blank" rel="noreferrer" className="text-emerald-400 hover:underline">Project xxpwunwppyassyvjgfxa</a></li>
|
| 362 |
+
<li>Navigate to Project Settings {"->"} API.</li>
|
| 363 |
+
<li>Copy the <strong>Project URL</strong> and add it to <code className="bg-zinc-950 px-1 py-0.5 rounded text-zinc-300">VITE_SUPABASE_URL</code>.</li>
|
| 364 |
+
<li>Copy the <strong>anon public</strong> key and add it to <code className="bg-zinc-950 px-1 py-0.5 rounded text-zinc-300">VITE_SUPABASE_ANON_KEY</code>.</li>
|
| 365 |
+
</ol>
|
| 366 |
+
</div>
|
| 367 |
+
</div>
|
| 368 |
+
</div>
|
| 369 |
+
)}
|
| 370 |
+
|
| 371 |
+
{/* Add Key Drawer */}
|
| 372 |
+
<FormDrawer
|
| 373 |
+
isOpen={isAddKeyOpen}
|
| 374 |
+
onClose={() => setIsAddKeyOpen(false)}
|
| 375 |
+
title="Add BRIDGE ModulS API Key"
|
| 376 |
+
subtitle="Retrieve your API key from Settings -> Profile -> API Keys"
|
| 377 |
+
>
|
| 378 |
+
<form
|
| 379 |
+
onSubmit={(e) => {
|
| 380 |
+
e.preventDefault();
|
| 381 |
+
const form = e.target as HTMLFormElement;
|
| 382 |
+
const name = (form.elements.namedItem("name") as HTMLInputElement).value;
|
| 383 |
+
const key = (form.elements.namedItem("key") as HTMLInputElement).value;
|
| 384 |
+
|
| 385 |
+
addApiKey(name, key);
|
| 386 |
+
toast.success("API Key saved & activated!");
|
| 387 |
+
setIsAddKeyOpen(false);
|
| 388 |
+
}}
|
| 389 |
+
className="space-y-4 text-xs"
|
| 390 |
+
>
|
| 391 |
+
<div>
|
| 392 |
+
<label className="block font-medium text-zinc-300 mb-1">Key Friendly Name *</label>
|
| 393 |
+
<input name="name" required placeholder="e.g. Production Main Key" className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100" />
|
| 394 |
+
</div>
|
| 395 |
+
<div>
|
| 396 |
+
<label className="block font-medium text-zinc-300 mb-1">API Key Token *</label>
|
| 397 |
+
<input name="key" type="password" required placeholder="sl_live_..." className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 font-mono" />
|
| 398 |
+
</div>
|
| 399 |
+
|
| 400 |
+
<div className="pt-4 flex justify-end gap-2 border-t border-zinc-800">
|
| 401 |
+
<button
|
| 402 |
+
type="button"
|
| 403 |
+
onClick={() => setIsAddKeyOpen(false)}
|
| 404 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 405 |
+
>
|
| 406 |
+
Cancel
|
| 407 |
+
</button>
|
| 408 |
+
<button
|
| 409 |
+
type="submit"
|
| 410 |
+
className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium shadow"
|
| 411 |
+
>
|
| 412 |
+
Save Key
|
| 413 |
+
</button>
|
| 414 |
+
</div>
|
| 415 |
+
</form>
|
| 416 |
+
</FormDrawer>
|
| 417 |
+
|
| 418 |
+
{/* Delete Key Modal */}
|
| 419 |
+
<ConfirmModal
|
| 420 |
+
isOpen={Boolean(keyToDelete)}
|
| 421 |
+
onClose={() => setKeyToDelete(null)}
|
| 422 |
+
onConfirm={() => {
|
| 423 |
+
if (keyToDelete) {
|
| 424 |
+
removeApiKey(keyToDelete);
|
| 425 |
+
toast.success("API key deleted");
|
| 426 |
+
setKeyToDelete(null);
|
| 427 |
+
}
|
| 428 |
+
}}
|
| 429 |
+
title="Delete API Key"
|
| 430 |
+
description="Are you sure you want to remove this stored API key?"
|
| 431 |
+
/>
|
| 432 |
+
</div>
|
| 433 |
+
);
|
| 434 |
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Flame,
|
| 5 |
+
ShieldCheck,
|
| 6 |
+
TrendingUp,
|
| 7 |
+
Sliders,
|
| 8 |
+
CheckCircle2,
|
| 9 |
+
AlertTriangle,
|
| 10 |
+
Zap,
|
| 11 |
+
Mail,
|
| 12 |
+
Play,
|
| 13 |
+
Pause,
|
| 14 |
+
ArrowUpRight
|
| 15 |
+
} from "lucide-react";
|
| 16 |
+
import { useState } from "react";
|
| 17 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 18 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 19 |
+
import toast from "react-hot-toast";
|
| 20 |
+
|
| 21 |
+
export default function Warmup() {
|
| 22 |
+
const queryClient = useQueryClient();
|
| 23 |
+
const [selectedWarmupAccount, setSelectedWarmupAccount] = useState<any | null>(null);
|
| 24 |
+
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
| 25 |
+
|
| 26 |
+
const { data: accounts = [], isLoading, refetch } = useQuery({
|
| 27 |
+
queryKey: ["email-accounts"],
|
| 28 |
+
queryFn: async () => {
|
| 29 |
+
const res = await apiClient.get("/email-accounts");
|
| 30 |
+
return res.data;
|
| 31 |
+
},
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
const toggleWarmupMutation = useMutation({
|
| 35 |
+
mutationFn: async ({ id, status }: { id: string; status: "ACTIVE" | "PAUSED" }) => {
|
| 36 |
+
const res = await apiClient.post(`/email-accounts/${id}/warmup`, { status });
|
| 37 |
+
return res.data;
|
| 38 |
+
},
|
| 39 |
+
onSuccess: (_, variables) => {
|
| 40 |
+
toast.success(`Warmup ${variables.status.toLowerCase()}ed`);
|
| 41 |
+
refetch();
|
| 42 |
+
},
|
| 43 |
+
onError: () => {
|
| 44 |
+
toast.error("Failed to update warmup status");
|
| 45 |
+
}
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
const activeWarmups = accounts.filter((a: any) => a.warmup_status === "ACTIVE").length;
|
| 49 |
+
|
| 50 |
+
return (
|
| 51 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 52 |
+
{/* Header */}
|
| 53 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 54 |
+
<div>
|
| 55 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 56 |
+
<Flame className="w-6 h-6 text-amber-400" />
|
| 57 |
+
Autonomous Warmup Engine
|
| 58 |
+
</h1>
|
| 59 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 60 |
+
Gradually ramps mailbox sending volume, interacts with peer networks, and rescues emails from spam folders.
|
| 61 |
+
</p>
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<div className="flex items-center gap-3">
|
| 65 |
+
<button
|
| 66 |
+
onClick={() => {
|
| 67 |
+
accounts.forEach((a: any) => {
|
| 68 |
+
toggleWarmupMutation.mutate({ id: a.id, status: "ACTIVE" });
|
| 69 |
+
});
|
| 70 |
+
toast.success("Warmup activated on all connected mailboxes");
|
| 71 |
+
}}
|
| 72 |
+
className="px-3.5 py-2 bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs font-medium rounded-lg transition-colors flex items-center gap-1.5"
|
| 73 |
+
>
|
| 74 |
+
<Play className="w-3.5 h-3.5 text-emerald-400" /> Bulk Enable All
|
| 75 |
+
</button>
|
| 76 |
+
<button
|
| 77 |
+
onClick={() => setIsSettingsOpen(true)}
|
| 78 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-1.5"
|
| 79 |
+
>
|
| 80 |
+
<Sliders className="w-4 h-4" /> Global Warmup Rules
|
| 81 |
+
</button>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
{/* KPI Overview */}
|
| 86 |
+
<div className="grid grid-cols-1 sm:grid-cols-4 gap-4">
|
| 87 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 88 |
+
<span className="text-xs text-zinc-400">Warmup Coverage</span>
|
| 89 |
+
<div className="text-2xl font-bold text-zinc-100 mt-1">
|
| 90 |
+
{activeWarmups} / {accounts.length}
|
| 91 |
+
</div>
|
| 92 |
+
<span className="text-[11px] text-emerald-400 font-medium">Inboxes in active pool</span>
|
| 93 |
+
</div>
|
| 94 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 95 |
+
<span className="text-xs text-zinc-400">Daily Warmup Volume</span>
|
| 96 |
+
<div className="text-2xl font-bold text-amber-400 mt-1">140 / day</div>
|
| 97 |
+
<span className="text-[11px] text-zinc-500">Auto-incrementing daily</span>
|
| 98 |
+
</div>
|
| 99 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 100 |
+
<span className="text-xs text-zinc-400">Warmup Reply Rate</span>
|
| 101 |
+
<div className="text-2xl font-bold text-indigo-400 mt-1">32.4%</div>
|
| 102 |
+
<span className="text-[11px] text-zinc-500">Autonomous peer response</span>
|
| 103 |
+
</div>
|
| 104 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl p-4">
|
| 105 |
+
<span className="text-xs text-zinc-400">Inbox Health Score</span>
|
| 106 |
+
<div className="text-2xl font-bold text-emerald-400 mt-1">98 / 100</div>
|
| 107 |
+
<span className="text-[11px] text-emerald-400 font-medium">Excellent deliverability</span>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
|
| 111 |
+
{/* Warmup Mailboxes Table */}
|
| 112 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden shadow-sm">
|
| 113 |
+
<div className="overflow-x-auto">
|
| 114 |
+
<table className="w-full text-sm text-left">
|
| 115 |
+
<thead className="bg-zinc-950 border-b border-zinc-800 text-zinc-400 text-xs uppercase">
|
| 116 |
+
<tr>
|
| 117 |
+
<th className="px-6 py-3.5 font-semibold">Mailbox</th>
|
| 118 |
+
<th className="px-6 py-3.5 font-semibold">Warmup Status</th>
|
| 119 |
+
<th className="px-6 py-3.5 font-semibold">Ramp Day</th>
|
| 120 |
+
<th className="px-6 py-3.5 font-semibold">Reputation Score</th>
|
| 121 |
+
<th className="px-6 py-3.5 font-semibold">Warmup Volume</th>
|
| 122 |
+
<th className="px-6 py-3.5 font-semibold text-right">Warmup Toggle</th>
|
| 123 |
+
</tr>
|
| 124 |
+
</thead>
|
| 125 |
+
<tbody className="divide-y divide-zinc-800/80">
|
| 126 |
+
{accounts.map((acc: any, index: number) => {
|
| 127 |
+
const isWarmupActive = acc.warmup_status === "ACTIVE";
|
| 128 |
+
const rampDay = 14 + index * 5;
|
| 129 |
+
const score = 95 + index * 2;
|
| 130 |
+
|
| 131 |
+
return (
|
| 132 |
+
<tr key={acc.id} className="hover:bg-zinc-800/30 transition-colors">
|
| 133 |
+
<td className="px-6 py-4">
|
| 134 |
+
<div className="font-semibold text-zinc-100 flex items-center gap-2">
|
| 135 |
+
{acc.from_name}
|
| 136 |
+
</div>
|
| 137 |
+
<div className="text-xs text-zinc-400 font-mono mt-0.5">{acc.from_email}</div>
|
| 138 |
+
</td>
|
| 139 |
+
<td className="px-6 py-4">
|
| 140 |
+
<StatusBadge status={isWarmupActive ? "ACTIVE" : "PAUSED"} size="sm" />
|
| 141 |
+
</td>
|
| 142 |
+
<td className="px-6 py-4 text-zinc-300 font-mono text-xs">
|
| 143 |
+
Day {rampDay} of 30
|
| 144 |
+
</td>
|
| 145 |
+
<td className="px-6 py-4">
|
| 146 |
+
<div className="flex items-center gap-2">
|
| 147 |
+
<span className="text-xs font-bold text-emerald-400">{score}%</span>
|
| 148 |
+
<div className="w-20 h-1.5 bg-zinc-950 rounded-full overflow-hidden border border-zinc-800">
|
| 149 |
+
<div className="h-full bg-emerald-400 rounded-full" style={{ width: `${score}%` }} />
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
</td>
|
| 153 |
+
<td className="px-6 py-4 text-xs font-mono text-zinc-300">
|
| 154 |
+
<span className="text-amber-400 font-semibold">{30 + index * 5}</span> warm emails sent today
|
| 155 |
+
</td>
|
| 156 |
+
<td className="px-6 py-4 text-right">
|
| 157 |
+
<button
|
| 158 |
+
onClick={() =>
|
| 159 |
+
toggleWarmupMutation.mutate({
|
| 160 |
+
id: acc.id,
|
| 161 |
+
status: isWarmupActive ? "PAUSED" : "ACTIVE",
|
| 162 |
+
})
|
| 163 |
+
}
|
| 164 |
+
className={`px-3 py-1 text-xs font-medium rounded-lg transition-colors ${
|
| 165 |
+
isWarmupActive
|
| 166 |
+
? "bg-rose-500/10 text-rose-400 hover:bg-rose-500/20 border border-rose-500/30"
|
| 167 |
+
: "bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 border border-emerald-500/30"
|
| 168 |
+
}`}
|
| 169 |
+
>
|
| 170 |
+
{isWarmupActive ? "Pause Warmup" : "Start Warmup"}
|
| 171 |
+
</button>
|
| 172 |
+
</td>
|
| 173 |
+
</tr>
|
| 174 |
+
);
|
| 175 |
+
})}
|
| 176 |
+
</tbody>
|
| 177 |
+
</table>
|
| 178 |
+
</div>
|
| 179 |
+
</div>
|
| 180 |
+
|
| 181 |
+
{/* Global Warmup Rules Drawer */}
|
| 182 |
+
<FormDrawer
|
| 183 |
+
isOpen={isSettingsOpen}
|
| 184 |
+
onClose={() => setIsSettingsOpen(false)}
|
| 185 |
+
title="Autonomous Warmup Settings"
|
| 186 |
+
subtitle="Fine-tune daily ramping schedules and simulated reply rates."
|
| 187 |
+
>
|
| 188 |
+
<div className="space-y-4 text-xs">
|
| 189 |
+
<div>
|
| 190 |
+
<label className="block font-medium text-zinc-300 mb-1">Target Daily Warmup Max</label>
|
| 191 |
+
<input
|
| 192 |
+
type="number"
|
| 193 |
+
defaultValue="40"
|
| 194 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100"
|
| 195 |
+
/>
|
| 196 |
+
<span className="text-[11px] text-zinc-500 mt-1 block">Maximum simulated emails per inbox daily</span>
|
| 197 |
+
</div>
|
| 198 |
+
|
| 199 |
+
<div>
|
| 200 |
+
<label className="block font-medium text-zinc-300 mb-1">Daily Ramp Increment</label>
|
| 201 |
+
<input
|
| 202 |
+
type="number"
|
| 203 |
+
defaultValue="4"
|
| 204 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100"
|
| 205 |
+
/>
|
| 206 |
+
<span className="text-[11px] text-zinc-500 mt-1 block">Additional emails added each consecutive day</span>
|
| 207 |
+
</div>
|
| 208 |
+
|
| 209 |
+
<div>
|
| 210 |
+
<label className="block font-medium text-zinc-300 mb-1">Simulated Reply Rate</label>
|
| 211 |
+
<input
|
| 212 |
+
type="range"
|
| 213 |
+
min="10"
|
| 214 |
+
max="60"
|
| 215 |
+
defaultValue="35"
|
| 216 |
+
className="w-full accent-indigo-500"
|
| 217 |
+
/>
|
| 218 |
+
<div className="flex justify-between text-[11px] text-zinc-400">
|
| 219 |
+
<span>Conservative (15%)</span>
|
| 220 |
+
<span className="text-indigo-400 font-semibold">Target: 35%</span>
|
| 221 |
+
<span>Aggressive (60%)</span>
|
| 222 |
+
</div>
|
| 223 |
+
</div>
|
| 224 |
+
|
| 225 |
+
<div className="flex items-center justify-between p-3 bg-zinc-900 border border-zinc-800 rounded-lg">
|
| 226 |
+
<div>
|
| 227 |
+
<span className="font-medium text-zinc-200 block text-xs">Spam Rescue Protocol</span>
|
| 228 |
+
<span className="text-[11px] text-zinc-500">Automatically moves warm emails out of spam folders</span>
|
| 229 |
+
</div>
|
| 230 |
+
<input
|
| 231 |
+
type="checkbox"
|
| 232 |
+
defaultChecked
|
| 233 |
+
className="w-4 h-4 rounded text-indigo-600 focus:ring-indigo-500 bg-zinc-950 border-zinc-700"
|
| 234 |
+
/>
|
| 235 |
+
</div>
|
| 236 |
+
|
| 237 |
+
<div className="pt-4 flex justify-end gap-2 border-t border-zinc-800">
|
| 238 |
+
<button
|
| 239 |
+
type="button"
|
| 240 |
+
onClick={() => setIsSettingsOpen(false)}
|
| 241 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 242 |
+
>
|
| 243 |
+
Cancel
|
| 244 |
+
</button>
|
| 245 |
+
<button
|
| 246 |
+
type="button"
|
| 247 |
+
onClick={() => {
|
| 248 |
+
toast.success("Warmup parameters saved!");
|
| 249 |
+
setIsSettingsOpen(false);
|
| 250 |
+
}}
|
| 251 |
+
className="px-4 py-2 bg-indigo-600 text-white font-medium rounded-lg"
|
| 252 |
+
>
|
| 253 |
+
Save Configuration
|
| 254 |
+
</button>
|
| 255 |
+
</div>
|
| 256 |
+
</div>
|
| 257 |
+
</FormDrawer>
|
| 258 |
+
</div>
|
| 259 |
+
);
|
| 260 |
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 2 |
+
import { apiClient } from "../../../lib/apiClient";
|
| 3 |
+
import {
|
| 4 |
+
Webhook,
|
| 5 |
+
Plus,
|
| 6 |
+
Play,
|
| 7 |
+
Trash2,
|
| 8 |
+
CheckCircle2,
|
| 9 |
+
AlertCircle,
|
| 10 |
+
Code,
|
| 11 |
+
ExternalLink,
|
| 12 |
+
Copy,
|
| 13 |
+
Terminal
|
| 14 |
+
} from "lucide-react";
|
| 15 |
+
import { useState } from "react";
|
| 16 |
+
import StatusBadge from "../../../components/StatusBadge";
|
| 17 |
+
import FormDrawer from "../../../components/FormDrawer";
|
| 18 |
+
import ConfirmModal from "../../../components/ConfirmModal";
|
| 19 |
+
import toast from "react-hot-toast";
|
| 20 |
+
|
| 21 |
+
const AVAILABLE_EVENTS = [
|
| 22 |
+
{ id: "EMAIL_REPLIED", label: "Email Replied" },
|
| 23 |
+
{ id: "EMAIL_OPENED", label: "Email Opened" },
|
| 24 |
+
{ id: "EMAIL_CLICKED", label: "Link Clicked" },
|
| 25 |
+
{ id: "EMAIL_BOUNCED", label: "Email Bounced" },
|
| 26 |
+
{ id: "LEAD_CATEGORY_UPDATED", label: "Lead Category Updated" },
|
| 27 |
+
{ id: "EMAIL_UNSUBSCRIBED", label: "Lead Unsubscribed" },
|
| 28 |
+
{ id: "CAMPAIGN_COMPLETED", label: "Campaign Completed" },
|
| 29 |
+
];
|
| 30 |
+
|
| 31 |
+
export default function Webhooks() {
|
| 32 |
+
const queryClient = useQueryClient();
|
| 33 |
+
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
| 34 |
+
const [selectedForDelete, setSelectedForDelete] = useState<string | null>(null);
|
| 35 |
+
const [testExecutionResult, setTestExecutionResult] = useState<any | null>(null);
|
| 36 |
+
|
| 37 |
+
const { data: webhooks = [], isLoading, refetch } = useQuery({
|
| 38 |
+
queryKey: ["webhooks"],
|
| 39 |
+
queryFn: async () => {
|
| 40 |
+
const res = await apiClient.get("/webhooks");
|
| 41 |
+
return res.data;
|
| 42 |
+
},
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
const { data: campaigns = [] } = useQuery({
|
| 46 |
+
queryKey: ["campaigns"],
|
| 47 |
+
queryFn: async () => {
|
| 48 |
+
const res = await apiClient.get("/campaigns");
|
| 49 |
+
return res.data;
|
| 50 |
+
},
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
const testFireMutation = useMutation({
|
| 54 |
+
mutationFn: async (id: string) => {
|
| 55 |
+
const res = await apiClient.post(`/webhooks/${id}/test`);
|
| 56 |
+
return res.data;
|
| 57 |
+
},
|
| 58 |
+
onSuccess: (data) => {
|
| 59 |
+
toast.success("Webhook test payload dispatched!");
|
| 60 |
+
setTestExecutionResult(data);
|
| 61 |
+
},
|
| 62 |
+
onError: () => {
|
| 63 |
+
toast.error("Failed to fire test webhook");
|
| 64 |
+
},
|
| 65 |
+
});
|
| 66 |
+
|
| 67 |
+
const deleteMutation = useMutation({
|
| 68 |
+
mutationFn: async (id: string) => {
|
| 69 |
+
const res = await apiClient.delete(`/webhooks/${id}`);
|
| 70 |
+
return res.data;
|
| 71 |
+
},
|
| 72 |
+
onSuccess: () => {
|
| 73 |
+
toast.success("Webhook endpoint removed");
|
| 74 |
+
setSelectedForDelete(null);
|
| 75 |
+
refetch();
|
| 76 |
+
},
|
| 77 |
+
});
|
| 78 |
+
|
| 79 |
+
return (
|
| 80 |
+
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
| 81 |
+
{/* Header */}
|
| 82 |
+
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
| 83 |
+
<div>
|
| 84 |
+
<h1 className="text-2xl font-bold tracking-tight text-zinc-100 flex items-center gap-2.5">
|
| 85 |
+
<Webhook className="w-6 h-6 text-purple-400" />
|
| 86 |
+
Event Webhooks & Integrations
|
| 87 |
+
</h1>
|
| 88 |
+
<p className="text-zinc-400 text-sm mt-1">
|
| 89 |
+
Stream real-time outreach events directly to your CRM, Slack, Zapier, or backend server.
|
| 90 |
+
</p>
|
| 91 |
+
</div>
|
| 92 |
+
|
| 93 |
+
<button
|
| 94 |
+
onClick={() => setIsCreateOpen(true)}
|
| 95 |
+
className="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-sm font-medium rounded-lg transition-all shadow-md shadow-indigo-600/20 flex items-center gap-2"
|
| 96 |
+
>
|
| 97 |
+
<Plus className="w-4 h-4" /> Add Webhook
|
| 98 |
+
</button>
|
| 99 |
+
</div>
|
| 100 |
+
|
| 101 |
+
{/* Webhooks Table */}
|
| 102 |
+
<div className="bg-zinc-900 border border-zinc-800 rounded-xl overflow-hidden shadow-sm">
|
| 103 |
+
<div className="overflow-x-auto">
|
| 104 |
+
<table className="w-full text-sm text-left">
|
| 105 |
+
<thead className="bg-zinc-950 border-b border-zinc-800 text-zinc-400 text-xs uppercase">
|
| 106 |
+
<tr>
|
| 107 |
+
<th className="px-6 py-3.5 font-semibold">Endpoint URL</th>
|
| 108 |
+
<th className="px-6 py-3.5 font-semibold">Campaign Scope</th>
|
| 109 |
+
<th className="px-6 py-3.5 font-semibold">Subscribed Events</th>
|
| 110 |
+
<th className="px-6 py-3.5 font-semibold">Status</th>
|
| 111 |
+
<th className="px-6 py-3.5 font-semibold text-right">Actions</th>
|
| 112 |
+
</tr>
|
| 113 |
+
</thead>
|
| 114 |
+
<tbody className="divide-y divide-zinc-800/80">
|
| 115 |
+
{webhooks.map((hook: any) => (
|
| 116 |
+
<tr key={hook.id} className="hover:bg-zinc-800/30 transition-colors">
|
| 117 |
+
<td className="px-6 py-4">
|
| 118 |
+
<div className="flex items-center gap-2">
|
| 119 |
+
<span className="font-mono text-xs text-zinc-200 font-medium">
|
| 120 |
+
{hook.target_url}
|
| 121 |
+
</span>
|
| 122 |
+
<button
|
| 123 |
+
onClick={() => {
|
| 124 |
+
navigator.clipboard.writeText(hook.target_url);
|
| 125 |
+
toast.success("Copied webhook URL");
|
| 126 |
+
}}
|
| 127 |
+
className="text-zinc-500 hover:text-zinc-300 p-1"
|
| 128 |
+
>
|
| 129 |
+
<Copy className="w-3.5 h-3.5" />
|
| 130 |
+
</button>
|
| 131 |
+
</div>
|
| 132 |
+
</td>
|
| 133 |
+
<td className="px-6 py-4 text-xs text-zinc-300">
|
| 134 |
+
{hook.campaign_id ? `Campaign: ${hook.campaign_id}` : "Global (All Campaigns)"}
|
| 135 |
+
</td>
|
| 136 |
+
<td className="px-6 py-4">
|
| 137 |
+
<div className="flex flex-wrap gap-1 max-w-xs">
|
| 138 |
+
{hook.event_types?.map((ev: string) => (
|
| 139 |
+
<span
|
| 140 |
+
key={ev}
|
| 141 |
+
className="px-2 py-0.5 bg-zinc-950 text-indigo-300 border border-indigo-500/20 rounded text-[10px] font-mono"
|
| 142 |
+
>
|
| 143 |
+
{ev}
|
| 144 |
+
</span>
|
| 145 |
+
))}
|
| 146 |
+
</div>
|
| 147 |
+
</td>
|
| 148 |
+
<td className="px-6 py-4">
|
| 149 |
+
<StatusBadge status={hook.status || "ACTIVE"} size="sm" />
|
| 150 |
+
</td>
|
| 151 |
+
<td className="px-6 py-4 text-right">
|
| 152 |
+
<div className="flex items-center justify-end gap-2">
|
| 153 |
+
<button
|
| 154 |
+
onClick={() => testFireMutation.mutate(hook.id)}
|
| 155 |
+
disabled={testFireMutation.isPending}
|
| 156 |
+
className="px-2.5 py-1 bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs font-medium rounded-md transition-colors flex items-center gap-1"
|
| 157 |
+
>
|
| 158 |
+
<Play className="w-3 h-3 text-emerald-400" /> Test Fire
|
| 159 |
+
</button>
|
| 160 |
+
<button
|
| 161 |
+
onClick={() => setSelectedForDelete(hook.id)}
|
| 162 |
+
className="p-1.5 text-zinc-500 hover:text-rose-400 hover:bg-rose-500/10 rounded-md transition-colors"
|
| 163 |
+
>
|
| 164 |
+
<Trash2 className="w-3.5 h-3.5" />
|
| 165 |
+
</button>
|
| 166 |
+
</div>
|
| 167 |
+
</td>
|
| 168 |
+
</tr>
|
| 169 |
+
))}
|
| 170 |
+
|
| 171 |
+
{webhooks.length === 0 && (
|
| 172 |
+
<tr>
|
| 173 |
+
<td colSpan={5} className="py-16 text-center text-xs text-zinc-500">
|
| 174 |
+
No webhooks configured yet. Create one to receive real-time JSON payloads.
|
| 175 |
+
</td>
|
| 176 |
+
</tr>
|
| 177 |
+
)}
|
| 178 |
+
</tbody>
|
| 179 |
+
</table>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
|
| 183 |
+
{/* Test Fire Response Inspector */}
|
| 184 |
+
{testExecutionResult && (
|
| 185 |
+
<div className="bg-zinc-950 border border-zinc-800 rounded-xl p-5 shadow-lg space-y-3">
|
| 186 |
+
<div className="flex items-center justify-between">
|
| 187 |
+
<h3 className="text-xs font-semibold text-emerald-400 flex items-center gap-2 uppercase tracking-wider">
|
| 188 |
+
<Terminal className="w-4 h-4" /> Live Webhook Delivery Simulation (200 OK)
|
| 189 |
+
</h3>
|
| 190 |
+
<button
|
| 191 |
+
onClick={() => setTestExecutionResult(null)}
|
| 192 |
+
className="text-xs text-zinc-500 hover:text-zinc-300"
|
| 193 |
+
>
|
| 194 |
+
Close Inspector
|
| 195 |
+
</button>
|
| 196 |
+
</div>
|
| 197 |
+
<pre className="p-4 bg-zinc-900 border border-zinc-800 rounded-lg text-xs font-mono text-zinc-300 overflow-x-auto">
|
| 198 |
+
{JSON.stringify(testExecutionResult, null, 2)}
|
| 199 |
+
</pre>
|
| 200 |
+
</div>
|
| 201 |
+
)}
|
| 202 |
+
|
| 203 |
+
{/* Delete Confirmation */}
|
| 204 |
+
<ConfirmModal
|
| 205 |
+
isOpen={Boolean(selectedForDelete)}
|
| 206 |
+
onClose={() => setSelectedForDelete(null)}
|
| 207 |
+
onConfirm={() => selectedForDelete && deleteMutation.mutate(selectedForDelete)}
|
| 208 |
+
title="Delete Webhook"
|
| 209 |
+
description="Are you sure you want to delete this webhook endpoint? No further notifications will be dispatched to this URL."
|
| 210 |
+
/>
|
| 211 |
+
|
| 212 |
+
{/* Create Webhook Drawer */}
|
| 213 |
+
<FormDrawer
|
| 214 |
+
isOpen={isCreateOpen}
|
| 215 |
+
onClose={() => setIsCreateOpen(false)}
|
| 216 |
+
title="Create Webhook Subscription"
|
| 217 |
+
subtitle="Specify the destination HTTPS endpoint and target event triggers."
|
| 218 |
+
>
|
| 219 |
+
<form
|
| 220 |
+
onSubmit={async (e) => {
|
| 221 |
+
e.preventDefault();
|
| 222 |
+
const form = e.target as HTMLFormElement;
|
| 223 |
+
const target_url = (form.elements.namedItem("target_url") as HTMLInputElement).value;
|
| 224 |
+
const campaign_id = (form.elements.namedItem("campaign_id") as HTMLSelectElement).value;
|
| 225 |
+
const checkedEvents = AVAILABLE_EVENTS.filter(
|
| 226 |
+
(ev) => (form.elements.namedItem(ev.id) as HTMLInputElement)?.checked
|
| 227 |
+
).map((ev) => ev.id);
|
| 228 |
+
|
| 229 |
+
if (checkedEvents.length === 0) {
|
| 230 |
+
toast.error("Please select at least one event trigger");
|
| 231 |
+
return;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
try {
|
| 235 |
+
await apiClient.post("/webhooks", {
|
| 236 |
+
target_url,
|
| 237 |
+
campaign_id: campaign_id === "ALL" ? null : campaign_id,
|
| 238 |
+
event_types: checkedEvents,
|
| 239 |
+
});
|
| 240 |
+
toast.success("Webhook configured successfully!");
|
| 241 |
+
setIsCreateOpen(false);
|
| 242 |
+
refetch();
|
| 243 |
+
} catch (err: any) {
|
| 244 |
+
toast.error("Failed to create webhook");
|
| 245 |
+
}
|
| 246 |
+
}}
|
| 247 |
+
className="space-y-4 text-xs"
|
| 248 |
+
>
|
| 249 |
+
<div>
|
| 250 |
+
<label className="block font-medium text-zinc-300 mb-1">Target Endpoint URL *</label>
|
| 251 |
+
<input
|
| 252 |
+
name="target_url"
|
| 253 |
+
type="url"
|
| 254 |
+
required
|
| 255 |
+
placeholder="https://api.yourdomain.com/webhooks/smartlead"
|
| 256 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100 font-mono"
|
| 257 |
+
/>
|
| 258 |
+
</div>
|
| 259 |
+
|
| 260 |
+
<div>
|
| 261 |
+
<label className="block font-medium text-zinc-300 mb-1">Campaign Scope</label>
|
| 262 |
+
<select
|
| 263 |
+
name="campaign_id"
|
| 264 |
+
defaultValue="ALL"
|
| 265 |
+
className="w-full bg-zinc-900 border border-zinc-800 rounded-lg p-2.5 text-zinc-100"
|
| 266 |
+
>
|
| 267 |
+
<option value="ALL">All Campaigns (Global Scope)</option>
|
| 268 |
+
{campaigns.map((c: any) => (
|
| 269 |
+
<option key={c.id} value={c.id}>
|
| 270 |
+
{c.name}
|
| 271 |
+
</option>
|
| 272 |
+
))}
|
| 273 |
+
</select>
|
| 274 |
+
</div>
|
| 275 |
+
|
| 276 |
+
<div className="space-y-2 pt-2 border-t border-zinc-800">
|
| 277 |
+
<label className="block font-medium text-zinc-300 mb-2">Subscribe to Events *</label>
|
| 278 |
+
<div className="grid grid-cols-1 gap-2">
|
| 279 |
+
{AVAILABLE_EVENTS.map((ev) => (
|
| 280 |
+
<label
|
| 281 |
+
key={ev.id}
|
| 282 |
+
className="flex items-center gap-2 p-2.5 bg-zinc-900 border border-zinc-800 rounded-lg cursor-pointer hover:bg-zinc-800/60"
|
| 283 |
+
>
|
| 284 |
+
<input
|
| 285 |
+
type="checkbox"
|
| 286 |
+
name={ev.id}
|
| 287 |
+
defaultChecked
|
| 288 |
+
className="w-4 h-4 rounded text-indigo-600 focus:ring-indigo-500 bg-zinc-950 border-zinc-700"
|
| 289 |
+
/>
|
| 290 |
+
<span className="text-zinc-200 font-medium">{ev.label}</span>
|
| 291 |
+
<span className="text-[10px] text-zinc-500 font-mono ml-auto">{ev.id}</span>
|
| 292 |
+
</label>
|
| 293 |
+
))}
|
| 294 |
+
</div>
|
| 295 |
+
</div>
|
| 296 |
+
|
| 297 |
+
<div className="pt-4 flex justify-end gap-2 border-t border-zinc-800">
|
| 298 |
+
<button
|
| 299 |
+
type="button"
|
| 300 |
+
onClick={() => setIsCreateOpen(false)}
|
| 301 |
+
className="px-3 py-2 bg-zinc-800 text-zinc-300 rounded-lg"
|
| 302 |
+
>
|
| 303 |
+
Cancel
|
| 304 |
+
</button>
|
| 305 |
+
<button
|
| 306 |
+
type="submit"
|
| 307 |
+
className="px-4 py-2 bg-indigo-600 text-white rounded-lg font-medium shadow"
|
| 308 |
+
>
|
| 309 |
+
Register Webhook
|
| 310 |
+
</button>
|
| 311 |
+
</div>
|
| 312 |
+
</form>
|
| 313 |
+
</FormDrawer>
|
| 314 |
+
</div>
|
| 315 |
+
);
|
| 316 |
+
}
|
|
@@ -46,7 +46,7 @@ describe('Analytics Page', () => {
|
|
| 46 |
</QueryClientProvider>
|
| 47 |
);
|
| 48 |
|
| 49 |
-
expect(screen.getByText(/Outbound Analytics
|
| 50 |
});
|
| 51 |
|
| 52 |
it('renders correctly with empty data', async () => {
|
|
@@ -76,7 +76,7 @@ describe('Analytics Page', () => {
|
|
| 76 |
|
| 77 |
// Should still render headers and fallback data
|
| 78 |
await waitFor(() => {
|
| 79 |
-
expect(screen.getByText(/Outbound Analytics
|
| 80 |
expect(screen.getByText(/LineChart/i)).toBeTruthy(); // Falls back to static data currently
|
| 81 |
});
|
| 82 |
});
|
|
|
|
| 46 |
</QueryClientProvider>
|
| 47 |
);
|
| 48 |
|
| 49 |
+
expect(screen.getByText(/Outbound Analytics/i)).toBeTruthy();
|
| 50 |
});
|
| 51 |
|
| 52 |
it('renders correctly with empty data', async () => {
|
|
|
|
| 76 |
|
| 77 |
// Should still render headers and fallback data
|
| 78 |
await waitFor(() => {
|
| 79 |
+
expect(screen.getByText(/Outbound Analytics/i)).toBeTruthy();
|
| 80 |
expect(screen.getByText(/LineChart/i)).toBeTruthy(); // Falls back to static data currently
|
| 81 |
});
|
| 82 |
});
|
|
@@ -171,7 +171,7 @@ export default function CampaignDetail() {
|
|
| 171 |
{/* Back Navigation and Header */}
|
| 172 |
<div className="space-y-4">
|
| 173 |
<Link
|
| 174 |
-
to="/campaigns"
|
| 175 |
className="inline-flex items-center gap-2 text-[10px] font-bold uppercase tracking-widest text-zinc-500 hover:text-emerald-400 transition-all group"
|
| 176 |
>
|
| 177 |
<ArrowLeft className="w-3.5 h-3.5 group-hover:-translate-x-1 transition-transform" />
|
|
|
|
| 171 |
{/* Back Navigation and Header */}
|
| 172 |
<div className="space-y-4">
|
| 173 |
<Link
|
| 174 |
+
to="/modules/e/campaigns"
|
| 175 |
className="inline-flex items-center gap-2 text-[10px] font-bold uppercase tracking-widest text-zinc-500 hover:text-emerald-400 transition-all group"
|
| 176 |
>
|
| 177 |
<ArrowLeft className="w-3.5 h-3.5 group-hover:-translate-x-1 transition-transform" />
|
|
@@ -294,7 +294,7 @@ export default function Dashboard() {
|
|
| 294 |
</button>
|
| 295 |
|
| 296 |
<Link
|
| 297 |
-
to="/warmup"
|
| 298 |
className="px-5 py-3 text-xs md:text-sm font-semibold rounded-xl border border-white/10 bg-white/5 hover:bg-white/10 text-zinc-300 transition-all flex items-center gap-2"
|
| 299 |
>
|
| 300 |
<Flame className="w-4 h-4 text-emerald-400" />
|
|
@@ -544,7 +544,7 @@ export default function Dashboard() {
|
|
| 544 |
<h3 className="text-xl font-bold text-white">Live outbound campaigns</h3>
|
| 545 |
</div>
|
| 546 |
<Link
|
| 547 |
-
to="/campaigns"
|
| 548 |
className="text-xs font-bold text-emerald-400 hover:text-emerald-300 transition-all flex items-center gap-1 hover:underline"
|
| 549 |
>
|
| 550 |
<span>Full Campaign Matrix</span>
|
|
|
|
| 294 |
</button>
|
| 295 |
|
| 296 |
<Link
|
| 297 |
+
to="/modules/e/warmup"
|
| 298 |
className="px-5 py-3 text-xs md:text-sm font-semibold rounded-xl border border-white/10 bg-white/5 hover:bg-white/10 text-zinc-300 transition-all flex items-center gap-2"
|
| 299 |
>
|
| 300 |
<Flame className="w-4 h-4 text-emerald-400" />
|
|
|
|
| 544 |
<h3 className="text-xl font-bold text-white">Live outbound campaigns</h3>
|
| 545 |
</div>
|
| 546 |
<Link
|
| 547 |
+
to="/modules/e/campaigns"
|
| 548 |
className="text-xs font-bold text-emerald-400 hover:text-emerald-300 transition-all flex items-center gap-1 hover:underline"
|
| 549 |
>
|
| 550 |
<span>Full Campaign Matrix</span>
|
|
@@ -11,6 +11,19 @@ export default defineConfig(() => {
|
|
| 11 |
'@': path.resolve(__dirname, '.'),
|
| 12 |
},
|
| 13 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
server: {
|
| 15 |
// HMR is disabled in AI Studio via DISABLE_HMR env var.
|
| 16 |
// Do not modifyâfile watching is disabled to prevent flickering during agent edits.
|
|
|
|
| 11 |
'@': path.resolve(__dirname, '.'),
|
| 12 |
},
|
| 13 |
},
|
| 14 |
+
build: {
|
| 15 |
+
rollupOptions: {
|
| 16 |
+
output: {
|
| 17 |
+
manualChunks: {
|
| 18 |
+
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
|
| 19 |
+
'vendor-motion': ['motion'],
|
| 20 |
+
'vendor-query': ['@tanstack/react-query'],
|
| 21 |
+
'vendor-charts': ['recharts'],
|
| 22 |
+
'vendor-forms': ['react-hook-form', 'zod', '@hookform/resolvers'],
|
| 23 |
+
},
|
| 24 |
+
},
|
| 25 |
+
},
|
| 26 |
+
},
|
| 27 |
server: {
|
| 28 |
// HMR is disabled in AI Studio via DISABLE_HMR env var.
|
| 29 |
// Do not modifyâfile watching is disabled to prevent flickering during agent edits.
|