@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/Daily.cjs.js +628 -0
- package/dist/Daily.cjs.js.map +1 -0
- package/dist/Daily.js +597 -0
- package/dist/Daily.js.map +1 -0
- package/dist/Twilio.cjs.js +385 -77
- package/dist/Twilio.cjs.js.map +1 -1
- package/dist/Twilio.js +386 -81
- package/dist/Twilio.js.map +1 -1
- package/dist/index.cjs.js +386 -94
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +384 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/translations/en.json +21 -0
- package/types.d.ts +10 -1
package/dist/Twilio.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import React, { useEffect, useRef
|
|
2
|
-
import { noop, keysToSnakeCase, _findBy } from '@bigbinary/neeto-cist';
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { isNotPresent, isPresent, noop, keysToSnakeCase, _findBy } from '@bigbinary/neeto-cist';
|
|
3
3
|
import '@bigbinary/neeto-molecules/IntegrationCard';
|
|
4
|
-
import '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
|
|
5
|
-
import '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { prop, equals } from 'ramda';
|
|
10
|
-
import i18next from 'i18next';
|
|
11
|
-
import { Input, Select, Form, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
12
|
-
import { useMutationWithInvalidation, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
4
|
+
import DisconnectAlert from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
|
|
5
|
+
import WalkthroughModal from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
|
|
6
|
+
import i18next, { t as t$1 } from 'i18next';
|
|
7
|
+
import { useMutationWithInvalidation, withTitle, withT, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
8
|
+
import { DEFAULT_STALE_TIME } from '@bigbinary/neeto-commons-frontend/constants';
|
|
13
9
|
import { useQuery } from 'react-query';
|
|
14
10
|
import axios from 'axios';
|
|
11
|
+
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
12
|
+
import { Button, Typography, Modal as Modal$1 } from '@bigbinary/neetoui';
|
|
13
|
+
import { Form as Form$2, Input, Select, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
14
|
+
import { useTranslation, Trans } from 'react-i18next';
|
|
15
|
+
import classnames from 'classnames';
|
|
16
|
+
import { prop, equals } from 'ramda';
|
|
15
17
|
import * as yup from 'yup';
|
|
16
18
|
|
|
17
19
|
function _arrayWithHoles(arr) {
|
|
@@ -69,6 +71,356 @@ function _slicedToArray(arr, i) {
|
|
|
69
71
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
function _typeof(obj) {
|
|
75
|
+
"@babel/helpers - typeof";
|
|
76
|
+
|
|
77
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
78
|
+
return typeof obj;
|
|
79
|
+
} : function (obj) {
|
|
80
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
81
|
+
}, _typeof(obj);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _toPrimitive(input, hint) {
|
|
85
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
86
|
+
var prim = input[Symbol.toPrimitive];
|
|
87
|
+
if (prim !== undefined) {
|
|
88
|
+
var res = prim.call(input, hint || "default");
|
|
89
|
+
if (_typeof(res) !== "object") return res;
|
|
90
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
91
|
+
}
|
|
92
|
+
return (hint === "string" ? String : Number)(input);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _toPropertyKey(arg) {
|
|
96
|
+
var key = _toPrimitive(arg, "string");
|
|
97
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _defineProperty(obj, key, value) {
|
|
101
|
+
key = _toPropertyKey(key);
|
|
102
|
+
if (key in obj) {
|
|
103
|
+
Object.defineProperty(obj, key, {
|
|
104
|
+
value: value,
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true
|
|
108
|
+
});
|
|
109
|
+
} else {
|
|
110
|
+
obj[key] = value;
|
|
111
|
+
}
|
|
112
|
+
return obj;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
|
|
116
|
+
var TWILIO_CONFIGURATION_BASE_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/twilio/sms_configurations");
|
|
117
|
+
var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
|
|
118
|
+
|
|
119
|
+
var create = function create(payload) {
|
|
120
|
+
return axios.post(INTEGRATIONS_ENGINE_DAILY_URL, {
|
|
121
|
+
daily: payload
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
var show = function show() {
|
|
125
|
+
return axios.get(INTEGRATIONS_ENGINE_DAILY_URL);
|
|
126
|
+
};
|
|
127
|
+
var destroy = function destroy() {
|
|
128
|
+
return axios["delete"](INTEGRATIONS_ENGINE_DAILY_URL);
|
|
129
|
+
};
|
|
130
|
+
var dailiesApi = {
|
|
131
|
+
create: create,
|
|
132
|
+
show: show,
|
|
133
|
+
destroy: destroy
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
var QUERY_KEYS = {
|
|
137
|
+
TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
|
|
138
|
+
TWILIO_PHONE_NUMBERS: "twilio-phone-numbers",
|
|
139
|
+
DAILY_CO_DETAILS: "daily-co-details"
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
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; }
|
|
143
|
+
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; }
|
|
144
|
+
var useCreateDaily = function useCreateDaily() {
|
|
145
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
146
|
+
return useMutationWithInvalidation(dailiesApi.create, _objectSpread$3({
|
|
147
|
+
keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS]
|
|
148
|
+
}, options));
|
|
149
|
+
};
|
|
150
|
+
var useFetchDaily = function useFetchDaily() {
|
|
151
|
+
return useQuery(QUERY_KEYS.DAILY_CO_DETAILS, dailiesApi.show, {
|
|
152
|
+
staleTime: DEFAULT_STALE_TIME
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
var useDestroyDaily = function useDestroyDaily(_ref) {
|
|
156
|
+
var onSuccess = _ref.onSuccess;
|
|
157
|
+
return useMutationWithInvalidation(dailiesApi.destroy, {
|
|
158
|
+
keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS],
|
|
159
|
+
onSuccess: onSuccess
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
function _extends() {
|
|
164
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
165
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
166
|
+
var source = arguments[i];
|
|
167
|
+
for (var key in source) {
|
|
168
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
169
|
+
target[key] = source[key];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return target;
|
|
174
|
+
};
|
|
175
|
+
return _extends.apply(this, arguments);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
179
|
+
if (source == null) return {};
|
|
180
|
+
var target = {};
|
|
181
|
+
var sourceKeys = Object.keys(source);
|
|
182
|
+
var key, i;
|
|
183
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
184
|
+
key = sourceKeys[i];
|
|
185
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
186
|
+
target[key] = source[key];
|
|
187
|
+
}
|
|
188
|
+
return target;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function _objectWithoutProperties(source, excluded) {
|
|
192
|
+
if (source == null) return {};
|
|
193
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
194
|
+
var key, i;
|
|
195
|
+
if (Object.getOwnPropertySymbols) {
|
|
196
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
197
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
198
|
+
key = sourceSymbolKeys[i];
|
|
199
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
200
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
201
|
+
target[key] = source[key];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return target;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var _excluded = ["className", "children"];
|
|
208
|
+
var ExternalLink = function ExternalLink(_ref) {
|
|
209
|
+
var _ref$className = _ref.className,
|
|
210
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
211
|
+
_ref$children = _ref.children,
|
|
212
|
+
children = _ref$children === void 0 ? null : _ref$children,
|
|
213
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
214
|
+
return /*#__PURE__*/React.createElement("a", _extends({
|
|
215
|
+
className: classnames(["neeto-ui-text-primary-800 hover:neeto-ui-text-primary-800 visited:neeto-ui-text-primary-600 font-medium", className])
|
|
216
|
+
}, props), children);
|
|
217
|
+
};
|
|
218
|
+
var ExternalLink$1 = /*#__PURE__*/React.memo(ExternalLink);
|
|
219
|
+
|
|
220
|
+
var MANAGE_DAILY_CO_FORM_INITIAL_VALUES = {
|
|
221
|
+
apiKey: ""
|
|
222
|
+
};
|
|
223
|
+
var DAILY_CO_VALIDATION_SCHEMA = yup.object().shape({
|
|
224
|
+
apiKey: yup.string().trim().required(t$1("neetoIntegrations.errors.required", {
|
|
225
|
+
entity: t$1("neetoIntegrations.daily.apiKey")
|
|
226
|
+
}))
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
var Form = function Form(_ref) {
|
|
230
|
+
var helpDocUrl = _ref.helpDocUrl,
|
|
231
|
+
videoUrl = _ref.videoUrl,
|
|
232
|
+
onConnect = _ref.onConnect;
|
|
233
|
+
var _useTranslation = useTranslation(),
|
|
234
|
+
t = _useTranslation.t;
|
|
235
|
+
var _useState = useState(false),
|
|
236
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
237
|
+
isDemoModalOpen = _useState2[0],
|
|
238
|
+
setIsDemoModalOpen = _useState2[1];
|
|
239
|
+
var _useCreateDaily = useCreateDaily({
|
|
240
|
+
onSuccess: function onSuccess() {
|
|
241
|
+
return onConnect === null || onConnect === void 0 ? void 0 : onConnect();
|
|
242
|
+
}
|
|
243
|
+
}),
|
|
244
|
+
createDaily = _useCreateDaily.mutate,
|
|
245
|
+
isConnecting = _useCreateDaily.isLoading;
|
|
246
|
+
var handleSubmit = function handleSubmit(payload) {
|
|
247
|
+
return createDaily(payload);
|
|
248
|
+
};
|
|
249
|
+
if (isConnecting) {
|
|
250
|
+
return /*#__PURE__*/React.createElement(PageLoader, null);
|
|
251
|
+
}
|
|
252
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: "mx-auto w-full max-w-md"
|
|
254
|
+
}, /*#__PURE__*/React.createElement(Form$2, {
|
|
255
|
+
formikProps: {
|
|
256
|
+
initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,
|
|
257
|
+
validationSchema: DAILY_CO_VALIDATION_SCHEMA,
|
|
258
|
+
onSubmit: handleSubmit
|
|
259
|
+
}
|
|
260
|
+
}, function (_ref2) {
|
|
261
|
+
var dirty = _ref2.dirty;
|
|
262
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
263
|
+
className: "mt-10 w-full space-y-5"
|
|
264
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
className: "block"
|
|
266
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
267
|
+
autoFocus: true,
|
|
268
|
+
required: true,
|
|
269
|
+
label: t("neetoIntegrations.daily.apiKey"),
|
|
270
|
+
name: "apiKey",
|
|
271
|
+
helpText: /*#__PURE__*/React.createElement(Trans, {
|
|
272
|
+
i18nKey: "neetoIntegrations.daily.helpDoc",
|
|
273
|
+
components: {
|
|
274
|
+
externalLink: /*#__PURE__*/React.createElement(ExternalLink$1, {
|
|
275
|
+
href: helpDocUrl,
|
|
276
|
+
rel: "noreferrer",
|
|
277
|
+
target: "_blank"
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
282
|
+
className: "mt-8",
|
|
283
|
+
label: t("neetoIntegrations.daily.walkthroughText"),
|
|
284
|
+
style: "link",
|
|
285
|
+
onClick: function onClick() {
|
|
286
|
+
return setIsDemoModalOpen(true);
|
|
287
|
+
}
|
|
288
|
+
})), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
|
289
|
+
disabled: isConnecting || !dirty,
|
|
290
|
+
label: t("neetoIntegrations.common.connect"),
|
|
291
|
+
loading: isConnecting,
|
|
292
|
+
type: "submit"
|
|
293
|
+
})));
|
|
294
|
+
}), /*#__PURE__*/React.createElement(WalkthroughModal, {
|
|
295
|
+
isOpen: isDemoModalOpen,
|
|
296
|
+
videoUrl: videoUrl,
|
|
297
|
+
onClose: function onClose() {
|
|
298
|
+
return setIsDemoModalOpen(false);
|
|
299
|
+
}
|
|
300
|
+
}));
|
|
301
|
+
};
|
|
302
|
+
var Form$1 = withTitle(Form, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
|
|
303
|
+
|
|
304
|
+
var Manage$1 = withT(function (_ref) {
|
|
305
|
+
var t = _ref.t,
|
|
306
|
+
title = _ref.title,
|
|
307
|
+
description = _ref.description,
|
|
308
|
+
integration = _ref.integration,
|
|
309
|
+
isDisconnectAlertOpen = _ref.isDisconnectAlertOpen,
|
|
310
|
+
setIsDisconnectAlertOpen = _ref.setIsDisconnectAlertOpen,
|
|
311
|
+
isDisconnecting = _ref.isDisconnecting,
|
|
312
|
+
onDisconnect = _ref.onDisconnect,
|
|
313
|
+
onClose = _ref.onClose;
|
|
314
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
315
|
+
className: "mx-auto w-full max-w-md"
|
|
316
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
317
|
+
className: "mt-10 w-full space-y-4"
|
|
318
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
319
|
+
className: "neeto-ui-text-gray-800 mb-0.5",
|
|
320
|
+
style: "h3",
|
|
321
|
+
weight: "semibold"
|
|
322
|
+
}, title), /*#__PURE__*/React.createElement(Typography, {
|
|
323
|
+
className: "neeto-ui-text-gray-600 break-all",
|
|
324
|
+
style: "body1",
|
|
325
|
+
weight: "normal"
|
|
326
|
+
}, description), /*#__PURE__*/React.createElement(Button, {
|
|
327
|
+
label: t("neetoIntegrations.common.disconnect"),
|
|
328
|
+
style: "danger",
|
|
329
|
+
onClick: function onClick() {
|
|
330
|
+
return setIsDisconnectAlertOpen(true);
|
|
331
|
+
}
|
|
332
|
+
}))), /*#__PURE__*/React.createElement(DisconnectAlert, {
|
|
333
|
+
isDisconnecting: isDisconnecting,
|
|
334
|
+
onClose: onClose,
|
|
335
|
+
onDisconnect: onDisconnect,
|
|
336
|
+
isOpen: isDisconnectAlertOpen,
|
|
337
|
+
message: t("neetoIntegrations.".concat(integration, ".disconnect.message")),
|
|
338
|
+
title: t("neetoIntegrations.".concat(integration, ".disconnect.title"))
|
|
339
|
+
}));
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
var Manage = function Manage(_ref) {
|
|
343
|
+
var onDisconnect = _ref.onDisconnect;
|
|
344
|
+
var _useState = useState(false),
|
|
345
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
346
|
+
isDisconnectAlertOpen = _useState2[0],
|
|
347
|
+
setIsDisconnectAlertOpen = _useState2[1];
|
|
348
|
+
var _useFetchDaily = useFetchDaily(),
|
|
349
|
+
_useFetchDaily$data = _useFetchDaily.data,
|
|
350
|
+
_useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
|
|
351
|
+
_useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
|
|
352
|
+
metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$,
|
|
353
|
+
isLoading = _useFetchDaily.isLoading;
|
|
354
|
+
var _ref2 = metadata || {},
|
|
355
|
+
_ref2$apiKey = _ref2.apiKey,
|
|
356
|
+
apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
|
|
357
|
+
var _useTranslation = useTranslation(),
|
|
358
|
+
t = _useTranslation.t;
|
|
359
|
+
var _useDestroyDaily = useDestroyDaily({
|
|
360
|
+
onSuccess: function onSuccess() {
|
|
361
|
+
setIsDisconnectAlertOpen(false);
|
|
362
|
+
onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
destroyIntegration = _useDestroyDaily.mutate,
|
|
366
|
+
isDisconnecting = _useDestroyDaily.isLoading;
|
|
367
|
+
var handleDisconnect = function handleDisconnect() {
|
|
368
|
+
return destroyIntegration("daily");
|
|
369
|
+
};
|
|
370
|
+
if (isLoading || isDisconnecting) {
|
|
371
|
+
return /*#__PURE__*/React.createElement(PageLoader, null);
|
|
372
|
+
}
|
|
373
|
+
if (isNotPresent(apiKey)) {
|
|
374
|
+
onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
|
|
375
|
+
}
|
|
376
|
+
return /*#__PURE__*/React.createElement(Manage$1, {
|
|
377
|
+
isDisconnectAlertOpen: isDisconnectAlertOpen,
|
|
378
|
+
isDisconnecting: isDisconnecting,
|
|
379
|
+
setIsDisconnectAlertOpen: setIsDisconnectAlertOpen,
|
|
380
|
+
description: t("neetoIntegrations.daily.yourApiKey", {
|
|
381
|
+
apiKey: apiKey
|
|
382
|
+
}),
|
|
383
|
+
integration: "daily",
|
|
384
|
+
title: t("neetoIntegrations.daily.connected"),
|
|
385
|
+
onClose: function onClose() {
|
|
386
|
+
return setIsDisconnectAlertOpen(false);
|
|
387
|
+
},
|
|
388
|
+
onDisconnect: handleDisconnect
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
var Daily = function Daily(_ref) {
|
|
393
|
+
var _ref$isOnboarding = _ref.isOnboarding,
|
|
394
|
+
isOnboarding = _ref$isOnboarding === void 0 ? false : _ref$isOnboarding,
|
|
395
|
+
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
396
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
|
|
397
|
+
_ref$videoUrl = _ref.videoUrl,
|
|
398
|
+
videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
|
|
399
|
+
_ref$onConnect = _ref.onConnect,
|
|
400
|
+
onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
|
|
401
|
+
_ref$onDisconnect = _ref.onDisconnect,
|
|
402
|
+
onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
|
|
403
|
+
var _useFetchDaily = useFetchDaily(),
|
|
404
|
+
_useFetchDaily$data = _useFetchDaily.data,
|
|
405
|
+
_useFetchDaily$data2 = _useFetchDaily$data === void 0 ? {} : _useFetchDaily$data,
|
|
406
|
+
_useFetchDaily$data2$ = _useFetchDaily$data2.metadata,
|
|
407
|
+
metadata = _useFetchDaily$data2$ === void 0 ? {} : _useFetchDaily$data2$;
|
|
408
|
+
var _ref2 = metadata || {},
|
|
409
|
+
_ref2$apiKey = _ref2.apiKey,
|
|
410
|
+
apiKey = _ref2$apiKey === void 0 ? null : _ref2$apiKey;
|
|
411
|
+
if (isPresent(apiKey) && !isOnboarding) {
|
|
412
|
+
return /*#__PURE__*/React.createElement(Manage, {
|
|
413
|
+
onDisconnect: onDisconnect
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
return /*#__PURE__*/React.createElement(Form$1, {
|
|
417
|
+
onConnect: onConnect,
|
|
418
|
+
helpDocUrl: helpDocUrl,
|
|
419
|
+
videoUrl: videoUrl
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
withTitle(Daily, i18next.t("neetoIntegrations.browserTitles.integrations.dailyco"));
|
|
423
|
+
|
|
72
424
|
var Stepper = function Stepper(_ref) {
|
|
73
425
|
var _ref$steps = _ref.steps,
|
|
74
426
|
steps = _ref$steps === void 0 ? {} : _ref$steps;
|
|
@@ -308,47 +660,6 @@ var TWILIO_INTEGRATION_STEPS = [{
|
|
|
308
660
|
isCompleted: false
|
|
309
661
|
}];
|
|
310
662
|
|
|
311
|
-
function _typeof(obj) {
|
|
312
|
-
"@babel/helpers - typeof";
|
|
313
|
-
|
|
314
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
315
|
-
return typeof obj;
|
|
316
|
-
} : function (obj) {
|
|
317
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
318
|
-
}, _typeof(obj);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function _toPrimitive(input, hint) {
|
|
322
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
323
|
-
var prim = input[Symbol.toPrimitive];
|
|
324
|
-
if (prim !== undefined) {
|
|
325
|
-
var res = prim.call(input, hint || "default");
|
|
326
|
-
if (_typeof(res) !== "object") return res;
|
|
327
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
328
|
-
}
|
|
329
|
-
return (hint === "string" ? String : Number)(input);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function _toPropertyKey(arg) {
|
|
333
|
-
var key = _toPrimitive(arg, "string");
|
|
334
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function _defineProperty(obj, key, value) {
|
|
338
|
-
key = _toPropertyKey(key);
|
|
339
|
-
if (key in obj) {
|
|
340
|
-
Object.defineProperty(obj, key, {
|
|
341
|
-
value: value,
|
|
342
|
-
enumerable: true,
|
|
343
|
-
configurable: true,
|
|
344
|
-
writable: true
|
|
345
|
-
});
|
|
346
|
-
} else {
|
|
347
|
-
obj[key] = value;
|
|
348
|
-
}
|
|
349
|
-
return obj;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
663
|
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; }
|
|
353
664
|
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; }
|
|
354
665
|
var ConfigurationForm = function ConfigurationForm(_ref) {
|
|
@@ -422,8 +733,6 @@ function _toConsumableArray(arr) {
|
|
|
422
733
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
423
734
|
}
|
|
424
735
|
|
|
425
|
-
var TWILIO_CONFIGURATION_BASE_URL = "/neeto_integrations/twilio/sms_configurations";
|
|
426
|
-
|
|
427
736
|
var twilioApi = {
|
|
428
737
|
fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
|
|
429
738
|
return axios.get(TWILIO_CONFIGURATION_BASE_URL);
|
|
@@ -441,11 +750,6 @@ var twilioApi = {
|
|
|
441
750
|
}
|
|
442
751
|
};
|
|
443
752
|
|
|
444
|
-
var QUERY_KEYS = {
|
|
445
|
-
TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
|
|
446
|
-
TWILIO_PHONE_NUMBERS: "twilio-phone-numbers"
|
|
447
|
-
};
|
|
448
|
-
|
|
449
753
|
var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
|
|
450
754
|
return useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
|
|
451
755
|
select: function select(response) {
|
|
@@ -460,13 +764,15 @@ var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
|
|
|
460
764
|
});
|
|
461
765
|
};
|
|
462
766
|
var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
|
|
463
|
-
var
|
|
767
|
+
var _formRef$current, _formRef$current$valu, _formRef$current2, _formRef$current2$val;
|
|
768
|
+
var credentials = _ref.credentials,
|
|
769
|
+
formRef = _ref.formRef;
|
|
464
770
|
return useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
|
|
465
771
|
credentials: credentials
|
|
466
772
|
}], function () {
|
|
467
773
|
return twilioApi.getTwilioPhoneNumbers(keysToSnakeCase(credentials));
|
|
468
774
|
}, {
|
|
469
|
-
enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid),
|
|
775
|
+
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),
|
|
470
776
|
select: prop("phoneNumbers"),
|
|
471
777
|
retry: false
|
|
472
778
|
});
|
|
@@ -484,8 +790,10 @@ var useTwilio = function useTwilio(_ref) {
|
|
|
484
790
|
onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
|
|
485
791
|
_ref$setSteps = _ref.setSteps,
|
|
486
792
|
setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
|
|
487
|
-
_ref$
|
|
488
|
-
|
|
793
|
+
_ref$onConnect = _ref.onConnect,
|
|
794
|
+
onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
|
|
795
|
+
_ref$formRef = _ref.formRef,
|
|
796
|
+
formRef = _ref$formRef === void 0 ? null : _ref$formRef;
|
|
489
797
|
var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
|
|
490
798
|
configuration = _useFetchTwilioSmsCon.data,
|
|
491
799
|
isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
|
|
@@ -495,20 +803,14 @@ var useTwilio = function useTwilio(_ref) {
|
|
|
495
803
|
credentials = _useStateWithDependen2[0],
|
|
496
804
|
setCredentials = _useStateWithDependen2[1];
|
|
497
805
|
var _useFetchTwilioPhoneN = useFetchTwilioPhoneNumbers({
|
|
498
|
-
credentials: credentials
|
|
806
|
+
credentials: credentials,
|
|
807
|
+
formRef: formRef
|
|
499
808
|
}),
|
|
500
809
|
phoneNumbers = _useFetchTwilioPhoneN.data,
|
|
501
810
|
isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
|
|
502
811
|
var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
|
|
503
812
|
saveConfiguration = _useCreateTwilioConfi.mutate,
|
|
504
813
|
isSubmitting = _useCreateTwilioConfi.isLoading;
|
|
505
|
-
var _useConnect = useConnect(),
|
|
506
|
-
installIntegration = _useConnect.mutate;
|
|
507
|
-
var connectTwilioApp = function connectTwilioApp() {
|
|
508
|
-
return installIntegration({
|
|
509
|
-
id: "twilio"
|
|
510
|
-
}, {});
|
|
511
|
-
};
|
|
512
814
|
useEffect(function () {
|
|
513
815
|
if (!(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) return;
|
|
514
816
|
setSteps(function (steps) {
|
|
@@ -533,8 +835,8 @@ var useTwilio = function useTwilio(_ref) {
|
|
|
533
835
|
saveConfiguration(payload, {
|
|
534
836
|
onSuccess: function onSuccess() {
|
|
535
837
|
onSave();
|
|
536
|
-
connectTwilioApp();
|
|
537
838
|
refetchTwilioSmsConfiguration();
|
|
839
|
+
onConnect === null || onConnect === void 0 ? void 0 : onConnect();
|
|
538
840
|
}
|
|
539
841
|
});
|
|
540
842
|
};
|
|
@@ -568,17 +870,19 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
|
568
870
|
onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
|
|
569
871
|
_ref$setSteps = _ref.setSteps,
|
|
570
872
|
setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
|
|
571
|
-
_ref$
|
|
572
|
-
|
|
873
|
+
_ref$onConnect = _ref.onConnect,
|
|
874
|
+
onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
|
|
573
875
|
_ref$isModal = _ref.isModal,
|
|
574
876
|
isModal = _ref$isModal === void 0 ? false : _ref$isModal;
|
|
575
877
|
var _useTranslation = useTranslation(),
|
|
576
878
|
t = _useTranslation.t;
|
|
577
879
|
var initialFocusRef = useRef();
|
|
880
|
+
var formRef = useRef();
|
|
578
881
|
var _useTwilio = useTwilio({
|
|
579
882
|
onSave: onSave,
|
|
580
883
|
setSteps: setSteps,
|
|
581
|
-
|
|
884
|
+
onConnect: onConnect,
|
|
885
|
+
formRef: formRef
|
|
582
886
|
}),
|
|
583
887
|
handleSubmit = _useTwilio.handleSubmit,
|
|
584
888
|
phoneNumbers = _useTwilio.phoneNumbers,
|
|
@@ -619,7 +923,7 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
|
619
923
|
submitButtonProps: {
|
|
620
924
|
label: phoneNumberOptions ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
|
|
621
925
|
disabled: isSubmitDisabled(values),
|
|
622
|
-
loading: isSubmitting || isPhoneNumbersLoading && !configuration.twilioAuthToken
|
|
926
|
+
loading: isSubmitting || isPhoneNumbersLoading && !(configuration !== null && configuration !== void 0 && configuration.twilioAuthToken)
|
|
623
927
|
}
|
|
624
928
|
});
|
|
625
929
|
};
|
|
@@ -632,12 +936,13 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
|
632
936
|
selectedPhoneNumber: selectedPhoneNumber
|
|
633
937
|
});
|
|
634
938
|
};
|
|
635
|
-
return /*#__PURE__*/React.createElement(Form, {
|
|
939
|
+
return /*#__PURE__*/React.createElement(Form$2, {
|
|
636
940
|
className: "mx-auto flex w-full max-w-md flex-col",
|
|
637
941
|
formikProps: {
|
|
638
942
|
enableReinitialize: true,
|
|
639
943
|
validationSchema: buildTwilioConfigurationValidationSchema(!!phoneNumbers),
|
|
640
944
|
initialValues: configuration,
|
|
945
|
+
innerRef: formRef,
|
|
641
946
|
onSubmit: handleSubmit
|
|
642
947
|
}
|
|
643
948
|
}, function (formikProps) {
|
|
@@ -650,8 +955,8 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
|
650
955
|
var Twilio = function Twilio(_ref) {
|
|
651
956
|
var _ref$onClose = _ref.onClose,
|
|
652
957
|
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
653
|
-
_ref$
|
|
654
|
-
|
|
958
|
+
_ref$onConnect = _ref.onConnect,
|
|
959
|
+
onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect;
|
|
655
960
|
var _useState = useState(TWILIO_INTEGRATION_STEPS),
|
|
656
961
|
_useState2 = _slicedToArray(_useState, 2),
|
|
657
962
|
steps = _useState2[0],
|
|
@@ -663,8 +968,8 @@ var Twilio = function Twilio(_ref) {
|
|
|
663
968
|
}, /*#__PURE__*/React.createElement(TwilioConfiguration, {
|
|
664
969
|
isModal: true,
|
|
665
970
|
setSteps: setSteps,
|
|
666
|
-
|
|
667
|
-
|
|
971
|
+
onCancel: onClose,
|
|
972
|
+
onConnect: onConnect
|
|
668
973
|
}));
|
|
669
974
|
};
|
|
670
975
|
|