@bigbinary/neeto-email-delivery-frontend 1.0.1

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.
Files changed (62) hide show
  1. package/README.md +150 -0
  2. package/app/javascript/src/translations/ar.json +5 -0
  3. package/app/javascript/src/translations/bg.json +5 -0
  4. package/app/javascript/src/translations/ca.json +5 -0
  5. package/app/javascript/src/translations/cs.json +5 -0
  6. package/app/javascript/src/translations/da.json +5 -0
  7. package/app/javascript/src/translations/de.json +5 -0
  8. package/app/javascript/src/translations/en.json +80 -0
  9. package/app/javascript/src/translations/es-MX.json +5 -0
  10. package/app/javascript/src/translations/es.json +5 -0
  11. package/app/javascript/src/translations/et.json +5 -0
  12. package/app/javascript/src/translations/fi.json +5 -0
  13. package/app/javascript/src/translations/fil.json +5 -0
  14. package/app/javascript/src/translations/fr.json +5 -0
  15. package/app/javascript/src/translations/hi.json +5 -0
  16. package/app/javascript/src/translations/hr.json +5 -0
  17. package/app/javascript/src/translations/id.json +5 -0
  18. package/app/javascript/src/translations/index.js +3 -0
  19. package/app/javascript/src/translations/it.json +5 -0
  20. package/app/javascript/src/translations/ja.json +5 -0
  21. package/app/javascript/src/translations/ko.json +5 -0
  22. package/app/javascript/src/translations/nl.json +5 -0
  23. package/app/javascript/src/translations/pl.json +5 -0
  24. package/app/javascript/src/translations/pt-BR.json +5 -0
  25. package/app/javascript/src/translations/pt.json +5 -0
  26. package/app/javascript/src/translations/ro.json +5 -0
  27. package/app/javascript/src/translations/ru.json +5 -0
  28. package/app/javascript/src/translations/sk.json +5 -0
  29. package/app/javascript/src/translations/sl.json +5 -0
  30. package/app/javascript/src/translations/sv.json +5 -0
  31. package/app/javascript/src/translations/th.json +5 -0
  32. package/app/javascript/src/translations/tr.json +5 -0
  33. package/app/javascript/src/translations/uk.json +5 -0
  34. package/app/javascript/src/translations/vi.json +5 -0
  35. package/app/javascript/src/translations/zh-CN.json +5 -0
  36. package/app/javascript/src/translations/zh-TW.json +5 -0
  37. package/dist/EmailDeliveryScreen.js +419 -0
  38. package/dist/EmailDeliveryScreen.js.map +1 -0
  39. package/dist/SparkpostDomainSetup.js +119 -0
  40. package/dist/SparkpostDomainSetup.js.map +1 -0
  41. package/dist/SparkpostDomainVerify.js +265 -0
  42. package/dist/SparkpostDomainVerify.js.map +1 -0
  43. package/dist/cjs/EmailDeliveryScreen.js +421 -0
  44. package/dist/cjs/EmailDeliveryScreen.js.map +1 -0
  45. package/dist/cjs/SparkpostDomainSetup.js +121 -0
  46. package/dist/cjs/SparkpostDomainSetup.js.map +1 -0
  47. package/dist/cjs/SparkpostDomainVerify.js +267 -0
  48. package/dist/cjs/SparkpostDomainVerify.js.map +1 -0
  49. package/dist/cjs/index.js +46 -0
  50. package/dist/cjs/index.js.map +1 -0
  51. package/dist/constants-9aNca_br.js +67 -0
  52. package/dist/constants-9aNca_br.js.map +1 -0
  53. package/dist/constants-DcHGgJC2.js +94 -0
  54. package/dist/constants-DcHGgJC2.js.map +1 -0
  55. package/dist/index.js +38 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/useSparkpostDomain-ByWd7ekp.js +183 -0
  58. package/dist/useSparkpostDomain-ByWd7ekp.js.map +1 -0
  59. package/dist/useSparkpostDomain-DogzCozg.js +193 -0
  60. package/dist/useSparkpostDomain-DogzCozg.js.map +1 -0
  61. package/package.json +235 -0
  62. package/types.d.ts +22 -0
@@ -0,0 +1,421 @@
1
+ 'use strict';
2
+
3
+ var neetoCist = require('@bigbinary/neeto-cist');
4
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
5
+ var utils = require('@bigbinary/neeto-commons-frontend/utils');
6
+ var MailSend = require('@bigbinary/neeto-icons/MailSend');
7
+ var GmailIcon = require('@bigbinary/neeto-icons/misc/Gmail');
8
+ var OutlookIcon = require('@bigbinary/neeto-icons/misc/Outlook');
9
+ var Spinner = require('@bigbinary/neetoui/Spinner');
10
+ var Callout = require('@bigbinary/neetoui/Callout');
11
+ var Toastr = require('@bigbinary/neetoui/Toastr');
12
+ var ramda = require('ramda');
13
+ var reactI18next = require('react-i18next');
14
+ var reactRouterDom = require('react-router-dom');
15
+ var useSparkpostDomain = require('../useSparkpostDomain-DogzCozg.js');
16
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
17
+ var react = require('react');
18
+ var reactQuery = require('@tanstack/react-query');
19
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
20
+ var axios = require('axios');
21
+ var i18next = require('i18next');
22
+ var Button = require('@bigbinary/neetoui/Button');
23
+ var Tag = require('@bigbinary/neetoui/Tag');
24
+ var Typography = require('@bigbinary/neetoui/Typography');
25
+ var jsxRuntime = require('react/jsx-runtime');
26
+
27
+ var get$1 = function get(ownerId) {
28
+ return axios.get(utils.buildUrl(useSparkpostDomain.GMAIL_URL, {
29
+ ownerId: ownerId
30
+ }), {
31
+ showToastr: false
32
+ });
33
+ };
34
+ var destroy$1 = function destroy(ownerId) {
35
+ axios["delete"](utils.buildUrl(useSparkpostDomain.GMAIL_OAUTH_URL, {
36
+ ownerId: ownerId
37
+ }), {
38
+ showToastr: false
39
+ });
40
+ };
41
+ var gmailApi = {
42
+ get: get$1,
43
+ destroy: destroy$1
44
+ };
45
+
46
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
47
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
48
+ var useFetchGmail = function useFetchGmail(ownerId, options) {
49
+ return reactQuery.useQuery(_objectSpread$1({
50
+ queryKey: [useSparkpostDomain.QUERY_KEYS.INTEGRATION_GMAIL, ownerId],
51
+ queryFn: function queryFn() {
52
+ return gmailApi.get(ownerId);
53
+ },
54
+ retry: 1
55
+ }, options));
56
+ };
57
+ var useDestroyGmail = function useDestroyGmail(_ref) {
58
+ var ownerId = _ref.ownerId;
59
+ return reactUtils.useMutationWithInvalidation(function () {
60
+ return gmailApi.destroy(ownerId);
61
+ }, {
62
+ keysToInvalidate: [[useSparkpostDomain.QUERY_KEYS.INTEGRATION_GMAIL, ownerId]]
63
+ });
64
+ };
65
+
66
+ var useGmail = function useGmail(_ref) {
67
+ var ownerId = _ref.ownerId,
68
+ indexRoute = _ref.indexRoute,
69
+ canManageIntegrations = _ref.canManageIntegrations;
70
+ var _useState = react.useState(false),
71
+ _useState2 = _slicedToArray(_useState, 2),
72
+ isDisconnectAlertOpen = _useState2[0],
73
+ setIsDisconnectAlertOpen = _useState2[1];
74
+ var history = reactRouterDom.useHistory();
75
+ var queryClient = reactQuery.useQueryClient();
76
+ var _useFetchGmail = useFetchGmail(ownerId, {
77
+ enabled: canManageIntegrations
78
+ }),
79
+ isLoading = _useFetchGmail.isLoading,
80
+ _useFetchGmail$data = _useFetchGmail.data,
81
+ data = _useFetchGmail$data === void 0 ? {} : _useFetchGmail$data,
82
+ isGmailFetched = _useFetchGmail.isSuccess;
83
+ var _useDestroyGmail = useDestroyGmail({
84
+ ownerId: ownerId
85
+ }),
86
+ isDestroying = _useDestroyGmail.isPending,
87
+ destroyIntegration = _useDestroyGmail.mutate;
88
+ var onClose = function onClose() {
89
+ return history.replace(indexRoute);
90
+ };
91
+ var onDisconnect = function onDisconnect() {
92
+ destroyIntegration(false, {
93
+ onSuccess: function onSuccess() {
94
+ utils.showThumbsUpToastr();
95
+ setIsDisconnectAlertOpen(false);
96
+ history.replace(indexRoute);
97
+ }
98
+ });
99
+ };
100
+ react.useEffect(function () {
101
+ if (isGmailFetched) {
102
+ queryClient.invalidateQueries({
103
+ predicate: function predicate(query) {
104
+ var _query$queryKey = _slicedToArray(query.queryKey, 2),
105
+ key = _query$queryKey[0],
106
+ id = _query$queryKey[1];
107
+ return key === useSparkpostDomain.QUERY_KEYS.INTEGRATION_GMAIL && id !== ownerId;
108
+ }
109
+ });
110
+ }
111
+ }, [isGmailFetched, queryClient, ownerId]);
112
+ return {
113
+ data: data,
114
+ isLoading: isLoading,
115
+ isDestroying: isDestroying,
116
+ isConnected: data === null || data === void 0 ? void 0 : data.connected,
117
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
118
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
119
+ onDisconnect: onDisconnect,
120
+ onClose: onClose,
121
+ errorMessage: data === null || data === void 0 ? void 0 : data.error
122
+ };
123
+ };
124
+
125
+ var get = function get(ownerId) {
126
+ return axios.get(utils.buildUrl(useSparkpostDomain.OUTLOOK_URL, {
127
+ ownerId: ownerId
128
+ }), {
129
+ showToastr: false
130
+ });
131
+ };
132
+ var destroy = function destroy(ownerId) {
133
+ axios["delete"](utils.buildUrl(useSparkpostDomain.OUTLOOK_OAUTH_URL, {
134
+ ownerId: ownerId
135
+ }), {
136
+ showToastr: false
137
+ });
138
+ };
139
+ var outlookApi = {
140
+ get: get,
141
+ destroy: destroy
142
+ };
143
+
144
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
145
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
146
+ var useFetchOutlook = function useFetchOutlook(ownerId, options) {
147
+ return reactQuery.useQuery(_objectSpread({
148
+ queryKey: [useSparkpostDomain.QUERY_KEYS.INTEGRATION_OUTLOOK, ownerId],
149
+ queryFn: function queryFn() {
150
+ return outlookApi.get(ownerId);
151
+ },
152
+ retry: 1
153
+ }, options));
154
+ };
155
+ var useDestroyOutlook = function useDestroyOutlook(_ref) {
156
+ var ownerId = _ref.ownerId;
157
+ return reactUtils.useMutationWithInvalidation(function () {
158
+ return outlookApi.destroy(ownerId);
159
+ }, {
160
+ keysToInvalidate: [[useSparkpostDomain.QUERY_KEYS.INTEGRATION_OUTLOOK, ownerId]]
161
+ });
162
+ };
163
+
164
+ var useOutlook = function useOutlook(_ref) {
165
+ var ownerId = _ref.ownerId,
166
+ indexRoute = _ref.indexRoute,
167
+ canManageIntegrations = _ref.canManageIntegrations;
168
+ var _useState = react.useState(false),
169
+ _useState2 = _slicedToArray(_useState, 2),
170
+ isDisconnectAlertOpen = _useState2[0],
171
+ setIsDisconnectAlertOpen = _useState2[1];
172
+ var history = reactRouterDom.useHistory();
173
+ var queryClient = reactQuery.useQueryClient();
174
+ var _useFetchOutlook = useFetchOutlook(ownerId, {
175
+ enabled: canManageIntegrations
176
+ }),
177
+ isLoading = _useFetchOutlook.isLoading,
178
+ _useFetchOutlook$data = _useFetchOutlook.data,
179
+ data = _useFetchOutlook$data === void 0 ? {} : _useFetchOutlook$data,
180
+ isOutlookFetched = _useFetchOutlook.isSuccess;
181
+ var _useDestroyOutlook = useDestroyOutlook({
182
+ ownerId: ownerId
183
+ }),
184
+ isDestroying = _useDestroyOutlook.isPending,
185
+ destroyIntegration = _useDestroyOutlook.mutate;
186
+ var onClose = function onClose() {
187
+ return history.replace(indexRoute);
188
+ };
189
+ var onDisconnect = function onDisconnect() {
190
+ destroyIntegration(false, {
191
+ onSuccess: function onSuccess() {
192
+ utils.showThumbsUpToastr();
193
+ setIsDisconnectAlertOpen(false);
194
+ history.replace(indexRoute);
195
+ }
196
+ });
197
+ };
198
+ react.useEffect(function () {
199
+ if (isOutlookFetched) {
200
+ queryClient.invalidateQueries({
201
+ predicate: function predicate(query) {
202
+ var _query$queryKey = _slicedToArray(query.queryKey, 2),
203
+ key = _query$queryKey[0],
204
+ id = _query$queryKey[1];
205
+ return key === useSparkpostDomain.QUERY_KEYS.INTEGRATION_OUTLOOK && id !== ownerId;
206
+ }
207
+ });
208
+ }
209
+ }, [isOutlookFetched, queryClient, ownerId]);
210
+ return {
211
+ data: data,
212
+ isLoading: isLoading,
213
+ isDestroying: isDestroying,
214
+ isConnected: data === null || data === void 0 ? void 0 : data.connected,
215
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
216
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
217
+ onDisconnect: onDisconnect,
218
+ onClose: onClose,
219
+ errorMessage: data === null || data === void 0 ? void 0 : data.error
220
+ };
221
+ };
222
+
223
+ var ERROR_MESSAGES = {
224
+ gmail_permission_not_given: i18next.t("neetoEmailDelivery.gmail.permissionNotGiven"),
225
+ outlook_permission_not_given: i18next.t("neetoEmailDelivery.outlook.permissionNotGiven"),
226
+ outlook_invalid_client: i18next.t("neetoEmailDelivery.outlook.invalidClient"),
227
+ outlook_nil_json_web_token: i18next.t("neetoEmailDelivery.outlook.nilJsonWebToken")
228
+ };
229
+
230
+ var IntegrationCard = reactUtils.withT(function (_ref) {
231
+ var t = _ref.t,
232
+ Icon = _ref.icon,
233
+ title = _ref.title,
234
+ description = _ref.description,
235
+ isConnected = _ref.isConnected,
236
+ isDisconnecting = _ref.isDisconnecting,
237
+ onConnect = _ref.onConnect,
238
+ onDisconnect = _ref.onDisconnect,
239
+ connectButtonText = _ref.connectButtonText,
240
+ _ref$disconnectButton = _ref.disconnectButtonText,
241
+ disconnectButtonText = _ref$disconnectButton === void 0 ? "neetoEmailDelivery.sparkpost.emailDelivery.disconnect" : _ref$disconnectButton,
242
+ _ref$connectedTagText = _ref.connectedTagText,
243
+ connectedTagText = _ref$connectedTagText === void 0 ? "neetoEmailDelivery.sparkpost.emailDelivery.connected" : _ref$connectedTagText;
244
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
245
+ className: "neeto-ui-rounded-lg neeto-ui-shadow-xs neeto-ui-border-gray-300 translate flex flex-col gap-y-4 border p-6 no-underline transition-transform duration-300 ease-in-out outline-none hover:-translate-y-1",
246
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
247
+ className: "flex flex-col gap-4",
248
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
249
+ className: "flex items-center gap-3",
250
+ children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
251
+ className: "shrink-0",
252
+ size: 32
253
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
254
+ className: "min-w-0 flex-1",
255
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
256
+ className: "flex items-center gap-2",
257
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
258
+ style: "h4",
259
+ weight: "semibold",
260
+ children: title
261
+ }), isConnected && /*#__PURE__*/jsxRuntime.jsx(Tag, {
262
+ label: t(connectedTagText)
263
+ })]
264
+ })
265
+ })]
266
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
267
+ style: "body2",
268
+ children: description
269
+ }), connectButtonText && /*#__PURE__*/jsxRuntime.jsx("div", {
270
+ className: "flex gap-2",
271
+ children: isConnected ? /*#__PURE__*/jsxRuntime.jsx(Button, {
272
+ "data-cy": "disconnect-button",
273
+ label: t(disconnectButtonText),
274
+ loading: isDisconnecting,
275
+ size: "small",
276
+ style: "danger",
277
+ onClick: onDisconnect
278
+ }) : /*#__PURE__*/jsxRuntime.jsx(Button, {
279
+ "data-cy": "connect-button",
280
+ label: t(connectButtonText),
281
+ size: "small",
282
+ style: "primary",
283
+ onClick: onConnect
284
+ })
285
+ })]
286
+ })
287
+ });
288
+ });
289
+
290
+ var EmailDeliveryScreen = function EmailDeliveryScreen(_ref) {
291
+ var indexRoute = _ref.indexRoute,
292
+ ownerId = _ref.ownerId,
293
+ ownDomainSetupRoute = _ref.ownDomainSetupRoute,
294
+ canManageIntegrations = _ref.canManageIntegrations;
295
+ var _useTranslation = reactI18next.useTranslation(),
296
+ t = _useTranslation.t;
297
+ var history = reactRouterDom.useHistory();
298
+ var _useQueryParams = reactUtils.useQueryParams(),
299
+ error = _useQueryParams.error,
300
+ errorDescription = _useQueryParams.errorDescription;
301
+ if (neetoCist.isPresent(error)) {
302
+ var _errorMessage;
303
+ var errorMessage = ERROR_MESSAGES[error];
304
+ if (errorDescription) {
305
+ errorMessage = "".concat(errorMessage, " ").concat(errorDescription);
306
+ }
307
+ Toastr.error((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 ? _errorMessage : neetoCist.humanize(error));
308
+ history.replace(indexRoute);
309
+ }
310
+ var gmailIntegration = useGmail({
311
+ ownerId: ownerId,
312
+ indexRoute: indexRoute,
313
+ canManageIntegrations: canManageIntegrations
314
+ });
315
+ var outlookIntegration = useOutlook({
316
+ ownerId: ownerId,
317
+ indexRoute: indexRoute,
318
+ canManageIntegrations: canManageIntegrations
319
+ });
320
+ var sparkpostIntegration = useSparkpostDomain.useSparkpostDomain({
321
+ ownerId: ownerId,
322
+ canManageIntegrations: canManageIntegrations
323
+ });
324
+ var _gmailIntegration$dat = gmailIntegration.data,
325
+ gmailData = _gmailIntegration$dat === void 0 ? {} : _gmailIntegration$dat,
326
+ isGmailConnected = gmailIntegration.isConnected,
327
+ isGmailLoading = gmailIntegration.isLoading,
328
+ isGmailDisconnecting = gmailIntegration.isDestroying,
329
+ onGmailDisconnect = gmailIntegration.onDisconnect;
330
+ var _outlookIntegration$d = outlookIntegration.data,
331
+ outlookData = _outlookIntegration$d === void 0 ? {} : _outlookIntegration$d,
332
+ isOutlookConnected = outlookIntegration.isConnected,
333
+ isOutlookLoading = outlookIntegration.isLoading,
334
+ isOutlookDisconnecting = outlookIntegration.isDestroying,
335
+ onOutlookDisconnect = outlookIntegration.onDisconnect;
336
+ var _sparkpostIntegration = sparkpostIntegration.data,
337
+ sparkpostData = _sparkpostIntegration === void 0 ? {} : _sparkpostIntegration,
338
+ isSparkpostConnected = sparkpostIntegration.isConnected,
339
+ isSparkpostLoading = sparkpostIntegration.isLoading,
340
+ onSparkpostDisconnect = sparkpostIntegration.onDisconnect,
341
+ isSparkpostDisconnecting = sparkpostIntegration.isDestroying;
342
+ var isLoading = isGmailLoading || isOutlookLoading || isSparkpostLoading;
343
+ var hasActiveIntegration = isGmailConnected || isOutlookConnected || isSparkpostConnected;
344
+ var handleGmailConnect = function handleGmailConnect() {
345
+ window.location.href = utils.buildUrl(useSparkpostDomain.GMAIL_OAUTH_CONNECT_URL, {
346
+ ownerId: ownerId
347
+ });
348
+ };
349
+ var handleOutlookConnect = function handleOutlookConnect() {
350
+ window.location.href = utils.buildUrl(useSparkpostDomain.OUTLOOK_OAUTH_CONNECT_URL, {
351
+ ownerId: ownerId
352
+ });
353
+ };
354
+ var handleOwnDomainConnect = function handleOwnDomainConnect() {
355
+ history.push(ownDomainSetupRoute);
356
+ };
357
+ var gmailEmail = ramda.prop("email", gmailData);
358
+ var outlookEmail = ramda.prop("email", outlookData);
359
+ var sparkpostEmail = ramda.prop("email", sparkpostData);
360
+ var gmailTitle = t("neetoEmailDelivery.gmail.title");
361
+ var gmailDescription = isGmailConnected ? t("neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail", {
362
+ email: gmailEmail
363
+ }) : t("neetoEmailDelivery.gmail.description");
364
+ var outlookTitle = t("neetoEmailDelivery.outlook.title");
365
+ var outlookDescription = isOutlookConnected ? t("neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail", {
366
+ email: outlookEmail
367
+ }) : t("neetoEmailDelivery.outlook.description");
368
+ var ownDomainTitle = t("neetoEmailDelivery.sparkpost.emailDelivery.ownDomainTitle");
369
+ var ownDomainDescription = isSparkpostConnected ? t("neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail", {
370
+ email: sparkpostEmail
371
+ }) : t("neetoEmailDelivery.sparkpost.emailDelivery.ownDomainDescription");
372
+ if (isLoading) {
373
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
374
+ className: "flex grow items-center justify-center",
375
+ children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
376
+ });
377
+ }
378
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
379
+ className: "min-h-0 w-full grow",
380
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
381
+ className: "@container mx-auto space-y-6",
382
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
383
+ className: "grid grid-cols-1 gap-3 py-1 @lg:grid-cols-2 @lg:gap-6 @3xl:grid-cols-3 @7xl:grid-cols-4",
384
+ children: [(!hasActiveIntegration || isGmailConnected) && /*#__PURE__*/jsxRuntime.jsx(IntegrationCard, {
385
+ connectButtonText: "neetoEmailDelivery.gmail.connectGmail",
386
+ description: gmailDescription,
387
+ icon: GmailIcon,
388
+ isConnected: isGmailConnected,
389
+ isDisconnecting: isGmailDisconnecting,
390
+ title: gmailTitle,
391
+ onConnect: handleGmailConnect,
392
+ onDisconnect: onGmailDisconnect
393
+ }), (!hasActiveIntegration || isOutlookConnected) && /*#__PURE__*/jsxRuntime.jsx(IntegrationCard, {
394
+ connectButtonText: "neetoEmailDelivery.outlook.connectOutlook",
395
+ description: outlookDescription,
396
+ icon: OutlookIcon,
397
+ isConnected: isOutlookConnected,
398
+ isDisconnecting: isOutlookDisconnecting,
399
+ title: outlookTitle,
400
+ onConnect: handleOutlookConnect,
401
+ onDisconnect: onOutlookDisconnect
402
+ }), (!hasActiveIntegration || isSparkpostConnected) && /*#__PURE__*/jsxRuntime.jsx(IntegrationCard, {
403
+ connectButtonText: "neetoEmailDelivery.sparkpost.emailDelivery.setupDomain",
404
+ description: ownDomainDescription,
405
+ icon: MailSend,
406
+ isConnected: isSparkpostConnected,
407
+ isDisconnecting: isSparkpostDisconnecting,
408
+ title: ownDomainTitle,
409
+ onConnect: handleOwnDomainConnect,
410
+ onDisconnect: onSparkpostDisconnect
411
+ })]
412
+ }), hasActiveIntegration && /*#__PURE__*/jsxRuntime.jsx(Callout, {
413
+ style: "success",
414
+ children: isGmailConnected ? t("neetoEmailDelivery.gmail.gmailConfigured") : isOutlookConnected ? t("neetoEmailDelivery.outlook.outlookConfigured") : t("neetoEmailDelivery.sparkpost.ownDomainConfigured")
415
+ })]
416
+ })
417
+ });
418
+ };
419
+
420
+ module.exports = EmailDeliveryScreen;
421
+ //# sourceMappingURL=EmailDeliveryScreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EmailDeliveryScreen.js","sources":["../../app/javascript/src/apis/integrations/gmail.js","../../app/javascript/src/hooks/reactQuery/integrations/useGmailIntegrationApi.js","../../app/javascript/src/hooks/integrations/useGmail.js","../../app/javascript/src/apis/integrations/outlook.js","../../app/javascript/src/hooks/reactQuery/integrations/useOutlookIntegrationApi.js","../../app/javascript/src/hooks/integrations/useOutlook.js","../../app/javascript/src/components/EmailDeliveryScreen/constants.js","../../app/javascript/src/components/EmailDeliveryScreen/IntegrationCard.jsx","../../app/javascript/src/components/EmailDeliveryScreen/index.jsx"],"sourcesContent":["import axios from \"axios\";\nimport { buildUrl } from \"neetocommons/utils\";\n\nimport { GMAIL_URL, GMAIL_OAUTH_URL } from \"./constants\";\n\nconst get = ownerId =>\n axios.get(buildUrl(GMAIL_URL, { ownerId }), { showToastr: false });\n\nconst destroy = ownerId => {\n axios.delete(buildUrl(GMAIL_OAUTH_URL, { ownerId }), { showToastr: false });\n};\n\nconst gmailApi = { get, destroy };\n\nexport default gmailApi;\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport gmailApi from \"apis/integrations/gmail\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nexport const useFetchGmail = (ownerId, options) =>\n useQuery({\n queryKey: [QUERY_KEYS.INTEGRATION_GMAIL, ownerId],\n queryFn: () => gmailApi.get(ownerId),\n retry: 1,\n ...options,\n });\n\nexport const useDestroyGmail = ({ ownerId }) =>\n useMutationWithInvalidation(() => gmailApi.destroy(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_GMAIL, ownerId]],\n });\n","import { useEffect, useState } from \"react\";\n\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { showThumbsUpToastr } from \"neetocommons/utils\";\nimport { useHistory } from \"react-router-dom\";\n\nimport {\n useFetchGmail,\n useDestroyGmail,\n} from \"hooks/reactQuery/integrations/useGmailIntegrationApi\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nconst useGmail = ({ ownerId, indexRoute, canManageIntegrations }) => {\n const [isDisconnectAlertOpen, setIsDisconnectAlertOpen] = useState(false);\n\n const history = useHistory();\n\n const queryClient = useQueryClient();\n\n const {\n isLoading,\n data = {},\n isSuccess: isGmailFetched,\n } = useFetchGmail(ownerId, { enabled: canManageIntegrations });\n\n const { isPending: isDestroying, mutate: destroyIntegration } =\n useDestroyGmail({ ownerId });\n\n const onClose = () => history.replace(indexRoute);\n\n const onDisconnect = () => {\n destroyIntegration(false, {\n onSuccess: () => {\n showThumbsUpToastr();\n setIsDisconnectAlertOpen(false);\n history.replace(indexRoute);\n },\n });\n };\n\n useEffect(() => {\n if (isGmailFetched) {\n queryClient.invalidateQueries({\n predicate: query => {\n const [key, id] = query.queryKey;\n\n return key === QUERY_KEYS.INTEGRATION_GMAIL && id !== ownerId;\n },\n });\n }\n }, [isGmailFetched, queryClient, ownerId]);\n\n return {\n data,\n isLoading,\n isDestroying,\n isConnected: data?.connected,\n isDisconnectAlertOpen,\n setIsDisconnectAlertOpen,\n onDisconnect,\n onClose,\n errorMessage: data?.error,\n };\n};\n\nexport default useGmail;\n","import axios from \"axios\";\nimport { buildUrl } from \"neetocommons/utils\";\n\nimport { OUTLOOK_URL, OUTLOOK_OAUTH_URL } from \"./constants\";\n\nconst get = ownerId =>\n axios.get(buildUrl(OUTLOOK_URL, { ownerId }), { showToastr: false });\n\nconst destroy = ownerId => {\n axios.delete(buildUrl(OUTLOOK_OAUTH_URL, { ownerId }), { showToastr: false });\n};\n\nconst outlookApi = { get, destroy };\n\nexport default outlookApi;\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport outlookApi from \"apis/integrations/outlook\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nexport const useFetchOutlook = (ownerId, options) =>\n useQuery({\n queryKey: [QUERY_KEYS.INTEGRATION_OUTLOOK, ownerId],\n queryFn: () => outlookApi.get(ownerId),\n retry: 1,\n ...options,\n });\n\nexport const useDestroyOutlook = ({ ownerId }) =>\n useMutationWithInvalidation(() => outlookApi.destroy(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_OUTLOOK, ownerId]],\n });\n","import { useEffect, useState } from \"react\";\n\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { showThumbsUpToastr } from \"neetocommons/utils\";\nimport { useHistory } from \"react-router-dom\";\n\nimport {\n useFetchOutlook,\n useDestroyOutlook,\n} from \"hooks/reactQuery/integrations/useOutlookIntegrationApi\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nconst useOutlook = ({ ownerId, indexRoute, canManageIntegrations }) => {\n const [isDisconnectAlertOpen, setIsDisconnectAlertOpen] = useState(false);\n\n const history = useHistory();\n\n const queryClient = useQueryClient();\n\n const {\n isLoading,\n data = {},\n isSuccess: isOutlookFetched,\n } = useFetchOutlook(ownerId, { enabled: canManageIntegrations });\n\n const { isPending: isDestroying, mutate: destroyIntegration } =\n useDestroyOutlook({ ownerId });\n\n const onClose = () => history.replace(indexRoute);\n\n const onDisconnect = () => {\n destroyIntegration(false, {\n onSuccess: () => {\n showThumbsUpToastr();\n setIsDisconnectAlertOpen(false);\n history.replace(indexRoute);\n },\n });\n };\n\n useEffect(() => {\n if (isOutlookFetched) {\n queryClient.invalidateQueries({\n predicate: query => {\n const [key, id] = query.queryKey;\n\n return key === QUERY_KEYS.INTEGRATION_OUTLOOK && id !== ownerId;\n },\n });\n }\n }, [isOutlookFetched, queryClient, ownerId]);\n\n return {\n data,\n isLoading,\n isDestroying,\n isConnected: data?.connected,\n isDisconnectAlertOpen,\n setIsDisconnectAlertOpen,\n onDisconnect,\n onClose,\n errorMessage: data?.error,\n };\n};\n\nexport default useOutlook;\n","import { t } from \"i18next\";\n\nexport const ERROR_MESSAGES = {\n gmail_permission_not_given: t(\"neetoEmailDelivery.gmail.permissionNotGiven\"),\n outlook_permission_not_given: t(\n \"neetoEmailDelivery.outlook.permissionNotGiven\"\n ),\n outlook_invalid_client: t(\"neetoEmailDelivery.outlook.invalidClient\"),\n outlook_nil_json_web_token: t(\"neetoEmailDelivery.outlook.nilJsonWebToken\"),\n};\n","import { withT } from \"neetocommons/react-utils\";\nimport { Button, Tag, Typography } from \"neetoui\";\n\nconst IntegrationCard = withT(\n ({\n t,\n icon: Icon,\n title,\n description,\n isConnected,\n isDisconnecting,\n onConnect,\n onDisconnect,\n connectButtonText,\n disconnectButtonText = \"neetoEmailDelivery.sparkpost.emailDelivery.disconnect\",\n connectedTagText = \"neetoEmailDelivery.sparkpost.emailDelivery.connected\",\n }) => (\n <div className=\"neeto-ui-rounded-lg neeto-ui-shadow-xs neeto-ui-border-gray-300 translate flex flex-col gap-y-4 border p-6 no-underline transition-transform duration-300 ease-in-out outline-none hover:-translate-y-1\">\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex items-center gap-3\">\n <Icon className=\"shrink-0\" size={32} />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2\">\n <Typography style=\"h4\" weight=\"semibold\">\n {title}\n </Typography>\n {isConnected && <Tag label={t(connectedTagText)} />}\n </div>\n </div>\n </div>\n <Typography style=\"body2\">{description}</Typography>\n {connectButtonText && (\n <div className=\"flex gap-2\">\n {isConnected ? (\n <Button\n data-cy=\"disconnect-button\"\n label={t(disconnectButtonText)}\n loading={isDisconnecting}\n size=\"small\"\n style=\"danger\"\n onClick={onDisconnect}\n />\n ) : (\n <Button\n data-cy=\"connect-button\"\n label={t(connectButtonText)}\n size=\"small\"\n style=\"primary\"\n onClick={onConnect}\n />\n )}\n </div>\n )}\n </div>\n </div>\n )\n);\n\nexport default IntegrationCard;\n","import { humanize, isPresent } from \"neetocist\";\nimport { useQueryParams } from \"neetocommons/react-utils\";\nimport { buildUrl } from \"neetocommons/utils\";\nimport { MailSend } from \"neetoicons\";\nimport { Gmail as GmailIcon, Outlook as OutlookIcon } from \"neetoicons/misc\";\nimport { Spinner, Callout, Toastr } from \"neetoui\";\nimport { prop } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport {\n GMAIL_OAUTH_CONNECT_URL,\n OUTLOOK_OAUTH_CONNECT_URL,\n} from \"apis/integrations/constants\";\nimport useGmail from \"hooks/integrations/useGmail\";\nimport useOutlook from \"hooks/integrations/useOutlook\";\nimport useSparkpostDomain from \"hooks/integrations/useSparkpostDomain\";\n\nimport { ERROR_MESSAGES } from \"./constants\";\nimport IntegrationCard from \"./IntegrationCard\";\n\nconst EmailDeliveryScreen = ({\n indexRoute,\n ownerId,\n ownDomainSetupRoute,\n canManageIntegrations,\n}) => {\n const { t } = useTranslation();\n const history = useHistory();\n const { error, errorDescription } = useQueryParams();\n\n if (isPresent(error)) {\n let errorMessage = ERROR_MESSAGES[error];\n if (errorDescription) {\n errorMessage = `${errorMessage} ${errorDescription}`;\n }\n Toastr.error(errorMessage ?? humanize(error));\n\n history.replace(indexRoute);\n }\n\n const gmailIntegration = useGmail({\n ownerId,\n indexRoute,\n canManageIntegrations,\n });\n\n const outlookIntegration = useOutlook({\n ownerId,\n indexRoute,\n canManageIntegrations,\n });\n\n const sparkpostIntegration = useSparkpostDomain({\n ownerId,\n canManageIntegrations,\n });\n\n const {\n data: gmailData = {},\n isConnected: isGmailConnected,\n isLoading: isGmailLoading,\n isDestroying: isGmailDisconnecting,\n onDisconnect: onGmailDisconnect,\n } = gmailIntegration;\n\n const {\n data: outlookData = {},\n isConnected: isOutlookConnected,\n isLoading: isOutlookLoading,\n isDestroying: isOutlookDisconnecting,\n onDisconnect: onOutlookDisconnect,\n } = outlookIntegration;\n\n const {\n data: sparkpostData = {},\n isConnected: isSparkpostConnected,\n isLoading: isSparkpostLoading,\n onDisconnect: onSparkpostDisconnect,\n isDestroying: isSparkpostDisconnecting,\n } = sparkpostIntegration;\n\n const isLoading = isGmailLoading || isOutlookLoading || isSparkpostLoading;\n const hasActiveIntegration =\n isGmailConnected || isOutlookConnected || isSparkpostConnected;\n\n const handleGmailConnect = () => {\n window.location.href = buildUrl(GMAIL_OAUTH_CONNECT_URL, { ownerId });\n };\n\n const handleOutlookConnect = () => {\n window.location.href = buildUrl(OUTLOOK_OAUTH_CONNECT_URL, { ownerId });\n };\n\n const handleOwnDomainConnect = () => {\n history.push(ownDomainSetupRoute);\n };\n\n const gmailEmail = prop(\"email\", gmailData);\n const outlookEmail = prop(\"email\", outlookData);\n const sparkpostEmail = prop(\"email\", sparkpostData);\n\n const gmailTitle = t(\"neetoEmailDelivery.gmail.title\");\n const gmailDescription = isGmailConnected\n ? t(\"neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail\", {\n email: gmailEmail,\n })\n : t(\"neetoEmailDelivery.gmail.description\");\n\n const outlookTitle = t(\"neetoEmailDelivery.outlook.title\");\n const outlookDescription = isOutlookConnected\n ? t(\"neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail\", {\n email: outlookEmail,\n })\n : t(\"neetoEmailDelivery.outlook.description\");\n\n const ownDomainTitle = t(\n \"neetoEmailDelivery.sparkpost.emailDelivery.ownDomainTitle\"\n );\n\n const ownDomainDescription = isSparkpostConnected\n ? t(\"neetoEmailDelivery.sparkpost.emailDelivery.connectedEmail\", {\n email: sparkpostEmail,\n })\n : t(\"neetoEmailDelivery.sparkpost.emailDelivery.ownDomainDescription\");\n\n if (isLoading) {\n return (\n <div className=\"flex grow items-center justify-center\">\n <Spinner />\n </div>\n );\n }\n\n return (\n <div className=\"min-h-0 w-full grow\">\n <div className=\"@container mx-auto space-y-6\">\n <div className=\"grid grid-cols-1 gap-3 py-1 @lg:grid-cols-2 @lg:gap-6 @3xl:grid-cols-3 @7xl:grid-cols-4\">\n {/* Gmail Option */}\n {(!hasActiveIntegration || isGmailConnected) && (\n <IntegrationCard\n connectButtonText=\"neetoEmailDelivery.gmail.connectGmail\"\n description={gmailDescription}\n icon={GmailIcon}\n isConnected={isGmailConnected}\n isDisconnecting={isGmailDisconnecting}\n title={gmailTitle}\n onConnect={handleGmailConnect}\n onDisconnect={onGmailDisconnect}\n />\n )}\n {/* Outlook Option */}\n {(!hasActiveIntegration || isOutlookConnected) && (\n <IntegrationCard\n connectButtonText=\"neetoEmailDelivery.outlook.connectOutlook\"\n description={outlookDescription}\n icon={OutlookIcon}\n isConnected={isOutlookConnected}\n isDisconnecting={isOutlookDisconnecting}\n title={outlookTitle}\n onConnect={handleOutlookConnect}\n onDisconnect={onOutlookDisconnect}\n />\n )}\n {/* Own Domain (Sparkpost) Option */}\n {(!hasActiveIntegration || isSparkpostConnected) && (\n <IntegrationCard\n connectButtonText=\"neetoEmailDelivery.sparkpost.emailDelivery.setupDomain\"\n description={ownDomainDescription}\n icon={MailSend}\n isConnected={isSparkpostConnected}\n isDisconnecting={isSparkpostDisconnecting}\n title={ownDomainTitle}\n onConnect={handleOwnDomainConnect}\n onDisconnect={onSparkpostDisconnect}\n />\n )}\n </div>\n {hasActiveIntegration && (\n <Callout style=\"success\">\n {isGmailConnected\n ? t(\"neetoEmailDelivery.gmail.gmailConfigured\")\n : isOutlookConnected\n ? t(\"neetoEmailDelivery.outlook.outlookConfigured\")\n : t(\"neetoEmailDelivery.sparkpost.ownDomainConfigured\")}\n </Callout>\n )}\n </div>\n </div>\n );\n};\n\nexport default EmailDeliveryScreen;\n"],"names":["get","ownerId","axios","buildUrl","GMAIL_URL","showToastr","destroy","GMAIL_OAUTH_URL","gmailApi","useFetchGmail","options","useQuery","_objectSpread","queryKey","QUERY_KEYS","INTEGRATION_GMAIL","queryFn","retry","useDestroyGmail","_ref","useMutationWithInvalidation","keysToInvalidate","useGmail","indexRoute","canManageIntegrations","_useState","useState","_useState2","_slicedToArray","isDisconnectAlertOpen","setIsDisconnectAlertOpen","history","useHistory","queryClient","useQueryClient","_useFetchGmail","enabled","isLoading","_useFetchGmail$data","data","isGmailFetched","isSuccess","_useDestroyGmail","isDestroying","isPending","destroyIntegration","mutate","onClose","replace","onDisconnect","onSuccess","showThumbsUpToastr","useEffect","invalidateQueries","predicate","query","_query$queryKey","key","id","isConnected","connected","errorMessage","error","OUTLOOK_URL","OUTLOOK_OAUTH_URL","outlookApi","useFetchOutlook","INTEGRATION_OUTLOOK","useDestroyOutlook","useOutlook","_useFetchOutlook","_useFetchOutlook$data","isOutlookFetched","_useDestroyOutlook","ERROR_MESSAGES","gmail_permission_not_given","t","outlook_permission_not_given","outlook_invalid_client","outlook_nil_json_web_token","IntegrationCard","withT","Icon","icon","title","description","isDisconnecting","onConnect","connectButtonText","_ref$disconnectButton","disconnectButtonText","_ref$connectedTagText","connectedTagText","_jsx","className","children","_jsxs","size","Typography","style","weight","Tag","label","Button","loading","onClick","EmailDeliveryScreen","ownDomainSetupRoute","_useTranslation","useTranslation","_useQueryParams","useQueryParams","errorDescription","isPresent","_errorMessage","concat","Toastr","humanize","gmailIntegration","outlookIntegration","sparkpostIntegration","useSparkpostDomain","_gmailIntegration$dat","gmailData","isGmailConnected","isGmailLoading","isGmailDisconnecting","onGmailDisconnect","_outlookIntegration$d","outlookData","isOutlookConnected","isOutlookLoading","isOutlookDisconnecting","onOutlookDisconnect","_sparkpostIntegration","sparkpostData","isSparkpostConnected","isSparkpostLoading","onSparkpostDisconnect","isSparkpostDisconnecting","hasActiveIntegration","handleGmailConnect","window","location","href","GMAIL_OAUTH_CONNECT_URL","handleOutlookConnect","OUTLOOK_OAUTH_CONNECT_URL","handleOwnDomainConnect","push","gmailEmail","prop","outlookEmail","sparkpostEmail","gmailTitle","gmailDescription","email","outlookTitle","outlookDescription","ownDomainTitle","ownDomainDescription","Spinner","GmailIcon","OutlookIcon","MailSend","Callout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAMA,KAAG,GAAG,SAANA,GAAGA,CAAGC,OAAO,EAAA;AAAA,EAAA,OACjBC,KAAK,CAACF,GAAG,CAACG,cAAQ,CAACC,4BAAS,EAAE;AAAEH,IAAAA,OAAO,EAAPA;AAAQ,GAAC,CAAC,EAAE;AAAEI,IAAAA,UAAU,EAAE;AAAM,GAAC,CAAC;AAAA,CAAA;AAEpE,IAAMC,SAAO,GAAG,SAAVA,OAAOA,CAAGL,OAAO,EAAI;AACzBC,EAAAA,KAAK,CAAO,QAAA,CAAA,CAACC,cAAQ,CAACI,kCAAe,EAAE;AAAEN,IAAAA,OAAO,EAAPA;AAAQ,GAAC,CAAC,EAAE;AAAEI,IAAAA,UAAU,EAAE;AAAM,GAAC,CAAC;AAC7E,CAAC;AAED,IAAMG,QAAQ,GAAG;AAAER,EAAAA,GAAG,EAAHA,KAAG;AAAEM,EAAAA,OAAO,EAAPA;AAAQ,CAAC;;;;ACN1B,IAAMG,aAAa,GAAG,SAAhBA,aAAaA,CAAIR,OAAO,EAAES,OAAO,EAAA;EAAA,OAC5CC,mBAAQ,CAAAC,eAAA,CAAA;AACNC,IAAAA,QAAQ,EAAE,CAACC,6BAAU,CAACC,iBAAiB,EAAEd,OAAO,CAAC;IACjDe,OAAO,EAAE,SAATA,OAAOA,GAAA;AAAA,MAAA,OAAQR,QAAQ,CAACR,GAAG,CAACC,OAAO,CAAC;AAAA,KAAA;AACpCgB,IAAAA,KAAK,EAAE;GACJP,EAAAA,OAAO,CACX,CAAC;AAAA,CAAA;AAEG,IAAMQ,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAMlB,OAAO,GAAAkB,IAAA,CAAPlB,OAAO;AAAA,EAAA,OACvCmB,sCAA2B,CAAC,YAAA;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CAAC,0CAA0C,CAAC,GAC7CsD,kBAAkB,GAChBtD,CAAC,CAAC,8CAA8C,CAAC,GACjDA,CAAC,CAAC,kDAAkD;AAAC,OACpD,CACV;KACE;AAAC,GACH,CAAC;AAEV;;;;"}
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+
3
+ var utils = require('@bigbinary/neeto-commons-frontend/utils');
4
+ var CardLayout = require('@bigbinary/neeto-molecules/CardLayout');
5
+ var Callout = require('@bigbinary/neetoui/Callout');
6
+ var Input = require('@bigbinary/neetoui/formik/Input');
7
+ var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
8
+ var Form = require('@bigbinary/neetoui/formik/Form');
9
+ var reactI18next = require('react-i18next');
10
+ var reactRouterDom = require('react-router-dom');
11
+ var constants = require('../constants-DcHGgJC2.js');
12
+ var useSparkpostDomain = require('../useSparkpostDomain-DogzCozg.js');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+ require('@babel/runtime/helpers/defineProperty');
15
+ require('@babel/runtime/helpers/objectWithoutProperties');
16
+ require('react');
17
+ require('classnames');
18
+ require('@bigbinary/neeto-molecules/Container');
19
+ require('@bigbinary/neeto-molecules/Header');
20
+ require('i18next');
21
+ require('yup');
22
+ require('@babel/runtime/helpers/slicedToArray');
23
+ require('@bigbinary/neetoui/Toastr');
24
+ require('@tanstack/react-query');
25
+ require('@bigbinary/neeto-commons-frontend/react-utils');
26
+ require('axios');
27
+
28
+ var getDomainFromEmail = function getDomainFromEmail(email) {
29
+ return email.trim().split("@")[1];
30
+ };
31
+
32
+ var SparkpostDomainSetup = function SparkpostDomainSetup(_ref) {
33
+ var ownerId = _ref.ownerId,
34
+ alreadyVerifiedRoute = _ref.alreadyVerifiedRoute,
35
+ verifyRoute = _ref.verifyRoute,
36
+ onCancelRoute = _ref.onCancelRoute,
37
+ canManageIntegrations = _ref.canManageIntegrations;
38
+ var _useTranslation = reactI18next.useTranslation(),
39
+ t = _useTranslation.t;
40
+ var history = reactRouterDom.useHistory();
41
+ var _useSparkpostDomain = useSparkpostDomain.useSparkpostDomain({
42
+ ownerId: ownerId,
43
+ canManageIntegrations: canManageIntegrations
44
+ }),
45
+ onCreateDomain = _useSparkpostDomain.onCreateDomain,
46
+ isCreating = _useSparkpostDomain.isCreating;
47
+ var handleSubmit = function handleSubmit(values, _ref2) {
48
+ var setFieldError = _ref2.setFieldError;
49
+ onCreateDomain(values.email.trim(), function (response) {
50
+ if (response !== null && response !== void 0 && response.alreadyVerified) {
51
+ // Domain is already verified, go back to email delivery settings
52
+ history.push(alreadyVerifiedRoute);
53
+ } else {
54
+ // Navigate to verification page with domain query parameter
55
+ var domain = getDomainFromEmail(values.email);
56
+ history.push(utils.buildUrl(verifyRoute, {
57
+ domain: domain,
58
+ email: values.email.trim()
59
+ }));
60
+ }
61
+ }, function (error) {
62
+ var _error$response;
63
+ var errorMessage = (error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.error) || t("neetoEmailDelivery.sparkpost.setup.validation.setupFailed");
64
+ setFieldError("email", errorMessage);
65
+ });
66
+ };
67
+ var handleCancel = function handleCancel() {
68
+ history.push(onCancelRoute);
69
+ };
70
+ return /*#__PURE__*/jsxRuntime.jsx(constants.PageWrapper, {
71
+ children: /*#__PURE__*/jsxRuntime.jsx(constants.PageContent, {
72
+ children: /*#__PURE__*/jsxRuntime.jsx(Form, {
73
+ className: "w-full",
74
+ formikProps: {
75
+ initialValues: {
76
+ email: ""
77
+ },
78
+ validationSchema: constants.VALIDATION_SCHEMA,
79
+ onSubmit: handleSubmit
80
+ },
81
+ children: function children(_ref3) {
82
+ var values = _ref3.values;
83
+ var domain = values.email ? getDomainFromEmail(values.email) : t("neetoEmailDelivery.sparkpost.customDomain");
84
+ return /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
85
+ title: String(t("neetoEmailDelivery.sparkpost.setup.title")),
86
+ actionBlock: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
87
+ cancelButtonProps: {
88
+ onClick: handleCancel
89
+ },
90
+ isSubmitting: isCreating,
91
+ submitButtonProps: {
92
+ label: t("neetoEmailDelivery.sparkpost.setup.setupEmail")
93
+ }
94
+ }),
95
+ description: String(t("neetoEmailDelivery.sparkpost.setup.description")),
96
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
97
+ className: "flex flex-col gap-6",
98
+ children: [/*#__PURE__*/jsxRuntime.jsx(Callout, {
99
+ style: "warning",
100
+ children: t("neetoEmailDelivery.sparkpost.setup.note")
101
+ }), /*#__PURE__*/jsxRuntime.jsx(Input, {
102
+ required: true,
103
+ unlimitedChars: true,
104
+ label: t("neetoEmailDelivery.sparkpost.setup.emailLabel"),
105
+ name: "email",
106
+ type: "email",
107
+ helpText: t("neetoEmailDelivery.sparkpost.setup.emailHelp", {
108
+ domain: domain
109
+ }),
110
+ placeholder: t("neetoEmailDelivery.sparkpost.setup.emailPlaceholder")
111
+ })]
112
+ })
113
+ });
114
+ }
115
+ })
116
+ })
117
+ });
118
+ };
119
+
120
+ module.exports = SparkpostDomainSetup;
121
+ //# sourceMappingURL=SparkpostDomainSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SparkpostDomainSetup.js","sources":["../../app/javascript/src/components/SparkpostDomain/utils.js","../../app/javascript/src/components/SparkpostDomain/Setup.jsx"],"sourcesContent":["const getDomainFromEmail = email => email.trim().split(\"@\")[1];\n\nexport { getDomainFromEmail };\n","import { buildUrl } from \"neetocommons/utils\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport { Callout } from \"neetoui\";\nimport { Input, ActionBlock, Form } from \"neetoui/formik\";\nimport { useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport { PageContent, PageWrapper } from \"components/PageLayout\";\nimport useSparkpostDomain from \"hooks/integrations/useSparkpostDomain\";\n\nimport { VALIDATION_SCHEMA } from \"./constants\";\nimport { getDomainFromEmail } from \"./utils\";\n\nconst SparkpostDomainSetup = ({\n ownerId,\n alreadyVerifiedRoute,\n verifyRoute,\n onCancelRoute,\n canManageIntegrations,\n}) => {\n const { t } = useTranslation();\n\n const history = useHistory();\n\n const { onCreateDomain, isCreating } = useSparkpostDomain({\n ownerId,\n canManageIntegrations,\n });\n\n const handleSubmit = (values, { setFieldError }) => {\n onCreateDomain(\n values.email.trim(),\n response => {\n if (response?.alreadyVerified) {\n // Domain is already verified, go back to email delivery settings\n history.push(alreadyVerifiedRoute);\n } else {\n // Navigate to verification page with domain query parameter\n const domain = getDomainFromEmail(values.email);\n history.push(\n buildUrl(verifyRoute, { domain, email: values.email.trim() })\n );\n }\n },\n error => {\n const errorMessage =\n error?.response?.data?.error ||\n t(\"neetoEmailDelivery.sparkpost.setup.validation.setupFailed\");\n setFieldError(\"email\", errorMessage);\n }\n );\n };\n\n const handleCancel = () => {\n history.push(onCancelRoute);\n };\n\n return (\n <PageWrapper>\n <PageContent>\n <Form\n className=\"w-full\"\n formikProps={{\n initialValues: { email: \"\" },\n validationSchema: VALIDATION_SCHEMA,\n onSubmit: handleSubmit,\n }}\n >\n {({ values }) => {\n const domain = values.email\n ? getDomainFromEmail(values.email)\n : t(\"neetoEmailDelivery.sparkpost.customDomain\");\n\n return (\n <CardLayout\n title={String(t(\"neetoEmailDelivery.sparkpost.setup.title\"))}\n actionBlock={\n <ActionBlock\n cancelButtonProps={{ onClick: handleCancel }}\n isSubmitting={isCreating}\n submitButtonProps={{\n label: t(\"neetoEmailDelivery.sparkpost.setup.setupEmail\"),\n }}\n />\n }\n description={String(\n t(\"neetoEmailDelivery.sparkpost.setup.description\")\n )}\n >\n <div className=\"flex flex-col gap-6\">\n <Callout style=\"warning\">\n {t(\"neetoEmailDelivery.sparkpost.setup.note\")}\n </Callout>\n <Input\n required\n unlimitedChars\n label={t(\"neetoEmailDelivery.sparkpost.setup.emailLabel\")}\n name=\"email\"\n type=\"email\"\n helpText={t(\n \"neetoEmailDelivery.sparkpost.setup.emailHelp\",\n { domain }\n )}\n placeholder={t(\n \"neetoEmailDelivery.sparkpost.setup.emailPlaceholder\"\n )}\n />\n </div>\n </CardLayout>\n );\n }}\n </Form>\n </PageContent>\n </PageWrapper>\n );\n};\n\nexport default SparkpostDomainSetup;\n"],"names":["getDomainFromEmail","email","trim","split","SparkpostDomainSetup","_ref","ownerId","alreadyVerifiedRoute","verifyRoute","onCancelRoute","canManageIntegrations","_useTranslation","useTranslation","t","history","useHistory","_useSparkpostDomain","useSparkpostDomain","onCreateDomain","isCreating","handleSubmit","values","_ref2","setFieldError","response","alreadyVerified","push","domain","buildUrl","error","_error$response","errorMessage","data","handleCancel","_jsx","PageWrapper","children","PageContent","Form","className","formikProps","initialValues","validationSchema","VALIDATION_SCHEMA","onSubmit","_ref3","CardLayout","title","String","actionBlock","ActionBlock","cancelButtonProps","onClick","isSubmitting","submitButtonProps","label","description","_jsxs","Callout","style","Input","required","unlimitedChars","name","type","helpText","placeholder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAGC,KAAK,EAAA;AAAA,EAAA,OAAIA,KAAK,CAACC,IAAI,EAAE,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,CAAA;;ACa9D,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAAC,IAAA,EAMpB;AAAA,EAAA,IALJC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,oBAAoB,GAAAF,IAAA,CAApBE,oBAAoB;IACpBC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,aAAa,GAAAJ,IAAA,CAAbI,aAAa;IACbC,qBAAqB,GAAAL,IAAA,CAArBK,qBAAqB;AAErB,EAAA,IAAAC,eAAA,GAAcC,2BAAc,EAAE;IAAtBC,CAAC,GAAAF,eAAA,CAADE,CAAC;AAET,EAAA,IAAMC,OAAO,GAAGC,yBAAU,EAAE;EAE5B,IAAAC,mBAAA,GAAuCC,qCA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