@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.js CHANGED
@@ -1,19 +1,112 @@
1
1
  export { default as Card } from '@bigbinary/neeto-molecules/IntegrationCard';
2
+ import DisconnectAlert from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
2
3
  export { default as DisconnectAlert } from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
4
+ import WalkthroughModal from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
3
5
  export { default as WalkthroughModal } from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
4
6
  import * as React from 'react';
5
- import React__default, { useEffect, useRef, useState } from 'react';
6
- import { keysToSnakeCase, noop, _findBy, isNotEmpty } from '@bigbinary/neeto-cist';
7
- import i18next from 'i18next';
8
- import { Modal as Modal$1, Typography, Button } from '@bigbinary/neetoui';
9
- import { Input, Select, Form, ActionBlock } from '@bigbinary/neetoui/formik';
10
- import { prop, equals, isEmpty } from 'ramda';
11
- import { useTranslation } from 'react-i18next';
12
- import { useMutationWithInvalidation, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
7
+ import React__default, { useState, useEffect, useRef } from 'react';
8
+ import i18next, { t as t$1 } from 'i18next';
9
+ import { isNotPresent, isPresent, noop, keysToSnakeCase, _findBy, isNotEmpty } from '@bigbinary/neeto-cist';
10
+ import { useMutationWithInvalidation, withTitle, withT, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
11
+ import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
13
12
  import { useQuery } from 'react-query';
14
13
  import axios from 'axios';
15
- import * as yup from 'yup';
14
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
15
+ import { Button, Typography, Modal as Modal$1 } from '@bigbinary/neetoui';
16
+ import { Form as Form$2, Input, Select, ActionBlock } from '@bigbinary/neetoui/formik';
17
+ import { useTranslation, Trans } from 'react-i18next';
16
18
  import classnames from 'classnames';
19
+ import { prop, equals, isEmpty } from 'ramda';
20
+ import * as yup from 'yup';
21
+
22
+ function _typeof(obj) {
23
+ "@babel/helpers - typeof";
24
+
25
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
26
+ return typeof obj;
27
+ } : function (obj) {
28
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
29
+ }, _typeof(obj);
30
+ }
31
+
32
+ function _toPrimitive(input, hint) {
33
+ if (_typeof(input) !== "object" || input === null) return input;
34
+ var prim = input[Symbol.toPrimitive];
35
+ if (prim !== undefined) {
36
+ var res = prim.call(input, hint || "default");
37
+ if (_typeof(res) !== "object") return res;
38
+ throw new TypeError("@@toPrimitive must return a primitive value.");
39
+ }
40
+ return (hint === "string" ? String : Number)(input);
41
+ }
42
+
43
+ function _toPropertyKey(arg) {
44
+ var key = _toPrimitive(arg, "string");
45
+ return _typeof(key) === "symbol" ? key : String(key);
46
+ }
47
+
48
+ function _defineProperty(obj, key, value) {
49
+ key = _toPropertyKey(key);
50
+ if (key in obj) {
51
+ Object.defineProperty(obj, key, {
52
+ value: value,
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true
56
+ });
57
+ } else {
58
+ obj[key] = value;
59
+ }
60
+ return obj;
61
+ }
62
+
63
+ var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
64
+ var TWILIO_CONFIGURATION_BASE_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/twilio/sms_configurations");
65
+ var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
66
+
67
+ var create = function create(payload) {
68
+ return axios.post(INTEGRATIONS_ENGINE_DAILY_URL, {
69
+ daily: payload
70
+ });
71
+ };
72
+ var show = function show() {
73
+ return axios.get(INTEGRATIONS_ENGINE_DAILY_URL);
74
+ };
75
+ var destroy = function destroy() {
76
+ return axios["delete"](INTEGRATIONS_ENGINE_DAILY_URL);
77
+ };
78
+ var dailiesApi = {
79
+ create: create,
80
+ show: show,
81
+ destroy: destroy
82
+ };
83
+
84
+ var QUERY_KEYS = {
85
+ TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
86
+ TWILIO_PHONE_NUMBERS: "twilio-phone-numbers",
87
+ DAILY_CO_DETAILS: "daily-co-details"
88
+ };
89
+
90
+ 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; }
91
+ 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; }
92
+ var useCreateDaily = function useCreateDaily() {
93
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
94
+ return useMutationWithInvalidation(dailiesApi.create, _objectSpread$3({
95
+ keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS]
96
+ }, options));
97
+ };
98
+ var useFetchDaily = function useFetchDaily() {
99
+ return useQuery(QUERY_KEYS.DAILY_CO_DETAILS, dailiesApi.show, {
100
+ staleTime: DEFAULT_STALE_TIME
101
+ });
102
+ };
103
+ var useDestroyDaily = function useDestroyDaily(_ref) {
104
+ var onSuccess = _ref.onSuccess;
105
+ return useMutationWithInvalidation(dailiesApi.destroy, {
106
+ keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS],
107
+ onSuccess: onSuccess
108
+ });
109
+ };
17
110
 
18
111
  function _arrayWithHoles(arr) {
19
112
  if (Array.isArray(arr)) return arr;
@@ -70,53 +163,273 @@ function _slicedToArray(arr, i) {
70
163
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
71
164
  }
72
165
 
73
- var TWILIO_INTEGRATION_STEPS = [{
74
- step: "1",
75
- label: i18next.t("neetoIntegrations.steps.configure"),
76
- isActive: true,
77
- isCompleted: false
78
- }];
79
-
80
- function _typeof(obj) {
81
- "@babel/helpers - typeof";
82
-
83
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
84
- return typeof obj;
85
- } : function (obj) {
86
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
87
- }, _typeof(obj);
166
+ function _extends$1() {
167
+ _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
168
+ for (var i = 1; i < arguments.length; i++) {
169
+ var source = arguments[i];
170
+ for (var key in source) {
171
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
172
+ target[key] = source[key];
173
+ }
174
+ }
175
+ }
176
+ return target;
177
+ };
178
+ return _extends$1.apply(this, arguments);
88
179
  }
89
180
 
90
- function _toPrimitive(input, hint) {
91
- if (_typeof(input) !== "object" || input === null) return input;
92
- var prim = input[Symbol.toPrimitive];
93
- if (prim !== undefined) {
94
- var res = prim.call(input, hint || "default");
95
- if (_typeof(res) !== "object") return res;
96
- throw new TypeError("@@toPrimitive must return a primitive value.");
181
+ function _objectWithoutPropertiesLoose(source, excluded) {
182
+ if (source == null) return {};
183
+ var target = {};
184
+ var sourceKeys = Object.keys(source);
185
+ var key, i;
186
+ for (i = 0; i < sourceKeys.length; i++) {
187
+ key = sourceKeys[i];
188
+ if (excluded.indexOf(key) >= 0) continue;
189
+ target[key] = source[key];
97
190
  }
98
- return (hint === "string" ? String : Number)(input);
191
+ return target;
99
192
  }
100
193
 
101
- function _toPropertyKey(arg) {
102
- var key = _toPrimitive(arg, "string");
103
- return _typeof(key) === "symbol" ? key : String(key);
194
+ function _objectWithoutProperties(source, excluded) {
195
+ if (source == null) return {};
196
+ var target = _objectWithoutPropertiesLoose(source, excluded);
197
+ var key, i;
198
+ if (Object.getOwnPropertySymbols) {
199
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
200
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
201
+ key = sourceSymbolKeys[i];
202
+ if (excluded.indexOf(key) >= 0) continue;
203
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
204
+ target[key] = source[key];
205
+ }
206
+ }
207
+ return target;
104
208
  }
105
209
 
106
- function _defineProperty(obj, key, value) {
107
- key = _toPropertyKey(key);
108
- if (key in obj) {
109
- Object.defineProperty(obj, key, {
110
- value: value,
111
- enumerable: true,
112
- configurable: true,
113
- writable: true
210
+ var _excluded = ["className", "children"];
211
+ var ExternalLink = function ExternalLink(_ref) {
212
+ var _ref$className = _ref.className,
213
+ className = _ref$className === void 0 ? "" : _ref$className,
214
+ _ref$children = _ref.children,
215
+ children = _ref$children === void 0 ? null : _ref$children,
216
+ props = _objectWithoutProperties(_ref, _excluded);
217
+ return /*#__PURE__*/React__default.createElement("a", _extends$1({
218
+ className: classnames(["neeto-ui-text-primary-800 hover:neeto-ui-text-primary-800 visited:neeto-ui-text-primary-600 font-medium", className])
219
+ }, props), children);
220
+ };
221
+ var ExternalLink$1 = /*#__PURE__*/React__default.memo(ExternalLink);
222
+
223
+ var MANAGE_DAILY_CO_FORM_INITIAL_VALUES = {
224
+ apiKey: ""
225
+ };
226
+ var DAILY_CO_VALIDATION_SCHEMA = yup.object().shape({
227
+ apiKey: yup.string().trim().required(t$1("neetoIntegrations.errors.required", {
228
+ entity: t$1("neetoIntegrations.daily.apiKey")
229
+ }))
230
+ });
231
+
232
+ var Form = function Form(_ref) {
233
+ var helpDocUrl = _ref.helpDocUrl,
234
+ videoUrl = _ref.videoUrl,
235
+ onConnect = _ref.onConnect;
236
+ var _useTranslation = useTranslation(),
237
+ t = _useTranslation.t;
238
+ var _useState = useState(false),
239
+ _useState2 = _slicedToArray(_useState, 2),
240
+ isDemoModalOpen = _useState2[0],
241
+ setIsDemoModalOpen = _useState2[1];
242
+ var _useCreateDaily = useCreateDaily({
243
+ onSuccess: function onSuccess() {
244
+ return onConnect === null || onConnect === void 0 ? void 0 : onConnect();
245
+ }
246
+ }),
247
+ createDaily = _useCreateDaily.mutate,
248
+ isConnecting = _useCreateDaily.isLoading;
249
+ var handleSubmit = function handleSubmit(payload) {
250
+ return createDaily(payload);
251
+ };
252
+ if (isConnecting) {
253
+ return /*#__PURE__*/React__default.createElement(PageLoader, null);
254
+ }
255
+ return /*#__PURE__*/React__default.createElement("div", {
256
+ className: "mx-auto w-full max-w-md"
257
+ }, /*#__PURE__*/React__default.createElement(Form$2, {
258
+ formikProps: {
259
+ initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,
260
+ validationSchema: DAILY_CO_VALIDATION_SCHEMA,
261
+ onSubmit: handleSubmit
262
+ }
263
+ }, function (_ref2) {
264
+ var dirty = _ref2.dirty;
265
+ return /*#__PURE__*/React__default.createElement("div", {
266
+ className: "mt-10 w-full space-y-5"
267
+ }, /*#__PURE__*/React__default.createElement("div", {
268
+ className: "block"
269
+ }, /*#__PURE__*/React__default.createElement(Input, {
270
+ autoFocus: true,
271
+ required: true,
272
+ label: t("neetoIntegrations.daily.apiKey"),
273
+ name: "apiKey",
274
+ helpText: /*#__PURE__*/React__default.createElement(Trans, {
275
+ i18nKey: "neetoIntegrations.daily.helpDoc",
276
+ components: {
277
+ externalLink: /*#__PURE__*/React__default.createElement(ExternalLink$1, {
278
+ href: helpDocUrl,
279
+ rel: "noreferrer",
280
+ target: "_blank"
281
+ })
282
+ }
283
+ })
284
+ }), /*#__PURE__*/React__default.createElement(Button, {
285
+ className: "mt-8",
286
+ label: t("neetoIntegrations.daily.walkthroughText"),
287
+ style: "link",
288
+ onClick: function onClick() {
289
+ return setIsDemoModalOpen(true);
290
+ }
291
+ })), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(Button, {
292
+ disabled: isConnecting || !dirty,
293
+ label: t("neetoIntegrations.common.connect"),
294
+ loading: isConnecting,
295
+ type: "submit"
296
+ })));
297
+ }), /*#__PURE__*/React__default.createElement(WalkthroughModal, {
298
+ isOpen: isDemoModalOpen,
299
+ videoUrl: videoUrl,
300
+ onClose: function onClose() {
301
+ return setIsDemoModalOpen(false);
302
+ }
303
+ }));
304
+ };
305
+ var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
306
+
307
+ var Manage$1 = withT(function (_ref) {
308
+ var t = _ref.t,
309
+ title = _ref.title,
310
+ description = _ref.description,
311
+ integration = _ref.integration,
312
+ isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
313
+ setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
314
+ isDisconnecting = _ref.isDisconnecting,
315
+ onDisconnect = _ref.onDisconnect,
316
+ onClose = _ref.onClose;
317
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
318
+ className: "mx-auto w-full max-w-md"
319
+ }, /*#__PURE__*/React__default.createElement("div", {
320
+ className: "mt-10 w-full space-y-4"
321
+ }, /*#__PURE__*/React__default.createElement(Typography, {
322
+ className: "neeto-ui-text-gray-800 mb-0.5",
323
+ style: "h3",
324
+ weight: "semibold"
325
+ }, title), /*#__PURE__*/React__default.createElement(Typography, {
326
+ className: "neeto-ui-text-gray-600 break-all",
327
+ style: "body1",
328
+ weight: "normal"
329
+ }, description), /*#__PURE__*/React__default.createElement(Button, {
330
+ label: t("neetoIntegrations.common.disconnect"),
331
+ style: "danger",
332
+ onClick: function onClick() {
333
+ return setIsDisconnectAlertOpen(true);
334
+ }
335
+ }))), /*#__PURE__*/React__default.createElement(DisconnectAlert, {
336
+ isDisconnecting: isDisconnecting,
337
+ onClose: onClose,
338
+ onDisconnect: onDisconnect,
339
+ isOpen: isDisconnectAlertOpen,
340
+ message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
341
+ title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
342
+ }));
343
+ });
344
+
345
+ var Manage = function Manage(_ref) {
346
+ var onDisconnect = _ref.onDisconnect;
347
+ var _useState = useState(false),
348
+ _useState2 = _slicedToArray(_useState, 2),
349
+ isDisconnectAlertOpen = _useState2[0],
350
+ setIsDisconnectAlertOpen = _useState2[1];
351
+ var _useFetchDaily = useFetchDaily(),
352
+ _useFetchDaily$data = _useFetchDaily.data,
353
+ _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
354
+ _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
355
+ metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
356
+ isLoading = _useFetchDaily.isLoading;
357
+ var _ref2 = metadata || {},
358
+ _ref2$apiKey = _ref2.apiKey,
359
+ apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
360
+ var _useTranslation = useTranslation(),
361
+ t = _useTranslation.t;
362
+ var _useDestroyDaily = useDestroyDaily({
363
+ onSuccess: function onSuccess() {
364
+ setIsDisconnectAlertOpen(false);
365
+ onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
366
+ }
367
+ }),
368
+ destroyIntegration = _useDestroyDaily.mutate,
369
+ isDisconnecting = _useDestroyDaily.isLoading;
370
+ var handleDisconnect = function handleDisconnect() {
371
+ return destroyIntegration("daily");
372
+ };
373
+ if (isLoading || isDisconnecting) {
374
+ return /*#__PURE__*/React__default.createElement(PageLoader, null);
375
+ }
376
+ if (isNotPresent(apiKey)) {
377
+ onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
378
+ }
379
+ return /*#__PURE__*/React__default.createElement(Manage$1, {
380
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
381
+ isDisconnecting: isDisconnecting,
382
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
383
+ description: t("neetoIntegrations.daily.yourApiKey", {
384
+ apiKey: apiKey
385
+ }),
386
+ integration: "daily",
387
+ title: t("neetoIntegrations.daily.connected"),
388
+ onClose: function onClose() {
389
+ return setIsDisconnectAlertOpen(false);
390
+ },
391
+ onDisconnect: handleDisconnect
392
+ });
393
+ };
394
+
395
+ var Daily = function Daily(_ref) {
396
+ var _ref$isOnboarding = _ref.isOnboarding,
397
+ isOnboarding = _ref$isOnboarding === void 0 ? false : _ref$isOnboarding,
398
+ _ref$helpDocUrl = _ref.helpDocUrl,
399
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
400
+ _ref$videoUrl = _ref.videoUrl,
401
+ videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
402
+ _ref$onConnect = _ref.onConnect,
403
+ onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
404
+ _ref$onDisconnect = _ref.onDisconnect,
405
+ onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
406
+ var _useFetchDaily = useFetchDaily(),
407
+ _useFetchDaily$data = _useFetchDaily.data,
408
+ _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
409
+ _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
410
+ metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$;
411
+ var _ref2 = metadata || {},
412
+ _ref2$apiKey = _ref2.apiKey,
413
+ apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
414
+ if (isPresent(apiKey) && !isOnboarding) {
415
+ return /*#__PURE__*/React__default.createElement(Manage, {
416
+ onDisconnect: onDisconnect
114
417
  });
115
- } else {
116
- obj[key] = value;
117
418
  }
118
- return obj;
119
- }
419
+ return /*#__PURE__*/React__default.createElement(Form$1, {
420
+ onConnect: onConnect,
421
+ helpDocUrl: helpDocUrl,
422
+ videoUrl: videoUrl
423
+ });
424
+ };
425
+ var index = withTitle(Daily, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
426
+
427
+ var TWILIO_INTEGRATION_STEPS = [{
428
+ step: "1",
429
+ label: i18next.t("neetoIntegrations.steps.configure"),
430
+ isActive: true,
431
+ isCompleted: false
432
+ }];
120
433
 
121
434
  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; }
122
435
  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; }
@@ -191,8 +504,6 @@ function _toConsumableArray(arr) {
191
504
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
192
505
  }
193
506
 
194
- var TWILIO_CONFIGURATION_BASE_URL = "/neeto_integrations/twilio/sms_configurations";
195
-
196
507
  var twilioApi = {
197
508
  fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
198
509
  return axios.get(TWILIO_CONFIGURATION_BASE_URL);
@@ -210,11 +521,6 @@ var twilioApi = {
210
521
  }
211
522
  };
212
523
 
213
- var QUERY_KEYS = {
214
- TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
215
- TWILIO_PHONE_NUMBERS: "twilio-phone-numbers"
216
- };
217
-
218
524
  var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
219
525
  return useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
220
526
  select: function select(response) {
@@ -229,13 +535,15 @@ var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
229
535
  });
230
536
  };
231
537
  var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
232
- var credentials = _ref.credentials;
538
+ var _formRef$current, _formRef$current$valu, _formRef$current2, _formRef$current2$val;
539
+ var credentials = _ref.credentials,
540
+ formRef = _ref.formRef;
233
541
  return useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
234
542
  credentials: credentials
235
543
  }], function () {
236
544
  return twilioApi.getTwilioPhoneNumbers(keysToSnakeCase(credentials));
237
545
  }, {
238
- enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid),
546
+ 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),
239
547
  select: prop("phoneNumbers"),
240
548
  retry: false
241
549
  });
@@ -253,8 +561,10 @@ var useTwilio = function useTwilio(_ref) {
253
561
  onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
254
562
  _ref$setSteps = _ref.setSteps,
255
563
  setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
256
- _ref$useConnect = _ref.useConnect,
257
- useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect;
564
+ _ref$onConnect = _ref.onConnect,
565
+ onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
566
+ _ref$formRef = _ref.formRef,
567
+ formRef = _ref$formRef === void 0 ? null : _ref$formRef;
258
568
  var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
259
569
  configuration = _useFetchTwilioSmsCon.data,
260
570
  isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
@@ -264,20 +574,14 @@ var useTwilio = function useTwilio(_ref) {
264
574
  credentials = _useStateWithDependen2[0],
265
575
  setCredentials = _useStateWithDependen2[1];
266
576
  var _useFetchTwilioPhoneN = useFetchTwilioPhoneNumbers({
267
- credentials: credentials
577
+ credentials: credentials,
578
+ formRef: formRef
268
579
  }),
269
580
  phoneNumbers = _useFetchTwilioPhoneN.data,
270
581
  isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
271
582
  var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
272
583
  saveConfiguration = _useCreateTwilioConfi.mutate,
273
584
  isSubmitting = _useCreateTwilioConfi.isLoading;
274
- var _useConnect = useConnect(),
275
- installIntegration = _useConnect.mutate;
276
- var connectTwilioApp = function connectTwilioApp() {
277
- return installIntegration({
278
- id: "twilio"
279
- }, {});
280
- };
281
585
  useEffect(function () {
282
586
  if (!(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) return;
283
587
  setSteps(function (steps) {
@@ -302,8 +606,8 @@ var useTwilio = function useTwilio(_ref) {
302
606
  saveConfiguration(payload, {
303
607
  onSuccess: function onSuccess() {
304
608
  onSave();
305
- connectTwilioApp();
306
609
  refetchTwilioSmsConfiguration();
610
+ onConnect === null || onConnect === void 0 ? void 0 : onConnect();
307
611
  }
308
612
  });
309
613
  };
@@ -337,17 +641,19 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
337
641
  onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
338
642
  _ref$setSteps = _ref.setSteps,
339
643
  setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
340
- _ref$useConnect = _ref.useConnect,
341
- useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect,
644
+ _ref$onConnect = _ref.onConnect,
645
+ onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
342
646
  _ref$isModal = _ref.isModal,
343
647
  isModal = _ref$isModal === void 0 ? false : _ref$isModal;
344
648
  var _useTranslation = useTranslation(),
345
649
  t = _useTranslation.t;
346
650
  var initialFocusRef = useRef();
651
+ var formRef = useRef();
347
652
  var _useTwilio = useTwilio({
348
653
  onSave: onSave,
349
654
  setSteps: setSteps,
350
- useConnect: useConnect
655
+ onConnect: onConnect,
656
+ formRef: formRef
351
657
  }),
352
658
  handleSubmit = _useTwilio.handleSubmit,
353
659
  phoneNumbers = _useTwilio.phoneNumbers,
@@ -388,7 +694,7 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
388
694
  submitButtonProps: {
389
695
  label: phoneNumberOptions ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
390
696
  disabled: isSubmitDisabled(values),
391
- loading: isSubmitting || isPhoneNumbersLoading && !configuration.twilioAuthToken
697
+ loading: isSubmitting || isPhoneNumbersLoading && !(configuration !== null && configuration !== void 0 && configuration.twilioAuthToken)
392
698
  }
393
699
  });
394
700
  };
@@ -401,12 +707,13 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
401
707
  selectedPhoneNumber: selectedPhoneNumber
402
708
  });
403
709
  };
404
- return /*#__PURE__*/React__default.createElement(Form, {
710
+ return /*#__PURE__*/React__default.createElement(Form$2, {
405
711
  className: "mx-auto flex w-full max-w-md flex-col",
406
712
  formikProps: {
407
713
  enableReinitialize: true,
408
714
  validationSchema: buildTwilioConfigurationValidationSchema(!!phoneNumbers),
409
715
  initialValues: configuration,
716
+ innerRef: formRef,
410
717
  onSubmit: handleSubmit
411
718
  }
412
719
  }, function (formikProps) {
@@ -419,8 +726,8 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
419
726
  var Twilio = function Twilio(_ref) {
420
727
  var _ref$onClose = _ref.onClose,
421
728
  onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
422
- _ref$useConnect = _ref.useConnect,
423
- useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect;
729
+ _ref$onConnect = _ref.onConnect,
730
+ onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect;
424
731
  var _useState = useState(TWILIO_INTEGRATION_STEPS),
425
732
  _useState2 = _slicedToArray(_useState, 2),
426
733
  steps = _useState2[0],
@@ -432,8 +739,8 @@ var Twilio = function Twilio(_ref) {
432
739
  }, /*#__PURE__*/React__default.createElement(TwilioConfiguration, {
433
740
  isModal: true,
434
741
  setSteps: setSteps,
435
- useConnect: useConnect,
436
- onCancel: onClose
742
+ onCancel: onClose,
743
+ onConnect: onConnect
437
744
  }));
438
745
  };
439
746
 
@@ -503,21 +810,6 @@ var Modal = function Modal(_ref) {
503
810
  }, children)));
504
811
  };
505
812
 
506
- function _extends$1() {
507
- _extends$1 = Object.assign ? Object.assign.bind() : function (target) {
508
- for (var i = 1; i < arguments.length; i++) {
509
- var source = arguments[i];
510
- for (var key in source) {
511
- if (Object.prototype.hasOwnProperty.call(source, key)) {
512
- target[key] = source[key];
513
- }
514
- }
515
- }
516
- return target;
517
- };
518
- return _extends$1.apply(this, arguments);
519
- }
520
-
521
813
  var propTypes = {exports: {}};
522
814
 
523
815
  /**
@@ -828,5 +1120,5 @@ function n(n, r) {
828
1120
  var css = ".intrinsic-container{height:0;overflow:hidden;position:relative}.intrinsic-container-16x9{padding-bottom:56.25%}.intrinsic-container-4x3{padding-bottom:75%}.intrinsic-container iframe{height:100%;left:0;position:absolute;top:0;width:100%}";
829
1121
  n(css,{});
830
1122
 
831
- export { Connect, Demo, Finish, Modal, Twilio };
1123
+ export { Connect, index as Daily, Demo, Finish, Modal, Twilio };
832
1124
  //# sourceMappingURL=index.js.map