@bigbinary/neeto-email-delivery-frontend 1.0.30 → 1.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,299 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var react = require('react');
5
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
6
+ var CardLayout = require('@bigbinary/neeto-molecules/CardLayout');
7
+ var Spinner = require('@bigbinary/neetoui/Spinner');
8
+ var ramda = require('ramda');
9
+ var reactI18next = require('react-i18next');
10
+ var reactRouterDom = require('react-router-dom');
11
+ var PageLayout = require('./PageLayout-CUMq2CmP.js');
12
+ var useSparkpostDomain = require('./useSparkpostDomain-CXs_VuGP.js');
13
+ var useEmailDeliveryIntegrationApi = require('./useEmailDeliveryIntegrationApi-BcQDhMIH.js');
14
+ var useSparkpostApi = require('./useSparkpostApi-DlgW14Wu.js');
15
+ var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
16
+ var Typography = require('@bigbinary/neetoui/Typography');
17
+ var Tag = require('@bigbinary/neetoui/Tag');
18
+ var CopyToClipboardButton = require('@bigbinary/neeto-molecules/CopyToClipboardButton');
19
+ var jsxRuntime = require('react/jsx-runtime');
20
+ var Button = require('@bigbinary/neetoui/Button');
21
+ var Callout = require('@bigbinary/neetoui/Callout');
22
+
23
+ var RecordField = function RecordField(_ref) {
24
+ var label = _ref.label,
25
+ value = _ref.value,
26
+ dataTestid = _ref.dataTestid;
27
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
28
+ className: "flex w-full flex-col gap-1",
29
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
30
+ className: "flex items-center justify-between",
31
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
32
+ style: "h6",
33
+ children: label
34
+ })
35
+ }), /*#__PURE__*/jsxRuntime.jsxs("code", {
36
+ className: "neeto-ui-text-gray-800 neeto-ui-bg-gray-100 neeto-ui-rounded-md relative block p-2 pe-10 font-mono text-xs break-all",
37
+ "data-testid": dataTestid,
38
+ children: [value, /*#__PURE__*/jsxRuntime.jsx(CopyToClipboardButton, {
39
+ value: value,
40
+ className: "absolute top-1 end-1 shrink-0",
41
+ style: "tertiary"
42
+ })]
43
+ })]
44
+ });
45
+ };
46
+
47
+ var DnsRecordsSection = function DnsRecordsSection(_ref) {
48
+ var dnsRecords = _ref.dnsRecords,
49
+ domain = _ref.domain,
50
+ sparkpostData = _ref.sparkpostData,
51
+ _ref$showTitle = _ref.showTitle,
52
+ showTitle = _ref$showTitle === void 0 ? true : _ref$showTitle;
53
+ var _useTranslation = reactI18next.useTranslation(),
54
+ t = _useTranslation.t;
55
+ var formatPurpose = function formatPurpose(purpose) {
56
+ switch (purpose) {
57
+ case "dkim":
58
+ return t("neetoEmailDelivery.sparkpost.dnsRecords.dkimSigning");
59
+ case "txt":
60
+ return t("neetoEmailDelivery.sparkpost.dnsRecords.txtVerification");
61
+ default:
62
+ return purpose;
63
+ }
64
+ };
65
+ var formatRecordName = function formatRecordName(hostname) {
66
+ if (!hostname) return "";
67
+ return hostname.endsWith(".".concat(domain)) ? hostname : "".concat(hostname, ".").concat(domain);
68
+ };
69
+ var status = sparkpostData.status,
70
+ txtVerificationValue = sparkpostData.txtVerificationValue,
71
+ txtVerificationHostname = sparkpostData.txtVerificationHostname;
72
+ var allRecords = [];
73
+ var isTxtUnverified = status === "txt_unverified";
74
+ if (isTxtUnverified) {
75
+ if (txtVerificationValue && txtVerificationHostname) {
76
+ allRecords.push({
77
+ type: "TXT",
78
+ purpose: "txt",
79
+ hostname: txtVerificationHostname,
80
+ value: txtVerificationValue
81
+ });
82
+ }
83
+ } else {
84
+ allRecords.push.apply(allRecords, _toConsumableArray(dnsRecords));
85
+ }
86
+ if (ramda.isEmpty(allRecords)) {
87
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
88
+ className: "p-8 text-center",
89
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
90
+ className: "neeto-ui-text-gray-600",
91
+ style: "body2",
92
+ children: sparkpostData !== null && sparkpostData !== void 0 && sparkpostData.connected ? t("neetoEmailDelivery.sparkpost.dnsRecords.alreadyVerified") : t("neetoEmailDelivery.sparkpost.dnsRecords.loading")
93
+ })
94
+ });
95
+ }
96
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
97
+ className: "flex flex-col gap-2",
98
+ children: [showTitle && /*#__PURE__*/jsxRuntime.jsx(Typography, {
99
+ style: "h4",
100
+ weight: "medium",
101
+ children: t("neetoEmailDelivery.sparkpost.dnsRecords.title")
102
+ }), allRecords.map(function (record, index) {
103
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
104
+ className: "neeto-ui-rounded-lg neeto-ui-bg-white neeto-ui-border-gray-300 border p-2",
105
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
106
+ className: "mb-2 flex items-center justify-between",
107
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
108
+ className: "flex items-center gap-2",
109
+ children: [/*#__PURE__*/jsxRuntime.jsx(Tag, {
110
+ label: formatPurpose(record.purpose),
111
+ size: "small",
112
+ style: PageLayout.PURPOSE_COLORS[record.purpose] || PageLayout.DEFAULT_COLOR
113
+ }), /*#__PURE__*/jsxRuntime.jsx(Tag, {
114
+ label: record.type,
115
+ size: "small",
116
+ style: "secondary"
117
+ })]
118
+ })
119
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
120
+ className: "flex flex-col gap-2",
121
+ children: [/*#__PURE__*/jsxRuntime.jsx(RecordField, {
122
+ dataTestid: "record-name",
123
+ label: t("neetoEmailDelivery.sparkpost.dnsRecords.nameLabel"),
124
+ value: formatRecordName(record.hostname)
125
+ }), /*#__PURE__*/jsxRuntime.jsx(RecordField, {
126
+ dataTestid: "record-value",
127
+ label: t("neetoEmailDelivery.sparkpost.dnsRecords.valueLabel"),
128
+ value: record.value
129
+ })]
130
+ })]
131
+ }, index);
132
+ })]
133
+ });
134
+ };
135
+
136
+ var VerificationActions = reactUtils.withT(function (_ref) {
137
+ var t = _ref.t,
138
+ isVerifying = _ref.isVerifying,
139
+ verificationStatus = _ref.verificationStatus,
140
+ onVerify = _ref.onVerify,
141
+ onCancel = _ref.onCancel;
142
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
143
+ className: "flex gap-3",
144
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
145
+ "data-testid": "verify-domain-button",
146
+ disabled: isVerifying || verificationStatus === "success",
147
+ loading: isVerifying,
148
+ onClick: onVerify,
149
+ children: isVerifying ? t("neetoEmailDelivery.sparkpost.verify.verifying") : t("neetoEmailDelivery.sparkpost.verify.verifyDomain")
150
+ }), /*#__PURE__*/jsxRuntime.jsx(Button, {
151
+ "data-testid": "cancel-button",
152
+ disabled: isVerifying,
153
+ style: "secondary",
154
+ onClick: onCancel,
155
+ children: t("neetoEmailDelivery.sparkpost.verify.cancel")
156
+ })]
157
+ });
158
+ });
159
+
160
+ var VerificationInstructions = function VerificationInstructions() {
161
+ var _useTranslation = reactI18next.useTranslation(),
162
+ t = _useTranslation.t;
163
+ var instructionText = t("neetoEmailDelivery.sparkpost.instructions.fullText");
164
+ var lines = instructionText.split("\n");
165
+ return /*#__PURE__*/jsxRuntime.jsx(Callout, {
166
+ style: "info",
167
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
168
+ className: "w-full",
169
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
170
+ style: "body2",
171
+ children: lines.map(function (line, index) {
172
+ return /*#__PURE__*/jsxRuntime.jsxs("span", {
173
+ children: [line, index < lines.length - 1 && /*#__PURE__*/jsxRuntime.jsx("br", {})]
174
+ }, index);
175
+ })
176
+ })
177
+ })
178
+ });
179
+ };
180
+
181
+ var VerificationStatusCallout = function VerificationStatusCallout(_ref) {
182
+ var verificationStatus = _ref.verificationStatus;
183
+ var _useTranslation = reactI18next.useTranslation(),
184
+ t = _useTranslation.t;
185
+ var config = PageLayout.VERIFICATION_STATUS_CONFIG[verificationStatus];
186
+ if (!config) return null;
187
+ return /*#__PURE__*/jsxRuntime.jsx(Callout, {
188
+ style: config.style,
189
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
190
+ className: "space-y-1",
191
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
192
+ style: "body2",
193
+ weight: "medium",
194
+ children: t(config.titleKey)
195
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
196
+ style: "body3",
197
+ children: t(config.descriptionKey)
198
+ })]
199
+ })
200
+ });
201
+ };
202
+
203
+ var SparkpostDomainVerify = function SparkpostDomainVerify(_ref) {
204
+ var ownerId = _ref.ownerId,
205
+ canManageIntegrations = _ref.canManageIntegrations,
206
+ emailDeliveryIndexRoute = _ref.emailDeliveryIndexRoute;
207
+ var _useState = react.useState(""),
208
+ _useState2 = _slicedToArray(_useState, 2),
209
+ verificationStatus = _useState2[0],
210
+ setVerificationStatus = _useState2[1];
211
+ var _useTranslation = reactI18next.useTranslation(),
212
+ t = _useTranslation.t;
213
+ var history = reactRouterDom.useHistory();
214
+ var _useFetchConnectedInt = useEmailDeliveryIntegrationApi.useFetchConnectedIntegration(ownerId),
215
+ integration = _useFetchConnectedInt.integration,
216
+ isIntegrationLoading = _useFetchConnectedInt.isLoading;
217
+ var hasConnectedIntegration = integration && !integration.isPending;
218
+ var _useQueryParams = reactUtils.useQueryParams(),
219
+ queryDomain = _useQueryParams.domain;
220
+ var _useFetchSparkpostDom = useSparkpostApi.useFetchSparkpostDomain(ownerId),
221
+ sparkpostData = _useFetchSparkpostDom.data,
222
+ isLoading = _useFetchSparkpostDom.isLoading;
223
+ var _useSparkpostDomain = useSparkpostDomain.useSparkpostDomain({
224
+ ownerId: ownerId,
225
+ canManageIntegrations: canManageIntegrations
226
+ }),
227
+ onVerifyDomain = _useSparkpostDomain.onVerifyDomain,
228
+ isVerifying = _useSparkpostDomain.isVerifying;
229
+ var domain = ramda.pathOr(queryDomain, ["domain"], sparkpostData);
230
+ var dnsRecords = ramda.pathOr([], ["verificationRecords"], sparkpostData);
231
+ react.useEffect(function () {
232
+ // Check if domain is already verified
233
+ if (!(sparkpostData !== null && sparkpostData !== void 0 && sparkpostData.connected)) return;
234
+ setVerificationStatus(PageLayout.VERIFICATION_STATUSES.SUCCESS);
235
+ setTimeout(function () {
236
+ history.push(emailDeliveryIndexRoute);
237
+ }, 5000);
238
+ }, [sparkpostData, emailDeliveryIndexRoute, history]);
239
+ var handleVerify = function handleVerify() {
240
+ onVerifyDomain(function (response) {
241
+ if ((response === null || response === void 0 ? void 0 : response.status) === "active") {
242
+ setVerificationStatus(PageLayout.VERIFICATION_STATUSES.SUCCESS);
243
+ setTimeout(function () {
244
+ history.push(emailDeliveryIndexRoute);
245
+ }, 3000);
246
+ } else {
247
+ setVerificationStatus(PageLayout.VERIFICATION_STATUSES.PENDING);
248
+ }
249
+ }, function (_error) {
250
+ setVerificationStatus(PageLayout.VERIFICATION_STATUSES.ERROR);
251
+ });
252
+ };
253
+ var isVerificationSuccessful = verificationStatus === PageLayout.VERIFICATION_STATUSES.SUCCESS;
254
+ var handleCancel = function handleCancel() {
255
+ history.push(emailDeliveryIndexRoute);
256
+ };
257
+ if (isLoading || isIntegrationLoading) {
258
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
259
+ className: "flex justify-center p-6",
260
+ children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
261
+ });
262
+ }
263
+ if (hasConnectedIntegration) {
264
+ history.replace(emailDeliveryIndexRoute);
265
+ return null;
266
+ }
267
+ return /*#__PURE__*/jsxRuntime.jsx(PageLayout.PageWrapper, {
268
+ children: /*#__PURE__*/jsxRuntime.jsx(PageLayout.PageContent, {
269
+ children: /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
270
+ title: t("neetoEmailDelivery.sparkpost.verify.title"),
271
+ actionBlock: /*#__PURE__*/jsxRuntime.jsx(VerificationActions, {
272
+ isVerifying: isVerifying,
273
+ verificationStatus: verificationStatus,
274
+ onCancel: handleCancel,
275
+ onVerify: handleVerify
276
+ }),
277
+ description: t("neetoEmailDelivery.sparkpost.verify.description", {
278
+ domain: domain
279
+ }).replace(/<strong>|<\/strong>/g, ""),
280
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
281
+ className: "flex flex-col gap-4",
282
+ children: [/*#__PURE__*/jsxRuntime.jsx(VerificationStatusCallout, {
283
+ verificationStatus: verificationStatus
284
+ }), !isVerificationSuccessful && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
285
+ children: [/*#__PURE__*/jsxRuntime.jsx(DnsRecordsSection, {
286
+ dnsRecords: dnsRecords,
287
+ domain: domain,
288
+ sparkpostData: sparkpostData
289
+ }), /*#__PURE__*/jsxRuntime.jsx(VerificationInstructions, {})]
290
+ })]
291
+ })
292
+ })
293
+ })
294
+ });
295
+ };
296
+
297
+ exports.DnsRecordsSection = DnsRecordsSection;
298
+ exports.SparkpostDomainVerify = SparkpostDomainVerify;
299
+ //# sourceMappingURL=Verify-BDOXn-By.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Verify-BDOXn-By.js","sources":["../app/javascript/src/components/SparkpostDomain/RecordField.jsx","../app/javascript/src/components/SparkpostDomain/DnsRecordsSection.jsx","../app/javascript/src/components/SparkpostDomain/VerificationActions.jsx","../app/javascript/src/components/SparkpostDomain/VerificationInstructions.jsx","../app/javascript/src/components/SparkpostDomain/VerificationStatusCallout.jsx","../app/javascript/src/components/SparkpostDomain/Verify.jsx"],"sourcesContent":["import CopyToClipboardButton from \"neetomolecules/CopyToClipboardButton\";\nimport { Typography } from \"neetoui\";\n\nconst RecordField = ({ label, value, dataTestid }) => (\n <div className=\"flex w-full flex-col gap-1\">\n <div className=\"flex items-center justify-between\">\n <Typography style=\"h6\">{label}</Typography>\n </div>\n <code\n className=\"neeto-ui-text-gray-800 neeto-ui-bg-gray-100 neeto-ui-rounded-md relative block p-2 pe-10 font-mono text-xs break-all\"\n data-testid={dataTestid}\n >\n {value}\n <CopyToClipboardButton\n {...{ value }}\n className=\"absolute top-1 end-1 shrink-0\"\n style=\"tertiary\"\n />\n </code>\n </div>\n);\n\nexport default RecordField;\n","import { Typography, Tag } from \"neetoui\";\nimport { isEmpty } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { PURPOSE_COLORS, DEFAULT_COLOR } from \"./constants\";\nimport RecordField from \"./RecordField\";\n\nconst DnsRecordsSection = ({\n dnsRecords,\n domain,\n sparkpostData,\n showTitle = true,\n}) => {\n const { t } = useTranslation();\n\n const formatPurpose = purpose => {\n switch (purpose) {\n case \"dkim\":\n return t(\"neetoEmailDelivery.sparkpost.dnsRecords.dkimSigning\");\n case \"txt\":\n return t(\"neetoEmailDelivery.sparkpost.dnsRecords.txtVerification\");\n default:\n return purpose;\n }\n };\n\n const formatRecordName = hostname => {\n if (!hostname) return \"\";\n\n return hostname.endsWith(`.${domain}`) ? hostname : `${hostname}.${domain}`;\n };\n\n const { status, txtVerificationValue, txtVerificationHostname } =\n sparkpostData;\n\n const allRecords = [];\n const isTxtUnverified = status === \"txt_unverified\";\n\n if (isTxtUnverified) {\n if (txtVerificationValue && txtVerificationHostname) {\n allRecords.push({\n type: \"TXT\",\n purpose: \"txt\",\n hostname: txtVerificationHostname,\n value: txtVerificationValue,\n });\n }\n } else {\n allRecords.push(...dnsRecords);\n }\n\n if (isEmpty(allRecords)) {\n return (\n <div className=\"p-8 text-center\">\n <Typography className=\"neeto-ui-text-gray-600\" style=\"body2\">\n {sparkpostData?.connected\n ? t(\"neetoEmailDelivery.sparkpost.dnsRecords.alreadyVerified\")\n : t(\"neetoEmailDelivery.sparkpost.dnsRecords.loading\")}\n </Typography>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-2\">\n {showTitle && (\n <Typography style=\"h4\" weight=\"medium\">\n {t(\"neetoEmailDelivery.sparkpost.dnsRecords.title\")}\n </Typography>\n )}\n {allRecords.map((record, index) => (\n <div\n className=\"neeto-ui-rounded-lg neeto-ui-bg-white neeto-ui-border-gray-300 border p-2\"\n key={index}\n >\n <div className=\"mb-2 flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n <Tag\n label={formatPurpose(record.purpose)}\n size=\"small\"\n style={PURPOSE_COLORS[record.purpose] || DEFAULT_COLOR}\n />\n <Tag label={record.type} size=\"small\" style=\"secondary\" />\n </div>\n </div>\n <div className=\"flex flex-col gap-2\">\n <RecordField\n dataTestid=\"record-name\"\n label={t(\"neetoEmailDelivery.sparkpost.dnsRecords.nameLabel\")}\n value={formatRecordName(record.hostname)}\n />\n <RecordField\n dataTestid=\"record-value\"\n label={t(\"neetoEmailDelivery.sparkpost.dnsRecords.valueLabel\")}\n value={record.value}\n />\n </div>\n </div>\n ))}\n </div>\n );\n};\n\nexport default DnsRecordsSection;\n","import { withT } from \"neetocommons/react-utils\";\nimport { Button } from \"neetoui\";\n\nconst VerificationActions = withT(\n ({ t, isVerifying, verificationStatus, onVerify, onCancel }) => (\n <div className=\"flex gap-3\">\n <Button\n data-testid=\"verify-domain-button\"\n disabled={isVerifying || verificationStatus === \"success\"}\n loading={isVerifying}\n onClick={onVerify}\n >\n {isVerifying\n ? t(\"neetoEmailDelivery.sparkpost.verify.verifying\")\n : t(\"neetoEmailDelivery.sparkpost.verify.verifyDomain\")}\n </Button>\n <Button\n data-testid=\"cancel-button\"\n disabled={isVerifying}\n style=\"secondary\"\n onClick={onCancel}\n >\n {t(\"neetoEmailDelivery.sparkpost.verify.cancel\")}\n </Button>\n </div>\n )\n);\n\nexport default VerificationActions;\n","import { Typography, Callout } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\n\nconst VerificationInstructions = () => {\n const { t } = useTranslation();\n\n const instructionText = t(\n \"neetoEmailDelivery.sparkpost.instructions.fullText\"\n );\n const lines = instructionText.split(\"\\n\");\n\n return (\n <Callout style=\"info\">\n <div className=\"w-full\">\n <Typography style=\"body2\">\n {lines.map((line, index) => (\n <span key={index}>\n {line}\n {index < lines.length - 1 && <br />}\n </span>\n ))}\n </Typography>\n </div>\n </Callout>\n );\n};\n\nexport default VerificationInstructions;\n","import { Callout, Typography } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { VERIFICATION_STATUS_CONFIG } from \"./constants\";\n\nconst VerificationStatusCallout = ({ verificationStatus }) => {\n const { t } = useTranslation();\n\n const config = VERIFICATION_STATUS_CONFIG[verificationStatus];\n\n if (!config) return null;\n\n return (\n <Callout style={config.style}>\n <div className=\"space-y-1\">\n <Typography style=\"body2\" weight=\"medium\">\n {t(config.titleKey)}\n </Typography>\n <Typography style=\"body3\">{t(config.descriptionKey)}</Typography>\n </div>\n </Callout>\n );\n};\n\nexport default VerificationStatusCallout;\n","import { useState, useEffect } from \"react\";\n\nimport { useQueryParams } from \"neetocommons/react-utils\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport { Spinner } from \"neetoui\";\nimport { pathOr } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport { PageContent, PageWrapper } from \"components/PageLayout\";\nimport useSparkpostDomain from \"hooks/integrations/useSparkpostDomain\";\nimport { useFetchConnectedIntegration } from \"hooks/reactQuery/integrations/useEmailDeliveryIntegrationApi\";\nimport { useFetchSparkpostDomain } from \"hooks/reactQuery/integrations/useSparkpostApi\";\n\nimport { VERIFICATION_STATUSES } from \"./constants\";\nimport DnsRecordsSection from \"./DnsRecordsSection\";\nimport VerificationActions from \"./VerificationActions\";\nimport VerificationInstructions from \"./VerificationInstructions\";\nimport VerificationStatusCallout from \"./VerificationStatusCallout\";\n\nconst SparkpostDomainVerify = ({\n ownerId,\n canManageIntegrations,\n emailDeliveryIndexRoute,\n}) => {\n const [verificationStatus, setVerificationStatus] = useState(\"\");\n const { t } = useTranslation();\n\n const history = useHistory();\n\n const { integration, isLoading: isIntegrationLoading } =\n useFetchConnectedIntegration(ownerId);\n\n const hasConnectedIntegration = integration && !integration.isPending;\n\n const { domain: queryDomain } = useQueryParams();\n\n const { data: sparkpostData, isLoading } = useFetchSparkpostDomain(ownerId);\n const { onVerifyDomain, isVerifying } = useSparkpostDomain({\n ownerId,\n canManageIntegrations,\n });\n\n const domain = pathOr(queryDomain, [\"domain\"], sparkpostData);\n const dnsRecords = pathOr([], [\"verificationRecords\"], sparkpostData);\n\n useEffect(() => {\n // Check if domain is already verified\n if (!sparkpostData?.connected) return;\n setVerificationStatus(VERIFICATION_STATUSES.SUCCESS);\n setTimeout(() => {\n history.push(emailDeliveryIndexRoute);\n }, 5000);\n }, [sparkpostData, emailDeliveryIndexRoute, history]);\n\n const handleVerify = () => {\n onVerifyDomain(\n response => {\n if (response?.status === \"active\") {\n setVerificationStatus(VERIFICATION_STATUSES.SUCCESS);\n setTimeout(() => {\n history.push(emailDeliveryIndexRoute);\n }, 3000);\n } else {\n setVerificationStatus(VERIFICATION_STATUSES.PENDING);\n }\n },\n _error => {\n setVerificationStatus(VERIFICATION_STATUSES.ERROR);\n }\n );\n };\n\n const isVerificationSuccessful =\n verificationStatus === VERIFICATION_STATUSES.SUCCESS;\n\n const handleCancel = () => {\n history.push(emailDeliveryIndexRoute);\n };\n\n if (isLoading || isIntegrationLoading) {\n return (\n <div className=\"flex justify-center p-6\">\n <Spinner />\n </div>\n );\n }\n\n if (hasConnectedIntegration) {\n history.replace(emailDeliveryIndexRoute);\n\n return null;\n }\n\n return (\n <PageWrapper>\n <PageContent>\n <CardLayout\n title={t(\"neetoEmailDelivery.sparkpost.verify.title\")}\n actionBlock={\n <VerificationActions\n {...{ isVerifying, verificationStatus }}\n onCancel={handleCancel}\n onVerify={handleVerify}\n />\n }\n description={t(\"neetoEmailDelivery.sparkpost.verify.description\", {\n domain,\n }).replace(/<strong>|<\\/strong>/g, \"\")}\n >\n <div className=\"flex flex-col gap-4\">\n <VerificationStatusCallout {...{ verificationStatus }} />\n {!isVerificationSuccessful && (\n <>\n <DnsRecordsSection {...{ dnsRecords, domain, sparkpostData }} />\n <VerificationInstructions />\n </>\n )}\n </div>\n </CardLayout>\n </PageContent>\n </PageWrapper>\n );\n};\n\nexport default SparkpostDomainVerify;\n"],"names":["RecordField","_ref","label","value","dataTestid","_jsxs","className","children","_jsx","Typography","style","CopyToClipboardButton","DnsRecordsSection","dnsRecords","domain","sparkpostData","_ref$showTitle","showTitle","_useTranslation","useTranslation","t","formatPurpose","purpose","formatRecordName","hostname","endsWith","concat","status","txtVerificationValue","txtVerificationHostname","allRecords","isTxtUnverified","push","type","apply","_toConsumableArray","isEmpty","connected","weight","map","record","index","Tag","size","PURPOSE_COLORS","DEFAULT_COLOR","VerificationActions","withT","isVerifying","verificationStatus","onVerify","onCancel","Button","disabled","loading","onClick","VerificationInstructions","instructionText","lines","split","Callout","line","length","VerificationStatusCallout","config","VERIFICATION_STATUS_CONFIG","titleKey","descriptionKey","SparkpostDomainVerify","ownerId","canManageIntegrations","emailDeliveryIndexRoute","_useState","useState","_useState2","_slicedToArray","setVerificationStatus","history","useHistory","_useFetchConnectedInt","useFetchConnectedIntegration","integration","isIntegrationLoading","isLoading","hasConnectedIntegration","isPending","_useQueryParams","useQueryParams","queryDomain","_useFetchSparkpostDom","useFetchSparkpostDomain","data","_useSparkpostDomain","useSparkpostDomain","onVerifyDomain","pathOr","useEffect","VERIFICATION_STATUSES","SUCCESS","setTimeout","handleVerify","response","PENDING","_error","ERROR","isVerificationSuccessful","handleCancel","Spinner","replace","PageWrapper","PageContent","CardLayout","title","actionBlock","description","_Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAMC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;IAAEC,UAAU,GAAAH,IAAA,CAAVG,UAAU;AAAA,EAAA,oBAC7CC,eAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,4BAA4B;AAAAC,IAAAA,QAAA,gBACzCC,cAAA,CAA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2CAA2C,CAAE;QACtD6F,WAAW,eACTzG,cAAA,CAACsC,mBAAmB,EAAA;AACZE,UAAAA,WAAW,EAAXA,WAAW;AAAEC,UAAAA,kBAAkB,EAAlBA,kBAAkB;AACrCE,UAAAA,QAAQ,EAAEuD,YAAa;AACvBxD,UAAAA,QAAQ,EAAEkD;AAAa,SACxB,CACF;AACDc,QAAAA,WAAW,EAAE9F,CAAC,CAAC,iDAAiD,EAAE;AAChEN,UAAAA,MAAM,EAANA;AACF,SAAC,CAAC,CAAC8F,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAE;AAAArG,QAAAA,QAAA,eAEvCF,eAAA,CAAA,KAAA,EAAA;AAAKC,UAAAA,SAAS,EAAC,qBAAqB;UAAAC,QAAA,EAAA,cAClCC,cAAA,CAACuD,yBAAyB,EAAA;AAAOd,YAAAA,kBAAkB,EAAlBA;AAAkB,WAAK,CAAC,EACxD,CAACwD,wBAAwB,iBACxBpG,eAAA,CAAA8G,mBAAA,EAAA;YAAA5G,QAAA,EAAA,cACEC,cAAA,CAACI,iBAAiB,EAAA;AAAOC,cAAAA,UAAU,EAAVA,UAAU;AAAEC,cAAAA,MAAM,EAANA,MAAM;AAAEC,cAAAA,aAAa,EAAbA;AAAa,aAAK,CAAC,eAChEP,cAAA,CAACgD,wBAAwB,IAAE,CAAC;AAAA,WAC5B,CACH;SACE;OACK;KACD;AAAC,GACH,CAAC;AAElB;;;;;"}
@@ -0,0 +1,296 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import { useState, useEffect } from 'react';
3
+ import { withT, useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
4
+ import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
5
+ import Spinner from '@bigbinary/neetoui/Spinner';
6
+ import { isEmpty, pathOr } from 'ramda';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { useHistory } from 'react-router-dom';
9
+ import { b as PURPOSE_COLORS, D as DEFAULT_COLOR, c as VERIFICATION_STATUS_CONFIG, d as VERIFICATION_STATUSES, P as PageWrapper, a as PageContent } from './PageLayout-RWJHf21f.js';
10
+ import { u as useSparkpostDomain } from './useSparkpostDomain-DA1nrWS3.js';
11
+ import { u as useFetchConnectedIntegration } from './useEmailDeliveryIntegrationApi-Dk9WPotT.js';
12
+ import { b as useFetchSparkpostDomain } from './useSparkpostApi-B-D8RNRF.js';
13
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
14
+ import Typography from '@bigbinary/neetoui/Typography';
15
+ import Tag from '@bigbinary/neetoui/Tag';
16
+ import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardButton';
17
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
18
+ import Button from '@bigbinary/neetoui/Button';
19
+ import Callout from '@bigbinary/neetoui/Callout';
20
+
21
+ var RecordField = function RecordField(_ref) {
22
+ var label = _ref.label,
23
+ value = _ref.value,
24
+ dataTestid = _ref.dataTestid;
25
+ return /*#__PURE__*/jsxs("div", {
26
+ className: "flex w-full flex-col gap-1",
27
+ children: [/*#__PURE__*/jsx("div", {
28
+ className: "flex items-center justify-between",
29
+ children: /*#__PURE__*/jsx(Typography, {
30
+ style: "h6",
31
+ children: label
32
+ })
33
+ }), /*#__PURE__*/jsxs("code", {
34
+ className: "neeto-ui-text-gray-800 neeto-ui-bg-gray-100 neeto-ui-rounded-md relative block p-2 pe-10 font-mono text-xs break-all",
35
+ "data-testid": dataTestid,
36
+ children: [value, /*#__PURE__*/jsx(CopyToClipboardButton, {
37
+ value: value,
38
+ className: "absolute top-1 end-1 shrink-0",
39
+ style: "tertiary"
40
+ })]
41
+ })]
42
+ });
43
+ };
44
+
45
+ var DnsRecordsSection = function DnsRecordsSection(_ref) {
46
+ var dnsRecords = _ref.dnsRecords,
47
+ domain = _ref.domain,
48
+ sparkpostData = _ref.sparkpostData,
49
+ _ref$showTitle = _ref.showTitle,
50
+ showTitle = _ref$showTitle === void 0 ? true : _ref$showTitle;
51
+ var _useTranslation = useTranslation(),
52
+ t = _useTranslation.t;
53
+ var formatPurpose = function formatPurpose(purpose) {
54
+ switch (purpose) {
55
+ case "dkim":
56
+ return t("neetoEmailDelivery.sparkpost.dnsRecords.dkimSigning");
57
+ case "txt":
58
+ return t("neetoEmailDelivery.sparkpost.dnsRecords.txtVerification");
59
+ default:
60
+ return purpose;
61
+ }
62
+ };
63
+ var formatRecordName = function formatRecordName(hostname) {
64
+ if (!hostname) return "";
65
+ return hostname.endsWith(".".concat(domain)) ? hostname : "".concat(hostname, ".").concat(domain);
66
+ };
67
+ var status = sparkpostData.status,
68
+ txtVerificationValue = sparkpostData.txtVerificationValue,
69
+ txtVerificationHostname = sparkpostData.txtVerificationHostname;
70
+ var allRecords = [];
71
+ var isTxtUnverified = status === "txt_unverified";
72
+ if (isTxtUnverified) {
73
+ if (txtVerificationValue && txtVerificationHostname) {
74
+ allRecords.push({
75
+ type: "TXT",
76
+ purpose: "txt",
77
+ hostname: txtVerificationHostname,
78
+ value: txtVerificationValue
79
+ });
80
+ }
81
+ } else {
82
+ allRecords.push.apply(allRecords, _toConsumableArray(dnsRecords));
83
+ }
84
+ if (isEmpty(allRecords)) {
85
+ return /*#__PURE__*/jsx("div", {
86
+ className: "p-8 text-center",
87
+ children: /*#__PURE__*/jsx(Typography, {
88
+ className: "neeto-ui-text-gray-600",
89
+ style: "body2",
90
+ children: sparkpostData !== null && sparkpostData !== void 0 && sparkpostData.connected ? t("neetoEmailDelivery.sparkpost.dnsRecords.alreadyVerified") : t("neetoEmailDelivery.sparkpost.dnsRecords.loading")
91
+ })
92
+ });
93
+ }
94
+ return /*#__PURE__*/jsxs("div", {
95
+ className: "flex flex-col gap-2",
96
+ children: [showTitle && /*#__PURE__*/jsx(Typography, {
97
+ style: "h4",
98
+ weight: "medium",
99
+ children: t("neetoEmailDelivery.sparkpost.dnsRecords.title")
100
+ }), allRecords.map(function (record, index) {
101
+ return /*#__PURE__*/jsxs("div", {
102
+ className: "neeto-ui-rounded-lg neeto-ui-bg-white neeto-ui-border-gray-300 border p-2",
103
+ children: [/*#__PURE__*/jsx("div", {
104
+ className: "mb-2 flex items-center justify-between",
105
+ children: /*#__PURE__*/jsxs("div", {
106
+ className: "flex items-center gap-2",
107
+ children: [/*#__PURE__*/jsx(Tag, {
108
+ label: formatPurpose(record.purpose),
109
+ size: "small",
110
+ style: PURPOSE_COLORS[record.purpose] || DEFAULT_COLOR
111
+ }), /*#__PURE__*/jsx(Tag, {
112
+ label: record.type,
113
+ size: "small",
114
+ style: "secondary"
115
+ })]
116
+ })
117
+ }), /*#__PURE__*/jsxs("div", {
118
+ className: "flex flex-col gap-2",
119
+ children: [/*#__PURE__*/jsx(RecordField, {
120
+ dataTestid: "record-name",
121
+ label: t("neetoEmailDelivery.sparkpost.dnsRecords.nameLabel"),
122
+ value: formatRecordName(record.hostname)
123
+ }), /*#__PURE__*/jsx(RecordField, {
124
+ dataTestid: "record-value",
125
+ label: t("neetoEmailDelivery.sparkpost.dnsRecords.valueLabel"),
126
+ value: record.value
127
+ })]
128
+ })]
129
+ }, index);
130
+ })]
131
+ });
132
+ };
133
+
134
+ var VerificationActions = withT(function (_ref) {
135
+ var t = _ref.t,
136
+ isVerifying = _ref.isVerifying,
137
+ verificationStatus = _ref.verificationStatus,
138
+ onVerify = _ref.onVerify,
139
+ onCancel = _ref.onCancel;
140
+ return /*#__PURE__*/jsxs("div", {
141
+ className: "flex gap-3",
142
+ children: [/*#__PURE__*/jsx(Button, {
143
+ "data-testid": "verify-domain-button",
144
+ disabled: isVerifying || verificationStatus === "success",
145
+ loading: isVerifying,
146
+ onClick: onVerify,
147
+ children: isVerifying ? t("neetoEmailDelivery.sparkpost.verify.verifying") : t("neetoEmailDelivery.sparkpost.verify.verifyDomain")
148
+ }), /*#__PURE__*/jsx(Button, {
149
+ "data-testid": "cancel-button",
150
+ disabled: isVerifying,
151
+ style: "secondary",
152
+ onClick: onCancel,
153
+ children: t("neetoEmailDelivery.sparkpost.verify.cancel")
154
+ })]
155
+ });
156
+ });
157
+
158
+ var VerificationInstructions = function VerificationInstructions() {
159
+ var _useTranslation = useTranslation(),
160
+ t = _useTranslation.t;
161
+ var instructionText = t("neetoEmailDelivery.sparkpost.instructions.fullText");
162
+ var lines = instructionText.split("\n");
163
+ return /*#__PURE__*/jsx(Callout, {
164
+ style: "info",
165
+ children: /*#__PURE__*/jsx("div", {
166
+ className: "w-full",
167
+ children: /*#__PURE__*/jsx(Typography, {
168
+ style: "body2",
169
+ children: lines.map(function (line, index) {
170
+ return /*#__PURE__*/jsxs("span", {
171
+ children: [line, index < lines.length - 1 && /*#__PURE__*/jsx("br", {})]
172
+ }, index);
173
+ })
174
+ })
175
+ })
176
+ });
177
+ };
178
+
179
+ var VerificationStatusCallout = function VerificationStatusCallout(_ref) {
180
+ var verificationStatus = _ref.verificationStatus;
181
+ var _useTranslation = useTranslation(),
182
+ t = _useTranslation.t;
183
+ var config = VERIFICATION_STATUS_CONFIG[verificationStatus];
184
+ if (!config) return null;
185
+ return /*#__PURE__*/jsx(Callout, {
186
+ style: config.style,
187
+ children: /*#__PURE__*/jsxs("div", {
188
+ className: "space-y-1",
189
+ children: [/*#__PURE__*/jsx(Typography, {
190
+ style: "body2",
191
+ weight: "medium",
192
+ children: t(config.titleKey)
193
+ }), /*#__PURE__*/jsx(Typography, {
194
+ style: "body3",
195
+ children: t(config.descriptionKey)
196
+ })]
197
+ })
198
+ });
199
+ };
200
+
201
+ var SparkpostDomainVerify = function SparkpostDomainVerify(_ref) {
202
+ var ownerId = _ref.ownerId,
203
+ canManageIntegrations = _ref.canManageIntegrations,
204
+ emailDeliveryIndexRoute = _ref.emailDeliveryIndexRoute;
205
+ var _useState = useState(""),
206
+ _useState2 = _slicedToArray(_useState, 2),
207
+ verificationStatus = _useState2[0],
208
+ setVerificationStatus = _useState2[1];
209
+ var _useTranslation = useTranslation(),
210
+ t = _useTranslation.t;
211
+ var history = useHistory();
212
+ var _useFetchConnectedInt = useFetchConnectedIntegration(ownerId),
213
+ integration = _useFetchConnectedInt.integration,
214
+ isIntegrationLoading = _useFetchConnectedInt.isLoading;
215
+ var hasConnectedIntegration = integration && !integration.isPending;
216
+ var _useQueryParams = useQueryParams(),
217
+ queryDomain = _useQueryParams.domain;
218
+ var _useFetchSparkpostDom = useFetchSparkpostDomain(ownerId),
219
+ sparkpostData = _useFetchSparkpostDom.data,
220
+ isLoading = _useFetchSparkpostDom.isLoading;
221
+ var _useSparkpostDomain = useSparkpostDomain({
222
+ ownerId: ownerId,
223
+ canManageIntegrations: canManageIntegrations
224
+ }),
225
+ onVerifyDomain = _useSparkpostDomain.onVerifyDomain,
226
+ isVerifying = _useSparkpostDomain.isVerifying;
227
+ var domain = pathOr(queryDomain, ["domain"], sparkpostData);
228
+ var dnsRecords = pathOr([], ["verificationRecords"], sparkpostData);
229
+ useEffect(function () {
230
+ // Check if domain is already verified
231
+ if (!(sparkpostData !== null && sparkpostData !== void 0 && sparkpostData.connected)) return;
232
+ setVerificationStatus(VERIFICATION_STATUSES.SUCCESS);
233
+ setTimeout(function () {
234
+ history.push(emailDeliveryIndexRoute);
235
+ }, 5000);
236
+ }, [sparkpostData, emailDeliveryIndexRoute, history]);
237
+ var handleVerify = function handleVerify() {
238
+ onVerifyDomain(function (response) {
239
+ if ((response === null || response === void 0 ? void 0 : response.status) === "active") {
240
+ setVerificationStatus(VERIFICATION_STATUSES.SUCCESS);
241
+ setTimeout(function () {
242
+ history.push(emailDeliveryIndexRoute);
243
+ }, 3000);
244
+ } else {
245
+ setVerificationStatus(VERIFICATION_STATUSES.PENDING);
246
+ }
247
+ }, function (_error) {
248
+ setVerificationStatus(VERIFICATION_STATUSES.ERROR);
249
+ });
250
+ };
251
+ var isVerificationSuccessful = verificationStatus === VERIFICATION_STATUSES.SUCCESS;
252
+ var handleCancel = function handleCancel() {
253
+ history.push(emailDeliveryIndexRoute);
254
+ };
255
+ if (isLoading || isIntegrationLoading) {
256
+ return /*#__PURE__*/jsx("div", {
257
+ className: "flex justify-center p-6",
258
+ children: /*#__PURE__*/jsx(Spinner, {})
259
+ });
260
+ }
261
+ if (hasConnectedIntegration) {
262
+ history.replace(emailDeliveryIndexRoute);
263
+ return null;
264
+ }
265
+ return /*#__PURE__*/jsx(PageWrapper, {
266
+ children: /*#__PURE__*/jsx(PageContent, {
267
+ children: /*#__PURE__*/jsx(CardLayout, {
268
+ title: t("neetoEmailDelivery.sparkpost.verify.title"),
269
+ actionBlock: /*#__PURE__*/jsx(VerificationActions, {
270
+ isVerifying: isVerifying,
271
+ verificationStatus: verificationStatus,
272
+ onCancel: handleCancel,
273
+ onVerify: handleVerify
274
+ }),
275
+ description: t("neetoEmailDelivery.sparkpost.verify.description", {
276
+ domain: domain
277
+ }).replace(/<strong>|<\/strong>/g, ""),
278
+ children: /*#__PURE__*/jsxs("div", {
279
+ className: "flex flex-col gap-4",
280
+ children: [/*#__PURE__*/jsx(VerificationStatusCallout, {
281
+ verificationStatus: verificationStatus
282
+ }), !isVerificationSuccessful && /*#__PURE__*/jsxs(Fragment, {
283
+ children: [/*#__PURE__*/jsx(DnsRecordsSection, {
284
+ dnsRecords: dnsRecords,
285
+ domain: domain,
286
+ sparkpostData: sparkpostData
287
+ }), /*#__PURE__*/jsx(VerificationInstructions, {})]
288
+ })]
289
+ })
290
+ })
291
+ })
292
+ });
293
+ };
294
+
295
+ export { DnsRecordsSection as D, SparkpostDomainVerify as S };
296
+ //# sourceMappingURL=Verify-Cbn8WE7T.js.map