sitcod3 commited on
Commit
65031d2
·
verified ·
1 Parent(s): 20fe129

Upload src/pages/Warmup.tsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. src/pages/Warmup.tsx +260 -0
src/pages/Warmup.tsx ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }