@bigbinary/neeto-integrations-frontend 2.6.0 → 2.7.1

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