@bigbinary/neeto-integrations-frontend 2.4.0 → 2.5.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.
- package/dist/Twilio.cjs.js +254 -94
- package/dist/Twilio.cjs.js.map +1 -1
- package/dist/Twilio.js +244 -84
- package/dist/Twilio.js.map +1 -1
- package/dist/ZapierForm.cjs.js +10 -10
- package/dist/ZapierForm.cjs.js.map +1 -1
- package/dist/ZapierForm.js +1 -1
- package/dist/ZapierForm.js.map +1 -1
- package/dist/index.cjs.js +468 -742
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +462 -748
- package/dist/index.js.map +1 -1
- package/package.json +7 -4
package/dist/index.js
CHANGED
|
@@ -1,306 +1,468 @@
|
|
|
1
|
+
export { default as Card } from '@bigbinary/neeto-molecules/IntegrationCard';
|
|
2
|
+
export { default as DisconnectAlert } from '@bigbinary/neeto-molecules/IntegrationDisconnectAlert';
|
|
3
|
+
export { default as WalkthroughModal } from '@bigbinary/neeto-molecules/IntegrationWalkthroughModal';
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
import React__default, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import { noop, isNotEmpty, keysToSnakeCase, _findBy } from '@bigbinary/neeto-commons-frontend/pure';
|
|
5
|
-
import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
|
|
6
|
-
import { Dropdown as Dropdown$1, Tag, Tooltip, Typography, Spinner, Button, Alert, Modal as Modal$1 } from '@bigbinary/neetoui';
|
|
7
|
-
import { isNotNil, isEmpty, prop, equals } from 'ramda';
|
|
8
|
-
import { useTranslation } from 'react-i18next';
|
|
9
|
-
import { MenuVertical, Warning, Check } from '@bigbinary/neeto-icons';
|
|
6
|
+
import { keysToSnakeCase, noop, _findBy, isNotEmpty } from '@bigbinary/neeto-cist';
|
|
10
7
|
import i18next from 'i18next';
|
|
8
|
+
import { Modal as Modal$1, Typography, Button } from '@bigbinary/neetoui';
|
|
11
9
|
import { Input, Select, Form, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { prop, equals, isEmpty } from 'ramda';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { useMutationWithInvalidation, useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
13
|
+
import { useQuery } from 'react-query';
|
|
15
14
|
import axios from 'axios';
|
|
16
15
|
import * as yup from 'yup';
|
|
16
|
+
import classnames from 'classnames';
|
|
17
17
|
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
function _arrayWithHoles(arr) {
|
|
19
|
+
if (Array.isArray(arr)) return arr;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _iterableToArrayLimit(arr, i) {
|
|
23
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24
|
+
if (null != _i) {
|
|
25
|
+
var _s,
|
|
26
|
+
_e,
|
|
27
|
+
_x,
|
|
28
|
+
_r,
|
|
29
|
+
_arr = [],
|
|
30
|
+
_n = !0,
|
|
31
|
+
_d = !1;
|
|
32
|
+
try {
|
|
33
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
34
|
+
if (Object(_i) !== _i) return;
|
|
35
|
+
_n = !1;
|
|
36
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
_d = !0, _e = err;
|
|
39
|
+
} finally {
|
|
40
|
+
try {
|
|
41
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
42
|
+
} finally {
|
|
43
|
+
if (_d) throw _e;
|
|
26
44
|
}
|
|
27
45
|
}
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
return _extends$1.apply(this, arguments);
|
|
46
|
+
return _arr;
|
|
47
|
+
}
|
|
31
48
|
}
|
|
32
49
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
function _arrayLikeToArray(arr, len) {
|
|
51
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
52
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
53
|
+
return arr2;
|
|
54
|
+
}
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
hideDisconnect = _ref$hideDisconnect === void 0 ? false : _ref$hideDisconnect,
|
|
46
|
-
_ref$onDisconnect = _ref.onDisconnect,
|
|
47
|
-
onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect;
|
|
48
|
-
var _useTranslation = useTranslation(),
|
|
49
|
-
t = _useTranslation.t;
|
|
50
|
-
var isManageable = isNotNil(handleManage);
|
|
51
|
-
if (isNotNil(CustomDropdown)) {
|
|
52
|
-
return CustomDropdown;
|
|
53
|
-
}
|
|
54
|
-
if (!isManageable && hideDisconnect) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/React__default.createElement(Dropdown$1, {
|
|
58
|
-
buttonProps: {
|
|
59
|
-
onClick: function onClick(e) {
|
|
60
|
-
return e.stopPropagation();
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
buttonStyle: "text",
|
|
64
|
-
dropdownProps: {
|
|
65
|
-
onClick: function onClick(e) {
|
|
66
|
-
return e.stopPropagation();
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
icon: MenuVertical
|
|
70
|
-
}, /*#__PURE__*/React__default.createElement(Menu, null, isManageable && /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
71
|
-
onClick: function onClick() {
|
|
72
|
-
return handleManage();
|
|
73
|
-
}
|
|
74
|
-
}, t("neetoIntegrations.common.manage")), !hideDisconnect && /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
75
|
-
onClick: function onClick() {
|
|
76
|
-
return onDisconnect();
|
|
77
|
-
}
|
|
78
|
-
}, t("neetoIntegrations.common.disconnect"))));
|
|
79
|
-
};
|
|
56
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
57
|
+
if (!o) return;
|
|
58
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
59
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
60
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
61
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
62
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
63
|
+
}
|
|
80
64
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
t = _useTranslation.t;
|
|
85
|
-
var tagProps = isExpired ? {
|
|
86
|
-
icon: Warning,
|
|
87
|
-
label: t("neetoIntegrations.tags.expired"),
|
|
88
|
-
style: "warning"
|
|
89
|
-
} : {
|
|
90
|
-
icon: Check,
|
|
91
|
-
label: t("neetoIntegrations.tags.connected"),
|
|
92
|
-
style: "success"
|
|
93
|
-
};
|
|
94
|
-
return /*#__PURE__*/React__default.createElement(Tag, _extends$1({
|
|
95
|
-
className: "flex-row-reverse"
|
|
96
|
-
}, tagProps));
|
|
97
|
-
};
|
|
65
|
+
function _nonIterableRest() {
|
|
66
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
67
|
+
}
|
|
98
68
|
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
var target = {};
|
|
102
|
-
var sourceKeys = Object.keys(source);
|
|
103
|
-
var key, i;
|
|
104
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
105
|
-
key = sourceKeys[i];
|
|
106
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
107
|
-
target[key] = source[key];
|
|
108
|
-
}
|
|
109
|
-
return target;
|
|
69
|
+
function _slicedToArray(arr, i) {
|
|
70
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
110
71
|
}
|
|
111
72
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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);
|
|
88
|
+
}
|
|
89
|
+
|
|
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.");
|
|
124
97
|
}
|
|
125
|
-
return
|
|
98
|
+
return (hint === "string" ? String : Number)(input);
|
|
126
99
|
}
|
|
127
100
|
|
|
128
|
-
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
tooltipProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
133
|
-
return disabled ? /*#__PURE__*/React__default.createElement(Tooltip, tooltipProps, children) : children;
|
|
134
|
-
};
|
|
101
|
+
function _toPropertyKey(arg) {
|
|
102
|
+
var key = _toPrimitive(arg, "string");
|
|
103
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
104
|
+
}
|
|
135
105
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
_ref$
|
|
157
|
-
|
|
158
|
-
_ref$
|
|
159
|
-
|
|
160
|
-
_ref$
|
|
161
|
-
|
|
162
|
-
_ref$
|
|
163
|
-
|
|
164
|
-
_ref$hideDisconnect = _ref.hideDisconnect,
|
|
165
|
-
hideDisconnect = _ref$hideDisconnect === void 0 ? false : _ref$hideDisconnect,
|
|
166
|
-
_ref$onClick = _ref.onClick,
|
|
167
|
-
onCardClick = _ref$onClick === void 0 ? undefined : _ref$onClick,
|
|
168
|
-
_ref$tooltipProps = _ref.tooltipProps,
|
|
169
|
-
tooltipProps = _ref$tooltipProps === void 0 ? {} : _ref$tooltipProps,
|
|
170
|
-
_ref$customDropDown = _ref.customDropDown,
|
|
171
|
-
customDropDown = _ref$customDropDown === void 0 ? null : _ref$customDropDown,
|
|
172
|
-
children = _ref.children;
|
|
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
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
obj[key] = value;
|
|
117
|
+
}
|
|
118
|
+
return obj;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
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
|
+
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; }
|
|
123
|
+
var ConfigurationForm = function ConfigurationForm(_ref) {
|
|
124
|
+
var _errors$twilioPhoneNu;
|
|
125
|
+
var phoneNumberOptions = _ref.phoneNumberOptions,
|
|
126
|
+
_ref$selectedPhoneNum = _ref.selectedPhoneNumber,
|
|
127
|
+
selectedPhoneNumber = _ref$selectedPhoneNum === void 0 ? null : _ref$selectedPhoneNum,
|
|
128
|
+
_ref$initialFocusRef = _ref.initialFocusRef,
|
|
129
|
+
initialFocusRef = _ref$initialFocusRef === void 0 ? null : _ref$initialFocusRef,
|
|
130
|
+
_ref$isUsingOverlay = _ref.isUsingOverlay,
|
|
131
|
+
isUsingOverlay = _ref$isUsingOverlay === void 0 ? false : _ref$isUsingOverlay,
|
|
132
|
+
_ref$formikProps = _ref.formikProps,
|
|
133
|
+
formikProps = _ref$formikProps === void 0 ? {} : _ref$formikProps;
|
|
173
134
|
var _useTranslation = useTranslation(),
|
|
174
135
|
t = _useTranslation.t;
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
className: classnames("outline-none neeto-ui-border-gray-300 neeto-ui-shadow-xs hover:neeto-ui-border-gray-500 focus:neeto-ui-border-gray-500 neeto-ui-rounded-lg flex flex-col border p-6 no-underline transition-colors", {
|
|
186
|
-
"hover:neeto-ui-bg-100 cursor-not-allowed opacity-50": disabled,
|
|
187
|
-
"cursor-pointer": isConnected && isNotNil(onCardClick),
|
|
188
|
-
hidden: hidden
|
|
189
|
-
}, className)
|
|
190
|
-
}, cardProps()), /*#__PURE__*/React__default.createElement("div", {
|
|
191
|
-
className: "flex flex-grow justify-between",
|
|
192
|
-
"data-cy": "integration-tabs"
|
|
193
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
194
|
-
className: "flex min-w-0 flex-col justify-end"
|
|
136
|
+
var setFieldValue = formikProps.setFieldValue,
|
|
137
|
+
setValues = formikProps.setValues,
|
|
138
|
+
errors = formikProps.errors,
|
|
139
|
+
values = formikProps.values,
|
|
140
|
+
initialValues = formikProps.initialValues;
|
|
141
|
+
useEffect(function () {
|
|
142
|
+
selectedPhoneNumber && setFieldValue("twilioPhoneNumber", selectedPhoneNumber);
|
|
143
|
+
}, [selectedPhoneNumber, initialValues]);
|
|
144
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
145
|
+
className: "flex w-full flex-col gap-4"
|
|
195
146
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
196
|
-
className: "
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
|
|
147
|
+
className: "flex w-full"
|
|
148
|
+
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
149
|
+
required: true,
|
|
150
|
+
autoFocus: !isUsingOverlay,
|
|
151
|
+
"data-testid": "integrations-twilio-sid",
|
|
152
|
+
label: t("neetoIntegrations.twilio.sid"),
|
|
153
|
+
name: "twilioSid",
|
|
154
|
+
ref: initialFocusRef
|
|
200
155
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
201
|
-
className: "
|
|
202
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
203
|
-
|
|
204
|
-
"data-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
className: "
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
156
|
+
className: "flex w-full"
|
|
157
|
+
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
158
|
+
required: true,
|
|
159
|
+
"data-testid": "integrations-twilio-auth-token",
|
|
160
|
+
label: t("neetoIntegrations.twilio.authToken"),
|
|
161
|
+
name: "twilioAuthToken"
|
|
162
|
+
})), phoneNumberOptions && /*#__PURE__*/React__default.createElement("div", {
|
|
163
|
+
className: "flex w-full"
|
|
164
|
+
}, /*#__PURE__*/React__default.createElement(Select, {
|
|
165
|
+
error: (_errors$twilioPhoneNu = errors.twilioPhoneNumber) === null || _errors$twilioPhoneNu === void 0 ? void 0 : _errors$twilioPhoneNu.value,
|
|
166
|
+
label: t("neetoIntegrations.common.phNo"),
|
|
167
|
+
name: "twilioPhoneNumber",
|
|
168
|
+
options: phoneNumberOptions,
|
|
169
|
+
size: "large",
|
|
170
|
+
onChange: function onChange(selected) {
|
|
171
|
+
return setValues(_objectSpread$2(_objectSpread$2({}, values), {}, {
|
|
172
|
+
twilioPhoneNumber: selected
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
})));
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
function _arrayWithoutHoles(arr) {
|
|
179
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function _iterableToArray(iter) {
|
|
183
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function _nonIterableSpread() {
|
|
187
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function _toConsumableArray(arr) {
|
|
191
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var TWILIO_CONFIGURATION_BASE_URL = "/neeto_integrations/twilio/sms_configurations";
|
|
195
|
+
|
|
196
|
+
var twilioApi = {
|
|
197
|
+
fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
|
|
198
|
+
return axios.get(TWILIO_CONFIGURATION_BASE_URL);
|
|
199
|
+
},
|
|
200
|
+
removeTwilioConfiguration: function removeTwilioConfiguration() {
|
|
201
|
+
return axios["delete"](TWILIO_CONFIGURATION_BASE_URL);
|
|
202
|
+
},
|
|
203
|
+
getTwilioPhoneNumbers: function getTwilioPhoneNumbers(data) {
|
|
204
|
+
return axios.get("".concat(TWILIO_CONFIGURATION_BASE_URL, "/new"), {
|
|
205
|
+
params: data
|
|
218
206
|
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}, /*#__PURE__*/React__default.createElement(Spinner, null)) : /*#__PURE__*/React__default.createElement("div", {
|
|
224
|
-
className: "flex h-8 items-center justify-between"
|
|
225
|
-
}, isConnected && /*#__PURE__*/React__default.createElement(Status, {
|
|
226
|
-
isExpired: isExpired
|
|
227
|
-
}), isFailed && /*#__PURE__*/React__default.createElement(Button, {
|
|
228
|
-
className: "neeto-ui-text-warning-500",
|
|
229
|
-
"data-cy": renderDataCy(label, "connect-button"),
|
|
230
|
-
disabled: disabled || isLoading,
|
|
231
|
-
label: t("neetoIntegrations.common.tryAgain"),
|
|
232
|
-
style: "link",
|
|
233
|
-
onClick: onConnect
|
|
234
|
-
}), !isConnected && !isFailed && /*#__PURE__*/React__default.createElement(Button, {
|
|
235
|
-
"data-cy": renderDataCy(label, "connect-button"),
|
|
236
|
-
disabled: disabled || isLoading,
|
|
237
|
-
label: t("neetoIntegrations.common.connect"),
|
|
238
|
-
style: "link",
|
|
239
|
-
onClick: onConnect
|
|
240
|
-
}), (isConnected || isFailed) && /*#__PURE__*/React__default.createElement(Dropdown, {
|
|
241
|
-
customDropDown: customDropDown,
|
|
242
|
-
handleManage: onManage,
|
|
243
|
-
hideDisconnect: hideDisconnect,
|
|
244
|
-
onDisconnect: onDisconnect
|
|
245
|
-
})))));
|
|
207
|
+
},
|
|
208
|
+
createTwilioConfiguration: function createTwilioConfiguration(payload) {
|
|
209
|
+
return axios.post(TWILIO_CONFIGURATION_BASE_URL, payload);
|
|
210
|
+
}
|
|
246
211
|
};
|
|
247
212
|
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
252
|
-
_ref$isDisconnecting = _ref.isDisconnecting,
|
|
253
|
-
isDisconnecting = _ref$isDisconnecting === void 0 ? false : _ref$isDisconnecting,
|
|
254
|
-
_ref$title = _ref.title,
|
|
255
|
-
title = _ref$title === void 0 ? "" : _ref$title,
|
|
256
|
-
_ref$message = _ref.message,
|
|
257
|
-
message = _ref$message === void 0 ? "" : _ref$message,
|
|
258
|
-
_ref$onClose = _ref.onClose,
|
|
259
|
-
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
260
|
-
_ref$onDisconnect = _ref.onDisconnect,
|
|
261
|
-
onDisconnect = _ref$onDisconnect === void 0 ? noop : _ref$onDisconnect,
|
|
262
|
-
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
263
|
-
var _useTranslation = useTranslation(),
|
|
264
|
-
t = _useTranslation.t;
|
|
265
|
-
return /*#__PURE__*/React__default.createElement(Alert, _extends$1({
|
|
266
|
-
closeOnEsc: true,
|
|
267
|
-
closeOnOutsideClick: true,
|
|
268
|
-
isOpen: isOpen,
|
|
269
|
-
isSubmitting: isDisconnecting,
|
|
270
|
-
message: message,
|
|
271
|
-
submitButtonLabel: t("neetoIntegrations.common.disconnect"),
|
|
272
|
-
title: title,
|
|
273
|
-
onClose: onClose,
|
|
274
|
-
onSubmit: onDisconnect
|
|
275
|
-
}, otherProps));
|
|
213
|
+
var QUERY_KEYS = {
|
|
214
|
+
TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
|
|
215
|
+
TWILIO_PHONE_NUMBERS: "twilio-phone-numbers"
|
|
276
216
|
};
|
|
277
217
|
|
|
278
|
-
var
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
218
|
+
var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
|
|
219
|
+
return useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
|
|
220
|
+
select: function select(response) {
|
|
221
|
+
var _smsConfiguration$twi, _smsConfiguration$twi2, _smsConfiguration$twi3;
|
|
222
|
+
var smsConfiguration = response.smsConfiguration;
|
|
223
|
+
return {
|
|
224
|
+
twilioSid: (_smsConfiguration$twi = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioSid) !== null && _smsConfiguration$twi !== void 0 ? _smsConfiguration$twi : "",
|
|
225
|
+
twilioAuthToken: (_smsConfiguration$twi2 = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioAuthToken) !== null && _smsConfiguration$twi2 !== void 0 ? _smsConfiguration$twi2 : "",
|
|
226
|
+
twilioPhoneNumber: (_smsConfiguration$twi3 = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioPhoneNumber) !== null && _smsConfiguration$twi3 !== void 0 ? _smsConfiguration$twi3 : ""
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
|
|
232
|
+
var credentials = _ref.credentials;
|
|
233
|
+
return useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
|
|
234
|
+
credentials: credentials
|
|
235
|
+
}], function () {
|
|
236
|
+
return twilioApi.getTwilioPhoneNumbers(keysToSnakeCase(credentials));
|
|
237
|
+
}, {
|
|
238
|
+
enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid),
|
|
239
|
+
select: prop("phoneNumbers"),
|
|
240
|
+
retry: false
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
var useCreateTwilioConfiguration = function useCreateTwilioConfiguration() {
|
|
244
|
+
return useMutationWithInvalidation(twilioApi.createTwilioConfiguration, {
|
|
245
|
+
keysToInvalidate: [QUERY_KEYS.TWILIO_SMS_CONFIGURATION]
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
function ownKeys$1(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; }
|
|
250
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
251
|
+
var useTwilio = function useTwilio(_ref) {
|
|
252
|
+
var _ref$onSave = _ref.onSave,
|
|
253
|
+
onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
|
|
254
|
+
_ref$setSteps = _ref.setSteps,
|
|
255
|
+
setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
|
|
256
|
+
_ref$useConnect = _ref.useConnect,
|
|
257
|
+
useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect;
|
|
258
|
+
var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
|
|
259
|
+
configuration = _useFetchTwilioSmsCon.data,
|
|
260
|
+
isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
|
|
261
|
+
refetchTwilioSmsConfiguration = _useFetchTwilioSmsCon.refetch;
|
|
262
|
+
var _useStateWithDependen = useStateWithDependency(configuration),
|
|
263
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
264
|
+
credentials = _useStateWithDependen2[0],
|
|
265
|
+
setCredentials = _useStateWithDependen2[1];
|
|
266
|
+
var _useFetchTwilioPhoneN = useFetchTwilioPhoneNumbers({
|
|
267
|
+
credentials: credentials
|
|
268
|
+
}),
|
|
269
|
+
phoneNumbers = _useFetchTwilioPhoneN.data,
|
|
270
|
+
isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
|
|
271
|
+
var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
|
|
272
|
+
saveConfiguration = _useCreateTwilioConfi.mutate,
|
|
273
|
+
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
|
+
useEffect(function () {
|
|
282
|
+
if (!(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) return;
|
|
283
|
+
setSteps(function (steps) {
|
|
284
|
+
var stepsClone = _toConsumableArray(steps);
|
|
285
|
+
stepsClone[0] = _objectSpread$1(_objectSpread$1({}, steps[0]), {}, {
|
|
286
|
+
isCompleted: true
|
|
287
|
+
});
|
|
288
|
+
return stepsClone;
|
|
289
|
+
});
|
|
290
|
+
}, [configuration]);
|
|
291
|
+
var handleSubmit = function handleSubmit(values) {
|
|
292
|
+
var _values$twilioPhoneNu;
|
|
293
|
+
var payload = {
|
|
294
|
+
twilio_sid: values.twilioSid,
|
|
295
|
+
twilio_auth_token: values.twilioAuthToken,
|
|
296
|
+
twilio_phone_number_sid: (_values$twilioPhoneNu = values.twilioPhoneNumber) === null || _values$twilioPhoneNu === void 0 ? void 0 : _values$twilioPhoneNu.value
|
|
297
|
+
};
|
|
298
|
+
if (!phoneNumbers && !(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) {
|
|
299
|
+
setCredentials(payload);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
saveConfiguration(payload, {
|
|
303
|
+
onSuccess: function onSuccess() {
|
|
304
|
+
onSave();
|
|
305
|
+
connectTwilioApp();
|
|
306
|
+
refetchTwilioSmsConfiguration();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
return {
|
|
311
|
+
handleSubmit: handleSubmit,
|
|
312
|
+
phoneNumbers: phoneNumbers,
|
|
313
|
+
isConfigurationLoading: isConfigurationLoading,
|
|
314
|
+
isPhoneNumbersLoading: isPhoneNumbersLoading,
|
|
315
|
+
isSubmitting: isSubmitting,
|
|
316
|
+
configuration: configuration
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
var buildTwilioConfigurationValidationSchema = function buildTwilioConfigurationValidationSchema(isTwilioPhoneRequired) {
|
|
321
|
+
return yup.object().shape({
|
|
322
|
+
twilioSid: yup.string().required(i18next.t("neetoIntegrations.twilio.validations.sidReq")),
|
|
323
|
+
twilioAuthToken: yup.string().required(i18next.t("neetoIntegrations.twilio.validations.authTokenReq")),
|
|
324
|
+
twilioPhoneNumber: isTwilioPhoneRequired ? yup.object().shape({
|
|
325
|
+
label: yup.string(),
|
|
326
|
+
value: yup.string().required(i18next.t("neetoIntegrations.twilio.validations.phNumReq"))
|
|
327
|
+
}) : null
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
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; }
|
|
332
|
+
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; }
|
|
333
|
+
var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
334
|
+
var _ref$onCancel = _ref.onCancel,
|
|
335
|
+
onCancel = _ref$onCancel === void 0 ? noop : _ref$onCancel,
|
|
336
|
+
_ref$onSave = _ref.onSave,
|
|
337
|
+
onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
|
|
338
|
+
_ref$setSteps = _ref.setSteps,
|
|
339
|
+
setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
|
|
340
|
+
_ref$useConnect = _ref.useConnect,
|
|
341
|
+
useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect,
|
|
342
|
+
_ref$isModal = _ref.isModal,
|
|
343
|
+
isModal = _ref$isModal === void 0 ? false : _ref$isModal;
|
|
344
|
+
var _useTranslation = useTranslation(),
|
|
345
|
+
t = _useTranslation.t;
|
|
346
|
+
var initialFocusRef = useRef();
|
|
347
|
+
var _useTwilio = useTwilio({
|
|
348
|
+
onSave: onSave,
|
|
349
|
+
setSteps: setSteps,
|
|
350
|
+
useConnect: useConnect
|
|
351
|
+
}),
|
|
352
|
+
handleSubmit = _useTwilio.handleSubmit,
|
|
353
|
+
phoneNumbers = _useTwilio.phoneNumbers,
|
|
354
|
+
isConfigurationLoading = _useTwilio.isConfigurationLoading,
|
|
355
|
+
isPhoneNumbersLoading = _useTwilio.isPhoneNumbersLoading,
|
|
356
|
+
isSubmitting = _useTwilio.isSubmitting,
|
|
357
|
+
configuration = _useTwilio.configuration;
|
|
358
|
+
var phoneNumberOptions = phoneNumbers === null || phoneNumbers === void 0 ? void 0 : phoneNumbers.map(function (_ref2) {
|
|
359
|
+
var phoneNumber = _ref2.phoneNumber,
|
|
360
|
+
sid = _ref2.sid;
|
|
361
|
+
return {
|
|
362
|
+
label: phoneNumber,
|
|
363
|
+
value: sid
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
var selectedPhoneNumber = _findBy({
|
|
367
|
+
label: configuration === null || configuration === void 0 ? void 0 : configuration.twilioPhoneNumber
|
|
368
|
+
}, phoneNumberOptions);
|
|
369
|
+
var wrapInModalBody = function wrapInModalBody(children) {
|
|
370
|
+
return /*#__PURE__*/React__default.createElement(Modal$1.Body, null, children);
|
|
371
|
+
};
|
|
372
|
+
var wrapInModalFooter = function wrapInModalFooter(children) {
|
|
373
|
+
return /*#__PURE__*/React__default.createElement(Modal$1.Footer, null, children);
|
|
374
|
+
};
|
|
375
|
+
var isLoading = isPhoneNumbersLoading || isConfigurationLoading;
|
|
376
|
+
var isSubmitDisabled = function isSubmitDisabled(values) {
|
|
377
|
+
return equals(_objectSpread(_objectSpread({}, configuration), {}, {
|
|
378
|
+
twilioPhoneNumber: selectedPhoneNumber
|
|
379
|
+
}), values) || isLoading;
|
|
380
|
+
};
|
|
381
|
+
var renderActionBlock = function renderActionBlock(values) {
|
|
382
|
+
return /*#__PURE__*/React__default.createElement(ActionBlock, {
|
|
383
|
+
cancelButtonProps: {
|
|
384
|
+
onClick: onCancel,
|
|
385
|
+
disabled: false
|
|
386
|
+
},
|
|
387
|
+
className: "space-x-3",
|
|
388
|
+
submitButtonProps: {
|
|
389
|
+
label: phoneNumberOptions ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
|
|
390
|
+
disabled: isSubmitDisabled(values),
|
|
391
|
+
loading: isSubmitting || isPhoneNumbersLoading && !configuration.twilioAuthToken
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
var renderForm = function renderForm(formikProps) {
|
|
396
|
+
return /*#__PURE__*/React__default.createElement(ConfigurationForm, {
|
|
397
|
+
formikProps: formikProps,
|
|
398
|
+
initialFocusRef: initialFocusRef,
|
|
399
|
+
isUsingOverlay: isModal,
|
|
400
|
+
phoneNumberOptions: phoneNumberOptions,
|
|
401
|
+
selectedPhoneNumber: selectedPhoneNumber
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
return /*#__PURE__*/React__default.createElement(Form, {
|
|
405
|
+
className: "mx-auto flex w-full max-w-md flex-col",
|
|
406
|
+
formikProps: {
|
|
407
|
+
enableReinitialize: true,
|
|
408
|
+
validationSchema: buildTwilioConfigurationValidationSchema(!!phoneNumbers),
|
|
409
|
+
initialValues: configuration,
|
|
410
|
+
onSubmit: handleSubmit
|
|
411
|
+
}
|
|
412
|
+
}, function (formikProps) {
|
|
413
|
+
return isModal ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, wrapInModalBody(renderForm(formikProps)), wrapInModalFooter(renderActionBlock(formikProps.values))) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "renderForm(formikProps)", /*#__PURE__*/React__default.createElement("div", {
|
|
414
|
+
className: "mt-4 flex items-center gap-x-2"
|
|
415
|
+
}, renderActionBlock(formikProps.values)));
|
|
416
|
+
});
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
var Twilio = function Twilio(_ref) {
|
|
420
|
+
var _ref$onClose = _ref.onClose,
|
|
421
|
+
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
422
|
+
_ref$useConnect = _ref.useConnect,
|
|
423
|
+
useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect;
|
|
424
|
+
var _useState = useState(TWILIO_INTEGRATION_STEPS),
|
|
425
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
426
|
+
steps = _useState2[0],
|
|
427
|
+
setSteps = _useState2[1];
|
|
428
|
+
return /*#__PURE__*/React__default.createElement(Modal, {
|
|
429
|
+
isOpen: true,
|
|
430
|
+
steps: steps,
|
|
431
|
+
onClose: onClose
|
|
432
|
+
}, /*#__PURE__*/React__default.createElement(TwilioConfiguration, {
|
|
433
|
+
isModal: true,
|
|
434
|
+
setSteps: setSteps,
|
|
435
|
+
useConnect: useConnect,
|
|
436
|
+
onCancel: onClose
|
|
437
|
+
}));
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
var Stepper = function Stepper(_ref) {
|
|
441
|
+
var _ref$steps = _ref.steps,
|
|
442
|
+
steps = _ref$steps === void 0 ? {} : _ref$steps;
|
|
443
|
+
var isActiveOrCompleted = function isActiveOrCompleted(activeStatus, completedStatus) {
|
|
444
|
+
return activeStatus || completedStatus;
|
|
445
|
+
};
|
|
446
|
+
return /*#__PURE__*/React__default.createElement("ul", {
|
|
447
|
+
className: "flex gap-4"
|
|
448
|
+
}, steps === null || steps === void 0 ? void 0 : steps.map(function (_ref2) {
|
|
449
|
+
var step = _ref2.step,
|
|
450
|
+
label = _ref2.label,
|
|
451
|
+
isActive = _ref2.isActive,
|
|
452
|
+
isCompleted = _ref2.isCompleted;
|
|
453
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
454
|
+
className: "flex items-center gap-4",
|
|
455
|
+
key: step
|
|
456
|
+
}, step !== "1" && /*#__PURE__*/React__default.createElement("div", {
|
|
457
|
+
className: classnames("w-10 border-b", {
|
|
458
|
+
"neeto-ui-border-gray-800": isActiveOrCompleted(isActive, isCompleted),
|
|
459
|
+
"neeto-ui-border-gray-400": !isActiveOrCompleted(isActive, isCompleted)
|
|
460
|
+
})
|
|
461
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
462
|
+
className: "flex items-center gap-2"
|
|
463
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
464
|
+
className: classnames("neeto-ui-rounded-full neeto-ui-gray-600 flex h-6 w-6 items-center justify-center border", {
|
|
465
|
+
"neeto-ui-bg-success-600 neeto-ui-border-success-600 neeto-ui-text-white": isActive,
|
|
304
466
|
"neeto-ui-bg-primary-600 neeto-ui-border-primary-600 neeto-ui-text-white": isCompleted,
|
|
305
467
|
"neeto-ui-border-gray-400": !isActiveOrCompleted(isActive, isCompleted)
|
|
306
468
|
})
|
|
@@ -341,16 +503,31 @@ var Modal = function Modal(_ref) {
|
|
|
341
503
|
}, children)));
|
|
342
504
|
};
|
|
343
505
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
+
var propTypes = {exports: {}};
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
525
|
+
*
|
|
526
|
+
* This source code is licensed under the MIT license found in the
|
|
527
|
+
* LICENSE file in the root directory of this source tree.
|
|
528
|
+
*/
|
|
529
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
530
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
354
531
|
|
|
355
532
|
/**
|
|
356
533
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -626,469 +803,6 @@ Finish.prototypes = {
|
|
|
626
803
|
secondaryButtonProps: propTypes.exports.object
|
|
627
804
|
};
|
|
628
805
|
|
|
629
|
-
var WalkthroughModal = function WalkthroughModal(_ref) {
|
|
630
|
-
var _ref$isOpen = _ref.isOpen,
|
|
631
|
-
isOpen = _ref$isOpen === void 0 ? noop : _ref$isOpen,
|
|
632
|
-
_ref$onClose = _ref.onClose,
|
|
633
|
-
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
634
|
-
_ref$videoUrl = _ref.videoUrl,
|
|
635
|
-
videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
|
|
636
|
-
children = _ref.children;
|
|
637
|
-
var _useTranslation = useTranslation(),
|
|
638
|
-
t = _useTranslation.t;
|
|
639
|
-
return /*#__PURE__*/React__default.createElement(Modal$1, {
|
|
640
|
-
isOpen: isOpen,
|
|
641
|
-
size: "large",
|
|
642
|
-
onClose: onClose
|
|
643
|
-
}, /*#__PURE__*/React__default.createElement(Modal$1.Header, null, /*#__PURE__*/React__default.createElement(Typography, {
|
|
644
|
-
style: "h2",
|
|
645
|
-
weight: "semibold"
|
|
646
|
-
}, t("neetoIntegrations.walkthroughModal.header"))), /*#__PURE__*/React__default.createElement(Modal$1.Body, null, /*#__PURE__*/React__default.createElement("div", {
|
|
647
|
-
className: "w-full py-10"
|
|
648
|
-
}, /*#__PURE__*/React__default.createElement("video", {
|
|
649
|
-
autoPlay: true,
|
|
650
|
-
controls: true,
|
|
651
|
-
muted: true,
|
|
652
|
-
className: "cursor-pointer",
|
|
653
|
-
id: "walkthrough-video"
|
|
654
|
-
}, /*#__PURE__*/React__default.createElement("source", {
|
|
655
|
-
src: videoUrl
|
|
656
|
-
})), children)), /*#__PURE__*/React__default.createElement(Modal$1.Footer, null, /*#__PURE__*/React__default.createElement(Button, {
|
|
657
|
-
label: t("neetoIntegrations.walkthroughModal.continue"),
|
|
658
|
-
onClick: onClose
|
|
659
|
-
})));
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
function _arrayWithHoles(arr) {
|
|
663
|
-
if (Array.isArray(arr)) return arr;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
function _iterableToArrayLimit(arr, i) {
|
|
667
|
-
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
668
|
-
if (null != _i) {
|
|
669
|
-
var _s,
|
|
670
|
-
_e,
|
|
671
|
-
_x,
|
|
672
|
-
_r,
|
|
673
|
-
_arr = [],
|
|
674
|
-
_n = !0,
|
|
675
|
-
_d = !1;
|
|
676
|
-
try {
|
|
677
|
-
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
678
|
-
if (Object(_i) !== _i) return;
|
|
679
|
-
_n = !1;
|
|
680
|
-
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
681
|
-
} catch (err) {
|
|
682
|
-
_d = !0, _e = err;
|
|
683
|
-
} finally {
|
|
684
|
-
try {
|
|
685
|
-
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
686
|
-
} finally {
|
|
687
|
-
if (_d) throw _e;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
return _arr;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
function _arrayLikeToArray(arr, len) {
|
|
695
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
696
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
697
|
-
return arr2;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
701
|
-
if (!o) return;
|
|
702
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
703
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
704
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
705
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
706
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
function _nonIterableRest() {
|
|
710
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
function _slicedToArray(arr, i) {
|
|
714
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
var TWILIO_INTEGRATION_STEPS = [{
|
|
718
|
-
step: "1",
|
|
719
|
-
label: i18next.t("neetoIntegrations.steps.configure"),
|
|
720
|
-
isActive: true,
|
|
721
|
-
isCompleted: false
|
|
722
|
-
}];
|
|
723
|
-
|
|
724
|
-
function _typeof(obj) {
|
|
725
|
-
"@babel/helpers - typeof";
|
|
726
|
-
|
|
727
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
728
|
-
return typeof obj;
|
|
729
|
-
} : function (obj) {
|
|
730
|
-
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
731
|
-
}, _typeof(obj);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
function _toPrimitive(input, hint) {
|
|
735
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
736
|
-
var prim = input[Symbol.toPrimitive];
|
|
737
|
-
if (prim !== undefined) {
|
|
738
|
-
var res = prim.call(input, hint || "default");
|
|
739
|
-
if (_typeof(res) !== "object") return res;
|
|
740
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
741
|
-
}
|
|
742
|
-
return (hint === "string" ? String : Number)(input);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
function _toPropertyKey(arg) {
|
|
746
|
-
var key = _toPrimitive(arg, "string");
|
|
747
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
function _defineProperty(obj, key, value) {
|
|
751
|
-
key = _toPropertyKey(key);
|
|
752
|
-
if (key in obj) {
|
|
753
|
-
Object.defineProperty(obj, key, {
|
|
754
|
-
value: value,
|
|
755
|
-
enumerable: true,
|
|
756
|
-
configurable: true,
|
|
757
|
-
writable: true
|
|
758
|
-
});
|
|
759
|
-
} else {
|
|
760
|
-
obj[key] = value;
|
|
761
|
-
}
|
|
762
|
-
return obj;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
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; }
|
|
766
|
-
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; }
|
|
767
|
-
var ConfigurationForm = function ConfigurationForm(_ref) {
|
|
768
|
-
var _errors$twilioPhoneNu;
|
|
769
|
-
var phoneNumberOptions = _ref.phoneNumberOptions,
|
|
770
|
-
_ref$selectedPhoneNum = _ref.selectedPhoneNumber,
|
|
771
|
-
selectedPhoneNumber = _ref$selectedPhoneNum === void 0 ? null : _ref$selectedPhoneNum,
|
|
772
|
-
_ref$initialFocusRef = _ref.initialFocusRef,
|
|
773
|
-
initialFocusRef = _ref$initialFocusRef === void 0 ? null : _ref$initialFocusRef,
|
|
774
|
-
_ref$isUsingOverlay = _ref.isUsingOverlay,
|
|
775
|
-
isUsingOverlay = _ref$isUsingOverlay === void 0 ? false : _ref$isUsingOverlay,
|
|
776
|
-
_ref$formikProps = _ref.formikProps,
|
|
777
|
-
formikProps = _ref$formikProps === void 0 ? {} : _ref$formikProps;
|
|
778
|
-
var _useTranslation = useTranslation(),
|
|
779
|
-
t = _useTranslation.t;
|
|
780
|
-
var setFieldValue = formikProps.setFieldValue,
|
|
781
|
-
setValues = formikProps.setValues,
|
|
782
|
-
errors = formikProps.errors,
|
|
783
|
-
values = formikProps.values,
|
|
784
|
-
initialValues = formikProps.initialValues;
|
|
785
|
-
useEffect(function () {
|
|
786
|
-
selectedPhoneNumber && setFieldValue("twilioPhoneNumber", selectedPhoneNumber);
|
|
787
|
-
}, [selectedPhoneNumber, initialValues]);
|
|
788
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
789
|
-
className: "flex w-full flex-col gap-4"
|
|
790
|
-
}, /*#__PURE__*/React__default.createElement("div", {
|
|
791
|
-
className: "flex w-full"
|
|
792
|
-
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
793
|
-
required: true,
|
|
794
|
-
autoFocus: !isUsingOverlay,
|
|
795
|
-
"data-testid": "integrations-twilio-sid",
|
|
796
|
-
label: t("neetoIntegrations.twilio.sid"),
|
|
797
|
-
name: "twilioSid",
|
|
798
|
-
ref: initialFocusRef
|
|
799
|
-
})), /*#__PURE__*/React__default.createElement("div", {
|
|
800
|
-
className: "flex w-full"
|
|
801
|
-
}, /*#__PURE__*/React__default.createElement(Input, {
|
|
802
|
-
required: true,
|
|
803
|
-
"data-testid": "integrations-twilio-auth-token",
|
|
804
|
-
label: t("neetoIntegrations.twilio.authToken"),
|
|
805
|
-
name: "twilioAuthToken"
|
|
806
|
-
})), phoneNumberOptions && /*#__PURE__*/React__default.createElement("div", {
|
|
807
|
-
className: "flex w-full"
|
|
808
|
-
}, /*#__PURE__*/React__default.createElement(Select, {
|
|
809
|
-
error: (_errors$twilioPhoneNu = errors.twilioPhoneNumber) === null || _errors$twilioPhoneNu === void 0 ? void 0 : _errors$twilioPhoneNu.value,
|
|
810
|
-
label: t("neetoIntegrations.common.phNo"),
|
|
811
|
-
name: "twilioPhoneNumber",
|
|
812
|
-
options: phoneNumberOptions,
|
|
813
|
-
size: "large",
|
|
814
|
-
onChange: function onChange(selected) {
|
|
815
|
-
return setValues(_objectSpread$2(_objectSpread$2({}, values), {}, {
|
|
816
|
-
twilioPhoneNumber: selected
|
|
817
|
-
}));
|
|
818
|
-
}
|
|
819
|
-
})));
|
|
820
|
-
};
|
|
821
|
-
|
|
822
|
-
function _arrayWithoutHoles(arr) {
|
|
823
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
function _iterableToArray(iter) {
|
|
827
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
function _nonIterableSpread() {
|
|
831
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
function _toConsumableArray(arr) {
|
|
835
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
var queryClient = new QueryClient({
|
|
839
|
-
queryCache: new QueryCache()
|
|
840
|
-
});
|
|
841
|
-
|
|
842
|
-
var TWILIO_CONFIGURATION_BASE_URL = "/neeto_integrations/twilio/sms_configurations";
|
|
843
|
-
|
|
844
|
-
var twilioApi = {
|
|
845
|
-
fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
|
|
846
|
-
return axios.get(TWILIO_CONFIGURATION_BASE_URL);
|
|
847
|
-
},
|
|
848
|
-
removeTwilioConfiguration: function removeTwilioConfiguration() {
|
|
849
|
-
return axios["delete"](TWILIO_CONFIGURATION_BASE_URL);
|
|
850
|
-
},
|
|
851
|
-
getTwilioPhoneNumbers: function getTwilioPhoneNumbers(data) {
|
|
852
|
-
return axios.get("".concat(TWILIO_CONFIGURATION_BASE_URL, "/new"), {
|
|
853
|
-
params: data
|
|
854
|
-
});
|
|
855
|
-
},
|
|
856
|
-
createTwilioConfiguration: function createTwilioConfiguration(payload) {
|
|
857
|
-
return axios.post(TWILIO_CONFIGURATION_BASE_URL, payload);
|
|
858
|
-
}
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
var QUERY_KEYS = {
|
|
862
|
-
TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
|
|
863
|
-
TWILIO_PHONE_NUMBERS: "twilio-phone-numbers"
|
|
864
|
-
};
|
|
865
|
-
|
|
866
|
-
var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
|
|
867
|
-
return useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
|
|
868
|
-
staleTime: DEFAULT_STALE_TIME,
|
|
869
|
-
select: function select(response) {
|
|
870
|
-
var _smsConfiguration$twi, _smsConfiguration$twi2, _smsConfiguration$twi3;
|
|
871
|
-
var smsConfiguration = response.smsConfiguration;
|
|
872
|
-
return {
|
|
873
|
-
twilioSid: (_smsConfiguration$twi = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioSid) !== null && _smsConfiguration$twi !== void 0 ? _smsConfiguration$twi : "",
|
|
874
|
-
twilioAuthToken: (_smsConfiguration$twi2 = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioAuthToken) !== null && _smsConfiguration$twi2 !== void 0 ? _smsConfiguration$twi2 : "",
|
|
875
|
-
twilioPhoneNumber: (_smsConfiguration$twi3 = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioPhoneNumber) !== null && _smsConfiguration$twi3 !== void 0 ? _smsConfiguration$twi3 : ""
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
};
|
|
880
|
-
var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
|
|
881
|
-
var credentials = _ref.credentials;
|
|
882
|
-
return useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
|
|
883
|
-
credentials: credentials
|
|
884
|
-
}], function () {
|
|
885
|
-
return twilioApi.getTwilioPhoneNumbers(keysToSnakeCase(credentials));
|
|
886
|
-
}, {
|
|
887
|
-
staleTime: DEFAULT_STALE_TIME,
|
|
888
|
-
enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid),
|
|
889
|
-
select: prop("phoneNumbers"),
|
|
890
|
-
retry: false
|
|
891
|
-
});
|
|
892
|
-
};
|
|
893
|
-
var useCreateTwilioConfiguration = function useCreateTwilioConfiguration() {
|
|
894
|
-
return useMutation(twilioApi.createTwilioConfiguration, {
|
|
895
|
-
onSuccess: function onSuccess() {
|
|
896
|
-
return queryClient.invalidateQueries(QUERY_KEYS.TWILIO_SMS_CONFIGURATION);
|
|
897
|
-
}
|
|
898
|
-
});
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
function ownKeys$1(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; }
|
|
902
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
903
|
-
var useTwilio = function useTwilio(_ref) {
|
|
904
|
-
var _ref$onSave = _ref.onSave,
|
|
905
|
-
onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
|
|
906
|
-
_ref$setSteps = _ref.setSteps,
|
|
907
|
-
setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
|
|
908
|
-
_ref$useConnect = _ref.useConnect,
|
|
909
|
-
useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect;
|
|
910
|
-
var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
|
|
911
|
-
configuration = _useFetchTwilioSmsCon.data,
|
|
912
|
-
isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
|
|
913
|
-
refetchTwilioSmsConfiguration = _useFetchTwilioSmsCon.refetch;
|
|
914
|
-
var _useStateWithDependen = useStateWithDependency(configuration),
|
|
915
|
-
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
916
|
-
credentials = _useStateWithDependen2[0],
|
|
917
|
-
setCredentials = _useStateWithDependen2[1];
|
|
918
|
-
var _useFetchTwilioPhoneN = useFetchTwilioPhoneNumbers({
|
|
919
|
-
credentials: credentials
|
|
920
|
-
}),
|
|
921
|
-
phoneNumbers = _useFetchTwilioPhoneN.data,
|
|
922
|
-
isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
|
|
923
|
-
var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
|
|
924
|
-
saveConfiguration = _useCreateTwilioConfi.mutate,
|
|
925
|
-
isSubmitting = _useCreateTwilioConfi.isLoading;
|
|
926
|
-
var _useConnect = useConnect(),
|
|
927
|
-
installIntegration = _useConnect.mutate;
|
|
928
|
-
var connectTwilioApp = function connectTwilioApp() {
|
|
929
|
-
return installIntegration({
|
|
930
|
-
id: "twilio"
|
|
931
|
-
}, {});
|
|
932
|
-
};
|
|
933
|
-
useEffect(function () {
|
|
934
|
-
if (!(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) return;
|
|
935
|
-
setSteps(function (steps) {
|
|
936
|
-
var stepsClone = _toConsumableArray(steps);
|
|
937
|
-
stepsClone[0] = _objectSpread$1(_objectSpread$1({}, steps[0]), {}, {
|
|
938
|
-
isCompleted: true
|
|
939
|
-
});
|
|
940
|
-
return stepsClone;
|
|
941
|
-
});
|
|
942
|
-
}, [configuration]);
|
|
943
|
-
var handleSubmit = function handleSubmit(values) {
|
|
944
|
-
var _values$twilioPhoneNu;
|
|
945
|
-
var payload = {
|
|
946
|
-
twilio_sid: values.twilioSid,
|
|
947
|
-
twilio_auth_token: values.twilioAuthToken,
|
|
948
|
-
twilio_phone_number_sid: (_values$twilioPhoneNu = values.twilioPhoneNumber) === null || _values$twilioPhoneNu === void 0 ? void 0 : _values$twilioPhoneNu.value
|
|
949
|
-
};
|
|
950
|
-
if (!phoneNumbers && !(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) {
|
|
951
|
-
setCredentials(payload);
|
|
952
|
-
return;
|
|
953
|
-
}
|
|
954
|
-
saveConfiguration(payload, {
|
|
955
|
-
onSuccess: function onSuccess() {
|
|
956
|
-
onSave();
|
|
957
|
-
connectTwilioApp();
|
|
958
|
-
refetchTwilioSmsConfiguration();
|
|
959
|
-
}
|
|
960
|
-
});
|
|
961
|
-
};
|
|
962
|
-
return {
|
|
963
|
-
handleSubmit: handleSubmit,
|
|
964
|
-
phoneNumbers: phoneNumbers,
|
|
965
|
-
isConfigurationLoading: isConfigurationLoading,
|
|
966
|
-
isPhoneNumbersLoading: isPhoneNumbersLoading,
|
|
967
|
-
isSubmitting: isSubmitting,
|
|
968
|
-
configuration: configuration
|
|
969
|
-
};
|
|
970
|
-
};
|
|
971
|
-
|
|
972
|
-
var buildTwilioConfigurationValidationSchema = function buildTwilioConfigurationValidationSchema(isTwilioPhoneRequired) {
|
|
973
|
-
return yup.object().shape({
|
|
974
|
-
twilioSid: yup.string().required(i18next.t("neetoIntegrations.twilio.validations.sidReq")),
|
|
975
|
-
twilioAuthToken: yup.string().required(i18next.t("neetoIntegrations.twilio.validations.authTokenReq")),
|
|
976
|
-
twilioPhoneNumber: isTwilioPhoneRequired ? yup.object().shape({
|
|
977
|
-
label: yup.string(),
|
|
978
|
-
value: yup.string().required(i18next.t("neetoIntegrations.twilio.validations.phNumReq"))
|
|
979
|
-
}) : null
|
|
980
|
-
});
|
|
981
|
-
};
|
|
982
|
-
|
|
983
|
-
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; }
|
|
984
|
-
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; }
|
|
985
|
-
var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
986
|
-
var _ref$onCancel = _ref.onCancel,
|
|
987
|
-
onCancel = _ref$onCancel === void 0 ? noop : _ref$onCancel,
|
|
988
|
-
_ref$onSave = _ref.onSave,
|
|
989
|
-
onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
|
|
990
|
-
_ref$setSteps = _ref.setSteps,
|
|
991
|
-
setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
|
|
992
|
-
_ref$useConnect = _ref.useConnect,
|
|
993
|
-
useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect,
|
|
994
|
-
_ref$isModal = _ref.isModal,
|
|
995
|
-
isModal = _ref$isModal === void 0 ? false : _ref$isModal;
|
|
996
|
-
var _useTranslation = useTranslation(),
|
|
997
|
-
t = _useTranslation.t;
|
|
998
|
-
var initialFocusRef = useRef();
|
|
999
|
-
var _useTwilio = useTwilio({
|
|
1000
|
-
onSave: onSave,
|
|
1001
|
-
setSteps: setSteps,
|
|
1002
|
-
useConnect: useConnect
|
|
1003
|
-
}),
|
|
1004
|
-
handleSubmit = _useTwilio.handleSubmit,
|
|
1005
|
-
phoneNumbers = _useTwilio.phoneNumbers,
|
|
1006
|
-
isConfigurationLoading = _useTwilio.isConfigurationLoading,
|
|
1007
|
-
isPhoneNumbersLoading = _useTwilio.isPhoneNumbersLoading,
|
|
1008
|
-
isSubmitting = _useTwilio.isSubmitting,
|
|
1009
|
-
configuration = _useTwilio.configuration;
|
|
1010
|
-
var phoneNumberOptions = phoneNumbers === null || phoneNumbers === void 0 ? void 0 : phoneNumbers.map(function (_ref2) {
|
|
1011
|
-
var phoneNumber = _ref2.phoneNumber,
|
|
1012
|
-
sid = _ref2.sid;
|
|
1013
|
-
return {
|
|
1014
|
-
label: phoneNumber,
|
|
1015
|
-
value: sid
|
|
1016
|
-
};
|
|
1017
|
-
});
|
|
1018
|
-
var selectedPhoneNumber = _findBy({
|
|
1019
|
-
label: configuration === null || configuration === void 0 ? void 0 : configuration.twilioPhoneNumber
|
|
1020
|
-
}, phoneNumberOptions);
|
|
1021
|
-
var wrapInModalBody = function wrapInModalBody(children) {
|
|
1022
|
-
return /*#__PURE__*/React__default.createElement(Modal$1.Body, null, children);
|
|
1023
|
-
};
|
|
1024
|
-
var wrapInModalFooter = function wrapInModalFooter(children) {
|
|
1025
|
-
return /*#__PURE__*/React__default.createElement(Modal$1.Footer, null, children);
|
|
1026
|
-
};
|
|
1027
|
-
var isLoading = isPhoneNumbersLoading || isConfigurationLoading;
|
|
1028
|
-
var isSubmitDisabled = function isSubmitDisabled(values) {
|
|
1029
|
-
return equals(_objectSpread(_objectSpread({}, configuration), {}, {
|
|
1030
|
-
twilioPhoneNumber: selectedPhoneNumber
|
|
1031
|
-
}), values) || isLoading;
|
|
1032
|
-
};
|
|
1033
|
-
var renderActionBlock = function renderActionBlock(values) {
|
|
1034
|
-
return /*#__PURE__*/React__default.createElement(ActionBlock, {
|
|
1035
|
-
cancelButtonProps: {
|
|
1036
|
-
onClick: onCancel,
|
|
1037
|
-
disabled: false
|
|
1038
|
-
},
|
|
1039
|
-
className: "space-x-3",
|
|
1040
|
-
submitButtonProps: {
|
|
1041
|
-
label: phoneNumberOptions ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
|
|
1042
|
-
disabled: isSubmitDisabled(values),
|
|
1043
|
-
loading: isSubmitting || isPhoneNumbersLoading && !configuration.twilioAuthToken
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
};
|
|
1047
|
-
var renderForm = function renderForm(formikProps) {
|
|
1048
|
-
return /*#__PURE__*/React__default.createElement(ConfigurationForm, {
|
|
1049
|
-
formikProps: formikProps,
|
|
1050
|
-
initialFocusRef: initialFocusRef,
|
|
1051
|
-
isUsingOverlay: isModal,
|
|
1052
|
-
phoneNumberOptions: phoneNumberOptions,
|
|
1053
|
-
selectedPhoneNumber: selectedPhoneNumber
|
|
1054
|
-
});
|
|
1055
|
-
};
|
|
1056
|
-
return /*#__PURE__*/React__default.createElement(Form, {
|
|
1057
|
-
className: "mx-auto flex w-full max-w-md flex-col",
|
|
1058
|
-
formikProps: {
|
|
1059
|
-
enableReinitialize: true,
|
|
1060
|
-
validationSchema: buildTwilioConfigurationValidationSchema(!!phoneNumbers),
|
|
1061
|
-
initialValues: configuration,
|
|
1062
|
-
onSubmit: handleSubmit
|
|
1063
|
-
}
|
|
1064
|
-
}, function (formikProps) {
|
|
1065
|
-
return isModal ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, wrapInModalBody(renderForm(formikProps)), wrapInModalFooter(renderActionBlock(formikProps.values))) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, "renderForm(formikProps)", /*#__PURE__*/React__default.createElement("div", {
|
|
1066
|
-
className: "mt-4 flex items-center gap-x-2"
|
|
1067
|
-
}, renderActionBlock(formikProps.values)));
|
|
1068
|
-
});
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
var Twilio = function Twilio(_ref) {
|
|
1072
|
-
var _ref$onClose = _ref.onClose,
|
|
1073
|
-
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
1074
|
-
_ref$useConnect = _ref.useConnect,
|
|
1075
|
-
useConnect = _ref$useConnect === void 0 ? noop : _ref$useConnect;
|
|
1076
|
-
var _useState = useState(TWILIO_INTEGRATION_STEPS),
|
|
1077
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1078
|
-
steps = _useState2[0],
|
|
1079
|
-
setSteps = _useState2[1];
|
|
1080
|
-
return /*#__PURE__*/React__default.createElement(Modal, {
|
|
1081
|
-
isOpen: true,
|
|
1082
|
-
steps: steps,
|
|
1083
|
-
onClose: onClose
|
|
1084
|
-
}, /*#__PURE__*/React__default.createElement(TwilioConfiguration, {
|
|
1085
|
-
isModal: true,
|
|
1086
|
-
setSteps: setSteps,
|
|
1087
|
-
useConnect: useConnect,
|
|
1088
|
-
onCancel: onClose
|
|
1089
|
-
}));
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
806
|
var e = [],
|
|
1093
807
|
t = [];
|
|
1094
808
|
function n(n, r) {
|
|
@@ -1114,5 +828,5 @@ function n(n, r) {
|
|
|
1114
828
|
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%}";
|
|
1115
829
|
n(css,{});
|
|
1116
830
|
|
|
1117
|
-
export {
|
|
831
|
+
export { Connect, Demo, Finish, Modal, Twilio };
|
|
1118
832
|
//# sourceMappingURL=index.js.map
|