@bigbinary/neeto-integrations-frontend 2.5.3 → 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.
@@ -0,0 +1,628 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var i18next = require('i18next');
5
+ var neetoCist = require('@bigbinary/neeto-cist');
6
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
7
+ var constants = require('@bigbinary/neeto-commons-frontend/constants');
8
+ var reactQuery = require('react-query');
9
+ var axios = require('axios');
10
+ var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
11
+ var neetoui = require('@bigbinary/neetoui');
12
+ var formik = require('@bigbinary/neetoui/formik');
13
+ var reactI18next = require('react-i18next');
14
+ var classnames = require('classnames');
15
+ require('@bigbinary/neeto-molecules/IntegrationCard');
16
+ var DisconnectAlert = require('@bigbinary/neeto-molecules/IntegrationDisconnectAlert');
17
+ var WalkthroughModal = require('@bigbinary/neeto-molecules/IntegrationWalkthroughModal');
18
+ require('ramda');
19
+ var yup = require('yup');
20
+
21
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
+
23
+ function _interopNamespace(e) {
24
+ if (e && e.__esModule) return e;
25
+ var n = Object.create(null);
26
+ if (e) {
27
+ Object.keys(e).forEach(function (k) {
28
+ if (k !== 'default') {
29
+ var d = Object.getOwnPropertyDescriptor(e, k);
30
+ Object.defineProperty(n, k, d.get ? d : {
31
+ enumerable: true,
32
+ get: function () { return e[k]; }
33
+ });
34
+ }
35
+ });
36
+ }
37
+ n["default"] = e;
38
+ return Object.freeze(n);
39
+ }
40
+
41
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
42
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
43
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
44
+ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
45
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
46
+ var DisconnectAlert__default = /*#__PURE__*/_interopDefaultLegacy(DisconnectAlert);
47
+ var WalkthroughModal__default = /*#__PURE__*/_interopDefaultLegacy(WalkthroughModal);
48
+ var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
49
+
50
+ function _typeof(obj) {
51
+ "@babel/helpers - typeof";
52
+
53
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
54
+ return typeof obj;
55
+ } : function (obj) {
56
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
57
+ }, _typeof(obj);
58
+ }
59
+
60
+ function _toPrimitive(input, hint) {
61
+ if (_typeof(input) !== "object" || input === null) return input;
62
+ var prim = input[Symbol.toPrimitive];
63
+ if (prim !== undefined) {
64
+ var res = prim.call(input, hint || "default");
65
+ if (_typeof(res) !== "object") return res;
66
+ throw new TypeError("@@toPrimitive must return a primitive value.");
67
+ }
68
+ return (hint === "string" ? String : Number)(input);
69
+ }
70
+
71
+ function _toPropertyKey(arg) {
72
+ var key = _toPrimitive(arg, "string");
73
+ return _typeof(key) === "symbol" ? key : String(key);
74
+ }
75
+
76
+ function _defineProperty(obj, key, value) {
77
+ key = _toPropertyKey(key);
78
+ if (key in obj) {
79
+ Object.defineProperty(obj, key, {
80
+ value: value,
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true
84
+ });
85
+ } else {
86
+ obj[key] = value;
87
+ }
88
+ return obj;
89
+ }
90
+
91
+ var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
92
+ var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
93
+
94
+ var create = function create(payload) {
95
+ return axios__default["default"].post(INTEGRATIONS_ENGINE_DAILY_URL, {
96
+ daily: payload
97
+ });
98
+ };
99
+ var show = function show() {
100
+ return axios__default["default"].get(INTEGRATIONS_ENGINE_DAILY_URL);
101
+ };
102
+ var destroy = function destroy() {
103
+ return axios__default["default"]["delete"](INTEGRATIONS_ENGINE_DAILY_URL);
104
+ };
105
+ var dailiesApi = {
106
+ create: create,
107
+ show: show,
108
+ destroy: destroy
109
+ };
110
+
111
+ var QUERY_KEYS = {
112
+ TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
113
+ TWILIO_PHONE_NUMBERS: "twilio-phone-numbers",
114
+ DAILY_CO_DETAILS: "daily-co-details"
115
+ };
116
+
117
+ function ownKeys(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; }
118
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
119
+ var useCreateDaily = function useCreateDaily() {
120
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
121
+ return reactUtils.useMutationWithInvalidation(dailiesApi.create, _objectSpread({
122
+ keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS]
123
+ }, options));
124
+ };
125
+ var useFetchDaily = function useFetchDaily() {
126
+ return reactQuery.useQuery(QUERY_KEYS.DAILY_CO_DETAILS, dailiesApi.show, {
127
+ staleTime: constants.DEFAULT_STALE_TIME
128
+ });
129
+ };
130
+ var useDestroyDaily = function useDestroyDaily(_ref) {
131
+ var onSuccess = _ref.onSuccess;
132
+ return reactUtils.useMutationWithInvalidation(dailiesApi.destroy, {
133
+ keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS],
134
+ onSuccess: onSuccess
135
+ });
136
+ };
137
+
138
+ function _arrayWithHoles(arr) {
139
+ if (Array.isArray(arr)) return arr;
140
+ }
141
+
142
+ function _iterableToArrayLimit(arr, i) {
143
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
144
+ if (null != _i) {
145
+ var _s,
146
+ _e,
147
+ _x,
148
+ _r,
149
+ _arr = [],
150
+ _n = !0,
151
+ _d = !1;
152
+ try {
153
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
154
+ if (Object(_i) !== _i) return;
155
+ _n = !1;
156
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
157
+ } catch (err) {
158
+ _d = !0, _e = err;
159
+ } finally {
160
+ try {
161
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
162
+ } finally {
163
+ if (_d) throw _e;
164
+ }
165
+ }
166
+ return _arr;
167
+ }
168
+ }
169
+
170
+ function _arrayLikeToArray(arr, len) {
171
+ if (len == null || len > arr.length) len = arr.length;
172
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
173
+ return arr2;
174
+ }
175
+
176
+ function _unsupportedIterableToArray(o, minLen) {
177
+ if (!o) return;
178
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
179
+ var n = Object.prototype.toString.call(o).slice(8, -1);
180
+ if (n === "Object" && o.constructor) n = o.constructor.name;
181
+ if (n === "Map" || n === "Set") return Array.from(o);
182
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
183
+ }
184
+
185
+ function _nonIterableRest() {
186
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
187
+ }
188
+
189
+ function _slicedToArray(arr, i) {
190
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
191
+ }
192
+
193
+ function _extends() {
194
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
195
+ for (var i = 1; i < arguments.length; i++) {
196
+ var source = arguments[i];
197
+ for (var key in source) {
198
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
199
+ target[key] = source[key];
200
+ }
201
+ }
202
+ }
203
+ return target;
204
+ };
205
+ return _extends.apply(this, arguments);
206
+ }
207
+
208
+ function _objectWithoutPropertiesLoose(source, excluded) {
209
+ if (source == null) return {};
210
+ var target = {};
211
+ var sourceKeys = Object.keys(source);
212
+ var key, i;
213
+ for (i = 0; i < sourceKeys.length; i++) {
214
+ key = sourceKeys[i];
215
+ if (excluded.indexOf(key) >= 0) continue;
216
+ target[key] = source[key];
217
+ }
218
+ return target;
219
+ }
220
+
221
+ function _objectWithoutProperties(source, excluded) {
222
+ if (source == null) return {};
223
+ var target = _objectWithoutPropertiesLoose(source, excluded);
224
+ var key, i;
225
+ if (Object.getOwnPropertySymbols) {
226
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
227
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
228
+ key = sourceSymbolKeys[i];
229
+ if (excluded.indexOf(key) >= 0) continue;
230
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
231
+ target[key] = source[key];
232
+ }
233
+ }
234
+ return target;
235
+ }
236
+
237
+ var _excluded = ["className", "children"];
238
+ var ExternalLink = function ExternalLink(_ref) {
239
+ var _ref$className = _ref.className,
240
+ className = _ref$className === void 0 ? "" : _ref$className,
241
+ _ref$children = _ref.children,
242
+ children = _ref$children === void 0 ? null : _ref$children,
243
+ props = _objectWithoutProperties(_ref, _excluded);
244
+ return /*#__PURE__*/React__default["default"].createElement("a", _extends({
245
+ className: classnames__default["default"](["neeto-ui-text-primary-800 hover:neeto-ui-text-primary-800 visited:neeto-ui-text-primary-600 font-medium", className])
246
+ }, props), children);
247
+ };
248
+ var ExternalLink$1 = /*#__PURE__*/React__default["default"].memo(ExternalLink);
249
+
250
+ [{
251
+ step: "1",
252
+ label: i18next__default["default"].t("neetoIntegrations.steps.configure"),
253
+ isActive: true,
254
+ isCompleted: false
255
+ }];
256
+
257
+ var propTypes = {exports: {}};
258
+
259
+ /**
260
+ * Copyright (c) 2013-present, Facebook, Inc.
261
+ *
262
+ * This source code is licensed under the MIT license found in the
263
+ * LICENSE file in the root directory of this source tree.
264
+ */
265
+ var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
266
+ var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
267
+
268
+ /**
269
+ * Copyright (c) 2013-present, Facebook, Inc.
270
+ *
271
+ * This source code is licensed under the MIT license found in the
272
+ * LICENSE file in the root directory of this source tree.
273
+ */
274
+ var ReactPropTypesSecret = ReactPropTypesSecret_1;
275
+ function emptyFunction() {}
276
+ function emptyFunctionWithReset() {}
277
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
278
+ var factoryWithThrowingShims = function factoryWithThrowingShims() {
279
+ function shim(props, propName, componentName, location, propFullName, secret) {
280
+ if (secret === ReactPropTypesSecret) {
281
+ // It is still safe when called from React.
282
+ return;
283
+ }
284
+ var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
285
+ err.name = 'Invariant Violation';
286
+ throw err;
287
+ }
288
+ shim.isRequired = shim;
289
+ function getShim() {
290
+ return shim;
291
+ }
292
+ // Important!
293
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
294
+ var ReactPropTypes = {
295
+ array: shim,
296
+ bigint: shim,
297
+ bool: shim,
298
+ func: shim,
299
+ number: shim,
300
+ object: shim,
301
+ string: shim,
302
+ symbol: shim,
303
+ any: shim,
304
+ arrayOf: getShim,
305
+ element: shim,
306
+ elementType: shim,
307
+ instanceOf: getShim,
308
+ node: shim,
309
+ objectOf: getShim,
310
+ oneOf: getShim,
311
+ oneOfType: getShim,
312
+ shape: getShim,
313
+ exact: getShim,
314
+ checkPropTypes: emptyFunctionWithReset,
315
+ resetWarningCache: emptyFunction
316
+ };
317
+ ReactPropTypes.PropTypes = ReactPropTypes;
318
+ return ReactPropTypes;
319
+ };
320
+
321
+ /**
322
+ * Copyright (c) 2013-present, Facebook, Inc.
323
+ *
324
+ * This source code is licensed under the MIT license found in the
325
+ * LICENSE file in the root directory of this source tree.
326
+ */
327
+ {
328
+ // By explicitly using `prop-types` you are opting into new production behavior.
329
+ // http://fb.me/prop-types-in-prod
330
+ propTypes.exports = factoryWithThrowingShims();
331
+ }
332
+
333
+ ({
334
+ /**
335
+ * To specify the Icon to be shown
336
+ */
337
+ Icon: propTypes.exports.PropTypes.node,
338
+ /**
339
+ * To specify the title of the connect component
340
+ */
341
+ title: propTypes.exports.PropTypes.string,
342
+ /**
343
+ * To specify the description for connect component
344
+ */
345
+ description: propTypes.exports.PropTypes.string,
346
+ /**
347
+ * To specify the props for the connect button
348
+ */
349
+ buttonProps: propTypes.exports.PropTypes.object,
350
+ /**
351
+ * Handler function that is triggered when the connect button is clicked.
352
+ */
353
+ onConnect: propTypes.exports.PropTypes.func
354
+ });
355
+
356
+ ({
357
+ /**
358
+ * To specify whether the integration modal should be opened or closed.
359
+ */
360
+ onClose: propTypes.exports.func,
361
+ /**
362
+ * To specify the walkthrough video link
363
+ */
364
+ videoUrl: propTypes.exports.string,
365
+ /**
366
+ * To specify the title of the demo component
367
+ */
368
+ title: propTypes.exports.string,
369
+ /**
370
+ * To specify the subtitle of the demo component
371
+ */
372
+ subtitle: propTypes.exports.string,
373
+ /**
374
+ * To specify the title of the video in the iframe
375
+ */
376
+ iframeTitle: propTypes.exports.string
377
+ });
378
+
379
+ ({
380
+ /**
381
+ * To specify whether the integration modal should be opened or closed.
382
+ */
383
+ onClick: propTypes.exports.func,
384
+ /**
385
+ * To show the title of the Finish component
386
+ */
387
+ title: propTypes.exports.string,
388
+ /**
389
+ * To specify props for primary button
390
+ */
391
+ buttonProps: propTypes.exports.object,
392
+ /**
393
+ * To specify props for secondary button
394
+ */
395
+ secondaryButtonProps: propTypes.exports.object
396
+ });
397
+
398
+ var e = [],
399
+ t = [];
400
+ function n(n, r) {
401
+ if (n && "undefined" != typeof document) {
402
+ var a,
403
+ s = !0 === r.prepend ? "prepend" : "append",
404
+ d = !0 === r.singleTag,
405
+ i = "string" == typeof r.container ? document.querySelector(r.container) : document.getElementsByTagName("head")[0];
406
+ if (d) {
407
+ var u = e.indexOf(i);
408
+ -1 === u && (u = e.push(i) - 1, t[u] = {}), a = t[u] && t[u][s] ? t[u][s] : t[u][s] = c();
409
+ } else a = c();
410
+ 65279 === n.charCodeAt(0) && (n = n.substring(1)), a.styleSheet ? a.styleSheet.cssText += n : a.appendChild(document.createTextNode(n));
411
+ }
412
+ function c() {
413
+ var e = document.createElement("style");
414
+ if (e.setAttribute("type", "text/css"), r.attributes) for (var t = Object.keys(r.attributes), n = 0; n < t.length; n++) e.setAttribute(t[n], r.attributes[t[n]]);
415
+ var a = "prepend" === s ? "afterbegin" : "beforeend";
416
+ return i.insertAdjacentElement(a, e), e;
417
+ }
418
+ }
419
+
420
+ 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%}";
421
+ n(css,{});
422
+
423
+ var MANAGE_DAILY_CO_FORM_INITIAL_VALUES = {
424
+ apiKey: ""
425
+ };
426
+ var DAILY_CO_VALIDATION_SCHEMA = yup__namespace.object().shape({
427
+ apiKey: yup__namespace.string().trim().required(i18next.t("neetoIntegrations.errors.required", {
428
+ entity: i18next.t("neetoIntegrations.daily.apiKey")
429
+ }))
430
+ });
431
+
432
+ var Form = function Form(_ref) {
433
+ var helpDocUrl = _ref.helpDocUrl,
434
+ videoUrl = _ref.videoUrl,
435
+ onConnect = _ref.onConnect;
436
+ var _useTranslation = reactI18next.useTranslation(),
437
+ t = _useTranslation.t;
438
+ var _useState = React.useState(false),
439
+ _useState2 = _slicedToArray(_useState, 2),
440
+ isDemoModalOpen = _useState2[0],
441
+ setIsDemoModalOpen = _useState2[1];
442
+ var _useCreateDaily = useCreateDaily({
443
+ onSuccess: function onSuccess() {
444
+ return onConnect === null || onConnect === void 0 ? void 0 : onConnect();
445
+ }
446
+ }),
447
+ createDaily = _useCreateDaily.mutate,
448
+ isConnecting = _useCreateDaily.isLoading;
449
+ var handleSubmit = function handleSubmit(payload) {
450
+ return createDaily(payload);
451
+ };
452
+ if (isConnecting) {
453
+ return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
454
+ }
455
+ return /*#__PURE__*/React__default["default"].createElement("div", {
456
+ className: "mx-auto w-full max-w-md"
457
+ }, /*#__PURE__*/React__default["default"].createElement(formik.Form, {
458
+ formikProps: {
459
+ initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,
460
+ validationSchema: DAILY_CO_VALIDATION_SCHEMA,
461
+ onSubmit: handleSubmit
462
+ }
463
+ }, function (_ref2) {
464
+ var dirty = _ref2.dirty;
465
+ return /*#__PURE__*/React__default["default"].createElement("div", {
466
+ className: "mt-10 w-full space-y-5"
467
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
468
+ className: "block"
469
+ }, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
470
+ autoFocus: true,
471
+ required: true,
472
+ label: t("neetoIntegrations.daily.apiKey"),
473
+ name: "apiKey",
474
+ helpText: /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
475
+ i18nKey: "neetoIntegrations.daily.helpDoc",
476
+ components: {
477
+ externalLink: /*#__PURE__*/React__default["default"].createElement(ExternalLink$1, {
478
+ href: helpDocUrl,
479
+ rel: "noreferrer",
480
+ target: "_blank"
481
+ })
482
+ }
483
+ })
484
+ }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
485
+ className: "mt-8",
486
+ label: t("neetoIntegrations.daily.walkthroughText"),
487
+ style: "link",
488
+ onClick: function onClick() {
489
+ return setIsDemoModalOpen(true);
490
+ }
491
+ })), /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
492
+ disabled: isConnecting || !dirty,
493
+ label: t("neetoIntegrations.common.connect"),
494
+ loading: isConnecting,
495
+ type: "submit"
496
+ })));
497
+ }), /*#__PURE__*/React__default["default"].createElement(WalkthroughModal__default["default"], {
498
+ isOpen: isDemoModalOpen,
499
+ videoUrl: videoUrl,
500
+ onClose: function onClose() {
501
+ return setIsDemoModalOpen(false);
502
+ }
503
+ }));
504
+ };
505
+ var Form$1 = reactUtils.withTitle(Form, i18next__default["default"].t("neetoIntegrations.browserTitles.integrations.dailyco"));
506
+
507
+ var Manage$1 = reactUtils.withT(function (_ref) {
508
+ var t = _ref.t,
509
+ title = _ref.title,
510
+ description = _ref.description,
511
+ integration = _ref.integration,
512
+ isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
513
+ setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
514
+ isDisconnecting = _ref.isDisconnecting,
515
+ onDisconnect = _ref.onDisconnect,
516
+ onClose = _ref.onClose;
517
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
518
+ className: "mx-auto w-full max-w-md"
519
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
520
+ className: "mt-10 w-full space-y-4"
521
+ }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
522
+ className: "neeto-ui-text-gray-800 mb-0.5",
523
+ style: "h3",
524
+ weight: "semibold"
525
+ }, title), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
526
+ className: "neeto-ui-text-gray-600 break-all",
527
+ style: "body1",
528
+ weight: "normal"
529
+ }, description), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
530
+ label: t("neetoIntegrations.common.disconnect"),
531
+ style: "danger",
532
+ onClick: function onClick() {
533
+ return setIsDisconnectAlertOpen(true);
534
+ }
535
+ }))), /*#__PURE__*/React__default["default"].createElement(DisconnectAlert__default["default"], {
536
+ isDisconnecting: isDisconnecting,
537
+ onClose: onClose,
538
+ onDisconnect: onDisconnect,
539
+ isOpen: isDisconnectAlertOpen,
540
+ message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
541
+ title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
542
+ }));
543
+ });
544
+
545
+ var Manage = function Manage(_ref) {
546
+ var onDisconnect = _ref.onDisconnect;
547
+ var _useState = React.useState(false),
548
+ _useState2 = _slicedToArray(_useState, 2),
549
+ isDisconnectAlertOpen = _useState2[0],
550
+ setIsDisconnectAlertOpen = _useState2[1];
551
+ var _useFetchDaily = useFetchDaily(),
552
+ _useFetchDaily$data = _useFetchDaily.data,
553
+ _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
554
+ _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
555
+ metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
556
+ isLoading = _useFetchDaily.isLoading;
557
+ var _ref2 = metadata || {},
558
+ _ref2$apiKey = _ref2.apiKey,
559
+ apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
560
+ var _useTranslation = reactI18next.useTranslation(),
561
+ t = _useTranslation.t;
562
+ var _useDestroyDaily = useDestroyDaily({
563
+ onSuccess: function onSuccess() {
564
+ setIsDisconnectAlertOpen(false);
565
+ onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
566
+ }
567
+ }),
568
+ destroyIntegration = _useDestroyDaily.mutate,
569
+ isDisconnecting = _useDestroyDaily.isLoading;
570
+ var handleDisconnect = function handleDisconnect() {
571
+ return destroyIntegration("daily");
572
+ };
573
+ if (isLoading || isDisconnecting) {
574
+ return /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], null);
575
+ }
576
+ if (neetoCist.isNotPresent(apiKey)) {
577
+ onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
578
+ }
579
+ return /*#__PURE__*/React__default["default"].createElement(Manage$1, {
580
+ isDisconnectAlertOpen: isDisconnectAlertOpen,
581
+ isDisconnecting: isDisconnecting,
582
+ setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
583
+ description: t("neetoIntegrations.daily.yourApiKey", {
584
+ apiKey: apiKey
585
+ }),
586
+ integration: "daily",
587
+ title: t("neetoIntegrations.daily.connected"),
588
+ onClose: function onClose() {
589
+ return setIsDisconnectAlertOpen(false);
590
+ },
591
+ onDisconnect: handleDisconnect
592
+ });
593
+ };
594
+
595
+ var Daily = function Daily(_ref) {
596
+ var _ref$isOnboarding = _ref.isOnboarding,
597
+ isOnboarding = _ref$isOnboarding === void 0 ? false : _ref$isOnboarding,
598
+ _ref$helpDocUrl = _ref.helpDocUrl,
599
+ helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
600
+ _ref$videoUrl = _ref.videoUrl,
601
+ videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
602
+ _ref$onConnect = _ref.onConnect,
603
+ onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect,
604
+ _ref$onDisconnect = _ref.onDisconnect,
605
+ onDisconnect = _ref$onDisconnect === void 0 ? neetoCist.noop : _ref$onDisconnect;
606
+ var _useFetchDaily = useFetchDaily(),
607
+ _useFetchDaily$data = _useFetchDaily.data,
608
+ _useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
609
+ _useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
610
+ metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$;
611
+ var _ref2 = metadata || {},
612
+ _ref2$apiKey = _ref2.apiKey,
613
+ apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
614
+ if (neetoCist.isPresent(apiKey) && !isOnboarding) {
615
+ return /*#__PURE__*/React__default["default"].createElement(Manage, {
616
+ onDisconnect: onDisconnect
617
+ });
618
+ }
619
+ return /*#__PURE__*/React__default["default"].createElement(Form$1, {
620
+ onConnect: onConnect,
621
+ helpDocUrl: helpDocUrl,
622
+ videoUrl: videoUrl
623
+ });
624
+ };
625
+ var index = reactUtils.withTitle(Daily, i18next__default["default"].t("neetoIntegrations.browserTitles.integrations.dailyco"));
626
+
627
+ module.exports = index;
628
+ //# sourceMappingURL=Daily.cjs.js.map