-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathemail-status-badge.tsx
92 lines (86 loc) · 2.62 KB
/
email-status-badge.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { EmailStatus } from "@prisma/client";
// ADD RATE_LIMITED STATUS LATER
export const EmailStatusBadge: React.FC<{ status: EmailStatus }> = ({
status,
}) => {
let badgeColor = "bg-gray-700/10 text-gray-400 border border-gray-400/10"; // Default color
switch (status) {
case "DELIVERED":
badgeColor =
"bg-green-500/15 dark:bg-green-600/10 text-green-700 dark:text-green-600/90 border border-green-500/25 dark:border-green-700/25";
break;
case "BOUNCED":
case "FAILED":
badgeColor =
"bg-red-500/10 text-red-600 dark:text-red-700/90 border border-red-600/10";
break;
case "CLICKED":
badgeColor =
"bg-sky-500/15 text-sky-700 dark:text-sky-600 border border-sky-600/20";
break;
case "OPENED":
badgeColor =
"bg-indigo-500/15 text-indigo-600 dark:text-indigo-500 border border-indigo-600/20";
break;
case "DELIVERY_DELAYED":
badgeColor = "bg-yellow-500/10 text-yellow-600 border-yellow-600/20";
break;
case "COMPLAINED":
badgeColor =
"bg-yellow-500/20 dark:bg-yellow-500/10 text-yellow-600 border border-yellow-600/10";
break;
default:
badgeColor =
"bg-gray-200/70 dark:bg-gray-400/10 text-gray-600 dark:text-gray-400 border border-gray-300 dark:border-gray-400/20";
}
return (
<div
className={` text-center w-[130px] rounded capitalize py-1 text-xs ${badgeColor}`}
>
{status.toLowerCase().split("_").join(" ")}
</div>
);
};
export const EmailStatusIcon: React.FC<{ status: EmailStatus }> = ({
status,
}) => {
let outsideColor = "bg-gray-500";
let insideColor = "bg-gray-500/50";
switch (status) {
case "DELIVERED":
outsideColor = "bg-green-500/30";
insideColor = "bg-green-500";
break;
case "BOUNCED":
case "FAILED":
outsideColor = "bg-red-500/30";
insideColor = "bg-red-500";
break;
case "CLICKED":
outsideColor = "bg-sky-500/30";
insideColor = "bg-sky-500";
break;
case "OPENED":
outsideColor = "bg-indigo-500/30";
insideColor = "bg-indigo-500";
break;
case "DELIVERY_DELAYED":
outsideColor = "bg-yellow-500/30";
insideColor = "bg-yellow-500";
break;
case "COMPLAINED":
outsideColor = "bg-yellow-500/30";
insideColor = "bg-yellow-500";
break;
default:
outsideColor = "bg-gray-500/20";
insideColor = "bg-gray-500";
}
return (
<div
className={`flex justify-center items-center p-1.5 ${outsideColor} rounded-full`}
>
<div className={`h-2 w-2 rounded-full ${insideColor}`}></div>
</div>
);
};