@bigbinary/neeto-integrations-frontend 2.5.2 → 2.6.0

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.
package/dist/index.cjs.js CHANGED
@@ -3,20 +3,22 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var IntegrationCard = require('@bigbinary/neeto-molecules/IntegrationCard');
6
- var IntegrationDisconnectAlert = require('@bigbinary/neeto-molecules/IntegrationDisconnectAlert');
7
- var IntegrationWalkthroughModal = require('@bigbinary/neeto-molecules/IntegrationWalkthroughModal');
6
+ var DisconnectAlert = require('@bigbinary/neeto-molecules/IntegrationDisconnectAlert');
7
+ var WalkthroughModal = require('@bigbinary/neeto-molecules/IntegrationWalkthroughModal');
8
8
  var React = require('react');
9
- var neetoCist = require('@bigbinary/neeto-cist');
10
9
  var i18next = require('i18next');
11
- var neetoui = require('@bigbinary/neetoui');
12
- var formik = require('@bigbinary/neetoui/formik');
13
- var ramda = require('ramda');
14
- var reactI18next = require('react-i18next');
10
+ var neetoCist = require('@bigbinary/neeto-cist');
15
11
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
12
+ var constants = require('@bigbinary/neeto-commons-frontend/constants');
16
13
  var reactQuery = require('react-query');
17
14
  var axios = require('axios');
18
- var yup = require('yup');
15
+ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
16
+ var neetoui = require('@bigbinary/neetoui');
17
+ var formik = require('@bigbinary/neetoui/formik');
18
+ var reactI18next = require('react-i18next');
19
19
  var classnames = require('classnames');
20
+ var ramda = require('ramda');
21
+ var yup = require('yup');
20
22
 
21
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
24
 
@@ -39,14 +41,104 @@ function _interopNamespace(e) {
39
41
  }
40
42
 
41
43
  var IntegrationCard__default = /*#__PURE__*/_interopDefaultLegacy(IntegrationCard);
42
- var IntegrationDisconnectAlert__default = /*#__PURE__*/_interopDefaultLegacy(IntegrationDisconnectAlert);
43
- var IntegrationWalkthroughModal__default = /*#__PURE__*/_interopDefaultLegacy(IntegrationWalkthroughModal);
44
+ var DisconnectAlert__default = /*#__PURE__*/_interopDefaultLegacy(DisconnectAlert);
45
+ var WalkthroughModal__default = /*#__PURE__*/_interopDefaultLegacy(WalkthroughModal);
44
46
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
47
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
46
48
  var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
47
49
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
48
- var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
50
+ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
49
51
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
52
+ var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
53
+
54
+ function _typeof(obj) {
55
+ "@babel/helpers - typeof";
56
+
57
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
58
+ return typeof obj;
59
+ } : function (obj) {
60
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
61
+ }, _typeof(obj);
62
+ }
63
+
64
+ function _toPrimitive(input, hint) {
65
+ if (_typeof(input) !== "object" || input === null) return input;
66
+ var prim = input[Symbol.toPrimitive];
67
+ if (prim !== undefined) {
68
+ var res = prim.call(input, hint || "default");
69
+ if (_typeof(res) !== "object") return res;
70
+ throw new TypeError("@@toPrimitive must return a primitive value.");
71
+ }
72
+ return (hint === "string" ? String : Number)(input);
73
+ }
74
+
75
+ function _toPropertyKey(arg) {
76
+ var key = _toPrimitive(arg, "string");
77
+ return _typeof(key) === "symbol" ? key : String(key);
78
+ }
79
+
80
+ function _defineProperty(obj, key, value) {
81
+ key = _toPropertyKey(key);
82
+ if (key in obj) {
83
+ Object.defineProperty(obj, key, {
84
+ value: value,
85
+ enumerable: true,
86
+ configurable: true,
87
+ writable: true
88
+ });
89
+ } else {
90
+ obj[key] = value;
91
+ }
92
+ return obj;
93
+ }
94
+
95
+ var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
96
+ var TWILIO_CONFIGURATION_BASE_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/twilio/sms_configurations");
97
+ var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
98
+
99
+ var create = function create(payload) {
100
+ return axios__default["default"].post(INTEGRATIONS_ENGINE_DAILY_URL, {
101
+ daily: payload
102
+ });
103
+ };
104
+ var show = function show() {
105
+ return axios__default["default"].get(INTEGRATIONS_ENGINE_DAILY_URL);
106
+ };
107
+ var destroy = function destroy() {
108
+ return axios__default["default"]["delete"](INTEGRATIONS_ENGINE_DAILY_URL);
109
+ };
110
+ var dailiesApi = {
111
+ create: create,
112
+ show: show,
113
+ destroy: destroy
114
+ };
115
+
116
+ var QUERY_KEYS = {
117
+ TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
118
+ TWILIO_PHONE_NUMBERS: "twilio-phone-numbers",
119
+ DAILY_CO_DETAILS: "daily-co-details"
120
+ };
121
+
122
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
123
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
124
+ var useCreateDaily = function useCreateDaily() {
125
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
126
+ return reactUtils.useMutationWithInvalidation(dailiesApi.create, _objectSpread$3({
127
+ keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS]
128
+ }, options));
129
+ };
130
+ var useFetchDaily = function useFetchDaily() {
131
+ return reactQuery.useQuery(QUERY_KEYS.DAILY_CO_DETAILS, dailiesApi.show, {
132
+ staleTime: constants.DEFAULT_STALE_TIME
133
+ });
134
+ };
135
+ var useDestroyDaily = function useDestroyDaily(_ref) {
136
+ var onSuccess = _ref.onSuccess;
137
+ return reactUtils.useMutationWithInvalidation(dailiesApi.destroy, {
138
+ keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS],
139
+ onSuccess: onSuccess
140
+ });
141
+ };
50
142
 
51
143
  function _arrayWithHoles(arr) {
52
144
  if (Array.isArray(arr)) return arr;
@@ -103,53 +195,273 @@ function _slicedToArray(arr, i) {
103
195
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
104
196
  }
105
197
 
106
- var TWILIO_INTEGRATION_STEPS = [{
107
- step: "1",
108
- label: i18next__default["default"].t("neetoIntegrations.steps.configure"),
109
- isActive: true,
110
- isCompleted: false
111
- }];
112
-
113
- function _typeof(obj) {
114
- "@babel/helpers - typeof";
115
-
116
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
117
- return typeof obj;
118
- } : function (obj) {
119
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
120
- }, _typeof(obj);
198
+ function _extends$1() {
199
+ _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
200
+ for (var i = 1; i < arguments.length; i++) {
201
+ var source = arguments[i];
202
+ for (var key in source) {
203
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
204
+ target[key] = source[key];
205
+ }
206
+ }
207
+ }
208
+ return target;
209
+ };
210
+ return _extends$1.apply(this, arguments);
121
211
  }
122
212
 
123
- function _toPrimitive(input, hint) {
124
- if (_typeof(input) !== "object" || input === null) return input;
125
- var prim = input[Symbol.toPrimitive];
126
- if (prim !== undefined) {
127
- var res = prim.call(input, hint || "default");
128
- if (_typeof(res) !== "object") return res;
129
- throw new TypeError("@@toPrimitive must return a primitive value.");
213
+ function _objectWithoutPropertiesLoose(source, excluded) {
214
+ if (source == null) return {};
215
+ var target = {};
216
+ var sourceKeys = Object.keys(source);
217
+ var key, i;
218
+ for (i = 0; i < sourceKeys.length; i++) {
219
+ key = sourceKeys[i];
220
+ if (excluded.indexOf(key) >= 0) continue;
221
+ target[key] = source[key];
130
222
  }
131
- return (hint === "string" ? String : Number)(input);
223
+ return target;
132
224
  }
133
225
 
134
- function _toPropertyKey(arg) {
135
- var key = _toPrimitive(arg, "string");
136
- return _typeof(key) === "symbol" ? key : String(key);
226
+ function _objectWithoutProperties(source, excluded) {
227
+ if (source == null) return {};
228
+ var target = _objectWithoutPropertiesLoose(source, excluded);
229
+ var key, i;
230
+ if (Object.getOwnPropertySymbols) {
231
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
232
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
233
+ key = sourceSymbolKeys[i];
234
+ if (excluded.indexOf(key) >= 0) continue;
235
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
236
+ target[key] = source[key];
237
+ }
238
+ }
239
+ return target;
137
240
  }
138
241
 
139
- function _defineProperty(obj, key, value) {
140
- key = _toPropertyKey(key);
141
- if (key in obj) {
142
- Object.defineProperty(obj, key, {
143
- value: value,
144
- enumerable: true,
145
- configurable: true,
146
- writable: true
242
+ var _excluded = ["className", "children"];
243
+ var ExternalLink = function ExternalLink(_ref) {
244
+ var _ref$className = _ref.className,
245
+ className = _ref$className === void 0 ? "" : _ref$className,
246
+ _ref$children = _ref.children,
247
+ children = _ref$children === void 0 ? null : _ref$children,
248
+ props = _objectWithoutProperties(_ref, _excluded);
249
+ return /*#__PURE__*/React__default["default"].createElement("a", _extends$1({
250
+ className: classnames__default["default"](["neeto-ui-text-primary-800 hover:neeto-ui-text-primary-800 visited:neeto-ui-text-primary-600 font-medium", className])
251
+ }, props), children);
252
+ };
253
+ var ExternalLink$1 = /*#__PURE__*/React__default["default"].memo(ExternalLink);
254
+
255
+ var MANAGE_DAILY_CO_FORM_INITIAL_VALUES = {
256
+ apiKey: ""
257
+ };
258
+ var DAILY_CO_VALIDATION_SCHEMA = yup__namespace.object().shape({
259
+ apiKey: yup__namespace.string().trim().required(i18next.t("neetoIntegrations.errors.required", {
260
+ entity: i18next.t("neetoIntegrations.daily.apiKey")
261
+ }))
262
+ });
263
+
264
+ var Form = function Form(_ref) {
265
+ var helpDocUrl = _ref.helpDocUrl,
266
+ videoUrl = _ref.videoUrl,
267
+ onConnect = _ref.onConnect;
268
+ var _useTranslation = reactI18next.useTranslation(),
269
+ t = _useTranslation.t;
270
+ var _useState = React.useState(false),
271
+ _useState2 = _slicedToArray(_useState, 2),
272
+ isDemoModalOpen = _useState2[0],
273
+ setIsDemoModalOpen = _useState2[1];
274
+ var _useCreateDaily = useCreateDaily({
275
+ onSuccess: function onSuccess() {
276
+ return onConnect === null || onConnect === void 0 ? void 0 : onConnect();
277
+ }
278
+ }),
279
+ createDaily = _useCreateDaily.mutate,
280
+ isConnecting = _useCreateDaily.isLoading;
281
+ var handleSubmit = function handleSubmit(payload) {
282
+ return createDaily(payload);
283
+ };
284
+ if (isConnecting) {
285
+ return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
286
+ }
287
+ return /*#__PURE__*/React__default["default"].createElement("div", {
288
+ className: "mx-auto w-full max-w-md"
289
+ }, /*#__PURE__*/React__default["default"].createElement(formik.Form, {
290
+ formikProps: {
291
+ initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,
292
+ validationSchema: DAILY_CO_VALIDATION_SCHEMA,
293
+ onSubmit: handleSubmit
294
+ }
295
+ }, function (_ref2) {
296
+ var dirty = _ref2.dirty;
297
+ return /*#__PURE__*/React__default["default"].createElement("div", {
298
+ className: "mt-10 w-full space-y-5"
299
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
300
+ className: "block"
301
+ }, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
302
+ autoFocus: true,
303
+ required: true,
304
+ label: t("neetoIntegrations.daily.apiKey"),
305
+ name: "apiKey",
306
+ helpText: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
307
+ i18nKey: "neetoIntegrations.daily.helpDoc",
308
+ components: {
309
+ externalLink: /*#__PURE__*/React__default["default"].createElement(ExternalLink$1, {
310
+ href: helpDocUrl,
311
+ rel: "noreferrer",
312
+ target: "_blank"
313
+ })
314
+ }
315
+ })
316
+ }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
317
+ className: "mt-8",
318
+ label: t("neetoIntegrations.daily.walkthroughText"),
319
+ style: "link",
320
+ onClick: function onClick() {
321
+ return setIsDemoModalOpen(true);
322
+ }
323
+ })), /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
324
+ disabled: isConnecting || !dirty,
325
+ label: t("neetoIntegrations.common.connect"),
326
+ loading: isConnecting,
327
+ type: "submit"
328
+ })));
329
+ }), /*#__PURE__*/React__default["default"].createElement(WalkthroughModal__default["default"], {
330
+ isOpen: isDemoModalOpen,
331
+ videoUrl: videoUrl,
332
+ onClose: function onClose() {
333
+ return setIsDemoModalOpen(false);
334
+ }
335
+ }));
336
+ };
337
+ var Form$1 = reactUtils.withTitle(Form, i18next__default["default"].t("neetoIntegrations.browserTitles.integrations.dailyco"));
338
+
339
+ var Manage$1 = reactUtils.withT(function (_ref) {
340
+ var t = _ref.t,
341
+ title = _ref.title,
342
+ description = _ref.description,
343
+ integration = _ref.integration,
344
+ isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
345
+ setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
346
+ isDisconnecting = _ref.isDisconnecting,
347
+ onDisconnect = _ref.onDisconnect,
348
+ onClose = _ref.onClose;
349
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
350
+ className: "mx-auto w-full max-w-md"
351
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
352
+ className: "mt-10 w-full space-y-4"
353
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
354
+ className: "neeto-ui-text-gray-800 mb-0.5",
355
+ style: "h3",
356
+ weight: "semibold"
357
+ }, title), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
358
+ className: "neeto-ui-text-gray-600 break-all",
359
+ style: "body1",
360
+ weight: "normal"
361
+ }, description), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
362
+ label: t("neetoIntegrations.common.disconnect"),
363
+ style: "danger",
364
+ onClick: function onClick() {
365
+ return setIsDisconnectAlertOpen(true);
366
+ }
367
+ }))), /*#__PURE__*/React__default["default"].createElement(DisconnectAlert__default["default"], {
368
+ isDisconnecting: isDisconnecting,
369
+ onClose: onClose,
370
+ onDisconnect: onDisconnect,
371
+ isOpen: isDisconnectAlertOpen,
372
+ message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
373
+ title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
374
+ }));
375
+ });
376
+
377
+ var Manage = function Manage(_ref) {
378
+ var onDisconnect = _ref.onDisconnect;
379
+ var _useState = React.useState(false),
380
+ _useState2 = _slicedToArray(_useState, 2),
381
+ isDisconnectAlertOpen = _useState2[0],
382
+ setIsDisconnectAlertOpen = _useState2[1];
383
+ var _useFetchDaily = useFetchDaily(),
384
+ _useFetchDaily$data = _useFetchDaily.data,
385
+ _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
386
+ _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
387
+ metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
388
+ isLoading = _useFetchDaily.isLoading;
389
+ var _ref2 = metadata || {},
390
+ _ref2$apiKey = _ref2.apiKey,
391
+ apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
392
+ var _useTranslation = reactI18next.useTranslation(),
393
+ t = _useTranslation.t;
394
+ var _useDestroyDaily = useDestroyDaily({
395
+ onSuccess: function onSuccess() {
396
+ setIsDisconnectAlertOpen(false);
397
+ onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
398
+ }
399
+ }),
400
+ destroyIntegration = _useDestroyDaily.mutate,
401
+ isDisconnecting = _useDestroyDaily.isLoading;
402
+ var handleDisconnect = function handleDisconnect() {
403
+ return destroyIntegration("daily");
404
+ };
405
+ if (isLoading || isDisconnecting) {
406
+ return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
407
+ }
408
+ if (neetoCist.isNotPresent(apiKey)) {
409
+ onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
410
+ }
411
+ return /*#__PURE__*/React__default["default"].createElement(Manage$1, {
412
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
413
+ isDisconnecting: isDisconnecting,
414
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
415
+ description: t("neetoIntegrations.daily.yourApiKey", {
416
+ apiKey: apiKey
417
+ }),
418
+ integration: "daily",
419
+ title: t("neetoIntegrations.daily.connected"),
420
+ onClose: function onClose() {
421
+ return setIsDisconnectAlertOpen(false);
422
+ },
423
+ onDisconnect: handleDisconnect
424
+ });
425
+ };
426
+
427
+ var Daily = function Daily(_ref) {
428
+ var _ref$isOnboarding = _ref.isOnboarding,
429
+ isOnboarding = _ref$isOnboarding === void 0 ? false : _ref$isOnboarding,
430
+ _ref$helpDocUrl = _ref.helpDocUrl,
431
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
432
+ _ref$videoUrl = _ref.videoUrl,
433
+ videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
434
+ _ref$onConnect = _ref.onConnect,
435
+ onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect,
436
+ _ref$onDisconnect = _ref.onDisconnect,
437
+ onDisconnect = _ref$onDisconnect === void 0 ? neetoCist.noop : _ref$onDisconnect;
438
+ var _useFetchDaily = useFetchDaily(),
439
+ _useFetchDaily$data = _useFetchDaily.data,
440
+ _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
441
+ _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
442
+ metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$;
443
+ var _ref2 = metadata || {},
444
+ _ref2$apiKey = _ref2.apiKey,
445
+ apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
446
+ if (neetoCist.isPresent(apiKey) && !isOnboarding) {
447
+ return /*#__PURE__*/React__default["default"].createElement(Manage, {
448
+ onDisconnect: onDisconnect
147
449
  });
148
- } else {
149
- obj[key] = value;
150
450
  }
151
- return obj;
152
- }
451
+ return /*#__PURE__*/React__default["default"].createElement(Form$1, {
452
+ onConnect: onConnect,
453
+ helpDocUrl: helpDocUrl,
454
+ videoUrl: videoUrl
455
+ });
456
+ };
457
+ var index = reactUtils.withTitle(Daily, i18next__default["default"].t("neetoIntegrations.browserTitles.integrations.dailyco"));
458
+
459
+ var TWILIO_INTEGRATION_STEPS = [{
460
+ step: "1",
461
+ label: i18next__default["default"].t("neetoIntegrations.steps.configure"),
462
+ isActive: true,
463
+ isCompleted: false
464
+ }];
153
465
 
154
466
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
155
467
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -224,8 +536,6 @@ function _toConsumableArray(arr) {
224
536
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
225
537
  }
226
538
 
227
- var TWILIO_CONFIGURATION_BASE_URL = "/neeto_integrations/twilio/sms_configurations";
228
-
229
539
  var twilioApi = {
230
540
  fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
231
541
  return axios__default["default"].get(TWILIO_CONFIGURATION_BASE_URL);
@@ -243,11 +553,6 @@ var twilioApi = {
243
553
  }
244
554
  };
245
555
 
246
- var QUERY_KEYS = {
247
- TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
248
- TWILIO_PHONE_NUMBERS: "twilio-phone-numbers"
249
- };
250
-
251
556
  var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
252
557
  return reactQuery.useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
253
558
  select: function select(response) {
@@ -262,13 +567,15 @@ var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
262
567
  });
263
568
  };
264
569
  var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
265
- var credentials = _ref.credentials;
570
+ var _formRef$current, _formRef$current$valu, _formRef$current2, _formRef$current2$val;
571
+ var credentials = _ref.credentials,
572
+ formRef = _ref.formRef;
266
573
  return reactQuery.useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
267
574
  credentials: credentials
268
575
  }], function () {
269
576
  return twilioApi.getTwilioPhoneNumbers(neetoCist.keysToSnakeCase(credentials));
270
577
  }, {
271
- enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid),
578
+ enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid) || !!(formRef !== null && formRef !== void 0 && (_formRef$current = formRef.current) !== null && _formRef$current !== void 0 && (_formRef$current$valu = _formRef$current.values) !== null && _formRef$current$valu !== void 0 && _formRef$current$valu.twilioSid) || !!(formRef !== null && formRef !== void 0 && (_formRef$current2 = formRef.current) !== null && _formRef$current2 !== void 0 && (_formRef$current2$val = _formRef$current2.values) !== null && _formRef$current2$val !== void 0 && _formRef$current2$val.twilioAuthToken),
272
579
  select: ramda.prop("phoneNumbers"),
273
580
  retry: false
274
581
  });
@@ -286,8 +593,10 @@ var useTwilio = function useTwilio(_ref) {
286
593
  onSave = _ref$onSave === void 0 ? neetoCist.noop : _ref$onSave,
287
594
  _ref$setSteps = _ref.setSteps,
288
595
  setSteps = _ref$setSteps === void 0 ? neetoCist.noop : _ref$setSteps,
289
- _ref$useConnect = _ref.useConnect,
290
- useConnect = _ref$useConnect === void 0 ? neetoCist.noop : _ref$useConnect;
596
+ _ref$onConnect = _ref.onConnect,
597
+ onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect,
598
+ _ref$formRef = _ref.formRef,
599
+ formRef = _ref$formRef === void 0 ? null : _ref$formRef;
291
600
  var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
292
601
  configuration = _useFetchTwilioSmsCon.data,
293
602
  isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
@@ -297,20 +606,14 @@ var useTwilio = function useTwilio(_ref) {
297
606
  credentials = _useStateWithDependen2[0],
298
607
  setCredentials = _useStateWithDependen2[1];
299
608
  var _useFetchTwilioPhoneN = useFetchTwilioPhoneNumbers({
300
- credentials: credentials
609
+ credentials: credentials,
610
+ formRef: formRef
301
611
  }),
302
612
  phoneNumbers = _useFetchTwilioPhoneN.data,
303
613
  isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
304
614
  var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
305
615
  saveConfiguration = _useCreateTwilioConfi.mutate,
306
616
  isSubmitting = _useCreateTwilioConfi.isLoading;
307
- var _useConnect = useConnect(),
308
- installIntegration = _useConnect.mutate;
309
- var connectTwilioApp = function connectTwilioApp() {
310
- return installIntegration({
311
- id: "twilio"
312
- }, {});
313
- };
314
617
  React.useEffect(function () {
315
618
  if (!(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) return;
316
619
  setSteps(function (steps) {
@@ -335,8 +638,8 @@ var useTwilio = function useTwilio(_ref) {
335
638
  saveConfiguration(payload, {
336
639
  onSuccess: function onSuccess() {
337
640
  onSave();
338
- connectTwilioApp();
339
641
  refetchTwilioSmsConfiguration();
642
+ onConnect === null || onConnect === void 0 ? void 0 : onConnect();
340
643
  }
341
644
  });
342
645
  };
@@ -370,17 +673,19 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
370
673
  onSave = _ref$onSave === void 0 ? neetoCist.noop : _ref$onSave,
371
674
  _ref$setSteps = _ref.setSteps,
372
675
  setSteps = _ref$setSteps === void 0 ? neetoCist.noop : _ref$setSteps,
373
- _ref$useConnect = _ref.useConnect,
374
- useConnect = _ref$useConnect === void 0 ? neetoCist.noop : _ref$useConnect,
676
+ _ref$onConnect = _ref.onConnect,
677
+ onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect,
375
678
  _ref$isModal = _ref.isModal,
376
679
  isModal = _ref$isModal === void 0 ? false : _ref$isModal;
377
680
  var _useTranslation = reactI18next.useTranslation(),
378
681
  t = _useTranslation.t;
379
682
  var initialFocusRef = React.useRef();
683
+ var formRef = React.useRef();
380
684
  var _useTwilio = useTwilio({
381
685
  onSave: onSave,
382
686
  setSteps: setSteps,
383
- useConnect: useConnect
687
+ onConnect: onConnect,
688
+ formRef: formRef
384
689
  }),
385
690
  handleSubmit = _useTwilio.handleSubmit,
386
691
  phoneNumbers = _useTwilio.phoneNumbers,
@@ -421,7 +726,7 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
421
726
  submitButtonProps: {
422
727
  label: phoneNumberOptions ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
423
728
  disabled: isSubmitDisabled(values),
424
- loading: isSubmitting || isPhoneNumbersLoading && !configuration.twilioAuthToken
729
+ loading: isSubmitting || isPhoneNumbersLoading && !(configuration !== null && configuration !== void 0 && configuration.twilioAuthToken)
425
730
  }
426
731
  });
427
732
  };
@@ -440,6 +745,7 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
440
745
  enableReinitialize: true,
441
746
  validationSchema: buildTwilioConfigurationValidationSchema(!!phoneNumbers),
442
747
  initialValues: configuration,
748
+ innerRef: formRef,
443
749
  onSubmit: handleSubmit
444
750
  }
445
751
  }, function (formikProps) {
@@ -452,8 +758,8 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
452
758
  var Twilio = function Twilio(_ref) {
453
759
  var _ref$onClose = _ref.onClose,
454
760
  onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose,
455
- _ref$useConnect = _ref.useConnect,
456
- useConnect = _ref$useConnect === void 0 ? neetoCist.noop : _ref$useConnect;
761
+ _ref$onConnect = _ref.onConnect,
762
+ onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect;
457
763
  var _useState = React.useState(TWILIO_INTEGRATION_STEPS),
458
764
  _useState2 = _slicedToArray(_useState, 2),
459
765
  steps = _useState2[0],
@@ -465,8 +771,8 @@ var Twilio = function Twilio(_ref) {
465
771
  }, /*#__PURE__*/React__default["default"].createElement(TwilioConfiguration, {
466
772
  isModal: true,
467
773
  setSteps: setSteps,
468
- useConnect: useConnect,
469
- onCancel: onClose
774
+ onCancel: onClose,
775
+ onConnect: onConnect
470
776
  }));
471
777
  };
472
778
 
@@ -536,21 +842,6 @@ var Modal = function Modal(_ref) {
536
842
  }, children)));
537
843
  };
538
844
 
539
- function _extends$1() {
540
- _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
541
- for (var i = 1; i < arguments.length; i++) {
542
- var source = arguments[i];
543
- for (var key in source) {
544
- if (Object.prototype.hasOwnProperty.call(source, key)) {
545
- target[key] = source[key];
546
- }
547
- }
548
- }
549
- return target;
550
- };
551
- return _extends$1.apply(this, arguments);
552
- }
553
-
554
845
  var propTypes = {exports: {}};
555
846
 
556
847
  /**
@@ -867,13 +1158,14 @@ Object.defineProperty(exports, 'Card', {
867
1158
  });
868
1159
  Object.defineProperty(exports, 'DisconnectAlert', {
869
1160
  enumerable: true,
870
- get: function () { return IntegrationDisconnectAlert__default["default"]; }
1161
+ get: function () { return DisconnectAlert__default["default"]; }
871
1162
  });
872
1163
  Object.defineProperty(exports, 'WalkthroughModal', {
873
1164
  enumerable: true,
874
- get: function () { return IntegrationWalkthroughModal__default["default"]; }
1165
+ get: function () { return WalkthroughModal__default["default"]; }
875
1166
  });
876
1167
  exports.Connect = Connect;
1168
+ exports.Daily = index;
877
1169
  exports.Demo = Demo;
878
1170
  exports.Finish = Finish;
879
1171
  exports.Modal = Modal;