-
-
Notifications
You must be signed in to change notification settings - Fork 367
Expand file tree
/
Copy pathDomainVerificationStatusEmail.tsx
More file actions
155 lines (140 loc) · 4.37 KB
/
DomainVerificationStatusEmail.tsx
File metadata and controls
155 lines (140 loc) · 4.37 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import React from "react";
import { Container, Text } from "jsx-email";
import { render } from "jsx-email";
import { DomainStatus } from "@prisma/client";
import { EmailButton } from "~/server/email-templates/components/EmailButton";
import { EmailFooter } from "~/server/email-templates/components/EmailFooter";
import { EmailHeader } from "~/server/email-templates/components/EmailHeader";
import { EmailLayout } from "~/server/email-templates/components/EmailLayout";
interface DomainVerificationStatusEmailProps {
domainName: string;
currentStatus: DomainStatus;
previousStatus: DomainStatus;
verificationError?: string | null;
domainUrl: string;
}
function formatDomainStatus(status: DomainStatus) {
return status.toLowerCase().replaceAll("_", " ");
}
function getTitle(currentStatus: DomainStatus, previousStatus: DomainStatus) {
if (currentStatus === DomainStatus.SUCCESS) {
return previousStatus === DomainStatus.SUCCESS
? "Domain verification checked"
: "Your domain is verified";
}
if (previousStatus === DomainStatus.SUCCESS) {
return "Your domain status changed";
}
return "Your domain verification needs attention";
}
export function DomainVerificationStatusEmail({
domainName,
currentStatus,
previousStatus,
verificationError,
domainUrl,
}: DomainVerificationStatusEmailProps) {
const isSuccess = currentStatus === DomainStatus.SUCCESS;
const preview = `${domainName} is now ${formatDomainStatus(currentStatus)}`;
return (
<EmailLayout preview={preview}>
<EmailHeader title={getTitle(currentStatus, previousStatus)} />
<Container style={{ padding: "20px 0", textAlign: "left" as const }}>
<Text
style={{
fontSize: "16px",
color: "#374151",
margin: "0 0 16px 0",
lineHeight: "1.6",
textAlign: "left" as const,
}}
>
Hey,
</Text>
{isSuccess ? (
<Text
style={{
fontSize: "15px",
color: "#4b5563",
margin: "0 0 16px 0",
lineHeight: "1.6",
textAlign: "left" as const,
}}
>
Your domain <strong>{domainName}</strong> is now verified, and you
can start sending emails.
</Text>
) : (
<Text
style={{
fontSize: "15px",
color: "#4b5563",
margin: "0 0 16px 0",
lineHeight: "1.6",
textAlign: "left" as const,
}}
>
Your domain <strong>{domainName}</strong> could not be verified
because the DNS records are not set up correctly yet. Please review
your DNS settings and try again.
</Text>
)}
{verificationError ? (
<Container
style={{
backgroundColor: "#fef2f2",
border: "1px solid #fecaca",
padding: "12px 16px",
margin: "0 0 24px 0",
borderRadius: "4px",
}}
>
<Text
style={{
margin: 0,
color: "#991b1b",
fontSize: 14,
textAlign: "left" as const,
}}
>
Verification error: {verificationError}
</Text>
</Container>
) : null}
<Text
style={{
fontSize: "14px",
color: "#6b7280",
margin: "0 0 24px 0",
lineHeight: "1.6",
textAlign: "left" as const,
}}
>
Open your domain settings to review records and verification details.
</Text>
<Container style={{ margin: "0 0 32px 0", textAlign: "left" as const }}>
<EmailButton href={domainUrl}>Open domain settings</EmailButton>
</Container>
<Text
style={{
fontSize: "14px",
color: "#6b7280",
margin: "0",
lineHeight: "1.6",
textAlign: "left" as const,
}}
>
Thanks,
<br />
useSend Team
</Text>
</Container>
<EmailFooter />
</EmailLayout>
);
}
export async function renderDomainVerificationStatusEmail(
props: DomainVerificationStatusEmailProps,
): Promise<string> {
return render(<DomainVerificationStatusEmail {...props} />);
}