@bigbinary/neeto-email-delivery-frontend 1.0.7 → 1.0.9

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 (38) hide show
  1. package/README.md +39 -0
  2. package/app/javascript/src/translations/en.json +4 -1
  3. package/dist/EmailDeliveryScreen.js +52 -99
  4. package/dist/EmailDeliveryScreen.js.map +1 -1
  5. package/dist/SparkpostDomainSetup.js +2 -1
  6. package/dist/SparkpostDomainSetup.js.map +1 -1
  7. package/dist/SparkpostDomainVerify.js +2 -1
  8. package/dist/SparkpostDomainVerify.js.map +1 -1
  9. package/dist/cjs/EmailDeliveryScreen.js +57 -104
  10. package/dist/cjs/EmailDeliveryScreen.js.map +1 -1
  11. package/dist/cjs/SparkpostDomainSetup.js +2 -1
  12. package/dist/cjs/SparkpostDomainSetup.js.map +1 -1
  13. package/dist/cjs/SparkpostDomainVerify.js +3 -2
  14. package/dist/cjs/SparkpostDomainVerify.js.map +1 -1
  15. package/dist/cjs/hooks.js +52 -0
  16. package/dist/cjs/hooks.js.map +1 -0
  17. package/dist/cjs/index.js +5 -3
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/hooks.js +50 -0
  20. package/dist/hooks.js.map +1 -0
  21. package/dist/index.js +5 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/useOutlookIntegrationApi-CtHj_BzG.js +92 -0
  24. package/dist/useOutlookIntegrationApi-CtHj_BzG.js.map +1 -0
  25. package/dist/useOutlookIntegrationApi-ZgRWrUQN.js +87 -0
  26. package/dist/useOutlookIntegrationApi-ZgRWrUQN.js.map +1 -0
  27. package/dist/{useSparkpostDomain-DdG5InhX.js → useSparkpostApi-W7XibjIp.js} +2 -92
  28. package/dist/useSparkpostApi-W7XibjIp.js.map +1 -0
  29. package/dist/{useSparkpostDomain-qxCkAS6s.js → useSparkpostApi-pa64NIl6.js} +4 -92
  30. package/dist/useSparkpostApi-pa64NIl6.js.map +1 -0
  31. package/dist/useSparkpostDomain-DO4bG1HD.js +95 -0
  32. package/dist/useSparkpostDomain-DO4bG1HD.js.map +1 -0
  33. package/dist/useSparkpostDomain-wsENCoto.js +97 -0
  34. package/dist/useSparkpostDomain-wsENCoto.js.map +1 -0
  35. package/hooks.d.ts +21 -0
  36. package/package.json +8 -7
  37. package/dist/useSparkpostDomain-DdG5InhX.js.map +0 -1
  38. package/dist/useSparkpostDomain-qxCkAS6s.js.map +0 -1
@@ -1,7 +1,3 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import { useState } from 'react';
3
- import Toastr from '@bigbinary/neetoui/Toastr';
4
- import { useTranslation } from 'react-i18next';
5
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
6
2
  import { useQuery } from '@tanstack/react-query';
7
3
  import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
@@ -92,91 +88,5 @@ var useDestroySparkpostDomain = function useDestroySparkpostDomain(_ref3) {
92
88
  });
93
89
  };
94
90
 
95
- var useSparkpostDomain = function useSparkpostDomain(_ref) {
96
- var ownerId = _ref.ownerId,
97
- canManageIntegrations = _ref.canManageIntegrations;
98
- var _useState = useState(false),
99
- _useState2 = _slicedToArray(_useState, 2),
100
- isDisconnectAlertOpen = _useState2[0],
101
- setIsDisconnectAlertOpen = _useState2[1];
102
- var _useTranslation = useTranslation(),
103
- t = _useTranslation.t;
104
- var _useFetchSparkpostDom = useFetchSparkpostDomain(ownerId, {
105
- enabled: canManageIntegrations
106
- }),
107
- isLoading = _useFetchSparkpostDom.isLoading,
108
- _useFetchSparkpostDom2 = _useFetchSparkpostDom.data,
109
- data = _useFetchSparkpostDom2 === void 0 ? {} : _useFetchSparkpostDom2;
110
- var _useCreateSparkpostDo = useCreateSparkpostDomain({
111
- ownerId: ownerId
112
- }),
113
- isCreating = _useCreateSparkpostDo.isPending,
114
- createDomain = _useCreateSparkpostDo.mutate;
115
- var _useVerifySparkpostDo = useVerifySparkpostDomain({
116
- ownerId: ownerId
117
- }),
118
- isVerifying = _useVerifySparkpostDo.isPending,
119
- verifyDomain = _useVerifySparkpostDo.mutate;
120
- var _useDestroySparkpostD = useDestroySparkpostDomain({
121
- ownerId: ownerId
122
- }),
123
- isDestroying = _useDestroySparkpostD.isPending,
124
- destroyDomain = _useDestroySparkpostD.mutate;
125
- var onCreateDomain = function onCreateDomain(email, _onSuccess, _onError) {
126
- createDomain({
127
- sparkpostDomain: {
128
- email: email
129
- }
130
- }, {
131
- onSuccess: function onSuccess(response) {
132
- if (response !== null && response !== void 0 && response.alreadyVerified) {
133
- Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected"));
134
- }
135
- _onSuccess === null || _onSuccess === void 0 || _onSuccess(response);
136
- },
137
- onError: function onError(error) {
138
- _onError === null || _onError === void 0 || _onError(error);
139
- }
140
- });
141
- };
142
- var onVerifyDomain = function onVerifyDomain(_onSuccess2, _onError2) {
143
- verifyDomain(false, {
144
- onSuccess: function onSuccess(response) {
145
- if (response !== null && response !== void 0 && response.verified) {
146
- Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerified"));
147
- } else {
148
- Toastr.warning(t("neetoEmailDelivery.sparkpost.toasts.verificationPending"));
149
- }
150
- _onSuccess2 === null || _onSuccess2 === void 0 || _onSuccess2(response);
151
- },
152
- onError: function onError(error) {
153
- _onError2 === null || _onError2 === void 0 || _onError2(error);
154
- }
155
- });
156
- };
157
- var onDisconnect = function onDisconnect(_onSuccess3) {
158
- destroyDomain(false, {
159
- onSuccess: function onSuccess() {
160
- Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainDisconnected"));
161
- setIsDisconnectAlertOpen(false);
162
- _onSuccess3 === null || _onSuccess3 === void 0 || _onSuccess3();
163
- }
164
- });
165
- };
166
- return {
167
- data: data,
168
- isLoading: isLoading,
169
- isCreating: isCreating,
170
- isVerifying: isVerifying,
171
- isDestroying: isDestroying,
172
- isConnected: (data === null || data === void 0 ? void 0 : data.connected) || false,
173
- isDisconnectAlertOpen: isDisconnectAlertOpen,
174
- setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
175
- onCreateDomain: onCreateDomain,
176
- onVerifyDomain: onVerifyDomain,
177
- onDisconnect: onDisconnect
178
- };
179
- };
180
-
181
- export { GMAIL_URL as G, OUTLOOK_URL as O, QUERY_KEYS as Q, useFetchSparkpostDomain as a, GMAIL_OAUTH_URL as b, OUTLOOK_OAUTH_URL as c, GMAIL_OAUTH_CONNECT_URL as d, OUTLOOK_OAUTH_CONNECT_URL as e, useSparkpostDomain as u };
182
- //# sourceMappingURL=useSparkpostDomain-DdG5InhX.js.map
91
+ export { GMAIL_URL as G, OUTLOOK_URL as O, QUERY_KEYS as Q, useCreateSparkpostDomain as a, useVerifySparkpostDomain as b, useDestroySparkpostDomain as c, GMAIL_OAUTH_URL as d, OUTLOOK_OAUTH_URL as e, GMAIL_OAUTH_CONNECT_URL as f, OUTLOOK_OAUTH_CONNECT_URL as g, useFetchSparkpostDomain as u };
92
+ //# sourceMappingURL=useSparkpostApi-W7XibjIp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSparkpostApi-W7XibjIp.js","sources":["../app/javascript/src/apis/integrations/constants.js","../app/javascript/src/constants/query.js","../app/javascript/src/apis/integrations/sparkpost_domains.js","../app/javascript/src/hooks/reactQuery/integrations/useSparkpostApi.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/api-connector-should-use-default-export */\n\nconst NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL = \"/neeto_email_delivery/api/v1\";\n\nexport const GMAIL_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/gmail`;\nexport const GMAIL_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/:ownerId`;\nexport const GMAIL_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/connect`;\n\nexport const OUTLOOK_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/outlook`;\nexport const OUTLOOK_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/:ownerId`;\nexport const OUTLOOK_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/connect`;\n\nexport const SPARKPOST_DOMAINS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_INTEGRATIONS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_VERIFY_URL = `${SPARKPOST_DOMAINS_INTEGRATIONS_URL}/verify`;\n","export const QUERY_KEYS = {\n INTEGRATION_GMAIL: \"integration-gmail\",\n INTEGRATION_OUTLOOK: \"integration-outlook\",\n INTEGRATION_SPARKPOST: \"integration-sparkpost\",\n};\n","import axios from \"axios\";\nimport { buildUrl } from \"neetocommons/utils\";\n\nimport {\n SPARKPOST_DOMAINS_URL,\n SPARKPOST_DOMAINS_VERIFY_URL,\n SPARKPOST_DOMAINS_INTEGRATIONS_URL,\n} from \"./constants\";\n\nconst get = ownerId =>\n axios.get(buildUrl(SPARKPOST_DOMAINS_URL, { ownerId }), {\n showToastr: false,\n });\n\nconst create = (ownerId, payload) =>\n axios.post(\n buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }),\n payload\n );\n\nconst verify = ownerId =>\n axios.post(buildUrl(SPARKPOST_DOMAINS_VERIFY_URL, { ownerId }));\n\nconst destroy = ownerId =>\n axios.delete(buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }));\n\nconst sparkpostDomainsApi = { get, create, verify, destroy };\n\nexport default sparkpostDomainsApi;\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport sparkpostDomainsApi from \"apis/integrations/sparkpost_domains\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nexport const useFetchSparkpostDomain = (ownerId, options) =>\n useQuery({\n queryKey: [QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId],\n queryFn: () => sparkpostDomainsApi.get(ownerId),\n retry: 1,\n ...options,\n });\n\nexport const useCreateSparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(\n payload => sparkpostDomainsApi.create(ownerId, payload),\n { keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]] }\n );\n\nexport const useVerifySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.verify(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n\nexport const useDestroySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.destroy(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n"],"names":["NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL","GMAIL_URL","concat","GMAIL_OAUTH_URL","GMAIL_OAUTH_CONNECT_URL","OUTLOOK_URL","OUTLOOK_OAUTH_URL","OUTLOOK_OAUTH_CONNECT_URL","SPARKPOST_DOMAINS_URL","SPARKPOST_DOMAINS_INTEGRATIONS_URL","SPARKPOST_DOMAINS_VERIFY_URL","QUERY_KEYS","INTEGRATION_GMAIL","INTEGRATION_OUTLOOK","INTEGRATION_SPARKPOST","get","ownerId","axios","buildUrl","showToastr","create","payload","post","verify","destroy","sparkpostDomainsApi","useFetchSparkpostDomain","options","useQuery","_objectSpread","queryKey","queryFn","retry","useCreateSparkpostDomain","_ref","useMutationWithInvalidation","keysToInvalidate","useVerifySparkpostDomain","_ref2","useDestroySparkpostDomain","_ref3"],"mappings":";;;;;;AAAA;;AAEA,IAAMA,oCAAoC,GAAG,8BAA8B;IAE9DC,SAAS,GAAA,EAAA,CAAAC,MAAA,CAAMF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AO,CAAC;AAAE,GACpE,CAAC;AAAA;IAEUqB,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAAC,KAAA,EAAA;AAAA,EAAA,IAAMtB,OAAO,GAAAsB,KAAA,CAAPtB,OAAO;AAAA,EAAA,OAChDmB,2BAA2B,CAAC,YAAA;AAAA,IAAA,OAAMV,mBAAmB,CAACF,MAAM,CAACP,OAAO,CAAC;GAAE,EAAA;IACrEoB,gBAAgB,EAAE,CAAC,CAACzB,UAAU,CAACG,qBAAqB,EAAEE,OAAO,CAAC;AAChE,GAAC,CAAC;AAAA;IAESuB,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAAC,KAAA,EAAA;AAAA,EAAA,IAAMxB,OAAO,GAAAwB,KAAA,CAAPxB,OAAO;AAAA,EAAA,OACjDmB,2BAA2B,CAAC,YAAA;AAAA,IAAA,OAAMV,mBAAmB,CAACD,OAAO,CAACR,OAAO,CAAC;GAAE,EAAA;IACtEoB,gBAAgB,EAAE,CAAC,CAACzB,UAAU,CAACG,qBAAqB,EAAEE,OAAO,CAAC;AAChE,GAAC,CAAC;AAAA;;;;"}
@@ -1,9 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
- var react = require('react');
5
- var Toastr = require('@bigbinary/neetoui/Toastr');
6
- var reactI18next = require('react-i18next');
7
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
8
4
  var reactQuery = require('@tanstack/react-query');
9
5
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
@@ -94,92 +90,6 @@ var useDestroySparkpostDomain = function useDestroySparkpostDomain(_ref3) {
94
90
  });
95
91
  };
96
92
 
97
- var useSparkpostDomain = function useSparkpostDomain(_ref) {
98
- var ownerId = _ref.ownerId,
99
- canManageIntegrations = _ref.canManageIntegrations;
100
- var _useState = react.useState(false),
101
- _useState2 = _slicedToArray(_useState, 2),
102
- isDisconnectAlertOpen = _useState2[0],
103
- setIsDisconnectAlertOpen = _useState2[1];
104
- var _useTranslation = reactI18next.useTranslation(),
105
- t = _useTranslation.t;
106
- var _useFetchSparkpostDom = useFetchSparkpostDomain(ownerId, {
107
- enabled: canManageIntegrations
108
- }),
109
- isLoading = _useFetchSparkpostDom.isLoading,
110
- _useFetchSparkpostDom2 = _useFetchSparkpostDom.data,
111
- data = _useFetchSparkpostDom2 === void 0 ? {} : _useFetchSparkpostDom2;
112
- var _useCreateSparkpostDo = useCreateSparkpostDomain({
113
- ownerId: ownerId
114
- }),
115
- isCreating = _useCreateSparkpostDo.isPending,
116
- createDomain = _useCreateSparkpostDo.mutate;
117
- var _useVerifySparkpostDo = useVerifySparkpostDomain({
118
- ownerId: ownerId
119
- }),
120
- isVerifying = _useVerifySparkpostDo.isPending,
121
- verifyDomain = _useVerifySparkpostDo.mutate;
122
- var _useDestroySparkpostD = useDestroySparkpostDomain({
123
- ownerId: ownerId
124
- }),
125
- isDestroying = _useDestroySparkpostD.isPending,
126
- destroyDomain = _useDestroySparkpostD.mutate;
127
- var onCreateDomain = function onCreateDomain(email, _onSuccess, _onError) {
128
- createDomain({
129
- sparkpostDomain: {
130
- email: email
131
- }
132
- }, {
133
- onSuccess: function onSuccess(response) {
134
- if (response !== null && response !== void 0 && response.alreadyVerified) {
135
- Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected"));
136
- }
137
- _onSuccess === null || _onSuccess === void 0 || _onSuccess(response);
138
- },
139
- onError: function onError(error) {
140
- _onError === null || _onError === void 0 || _onError(error);
141
- }
142
- });
143
- };
144
- var onVerifyDomain = function onVerifyDomain(_onSuccess2, _onError2) {
145
- verifyDomain(false, {
146
- onSuccess: function onSuccess(response) {
147
- if (response !== null && response !== void 0 && response.verified) {
148
- Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerified"));
149
- } else {
150
- Toastr.warning(t("neetoEmailDelivery.sparkpost.toasts.verificationPending"));
151
- }
152
- _onSuccess2 === null || _onSuccess2 === void 0 || _onSuccess2(response);
153
- },
154
- onError: function onError(error) {
155
- _onError2 === null || _onError2 === void 0 || _onError2(error);
156
- }
157
- });
158
- };
159
- var onDisconnect = function onDisconnect(_onSuccess3) {
160
- destroyDomain(false, {
161
- onSuccess: function onSuccess() {
162
- Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainDisconnected"));
163
- setIsDisconnectAlertOpen(false);
164
- _onSuccess3 === null || _onSuccess3 === void 0 || _onSuccess3();
165
- }
166
- });
167
- };
168
- return {
169
- data: data,
170
- isLoading: isLoading,
171
- isCreating: isCreating,
172
- isVerifying: isVerifying,
173
- isDestroying: isDestroying,
174
- isConnected: (data === null || data === void 0 ? void 0 : data.connected) || false,
175
- isDisconnectAlertOpen: isDisconnectAlertOpen,
176
- setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
177
- onCreateDomain: onCreateDomain,
178
- onVerifyDomain: onVerifyDomain,
179
- onDisconnect: onDisconnect
180
- };
181
- };
182
-
183
93
  exports.GMAIL_OAUTH_CONNECT_URL = GMAIL_OAUTH_CONNECT_URL;
184
94
  exports.GMAIL_OAUTH_URL = GMAIL_OAUTH_URL;
185
95
  exports.GMAIL_URL = GMAIL_URL;
@@ -187,6 +97,8 @@ exports.OUTLOOK_OAUTH_CONNECT_URL = OUTLOOK_OAUTH_CONNECT_URL;
187
97
  exports.OUTLOOK_OAUTH_URL = OUTLOOK_OAUTH_URL;
188
98
  exports.OUTLOOK_URL = OUTLOOK_URL;
189
99
  exports.QUERY_KEYS = QUERY_KEYS;
100
+ exports.useCreateSparkpostDomain = useCreateSparkpostDomain;
101
+ exports.useDestroySparkpostDomain = useDestroySparkpostDomain;
190
102
  exports.useFetchSparkpostDomain = useFetchSparkpostDomain;
191
- exports.useSparkpostDomain = useSparkpostDomain;
192
- //# sourceMappingURL=useSparkpostDomain-qxCkAS6s.js.map
103
+ exports.useVerifySparkpostDomain = useVerifySparkpostDomain;
104
+ //# sourceMappingURL=useSparkpostApi-pa64NIl6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSparkpostApi-pa64NIl6.js","sources":["../app/javascript/src/apis/integrations/constants.js","../app/javascript/src/constants/query.js","../app/javascript/src/apis/integrations/sparkpost_domains.js","../app/javascript/src/hooks/reactQuery/integrations/useSparkpostApi.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/api-connector-should-use-default-export */\n\nconst NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL = \"/neeto_email_delivery/api/v1\";\n\nexport const GMAIL_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/gmail`;\nexport const GMAIL_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/:ownerId`;\nexport const GMAIL_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/connect`;\n\nexport const OUTLOOK_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/outlook`;\nexport const OUTLOOK_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/:ownerId`;\nexport const OUTLOOK_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/connect`;\n\nexport const SPARKPOST_DOMAINS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_INTEGRATIONS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_VERIFY_URL = `${SPARKPOST_DOMAINS_INTEGRATIONS_URL}/verify`;\n","export const QUERY_KEYS = {\n INTEGRATION_GMAIL: \"integration-gmail\",\n INTEGRATION_OUTLOOK: \"integration-outlook\",\n INTEGRATION_SPARKPOST: \"integration-sparkpost\",\n};\n","import axios from \"axios\";\nimport { buildUrl } from \"neetocommons/utils\";\n\nimport {\n SPARKPOST_DOMAINS_URL,\n SPARKPOST_DOMAINS_VERIFY_URL,\n SPARKPOST_DOMAINS_INTEGRATIONS_URL,\n} from \"./constants\";\n\nconst get = ownerId =>\n axios.get(buildUrl(SPARKPOST_DOMAINS_URL, { ownerId }), {\n showToastr: false,\n });\n\nconst create = (ownerId, payload) =>\n axios.post(\n buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }),\n payload\n );\n\nconst verify = ownerId =>\n axios.post(buildUrl(SPARKPOST_DOMAINS_VERIFY_URL, { ownerId }));\n\nconst destroy = ownerId =>\n axios.delete(buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }));\n\nconst sparkpostDomainsApi = { get, create, verify, destroy };\n\nexport default sparkpostDomainsApi;\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport sparkpostDomainsApi from \"apis/integrations/sparkpost_domains\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nexport const useFetchSparkpostDomain = (ownerId, options) =>\n useQuery({\n queryKey: [QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId],\n queryFn: () => sparkpostDomainsApi.get(ownerId),\n retry: 1,\n ...options,\n });\n\nexport const useCreateSparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(\n payload => sparkpostDomainsApi.create(ownerId, payload),\n { keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]] }\n );\n\nexport const useVerifySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.verify(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n\nexport const useDestroySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.destroy(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n"],"names":["NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL","GMAIL_URL","concat","GMAIL_OAUTH_URL","GMAIL_OAUTH_CONNECT_URL","OUTLOOK_URL","OUTLOOK_OAUTH_URL","OUTLOOK_OAUTH_CONNECT_URL","SPARKPOST_DOMAINS_URL","SPARKPOST_DOMAINS_INTEGRATIONS_URL","SPARKPOST_DOMAINS_VERIFY_URL","QUERY_KEYS","INTEGRATION_GMAIL","INTEGRATION_OUTLOOK","INTEGRATION_SPARKPOST","get","ownerId","axios","buildUrl","showToastr","create","payload","post","verify","destroy","sparkpostDomainsApi","useFetchSparkpostDomain","options","useQuery","_objectSpread","queryKey","queryFn","retry","useCreateSparkpostDomain","_ref","useMutationWithInvalidation","keysToInvalidate","useVerifySparkpostDomain","_ref2","useDestroySparkpostDomain","_ref3"],"mappings":";;;;;;;;AAAA;;AAEA,IAAMA,oCAAoC,GAAG,8BAA8B;IAE9DC,SAAS,GAAA,EAAA,CAAAC,MAAA,CAAMF,oCAAoC,EAAQ,QAAA;IAC3DG,eAAe,GAAA,EAAA,CAAAD,MAAA,CAAMF,oCAAoC,EAAoC,oCAAA;IAC7FI,uBAAuB,GAAA,EAAA,CAAAF,MAAA,CAAMF,oCAAoC,EAAmC,mCAAA;IAEpGK,WAAW,GAAA,EAAA,CAAAH,MAAA,CAAMF,oCAAoC,EAAU,UAAA;IAC/DM,iBAAiB,GAAA,EAAA,CAAAJ,MAAA,CAAMF,oCAAoC,EAAsC,sCAAA;IACjGO,yBAAyB,GAAA,EAAA,CAAAL,MAAA,CAAMF,oCAAoC,EAAqC,qCAAA;AAE9G,IAAMQ,qBAAqB,GAAA,EAAA,CAAAN,MAAA,CAAMF,oCAAoC,EAAoB,oBAAA,CAAA;AACzF,IAAMS,kCAAkC,GAAA,EAAA,CAAAP,MAAA,CAAMF,oCAAoC,EAAiC,iCAAA,CAAA;AACnH,IAAMU,4BAA4B,GAAA,EAAA,CAAAR,MAAA,CAAMO,kCAAkC,EAAS,SAAA,CAAA;;ACdnF,IAAME,UAAU,GAAG;AACxBC,EAA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AChE,GAAC,CAAC;AAAA;;;;;;;;;;;;;;"}
@@ -0,0 +1,95 @@
1
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import { useState } from 'react';
3
+ import Toastr from '@bigbinary/neetoui/Toastr';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { u as useFetchSparkpostDomain, a as useCreateSparkpostDomain, b as useVerifySparkpostDomain, c as useDestroySparkpostDomain } from './useSparkpostApi-W7XibjIp.js';
6
+
7
+ var useSparkpostDomain = function useSparkpostDomain(_ref) {
8
+ var ownerId = _ref.ownerId,
9
+ canManageIntegrations = _ref.canManageIntegrations;
10
+ var _useState = useState(false),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ isDisconnectAlertOpen = _useState2[0],
13
+ setIsDisconnectAlertOpen = _useState2[1];
14
+ var _useTranslation = useTranslation(),
15
+ t = _useTranslation.t;
16
+ var _useFetchSparkpostDom = useFetchSparkpostDomain(ownerId, {
17
+ enabled: canManageIntegrations
18
+ }),
19
+ isLoading = _useFetchSparkpostDom.isLoading,
20
+ _useFetchSparkpostDom2 = _useFetchSparkpostDom.data,
21
+ data = _useFetchSparkpostDom2 === void 0 ? {} : _useFetchSparkpostDom2;
22
+ var _useCreateSparkpostDo = useCreateSparkpostDomain({
23
+ ownerId: ownerId
24
+ }),
25
+ isCreating = _useCreateSparkpostDo.isPending,
26
+ createDomain = _useCreateSparkpostDo.mutate;
27
+ var _useVerifySparkpostDo = useVerifySparkpostDomain({
28
+ ownerId: ownerId
29
+ }),
30
+ isVerifying = _useVerifySparkpostDo.isPending,
31
+ verifyDomain = _useVerifySparkpostDo.mutate;
32
+ var _useDestroySparkpostD = useDestroySparkpostDomain({
33
+ ownerId: ownerId
34
+ }),
35
+ isDestroying = _useDestroySparkpostD.isPending,
36
+ destroyDomain = _useDestroySparkpostD.mutate;
37
+ var onCreateDomain = function onCreateDomain(email, _onSuccess, _onError) {
38
+ createDomain({
39
+ sparkpostDomain: {
40
+ email: email
41
+ }
42
+ }, {
43
+ onSuccess: function onSuccess(response) {
44
+ if (response !== null && response !== void 0 && response.alreadyVerified) {
45
+ Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected"));
46
+ }
47
+ _onSuccess === null || _onSuccess === void 0 || _onSuccess(response);
48
+ },
49
+ onError: function onError(error) {
50
+ _onError === null || _onError === void 0 || _onError(error);
51
+ }
52
+ });
53
+ };
54
+ var onVerifyDomain = function onVerifyDomain(_onSuccess2, _onError2) {
55
+ verifyDomain(false, {
56
+ onSuccess: function onSuccess(response) {
57
+ if (response !== null && response !== void 0 && response.verified) {
58
+ Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerified"));
59
+ } else {
60
+ Toastr.warning(t("neetoEmailDelivery.sparkpost.toasts.verificationPending"));
61
+ }
62
+ _onSuccess2 === null || _onSuccess2 === void 0 || _onSuccess2(response);
63
+ },
64
+ onError: function onError(error) {
65
+ _onError2 === null || _onError2 === void 0 || _onError2(error);
66
+ }
67
+ });
68
+ };
69
+ var onDisconnect = function onDisconnect(_onSuccess3) {
70
+ destroyDomain(false, {
71
+ onSuccess: function onSuccess() {
72
+ Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainDisconnected"));
73
+ setIsDisconnectAlertOpen(false);
74
+ _onSuccess3 === null || _onSuccess3 === void 0 || _onSuccess3();
75
+ }
76
+ });
77
+ };
78
+ return {
79
+ data: data,
80
+ isLoading: isLoading,
81
+ isCreating: isCreating,
82
+ isVerifying: isVerifying,
83
+ isDestroying: isDestroying,
84
+ exists: data === null || data === void 0 ? void 0 : data.exists,
85
+ isConnected: (data === null || data === void 0 ? void 0 : data.connected) || false,
86
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
87
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
88
+ onCreateDomain: onCreateDomain,
89
+ onVerifyDomain: onVerifyDomain,
90
+ onDisconnect: onDisconnect
91
+ };
92
+ };
93
+
94
+ export { useSparkpostDomain as u };
95
+ //# sourceMappingURL=useSparkpostDomain-DO4bG1HD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSparkpostDomain-DO4bG1HD.js","sources":["../app/javascript/src/hooks/integrations/useSparkpostDomain.js"],"sourcesContent":["import { useState } from \"react\";\n\nimport { Toastr } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n useFetchSparkpostDomain,\n useCreateSparkpostDomain,\n useVerifySparkpostDomain,\n useDestroySparkpostDomain,\n} from \"hooks/reactQuery/integrations/useSparkpostApi\";\n\nconst useSparkpostDomain = ({ ownerId, canManageIntegrations }) => {\n const [isDisconnectAlertOpen, setIsDisconnectAlertOpen] = useState(false);\n const { t } = useTranslation();\n\n const { isLoading, data = {} } = useFetchSparkpostDomain(ownerId, {\n enabled: canManageIntegrations,\n });\n\n const { isPending: isCreating, mutate: createDomain } =\n useCreateSparkpostDomain({ ownerId });\n\n const { isPending: isVerifying, mutate: verifyDomain } =\n useVerifySparkpostDomain({ ownerId });\n\n const { isPending: isDestroying, mutate: destroyDomain } =\n useDestroySparkpostDomain({ ownerId });\n\n const onCreateDomain = (email, onSuccess, onError) => {\n createDomain(\n { sparkpostDomain: { email } },\n {\n onSuccess: response => {\n if (response?.alreadyVerified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n }\n );\n };\n\n const onVerifyDomain = (onSuccess, onError) => {\n verifyDomain(false, {\n onSuccess: response => {\n if (response?.verified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerified\")\n );\n } else {\n Toastr.warning(\n t(\"neetoEmailDelivery.sparkpost.toasts.verificationPending\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n });\n };\n\n const onDisconnect = onSuccess => {\n destroyDomain(false, {\n onSuccess: () => {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainDisconnected\")\n );\n setIsDisconnectAlertOpen(false);\n onSuccess?.();\n },\n });\n };\n\n return {\n data,\n isLoading,\n isCreating,\n isVerifying,\n isDestroying,\n exists: data?.exists,\n isConnected: data?.connected || false,\n isDisconnectAlertOpen,\n setIsDisconnectAlertOpen,\n onCreateDomain,\n onVerifyDomain,\n onDisconnect,\n };\n};\n\nexport default useSparkpostDomain;\n"],"names":["useSparkpostDomain","_ref","ownerId","canManageIntegrations","_useState","useState","_useState2","_slicedToArray","isDisconnectAlertOpen","setIsDisconnectAlertOpen","_useTranslation","useTranslation","t","_useFetchSparkpostDom","useFetchSparkpostDomain","enabled","isLoading","_useFetchSparkpostDom2","data","_useCreateSparkpostDo","useCreateSparkpostDomain","isCreating","isPending","createDomain","mutate","_useVerifySparkpostDo","useVerifySparkpostDomain","isVerifying","verifyDomain","_useDestroySparkpostD","useDestroySparkpostDomain","isDestroying","destroyDomain","onCreateDomain","email","onSuccess","onError","sparkpostDomain","response","alreadyVerified","Toastr","success","error","onVerifyDomain","verified","warning","onDisconnect","exists","isConnected","connected"],"mappings":";;;;;;AAYA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAAC,IAAA,EAA2C;AAAA,EAAA,IAArCC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IAAEC,qBAAqB,GAAAF,IAAA,CAArBE,qBAAqB;AAC1D,EAAA,IAAAC,SAAA,GAA0DC,QAAQ,CAAC,KAAK,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAlEI,IAAAA,qBAAqB,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,wBAAwB,GAAAH,UAAA,CAAA,CAAA,CAAA;AACtD,EAAA,IAAAI,eAAA,GAAcC,cAAc,EAAE;IAAtBC,CAAC,GAAAF,eAAA,CAADE,CAAC;AAET,EAAA,IAAAC,qBAAA,GAAiCC,uBAAuB,CAACZ,OAAO,EAAE;AAChEa,MAAAA,OAAO,EAAEZ;AAC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ACJF,IAAAA,SAAS,EAATA,SAAS;AACTK,IAAAA,UAAU,EAAVA,UAAU;AACVM,IAAAA,WAAW,EAAXA,WAAW;AACXI,IAAAA,YAAY,EAAZA,YAAY;AACZgB,IAAAA,MAAM,EAAE7B,IAAI,KAAA,IAAA,IAAJA,IAAI,KAAJA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,IAAI,CAAE6B,MAAM;IACpBC,WAAW,EAAE,CAAA9B,IAAI,KAAJA,IAAAA,IAAAA,IAAI,uBAAJA,IAAI,CAAE+B,SAAS,KAAI,KAAK;AACrCzC,IAAAA,qBAAqB,EAArBA,qBAAqB;AACrBC,IAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBwB,IAAAA,cAAc,EAAdA,cAAc;AACdU,IAAAA,cAAc,EAAdA,cAAc;AACdG,IAAAA,YAAY,EAAZA;GACD;AACH;;;;"}
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
+ var react = require('react');
5
+ var Toastr = require('@bigbinary/neetoui/Toastr');
6
+ var reactI18next = require('react-i18next');
7
+ var useSparkpostApi = require('./useSparkpostApi-pa64NIl6.js');
8
+
9
+ var useSparkpostDomain = function useSparkpostDomain(_ref) {
10
+ var ownerId = _ref.ownerId,
11
+ canManageIntegrations = _ref.canManageIntegrations;
12
+ var _useState = react.useState(false),
13
+ _useState2 = _slicedToArray(_useState, 2),
14
+ isDisconnectAlertOpen = _useState2[0],
15
+ setIsDisconnectAlertOpen = _useState2[1];
16
+ var _useTranslation = reactI18next.useTranslation(),
17
+ t = _useTranslation.t;
18
+ var _useFetchSparkpostDom = useSparkpostApi.useFetchSparkpostDomain(ownerId, {
19
+ enabled: canManageIntegrations
20
+ }),
21
+ isLoading = _useFetchSparkpostDom.isLoading,
22
+ _useFetchSparkpostDom2 = _useFetchSparkpostDom.data,
23
+ data = _useFetchSparkpostDom2 === void 0 ? {} : _useFetchSparkpostDom2;
24
+ var _useCreateSparkpostDo = useSparkpostApi.useCreateSparkpostDomain({
25
+ ownerId: ownerId
26
+ }),
27
+ isCreating = _useCreateSparkpostDo.isPending,
28
+ createDomain = _useCreateSparkpostDo.mutate;
29
+ var _useVerifySparkpostDo = useSparkpostApi.useVerifySparkpostDomain({
30
+ ownerId: ownerId
31
+ }),
32
+ isVerifying = _useVerifySparkpostDo.isPending,
33
+ verifyDomain = _useVerifySparkpostDo.mutate;
34
+ var _useDestroySparkpostD = useSparkpostApi.useDestroySparkpostDomain({
35
+ ownerId: ownerId
36
+ }),
37
+ isDestroying = _useDestroySparkpostD.isPending,
38
+ destroyDomain = _useDestroySparkpostD.mutate;
39
+ var onCreateDomain = function onCreateDomain(email, _onSuccess, _onError) {
40
+ createDomain({
41
+ sparkpostDomain: {
42
+ email: email
43
+ }
44
+ }, {
45
+ onSuccess: function onSuccess(response) {
46
+ if (response !== null && response !== void 0 && response.alreadyVerified) {
47
+ Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected"));
48
+ }
49
+ _onSuccess === null || _onSuccess === void 0 || _onSuccess(response);
50
+ },
51
+ onError: function onError(error) {
52
+ _onError === null || _onError === void 0 || _onError(error);
53
+ }
54
+ });
55
+ };
56
+ var onVerifyDomain = function onVerifyDomain(_onSuccess2, _onError2) {
57
+ verifyDomain(false, {
58
+ onSuccess: function onSuccess(response) {
59
+ if (response !== null && response !== void 0 && response.verified) {
60
+ Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainVerified"));
61
+ } else {
62
+ Toastr.warning(t("neetoEmailDelivery.sparkpost.toasts.verificationPending"));
63
+ }
64
+ _onSuccess2 === null || _onSuccess2 === void 0 || _onSuccess2(response);
65
+ },
66
+ onError: function onError(error) {
67
+ _onError2 === null || _onError2 === void 0 || _onError2(error);
68
+ }
69
+ });
70
+ };
71
+ var onDisconnect = function onDisconnect(_onSuccess3) {
72
+ destroyDomain(false, {
73
+ onSuccess: function onSuccess() {
74
+ Toastr.success(t("neetoEmailDelivery.sparkpost.toasts.domainDisconnected"));
75
+ setIsDisconnectAlertOpen(false);
76
+ _onSuccess3 === null || _onSuccess3 === void 0 || _onSuccess3();
77
+ }
78
+ });
79
+ };
80
+ return {
81
+ data: data,
82
+ isLoading: isLoading,
83
+ isCreating: isCreating,
84
+ isVerifying: isVerifying,
85
+ isDestroying: isDestroying,
86
+ exists: data === null || data === void 0 ? void 0 : data.exists,
87
+ isConnected: (data === null || data === void 0 ? void 0 : data.connected) || false,
88
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
89
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
90
+ onCreateDomain: onCreateDomain,
91
+ onVerifyDomain: onVerifyDomain,
92
+ onDisconnect: onDisconnect
93
+ };
94
+ };
95
+
96
+ exports.useSparkpostDomain = useSparkpostDomain;
97
+ //# sourceMappingURL=useSparkpostDomain-wsENCoto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSparkpostDomain-wsENCoto.js","sources":["../app/javascript/src/hooks/integrations/useSparkpostDomain.js"],"sourcesContent":["import { useState } from \"react\";\n\nimport { Toastr } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n useFetchSparkpostDomain,\n useCreateSparkpostDomain,\n useVerifySparkpostDomain,\n useDestroySparkpostDomain,\n} from \"hooks/reactQuery/integrations/useSparkpostApi\";\n\nconst useSparkpostDomain = ({ ownerId, canManageIntegrations }) => {\n const [isDisconnectAlertOpen, setIsDisconnectAlertOpen] = useState(false);\n const { t } = useTranslation();\n\n const { isLoading, data = {} } = useFetchSparkpostDomain(ownerId, {\n enabled: canManageIntegrations,\n });\n\n const { isPending: isCreating, mutate: createDomain } =\n useCreateSparkpostDomain({ ownerId });\n\n const { isPending: isVerifying, mutate: verifyDomain } =\n useVerifySparkpostDomain({ ownerId });\n\n const { isPending: isDestroying, mutate: destroyDomain } =\n useDestroySparkpostDomain({ ownerId });\n\n const onCreateDomain = (email, onSuccess, onError) => {\n createDomain(\n { sparkpostDomain: { email } },\n {\n onSuccess: response => {\n if (response?.alreadyVerified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n }\n );\n };\n\n const onVerifyDomain = (onSuccess, onError) => {\n verifyDomain(false, {\n onSuccess: response => {\n if (response?.verified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerified\")\n );\n } else {\n Toastr.warning(\n t(\"neetoEmailDelivery.sparkpost.toasts.verificationPending\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n });\n };\n\n const onDisconnect = onSuccess => {\n destroyDomain(false, {\n onSuccess: () => {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainDisconnected\")\n );\n setIsDisconnectAlertOpen(false);\n onSuccess?.();\n },\n });\n };\n\n return {\n data,\n isLoading,\n isCreating,\n isVerifying,\n isDestroying,\n exists: data?.exists,\n isConnected: data?.connected || false,\n isDisconnectAlertOpen,\n setIsDisconnectAlertOpen,\n onCreateDomain,\n onVerifyDomain,\n onDisconnect,\n };\n};\n\nexport default useSparkpostDomain;\n"],"names":["useSparkpostDomain","_ref","ownerId","canManageIntegrations","_useState","useState","_useState2","_slicedToArray","isDisconnectAlertOpen","setIsDisconnectAlertOpen","_useTranslation","useTranslation","t","_useFetchSparkpostDom","useFetchSparkpostDomain","enabled","isLoading","_useFetchSparkpostDom2","data","_useCreateSparkpostDo","useCreateSparkpostDomain","isCreating","isPending","createDomain","mutate","_useVerifySparkpostDo","useVerifySparkpostDomain","isVerifying","verifyDomain","_useDestroySparkpostD","useDestroySparkpostDomain","isDestroying","destroyDomain","onCreateDomain","email","onSuccess","onError","sparkpostDomain","response","alreadyVerified","Toastr","success","error","onVerifyDomain","verified","warning","onDisconnect","exists","isConnected","connected"],"mappings":";;;;;;;;AAYA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAkB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AI;AAChBN,QAAAA,SAAO,aAAPA,SAAO,KAAA,KAAA,CAAA,IAAPA,SAAO,CAAGM,KAAK,CAAC;AAClB;AACF,KAAC,CAAC;GACH;AAED,EAAA,IAAMI,YAAY,GAAG,SAAfA,YAAYA,CAAGX,WAAS,EAAI;IAChCH,aAAa,CAAC,KAAK,EAAE;AACnBG,MAAAA,SAAS,EAAE,SAAXA,SAASA,GAAQ;AACfK,QAAAA,MAAM,CAACC,OAAO,CACZ7B,CAAC,CAAC,wDAAwD,CAC5D,CAAC;QACDH,wBAAwB,CAAC,KAAK,CAAC;AAC/B0B,QAAAA,WAAS,KAATA,IAAAA,IAAAA,WAAS,KAATA,KAAAA,CAAAA,IAAAA,WAAS,EAAI;AACf;AACF,KAAC,CAAC;GACH;EAED,OAAO;AACLjB,IAAAA,IAAI,EAAJA,IAAI;AACJF,IAAAA,SAAS,EAATA,SAAS;AACTK,IAAAA,UAAU,EAAVA,UAAU;AACVM,IAAAA,WAAW,EAAXA,WAAW;AACXI,IAAAA,YAAY,EAAZA,YAAY;AACZgB,IAAAA,MAAM,EAAE7B,IAAI,KAAA,IAAA,IAAJA,IAAI,KAAJA,KAAAA,CAAAA,GAAAA,KAAAA,CAAAA,GAAAA,IAAI,CAAE6B,MAAM;IACpBC,WAAW,EAAE,CAAA9B,IAAI,KAAJA,IAAAA,IAAAA,IAAI,uBAAJA,IAAI,CAAE+B,SAAS,KAAI,KAAK;AACrCzC,IAAAA,qBAAqB,EAArBA,qBAAqB;AACrBC,IAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBwB,IAAAA,cAAc,EAAdA,cAAc;AACdU,IAAAA,cAAc,EAAdA,cAAc;AACdG,IAAAA,YAAY,EAAZA;GACD;AACH;;;;"}
package/hooks.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ interface Integration {
2
+ type: "gmail" | "outlook" | "sparkpost";
3
+ data: {
4
+ connected: boolean;
5
+ email: string;
6
+ domain?: string;
7
+ status?: string;
8
+ dkim_verified?: boolean;
9
+ last_verification_attempt_at?: string;
10
+ };
11
+ }
12
+
13
+ interface UseFetchConnectedIntegrationReturn {
14
+ integration: Integration | null;
15
+ isLoading: boolean;
16
+ isError: boolean;
17
+ }
18
+
19
+ export function useFetchConnectedIntegration(
20
+ ownerId: string
21
+ ): UseFetchConnectedIntegrationReturn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-email-delivery-frontend",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "This repo is for implementing custom email delivery functionality for the Neeto platform.",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://github.com/bigbinary/neeto-email-delivery-nano",
@@ -17,6 +17,7 @@
17
17
  "files": [
18
18
  "dist",
19
19
  "types.d.ts",
20
+ "hooks.d.ts",
20
21
  "app/javascript/src/translations"
21
22
  ],
22
23
  "exports": {
@@ -67,11 +68,11 @@
67
68
  "@bigbinary/babel-preset-neeto": "^1.0.3",
68
69
  "@bigbinary/eslint-plugin-neeto": "1.8.0",
69
70
  "@bigbinary/neeto-cist": "1.0.17",
70
- "@bigbinary/neeto-commons-frontend": "4.13.87",
71
+ "@bigbinary/neeto-commons-frontend": "4.13.89",
71
72
  "@bigbinary/neeto-filters-frontend": "4.3.27",
72
73
  "@bigbinary/neeto-icons": "1.20.67",
73
- "@bigbinary/neeto-molecules": "4.0.109",
74
- "@bigbinary/neetoui": "8.3.46",
74
+ "@bigbinary/neeto-molecules": "4.0.117",
75
+ "@bigbinary/neetoui": "8.3.47",
75
76
  "@emotion/is-prop-valid": "1.2.0",
76
77
  "@faker-js/faker": "8.2.0",
77
78
  "@honeybadger-io/js": "6.10.1",
@@ -177,11 +178,11 @@
177
178
  "peerDependencies": {
178
179
  "@babel/runtime": "7.26.10",
179
180
  "@bigbinary/neeto-cist": "1.0.17",
180
- "@bigbinary/neeto-commons-frontend": "4.13.87",
181
+ "@bigbinary/neeto-commons-frontend": "4.13.89",
181
182
  "@bigbinary/neeto-filters-frontend": "4.3.27",
182
183
  "@bigbinary/neeto-icons": "1.20.67",
183
- "@bigbinary/neeto-molecules": "4.0.109",
184
- "@bigbinary/neetoui": "8.3.46",
184
+ "@bigbinary/neeto-molecules": "4.0.117",
185
+ "@bigbinary/neetoui": "8.3.47",
185
186
  "@honeybadger-io/js": "6.10.1",
186
187
  "@honeybadger-io/react": "6.1.25",
187
188
  "@tanstack/react-query": "5.59.20",
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSparkpostDomain-DdG5InhX.js","sources":["../app/javascript/src/apis/integrations/constants.js","../app/javascript/src/constants/query.js","../app/javascript/src/apis/integrations/sparkpost_domains.js","../app/javascript/src/hooks/reactQuery/integrations/useSparkpostApi.js","../app/javascript/src/hooks/integrations/useSparkpostDomain.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/api-connector-should-use-default-export */\n\nconst NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL = \"/neeto_email_delivery/api/v1\";\n\nexport const GMAIL_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/gmail`;\nexport const GMAIL_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/:ownerId`;\nexport const GMAIL_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/connect`;\n\nexport const OUTLOOK_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/outlook`;\nexport const OUTLOOK_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/:ownerId`;\nexport const OUTLOOK_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/connect`;\n\nexport const SPARKPOST_DOMAINS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_INTEGRATIONS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_VERIFY_URL = `${SPARKPOST_DOMAINS_INTEGRATIONS_URL}/verify`;\n","export const QUERY_KEYS = {\n INTEGRATION_GMAIL: \"integration-gmail\",\n INTEGRATION_OUTLOOK: \"integration-outlook\",\n INTEGRATION_SPARKPOST: \"integration-sparkpost\",\n};\n","import axios from \"axios\";\nimport { buildUrl } from \"neetocommons/utils\";\n\nimport {\n SPARKPOST_DOMAINS_URL,\n SPARKPOST_DOMAINS_VERIFY_URL,\n SPARKPOST_DOMAINS_INTEGRATIONS_URL,\n} from \"./constants\";\n\nconst get = ownerId =>\n axios.get(buildUrl(SPARKPOST_DOMAINS_URL, { ownerId }), {\n showToastr: false,\n });\n\nconst create = (ownerId, payload) =>\n axios.post(\n buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }),\n payload\n );\n\nconst verify = ownerId =>\n axios.post(buildUrl(SPARKPOST_DOMAINS_VERIFY_URL, { ownerId }));\n\nconst destroy = ownerId =>\n axios.delete(buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }));\n\nconst sparkpostDomainsApi = { get, create, verify, destroy };\n\nexport default sparkpostDomainsApi;\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport sparkpostDomainsApi from \"apis/integrations/sparkpost_domains\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nexport const useFetchSparkpostDomain = (ownerId, options) =>\n useQuery({\n queryKey: [QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId],\n queryFn: () => sparkpostDomainsApi.get(ownerId),\n retry: 1,\n ...options,\n });\n\nexport const useCreateSparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(\n payload => sparkpostDomainsApi.create(ownerId, payload),\n { keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]] }\n );\n\nexport const useVerifySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.verify(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n\nexport const useDestroySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.destroy(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n","import { useState } from \"react\";\n\nimport { Toastr } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n useFetchSparkpostDomain,\n useCreateSparkpostDomain,\n useVerifySparkpostDomain,\n useDestroySparkpostDomain,\n} from \"hooks/reactQuery/integrations/useSparkpostApi\";\n\nconst useSparkpostDomain = ({ ownerId, canManageIntegrations }) => {\n const [isDisconnectAlertOpen, setIsDisconnectAlertOpen] = useState(false);\n const { t } = useTranslation();\n\n const { isLoading, data = {} } = useFetchSparkpostDomain(ownerId, {\n enabled: canManageIntegrations,\n });\n\n const { isPending: isCreating, mutate: createDomain } =\n useCreateSparkpostDomain({ ownerId });\n\n const { isPending: isVerifying, mutate: verifyDomain } =\n useVerifySparkpostDomain({ ownerId });\n\n const { isPending: isDestroying, mutate: destroyDomain } =\n useDestroySparkpostDomain({ ownerId });\n\n const onCreateDomain = (email, onSuccess, onError) => {\n createDomain(\n { sparkpostDomain: { email } },\n {\n onSuccess: response => {\n if (response?.alreadyVerified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n }\n );\n };\n\n const onVerifyDomain = (onSuccess, onError) => {\n verifyDomain(false, {\n onSuccess: response => {\n if (response?.verified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerified\")\n );\n } else {\n Toastr.warning(\n t(\"neetoEmailDelivery.sparkpost.toasts.verificationPending\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n });\n };\n\n const onDisconnect = onSuccess => {\n destroyDomain(false, {\n onSuccess: () => {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainDisconnected\")\n );\n setIsDisconnectAlertOpen(false);\n onSuccess?.();\n },\n });\n };\n\n return {\n data,\n isLoading,\n isCreating,\n isVerifying,\n isDestroying,\n isConnected: data?.connected || false,\n isDisconnectAlertOpen,\n setIsDisconnectAlertOpen,\n onCreateDomain,\n onVerifyDomain,\n onDisconnect,\n };\n};\n\nexport default useSparkpostDomain;\n"],"names":["NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL","GMAIL_URL","concat","GMAIL_OAUTH_URL","GMAIL_OAUTH_CONNECT_URL","OUTLOOK_URL","OUTLOOK_OAUTH_URL","OUTLOOK_OAUTH_CONNECT_URL","SPARKPOST_DOMAINS_URL","SPARKPOST_DOMAINS_INTEGRATIONS_URL","SPARKPOST_DOMAINS_VERIFY_URL","QUERY_KEYS","INTEGRATION_GMAIL","INTEGRATION_OUTLOOK","INTEGRATION_SPARKPOST","get","ownerId","axios","buildUrl","showToastr","create","payload","post","verify","destroy","sparkpostDomainsApi","useFetchSparkpostDomain","options","useQuery","_objectSpread","queryKey","queryFn","retry","useCreateSparkpostDomain","_ref","useMutationWithInvalidation","keysToInvalidate","useVerifySparkpostDomain","_ref2","useDestroySparkpostDomain","_ref3","useSparkpostDomain","canManageIntegrations","_useState","useState","_useState2","_slicedToArray","isDisconnectAlertOpen","setIsDisconnectAlertOpen","_useTranslation","useTranslation","t","_useFetchSparkpostDom","enabled","isLoading","_useFetchSparkpostDom2","data","_useCreateSparkpostDo","isCreating","isPending","createDomain","mutate","_useVerifySparkpostDo","isVerifying","verifyDomain","_useDestroySparkpostD","isDestroying","destroyDomain","onCreateDomain","email","onSuccess","onError","sparkpostDomain","response","alreadyVerified","Toastr","success","error","onVerifyDomain","verified","warning","onDisconnect","isConnected","connected"],"mappings":";;;;;;;;;;AAAA;;AAEA,IAAMA,oC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,IAAAA,IAAAA,WAAS,KAATA,KAAAA,CAAAA,IAAAA,WAAS,EAAI;AACf;AACF,KAAC,CAAC;GACH;EAED,OAAO;AACLd,IAAAA,IAAI,EAAJA,IAAI;AACJF,IAAAA,SAAS,EAATA,SAAS;AACTI,IAAAA,UAAU,EAAVA,UAAU;AACVK,IAAAA,WAAW,EAAXA,WAAW;AACXG,IAAAA,YAAY,EAAZA,YAAY;IACZgB,WAAW,EAAE,CAAA1B,IAAI,KAAJA,IAAAA,IAAAA,IAAI,uBAAJA,IAAI,CAAE2B,SAAS,KAAI,KAAK;AACrCpC,IAAAA,qBAAqB,EAArBA,qBAAqB;AACrBC,IAAAA,wBAAwB,EAAxBA,wBAAwB;AACxBoB,IAAAA,cAAc,EAAdA,cAAc;AACdU,IAAAA,cAAc,EAAdA,cAAc;AACdG,IAAAA,YAAY,EAAZA;GACD;AACH;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSparkpostDomain-qxCkAS6s.js","sources":["../app/javascript/src/apis/integrations/constants.js","../app/javascript/src/constants/query.js","../app/javascript/src/apis/integrations/sparkpost_domains.js","../app/javascript/src/hooks/reactQuery/integrations/useSparkpostApi.js","../app/javascript/src/hooks/integrations/useSparkpostDomain.js"],"sourcesContent":["/* eslint-disable @bigbinary/neeto/api-connector-should-use-default-export */\n\nconst NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL = \"/neeto_email_delivery/api/v1\";\n\nexport const GMAIL_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/gmail`;\nexport const GMAIL_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/:ownerId`;\nexport const GMAIL_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/gmail/oauth/connect`;\n\nexport const OUTLOOK_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/outlook`;\nexport const OUTLOOK_OAUTH_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/:ownerId`;\nexport const OUTLOOK_OAUTH_CONNECT_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/outlook/oauth/connect`;\n\nexport const SPARKPOST_DOMAINS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_INTEGRATIONS_URL = `${NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL}/integrations/sparkpost_domains`;\nexport const SPARKPOST_DOMAINS_VERIFY_URL = `${SPARKPOST_DOMAINS_INTEGRATIONS_URL}/verify`;\n","export const QUERY_KEYS = {\n INTEGRATION_GMAIL: \"integration-gmail\",\n INTEGRATION_OUTLOOK: \"integration-outlook\",\n INTEGRATION_SPARKPOST: \"integration-sparkpost\",\n};\n","import axios from \"axios\";\nimport { buildUrl } from \"neetocommons/utils\";\n\nimport {\n SPARKPOST_DOMAINS_URL,\n SPARKPOST_DOMAINS_VERIFY_URL,\n SPARKPOST_DOMAINS_INTEGRATIONS_URL,\n} from \"./constants\";\n\nconst get = ownerId =>\n axios.get(buildUrl(SPARKPOST_DOMAINS_URL, { ownerId }), {\n showToastr: false,\n });\n\nconst create = (ownerId, payload) =>\n axios.post(\n buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }),\n payload\n );\n\nconst verify = ownerId =>\n axios.post(buildUrl(SPARKPOST_DOMAINS_VERIFY_URL, { ownerId }));\n\nconst destroy = ownerId =>\n axios.delete(buildUrl(SPARKPOST_DOMAINS_INTEGRATIONS_URL, { ownerId }));\n\nconst sparkpostDomainsApi = { get, create, verify, destroy };\n\nexport default sparkpostDomainsApi;\n","import { useQuery } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\n\nimport sparkpostDomainsApi from \"apis/integrations/sparkpost_domains\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nexport const useFetchSparkpostDomain = (ownerId, options) =>\n useQuery({\n queryKey: [QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId],\n queryFn: () => sparkpostDomainsApi.get(ownerId),\n retry: 1,\n ...options,\n });\n\nexport const useCreateSparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(\n payload => sparkpostDomainsApi.create(ownerId, payload),\n { keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]] }\n );\n\nexport const useVerifySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.verify(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n\nexport const useDestroySparkpostDomain = ({ ownerId }) =>\n useMutationWithInvalidation(() => sparkpostDomainsApi.destroy(ownerId), {\n keysToInvalidate: [[QUERY_KEYS.INTEGRATION_SPARKPOST, ownerId]],\n });\n","import { useState } from \"react\";\n\nimport { Toastr } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n useFetchSparkpostDomain,\n useCreateSparkpostDomain,\n useVerifySparkpostDomain,\n useDestroySparkpostDomain,\n} from \"hooks/reactQuery/integrations/useSparkpostApi\";\n\nconst useSparkpostDomain = ({ ownerId, canManageIntegrations }) => {\n const [isDisconnectAlertOpen, setIsDisconnectAlertOpen] = useState(false);\n const { t } = useTranslation();\n\n const { isLoading, data = {} } = useFetchSparkpostDomain(ownerId, {\n enabled: canManageIntegrations,\n });\n\n const { isPending: isCreating, mutate: createDomain } =\n useCreateSparkpostDomain({ ownerId });\n\n const { isPending: isVerifying, mutate: verifyDomain } =\n useVerifySparkpostDomain({ ownerId });\n\n const { isPending: isDestroying, mutate: destroyDomain } =\n useDestroySparkpostDomain({ ownerId });\n\n const onCreateDomain = (email, onSuccess, onError) => {\n createDomain(\n { sparkpostDomain: { email } },\n {\n onSuccess: response => {\n if (response?.alreadyVerified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerifiedConnected\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n }\n );\n };\n\n const onVerifyDomain = (onSuccess, onError) => {\n verifyDomain(false, {\n onSuccess: response => {\n if (response?.verified) {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainVerified\")\n );\n } else {\n Toastr.warning(\n t(\"neetoEmailDelivery.sparkpost.toasts.verificationPending\")\n );\n }\n onSuccess?.(response);\n },\n onError: error => {\n onError?.(error);\n },\n });\n };\n\n const onDisconnect = onSuccess => {\n destroyDomain(false, {\n onSuccess: () => {\n Toastr.success(\n t(\"neetoEmailDelivery.sparkpost.toasts.domainDisconnected\")\n );\n setIsDisconnectAlertOpen(false);\n onSuccess?.();\n },\n });\n };\n\n return {\n data,\n isLoading,\n isCreating,\n isVerifying,\n isDestroying,\n isConnected: data?.connected || false,\n isDisconnectAlertOpen,\n setIsDisconnectAlertOpen,\n onCreateDomain,\n onVerifyDomain,\n onDisconnect,\n };\n};\n\nexport default useSparkpostDomain;\n"],"names":["NEETO_EMAIL_DELIVERY_ENGINE_BASE_URL","GMAIL_URL","concat","GMAIL_OAUTH_URL","GMAIL_OAUTH_CONNECT_URL","OUTLOOK_URL","OUTLOOK_OAUTH_URL","OUTLOOK_OAUTH_CONNECT_URL","SPARKPOST_DOMAINS_URL","SPARKPOST_DOMAINS_INTEGRATIONS_URL","SPARKPOST_DOMAINS_VERIFY_URL","QUERY_KEYS","INTEGRATION_GMAIL","INTEGRATION_OUTLOOK","INTEGRATION_SPARKPOST","get","ownerId","axios","buildUrl","showToastr","create","payload","post","verify","destroy","sparkpostDomainsApi","useFetchSparkpostDomain","options","useQuery","_objectSpread","queryKey","queryFn","retry","useCreateSparkpostDomain","_ref","useMutationWithInvalidation","keysToInvalidate","useVerifySparkpostDomain","_ref2","useDestroySparkpostDomain","_ref3","useSparkpostDomain","canManageIntegrations","_useState","useState","_useState2","_slicedToArray","isDisconnectAlertOpen","setIsDisconnectAlertOpen","_useTranslation","useTranslation","t","_useFetchSparkpostDom","enabled","isLoading","_useFetchSparkpostDom2","data","_useCreateSparkpostDo","isCreating","isPending","createDomain","mutate","_useVerifySparkpostDo","isVerifying","verifyDomain","_useDestroySparkpostD","isDestroying","destroyDomain","onCreateDomain","email","onSuccess","onError","sparkpostDomain","response","alreadyVerified","Toastr","success","error","onVerifyDomain","verified","warning","onDisconnect","isConnected","connected"],"mappings":";;;;;;;;;;;;AAAA;;AAEA,IAAMA,oCAAoC,GAAG,8BAA8B;IAE9DC,SAAS,GAAA,EAAA,CAAAC,MAAA,CAAMF,oCAAoC,EAAQ,QAAA;IAC3DG,eAAe,GAAA,EAAA,CAAAD,MAAA,CAAMF,oCAAoC,EAAoC,oCAAA;IAC7FI,uBAAuB,GAAA,EAAA,CAAAF,MAAA,CAAMF,oCAAoC,EAAmC,mCAAA;IAEpGK,WAAW,GAAA,EAAA,CAAAH,MAAA,CAAMF,oCAAoC,EAAU,UAAA;IAC/DM,iBAAiB,GAAA,EAAA,CAAAJ,MAAA,CAAMF,oCAAoC,EAAsC,sCAAA;IACjGO,yBAAyB,GAAA,EAAA,CAAAL,MAAA,CAAMF,oCAAoC,EAAqC,qCAAA;AAE9G,IAAMQ,qBAAqB,GAAA,EAAA,CAAAN,MAAA,CAAMF,oCAAoC,EAAoB,oBAAA,CAAA;AACzF,IAAMS,kCAAkC,GAAA,EAAA,CAAAP,MAAA,CAAMF,oCAAoC,EAAiC,iCAAA,CAAA;AACnH,IAAMU,4BAA4B,GAAA,EAAA,CAAAR,MAAA,CAAMO,kCAAkC,EAAS,SAAA,CAAA;;ACdnF,IAAME,UAAU,GAAG;AACxBC,EAAAA,iBAAiB,EAAE,mBAAmB;AACtCC,EAAAA,mBAAmB,EAAE,qBAAqB;AAC1CC,EAAAA,qBAAqB,EAAE;AACzB;;ACKA,IAAMC,GAAG,GAAG,SAANA,GAAGA,CAAGC,OAAO,EAAA;AAAA,EAAA,OACjBC,KAAK,CAACF,GAAG,CAACG,cAAQ,CAACV,q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