@bigbinary/neeto-integrations-frontend 2.3.1 → 2.5.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/Twilio.cjs.js +709 -0
- package/dist/Twilio.cjs.js.map +1 -0
- package/dist/Twilio.js +681 -0
- package/dist/Twilio.js.map +1 -0
- package/dist/index.cjs.js +448 -272
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +434 -274
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/translations/en.json +22 -1
- package/types.d.ts +10 -5
package/dist/index.cjs.js
CHANGED
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var IntegrationCard = require('@bigbinary/neeto-molecules/IntegrationCard');
|
|
6
|
+
var IntegrationDisconnectAlert = require('@bigbinary/neeto-molecules/IntegrationDisconnectAlert');
|
|
7
|
+
var IntegrationWalkthroughModal = require('@bigbinary/neeto-molecules/IntegrationWalkthroughModal');
|
|
5
8
|
var React = require('react');
|
|
6
|
-
var classnames = require('classnames');
|
|
7
9
|
var pure = require('@bigbinary/neeto-commons-frontend/pure');
|
|
8
|
-
var
|
|
10
|
+
var i18next = require('i18next');
|
|
9
11
|
var neetoui = require('@bigbinary/neetoui');
|
|
12
|
+
var formik = require('@bigbinary/neetoui/formik');
|
|
10
13
|
var ramda = require('ramda');
|
|
11
14
|
var reactI18next = require('react-i18next');
|
|
12
|
-
var
|
|
15
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
16
|
+
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
17
|
+
var reactQuery = require('react-query');
|
|
18
|
+
var axios = require('axios');
|
|
19
|
+
var yup = require('yup');
|
|
20
|
+
var classnames = require('classnames');
|
|
13
21
|
|
|
14
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
23
|
|
|
@@ -31,268 +39,444 @@ function _interopNamespace(e) {
|
|
|
31
39
|
return Object.freeze(n);
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
var IntegrationCard__default = /*#__PURE__*/_interopDefaultLegacy(IntegrationCard);
|
|
43
|
+
var IntegrationDisconnectAlert__default = /*#__PURE__*/_interopDefaultLegacy(IntegrationDisconnectAlert);
|
|
44
|
+
var IntegrationWalkthroughModal__default = /*#__PURE__*/_interopDefaultLegacy(IntegrationWalkthroughModal);
|
|
34
45
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
35
46
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
47
|
+
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
48
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
49
|
+
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
36
50
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
37
51
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
function _arrayWithHoles(arr) {
|
|
53
|
+
if (Array.isArray(arr)) return arr;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _iterableToArrayLimit(arr, i) {
|
|
57
|
+
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
58
|
+
if (null != _i) {
|
|
59
|
+
var _s,
|
|
60
|
+
_e,
|
|
61
|
+
_x,
|
|
62
|
+
_r,
|
|
63
|
+
_arr = [],
|
|
64
|
+
_n = !0,
|
|
65
|
+
_d = !1;
|
|
66
|
+
try {
|
|
67
|
+
if (_x = (_i = _i.call(arr)).next, 0 === i) {
|
|
68
|
+
if (Object(_i) !== _i) return;
|
|
69
|
+
_n = !1;
|
|
70
|
+
} else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_d = !0, _e = err;
|
|
73
|
+
} finally {
|
|
74
|
+
try {
|
|
75
|
+
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
|
|
76
|
+
} finally {
|
|
77
|
+
if (_d) throw _e;
|
|
46
78
|
}
|
|
47
79
|
}
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
return _extends$1.apply(this, arguments);
|
|
80
|
+
return _arr;
|
|
81
|
+
}
|
|
51
82
|
}
|
|
52
83
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
84
|
+
function _arrayLikeToArray(arr, len) {
|
|
85
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
86
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
87
|
+
return arr2;
|
|
88
|
+
}
|
|
56
89
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
91
|
+
if (!o) return;
|
|
92
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
93
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
94
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
95
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
96
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function _nonIterableRest() {
|
|
100
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function _slicedToArray(arr, i) {
|
|
104
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var TWILIO_INTEGRATION_STEPS = [{
|
|
108
|
+
step: "1",
|
|
109
|
+
label: i18next__default["default"].t("neetoIntegrations.steps.configure"),
|
|
110
|
+
isActive: true,
|
|
111
|
+
isCompleted: false
|
|
112
|
+
}];
|
|
113
|
+
|
|
114
|
+
function _typeof(obj) {
|
|
115
|
+
"@babel/helpers - typeof";
|
|
116
|
+
|
|
117
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
118
|
+
return typeof obj;
|
|
119
|
+
} : function (obj) {
|
|
120
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
121
|
+
}, _typeof(obj);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _toPrimitive(input, hint) {
|
|
125
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
126
|
+
var prim = input[Symbol.toPrimitive];
|
|
127
|
+
if (prim !== undefined) {
|
|
128
|
+
var res = prim.call(input, hint || "default");
|
|
129
|
+
if (_typeof(res) !== "object") return res;
|
|
130
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
73
131
|
}
|
|
74
|
-
|
|
75
|
-
|
|
132
|
+
return (hint === "string" ? String : Number)(input);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function _toPropertyKey(arg) {
|
|
136
|
+
var key = _toPrimitive(arg, "string");
|
|
137
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function _defineProperty(obj, key, value) {
|
|
141
|
+
key = _toPropertyKey(key);
|
|
142
|
+
if (key in obj) {
|
|
143
|
+
Object.defineProperty(obj, key, {
|
|
144
|
+
value: value,
|
|
145
|
+
enumerable: true,
|
|
146
|
+
configurable: true,
|
|
147
|
+
writable: true
|
|
148
|
+
});
|
|
149
|
+
} else {
|
|
150
|
+
obj[key] = value;
|
|
76
151
|
}
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
onClick: function onClick(e) {
|
|
80
|
-
return e.stopPropagation();
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
buttonStyle: "text",
|
|
84
|
-
dropdownProps: {
|
|
85
|
-
onClick: function onClick(e) {
|
|
86
|
-
return e.stopPropagation();
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
icon: neetoIcons.MenuVertical
|
|
90
|
-
}, /*#__PURE__*/React__default["default"].createElement(Menu, null, isManageable && /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
|
|
91
|
-
onClick: function onClick() {
|
|
92
|
-
return handleManage();
|
|
93
|
-
}
|
|
94
|
-
}, t("neetoIntegrations.common.manage")), !hideDisconnect && /*#__PURE__*/React__default["default"].createElement(MenuItem.Button, {
|
|
95
|
-
onClick: function onClick() {
|
|
96
|
-
return onDisconnect();
|
|
97
|
-
}
|
|
98
|
-
}, t("neetoIntegrations.common.disconnect"))));
|
|
99
|
-
};
|
|
152
|
+
return obj;
|
|
153
|
+
}
|
|
100
154
|
|
|
101
|
-
var
|
|
102
|
-
|
|
155
|
+
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; }
|
|
156
|
+
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; }
|
|
157
|
+
var ConfigurationForm = function ConfigurationForm(_ref) {
|
|
158
|
+
var _errors$twilioPhoneNu;
|
|
159
|
+
var phoneNumberOptions = _ref.phoneNumberOptions,
|
|
160
|
+
_ref$selectedPhoneNum = _ref.selectedPhoneNumber,
|
|
161
|
+
selectedPhoneNumber = _ref$selectedPhoneNum === void 0 ? null : _ref$selectedPhoneNum,
|
|
162
|
+
_ref$initialFocusRef = _ref.initialFocusRef,
|
|
163
|
+
initialFocusRef = _ref$initialFocusRef === void 0 ? null : _ref$initialFocusRef,
|
|
164
|
+
_ref$isUsingOverlay = _ref.isUsingOverlay,
|
|
165
|
+
isUsingOverlay = _ref$isUsingOverlay === void 0 ? false : _ref$isUsingOverlay,
|
|
166
|
+
_ref$formikProps = _ref.formikProps,
|
|
167
|
+
formikProps = _ref$formikProps === void 0 ? {} : _ref$formikProps;
|
|
103
168
|
var _useTranslation = reactI18next.useTranslation(),
|
|
104
169
|
t = _useTranslation.t;
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
170
|
+
var setFieldValue = formikProps.setFieldValue,
|
|
171
|
+
setValues = formikProps.setValues,
|
|
172
|
+
errors = formikProps.errors,
|
|
173
|
+
values = formikProps.values,
|
|
174
|
+
initialValues = formikProps.initialValues;
|
|
175
|
+
React.useEffect(function () {
|
|
176
|
+
selectedPhoneNumber && setFieldValue("twilioPhoneNumber", selectedPhoneNumber);
|
|
177
|
+
}, [selectedPhoneNumber, initialValues]);
|
|
178
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
179
|
+
className: "flex w-full flex-col gap-4"
|
|
180
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
181
|
+
className: "flex w-full"
|
|
182
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
|
|
183
|
+
required: true,
|
|
184
|
+
autoFocus: !isUsingOverlay,
|
|
185
|
+
"data-testid": "integrations-twilio-sid",
|
|
186
|
+
label: t("neetoIntegrations.twilio.sid"),
|
|
187
|
+
name: "twilioSid",
|
|
188
|
+
ref: initialFocusRef
|
|
189
|
+
})), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
190
|
+
className: "flex w-full"
|
|
191
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik.Input, {
|
|
192
|
+
required: true,
|
|
193
|
+
"data-testid": "integrations-twilio-auth-token",
|
|
194
|
+
label: t("neetoIntegrations.twilio.authToken"),
|
|
195
|
+
name: "twilioAuthToken"
|
|
196
|
+
})), phoneNumberOptions && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
197
|
+
className: "flex w-full"
|
|
198
|
+
}, /*#__PURE__*/React__default["default"].createElement(formik.Select, {
|
|
199
|
+
error: (_errors$twilioPhoneNu = errors.twilioPhoneNumber) === null || _errors$twilioPhoneNu === void 0 ? void 0 : _errors$twilioPhoneNu.value,
|
|
200
|
+
label: t("neetoIntegrations.common.phNo"),
|
|
201
|
+
name: "twilioPhoneNumber",
|
|
202
|
+
options: phoneNumberOptions,
|
|
203
|
+
size: "large",
|
|
204
|
+
onChange: function onChange(selected) {
|
|
205
|
+
return setValues(_objectSpread$2(_objectSpread$2({}, values), {}, {
|
|
206
|
+
twilioPhoneNumber: selected
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
})));
|
|
117
210
|
};
|
|
118
211
|
|
|
119
|
-
function
|
|
120
|
-
if (
|
|
121
|
-
var target = {};
|
|
122
|
-
var sourceKeys = Object.keys(source);
|
|
123
|
-
var key, i;
|
|
124
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
125
|
-
key = sourceKeys[i];
|
|
126
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
127
|
-
target[key] = source[key];
|
|
128
|
-
}
|
|
129
|
-
return target;
|
|
212
|
+
function _arrayWithoutHoles(arr) {
|
|
213
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
130
214
|
}
|
|
131
215
|
|
|
132
|
-
function
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
139
|
-
key = sourceSymbolKeys[i];
|
|
140
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
141
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
142
|
-
target[key] = source[key];
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return target;
|
|
216
|
+
function _iterableToArray(iter) {
|
|
217
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function _nonIterableSpread() {
|
|
221
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
146
222
|
}
|
|
147
223
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
224
|
+
function _toConsumableArray(arr) {
|
|
225
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var queryClient = new reactQuery.QueryClient({
|
|
229
|
+
queryCache: new reactQuery.QueryCache()
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
var TWILIO_CONFIGURATION_BASE_URL = "/neeto_integrations/twilio/sms_configurations";
|
|
233
|
+
|
|
234
|
+
var twilioApi = {
|
|
235
|
+
fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
|
|
236
|
+
return axios__default["default"].get(TWILIO_CONFIGURATION_BASE_URL);
|
|
237
|
+
},
|
|
238
|
+
removeTwilioConfiguration: function removeTwilioConfiguration() {
|
|
239
|
+
return axios__default["default"]["delete"](TWILIO_CONFIGURATION_BASE_URL);
|
|
240
|
+
},
|
|
241
|
+
getTwilioPhoneNumbers: function getTwilioPhoneNumbers(data) {
|
|
242
|
+
return axios__default["default"].get("".concat(TWILIO_CONFIGURATION_BASE_URL, "/new"), {
|
|
243
|
+
params: data
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
createTwilioConfiguration: function createTwilioConfiguration(payload) {
|
|
247
|
+
return axios__default["default"].post(TWILIO_CONFIGURATION_BASE_URL, payload);
|
|
248
|
+
}
|
|
154
249
|
};
|
|
155
250
|
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
251
|
+
var QUERY_KEYS = {
|
|
252
|
+
TWILIO_SMS_CONFIGURATION: "twilio-sms-configuration",
|
|
253
|
+
TWILIO_PHONE_NUMBERS: "twilio-phone-numbers"
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
|
|
257
|
+
return reactQuery.useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
|
|
258
|
+
staleTime: constants.DEFAULT_STALE_TIME,
|
|
259
|
+
select: function select(response) {
|
|
260
|
+
var _smsConfiguration$twi, _smsConfiguration$twi2, _smsConfiguration$twi3;
|
|
261
|
+
var smsConfiguration = response.smsConfiguration;
|
|
262
|
+
return {
|
|
263
|
+
twilioSid: (_smsConfiguration$twi = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioSid) !== null && _smsConfiguration$twi !== void 0 ? _smsConfiguration$twi : "",
|
|
264
|
+
twilioAuthToken: (_smsConfiguration$twi2 = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioAuthToken) !== null && _smsConfiguration$twi2 !== void 0 ? _smsConfiguration$twi2 : "",
|
|
265
|
+
twilioPhoneNumber: (_smsConfiguration$twi3 = smsConfiguration === null || smsConfiguration === void 0 ? void 0 : smsConfiguration.twilioPhoneNumber) !== null && _smsConfiguration$twi3 !== void 0 ? _smsConfiguration$twi3 : ""
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
|
|
271
|
+
var credentials = _ref.credentials;
|
|
272
|
+
return reactQuery.useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
|
|
273
|
+
credentials: credentials
|
|
274
|
+
}], function () {
|
|
275
|
+
return twilioApi.getTwilioPhoneNumbers(pure.keysToSnakeCase(credentials));
|
|
276
|
+
}, {
|
|
277
|
+
staleTime: constants.DEFAULT_STALE_TIME,
|
|
278
|
+
enabled: !!(credentials !== null && credentials !== void 0 && credentials.twilio_sid) || !!(credentials !== null && credentials !== void 0 && credentials.twilioSid),
|
|
279
|
+
select: ramda.prop("phoneNumbers"),
|
|
280
|
+
retry: false
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
var useCreateTwilioConfiguration = function useCreateTwilioConfiguration() {
|
|
284
|
+
return reactQuery.useMutation(twilioApi.createTwilioConfiguration, {
|
|
285
|
+
onSuccess: function onSuccess() {
|
|
286
|
+
return queryClient.invalidateQueries(QUERY_KEYS.TWILIO_SMS_CONFIGURATION);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
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; }
|
|
292
|
+
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; }
|
|
293
|
+
var useTwilio = function useTwilio(_ref) {
|
|
294
|
+
var _ref$onSave = _ref.onSave,
|
|
295
|
+
onSave = _ref$onSave === void 0 ? pure.noop : _ref$onSave,
|
|
296
|
+
_ref$setSteps = _ref.setSteps,
|
|
297
|
+
setSteps = _ref$setSteps === void 0 ? pure.noop : _ref$setSteps,
|
|
298
|
+
_ref$useConnect = _ref.useConnect,
|
|
299
|
+
useConnect = _ref$useConnect === void 0 ? pure.noop : _ref$useConnect;
|
|
300
|
+
var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
|
|
301
|
+
configuration = _useFetchTwilioSmsCon.data,
|
|
302
|
+
isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
|
|
303
|
+
refetchTwilioSmsConfiguration = _useFetchTwilioSmsCon.refetch;
|
|
304
|
+
var _useStateWithDependen = reactUtils.useStateWithDependency(configuration),
|
|
305
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
306
|
+
credentials = _useStateWithDependen2[0],
|
|
307
|
+
setCredentials = _useStateWithDependen2[1];
|
|
308
|
+
var _useFetchTwilioPhoneN = useFetchTwilioPhoneNumbers({
|
|
309
|
+
credentials: credentials
|
|
310
|
+
}),
|
|
311
|
+
phoneNumbers = _useFetchTwilioPhoneN.data,
|
|
312
|
+
isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
|
|
313
|
+
var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
|
|
314
|
+
saveConfiguration = _useCreateTwilioConfi.mutate,
|
|
315
|
+
isSubmitting = _useCreateTwilioConfi.isLoading;
|
|
316
|
+
var _useConnect = useConnect(),
|
|
317
|
+
installIntegration = _useConnect.mutate;
|
|
318
|
+
var connectTwilioApp = function connectTwilioApp() {
|
|
319
|
+
return installIntegration({
|
|
320
|
+
id: "twilio"
|
|
321
|
+
}, {});
|
|
322
|
+
};
|
|
323
|
+
React.useEffect(function () {
|
|
324
|
+
if (!(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) return;
|
|
325
|
+
setSteps(function (steps) {
|
|
326
|
+
var stepsClone = _toConsumableArray(steps);
|
|
327
|
+
stepsClone[0] = _objectSpread$1(_objectSpread$1({}, steps[0]), {}, {
|
|
328
|
+
isCompleted: true
|
|
329
|
+
});
|
|
330
|
+
return stepsClone;
|
|
331
|
+
});
|
|
332
|
+
}, [configuration]);
|
|
333
|
+
var handleSubmit = function handleSubmit(values) {
|
|
334
|
+
var _values$twilioPhoneNu;
|
|
335
|
+
var payload = {
|
|
336
|
+
twilio_sid: values.twilioSid,
|
|
337
|
+
twilio_auth_token: values.twilioAuthToken,
|
|
338
|
+
twilio_phone_number_sid: (_values$twilioPhoneNu = values.twilioPhoneNumber) === null || _values$twilioPhoneNu === void 0 ? void 0 : _values$twilioPhoneNu.value
|
|
339
|
+
};
|
|
340
|
+
if (!phoneNumbers && !(configuration !== null && configuration !== void 0 && configuration.twilioPhoneNumber)) {
|
|
341
|
+
setCredentials(payload);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
saveConfiguration(payload, {
|
|
345
|
+
onSuccess: function onSuccess() {
|
|
346
|
+
onSave();
|
|
347
|
+
connectTwilioApp();
|
|
348
|
+
refetchTwilioSmsConfiguration();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
return {
|
|
353
|
+
handleSubmit: handleSubmit,
|
|
354
|
+
phoneNumbers: phoneNumbers,
|
|
355
|
+
isConfigurationLoading: isConfigurationLoading,
|
|
356
|
+
isPhoneNumbersLoading: isPhoneNumbersLoading,
|
|
357
|
+
isSubmitting: isSubmitting,
|
|
358
|
+
configuration: configuration
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
var buildTwilioConfigurationValidationSchema = function buildTwilioConfigurationValidationSchema(isTwilioPhoneRequired) {
|
|
363
|
+
return yup__namespace.object().shape({
|
|
364
|
+
twilioSid: yup__namespace.string().required(i18next__default["default"].t("neetoIntegrations.twilio.validations.sidReq")),
|
|
365
|
+
twilioAuthToken: yup__namespace.string().required(i18next__default["default"].t("neetoIntegrations.twilio.validations.authTokenReq")),
|
|
366
|
+
twilioPhoneNumber: isTwilioPhoneRequired ? yup__namespace.object().shape({
|
|
367
|
+
label: yup__namespace.string(),
|
|
368
|
+
value: yup__namespace.string().required(i18next__default["default"].t("neetoIntegrations.twilio.validations.phNumReq"))
|
|
369
|
+
}) : null
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
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; }
|
|
374
|
+
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; }
|
|
375
|
+
var TwilioConfiguration = function TwilioConfiguration(_ref) {
|
|
376
|
+
var _ref$onCancel = _ref.onCancel,
|
|
377
|
+
onCancel = _ref$onCancel === void 0 ? pure.noop : _ref$onCancel,
|
|
378
|
+
_ref$onSave = _ref.onSave,
|
|
379
|
+
onSave = _ref$onSave === void 0 ? pure.noop : _ref$onSave,
|
|
380
|
+
_ref$setSteps = _ref.setSteps,
|
|
381
|
+
setSteps = _ref$setSteps === void 0 ? pure.noop : _ref$setSteps,
|
|
382
|
+
_ref$useConnect = _ref.useConnect,
|
|
383
|
+
useConnect = _ref$useConnect === void 0 ? pure.noop : _ref$useConnect,
|
|
384
|
+
_ref$isModal = _ref.isModal,
|
|
385
|
+
isModal = _ref$isModal === void 0 ? false : _ref$isModal;
|
|
193
386
|
var _useTranslation = reactI18next.useTranslation(),
|
|
194
387
|
t = _useTranslation.t;
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
388
|
+
var initialFocusRef = React.useRef();
|
|
389
|
+
var _useTwilio = useTwilio({
|
|
390
|
+
onSave: onSave,
|
|
391
|
+
setSteps: setSteps,
|
|
392
|
+
useConnect: useConnect
|
|
393
|
+
}),
|
|
394
|
+
handleSubmit = _useTwilio.handleSubmit,
|
|
395
|
+
phoneNumbers = _useTwilio.phoneNumbers,
|
|
396
|
+
isConfigurationLoading = _useTwilio.isConfigurationLoading,
|
|
397
|
+
isPhoneNumbersLoading = _useTwilio.isPhoneNumbersLoading,
|
|
398
|
+
isSubmitting = _useTwilio.isSubmitting,
|
|
399
|
+
configuration = _useTwilio.configuration;
|
|
400
|
+
var phoneNumberOptions = phoneNumbers === null || phoneNumbers === void 0 ? void 0 : phoneNumbers.map(function (_ref2) {
|
|
401
|
+
var phoneNumber = _ref2.phoneNumber,
|
|
402
|
+
sid = _ref2.sid;
|
|
403
|
+
return {
|
|
404
|
+
label: phoneNumber,
|
|
405
|
+
value: sid
|
|
406
|
+
};
|
|
407
|
+
});
|
|
408
|
+
var selectedPhoneNumber = pure._findBy({
|
|
409
|
+
label: configuration === null || configuration === void 0 ? void 0 : configuration.twilioPhoneNumber
|
|
410
|
+
}, phoneNumberOptions);
|
|
411
|
+
var wrapInModalBody = function wrapInModalBody(children) {
|
|
412
|
+
return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Body, null, children);
|
|
199
413
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
className: "my-auto"
|
|
222
|
-
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
223
|
-
className: "mb-2",
|
|
224
|
-
"data-cy": renderDataCy(label, "integration-card-label"),
|
|
225
|
-
style: "h4",
|
|
226
|
-
weight: "semibold"
|
|
227
|
-
}, label), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
228
|
-
className: "break-words",
|
|
229
|
-
"data-cy": "".concat(utils.joinHyphenCase(label), "-integration-description"),
|
|
230
|
-
style: "body2"
|
|
231
|
-
}, description), children)), pure.isNotEmpty(subIcons) && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
232
|
-
className: "flex h-24 flex-col gap-2"
|
|
233
|
-
}, subIcons.map(function (Icon) {
|
|
234
|
-
return /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
235
|
-
className: "neeto-ui-text-gray-600",
|
|
236
|
-
key: Icon,
|
|
237
|
-
size: 24
|
|
414
|
+
var wrapInModalFooter = function wrapInModalFooter(children) {
|
|
415
|
+
return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Footer, null, children);
|
|
416
|
+
};
|
|
417
|
+
var isLoading = isPhoneNumbersLoading || isConfigurationLoading;
|
|
418
|
+
var isSubmitDisabled = function isSubmitDisabled(values) {
|
|
419
|
+
return ramda.equals(_objectSpread(_objectSpread({}, configuration), {}, {
|
|
420
|
+
twilioPhoneNumber: selectedPhoneNumber
|
|
421
|
+
}), values) || isLoading;
|
|
422
|
+
};
|
|
423
|
+
var renderActionBlock = function renderActionBlock(values) {
|
|
424
|
+
return /*#__PURE__*/React__default["default"].createElement(formik.ActionBlock, {
|
|
425
|
+
cancelButtonProps: {
|
|
426
|
+
onClick: onCancel,
|
|
427
|
+
disabled: false
|
|
428
|
+
},
|
|
429
|
+
className: "space-x-3",
|
|
430
|
+
submitButtonProps: {
|
|
431
|
+
label: phoneNumberOptions ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
|
|
432
|
+
disabled: isSubmitDisabled(values),
|
|
433
|
+
loading: isSubmitting || isPhoneNumbersLoading && !configuration.twilioAuthToken
|
|
434
|
+
}
|
|
238
435
|
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
handleManage: onManage,
|
|
263
|
-
hideDisconnect: hideDisconnect,
|
|
264
|
-
onDisconnect: onDisconnect
|
|
265
|
-
})))));
|
|
436
|
+
};
|
|
437
|
+
var renderForm = function renderForm(formikProps) {
|
|
438
|
+
return /*#__PURE__*/React__default["default"].createElement(ConfigurationForm, {
|
|
439
|
+
formikProps: formikProps,
|
|
440
|
+
initialFocusRef: initialFocusRef,
|
|
441
|
+
isUsingOverlay: isModal,
|
|
442
|
+
phoneNumberOptions: phoneNumberOptions,
|
|
443
|
+
selectedPhoneNumber: selectedPhoneNumber
|
|
444
|
+
});
|
|
445
|
+
};
|
|
446
|
+
return /*#__PURE__*/React__default["default"].createElement(formik.Form, {
|
|
447
|
+
className: "mx-auto flex w-full max-w-md flex-col",
|
|
448
|
+
formikProps: {
|
|
449
|
+
enableReinitialize: true,
|
|
450
|
+
validationSchema: buildTwilioConfigurationValidationSchema(!!phoneNumbers),
|
|
451
|
+
initialValues: configuration,
|
|
452
|
+
onSubmit: handleSubmit
|
|
453
|
+
}
|
|
454
|
+
}, function (formikProps) {
|
|
455
|
+
return isModal ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, wrapInModalBody(renderForm(formikProps)), wrapInModalFooter(renderActionBlock(formikProps.values))) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, "renderForm(formikProps)", /*#__PURE__*/React__default["default"].createElement("div", {
|
|
456
|
+
className: "mt-4 flex items-center gap-x-2"
|
|
457
|
+
}, renderActionBlock(formikProps.values)));
|
|
458
|
+
});
|
|
266
459
|
};
|
|
267
460
|
|
|
268
|
-
var
|
|
269
|
-
var
|
|
270
|
-
var _ref$isOpen = _ref.isOpen,
|
|
271
|
-
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
272
|
-
_ref$isDisconnecting = _ref.isDisconnecting,
|
|
273
|
-
isDisconnecting = _ref$isDisconnecting === void 0 ? false : _ref$isDisconnecting,
|
|
274
|
-
_ref$title = _ref.title,
|
|
275
|
-
title = _ref$title === void 0 ? "" : _ref$title,
|
|
276
|
-
_ref$message = _ref.message,
|
|
277
|
-
message = _ref$message === void 0 ? "" : _ref$message,
|
|
278
|
-
_ref$onClose = _ref.onClose,
|
|
461
|
+
var Twilio = function Twilio(_ref) {
|
|
462
|
+
var _ref$onClose = _ref.onClose,
|
|
279
463
|
onClose = _ref$onClose === void 0 ? pure.noop : _ref$onClose,
|
|
280
|
-
_ref$
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
464
|
+
_ref$useConnect = _ref.useConnect,
|
|
465
|
+
useConnect = _ref$useConnect === void 0 ? pure.noop : _ref$useConnect;
|
|
466
|
+
var _useState = React.useState(TWILIO_INTEGRATION_STEPS),
|
|
467
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
468
|
+
steps = _useState2[0],
|
|
469
|
+
setSteps = _useState2[1];
|
|
470
|
+
return /*#__PURE__*/React__default["default"].createElement(Modal, {
|
|
471
|
+
isOpen: true,
|
|
472
|
+
steps: steps,
|
|
473
|
+
onClose: onClose
|
|
474
|
+
}, /*#__PURE__*/React__default["default"].createElement(TwilioConfiguration, {
|
|
475
|
+
isModal: true,
|
|
476
|
+
setSteps: setSteps,
|
|
477
|
+
useConnect: useConnect,
|
|
478
|
+
onCancel: onClose
|
|
479
|
+
}));
|
|
296
480
|
};
|
|
297
481
|
|
|
298
482
|
var Stepper = function Stepper(_ref) {
|
|
@@ -361,6 +545,21 @@ var Modal = function Modal(_ref) {
|
|
|
361
545
|
}, children)));
|
|
362
546
|
};
|
|
363
547
|
|
|
548
|
+
function _extends$1() {
|
|
549
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
550
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
551
|
+
var source = arguments[i];
|
|
552
|
+
for (var key in source) {
|
|
553
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
554
|
+
target[key] = source[key];
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return target;
|
|
559
|
+
};
|
|
560
|
+
return _extends$1.apply(this, arguments);
|
|
561
|
+
}
|
|
562
|
+
|
|
364
563
|
var propTypes = {exports: {}};
|
|
365
564
|
|
|
366
565
|
/**
|
|
@@ -646,39 +845,6 @@ Finish.prototypes = {
|
|
|
646
845
|
secondaryButtonProps: propTypes.exports.object
|
|
647
846
|
};
|
|
648
847
|
|
|
649
|
-
var WalkthroughModal = function WalkthroughModal(_ref) {
|
|
650
|
-
var _ref$isOpen = _ref.isOpen,
|
|
651
|
-
isOpen = _ref$isOpen === void 0 ? pure.noop : _ref$isOpen,
|
|
652
|
-
_ref$onClose = _ref.onClose,
|
|
653
|
-
onClose = _ref$onClose === void 0 ? pure.noop : _ref$onClose,
|
|
654
|
-
_ref$videoUrl = _ref.videoUrl,
|
|
655
|
-
videoUrl = _ref$videoUrl === void 0 ? "" : _ref$videoUrl,
|
|
656
|
-
children = _ref.children;
|
|
657
|
-
var _useTranslation = reactI18next.useTranslation(),
|
|
658
|
-
t = _useTranslation.t;
|
|
659
|
-
return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal, {
|
|
660
|
-
isOpen: isOpen,
|
|
661
|
-
size: "large",
|
|
662
|
-
onClose: onClose
|
|
663
|
-
}, /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Header, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
|
|
664
|
-
style: "h2",
|
|
665
|
-
weight: "semibold"
|
|
666
|
-
}, t("neetoIntegrations.walkthroughModal.header"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Body, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
667
|
-
className: "w-full py-10"
|
|
668
|
-
}, /*#__PURE__*/React__default["default"].createElement("video", {
|
|
669
|
-
autoPlay: true,
|
|
670
|
-
controls: true,
|
|
671
|
-
muted: true,
|
|
672
|
-
className: "cursor-pointer",
|
|
673
|
-
id: "walkthrough-video"
|
|
674
|
-
}, /*#__PURE__*/React__default["default"].createElement("source", {
|
|
675
|
-
src: videoUrl
|
|
676
|
-
})), children)), /*#__PURE__*/React__default["default"].createElement(neetoui.Modal.Footer, null, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
|
|
677
|
-
label: t("neetoIntegrations.walkthroughModal.continue"),
|
|
678
|
-
onClick: onClose
|
|
679
|
-
})));
|
|
680
|
-
};
|
|
681
|
-
|
|
682
848
|
var e = [],
|
|
683
849
|
t = [];
|
|
684
850
|
function n(n, r) {
|
|
@@ -704,11 +870,21 @@ function n(n, r) {
|
|
|
704
870
|
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%}";
|
|
705
871
|
n(css,{});
|
|
706
872
|
|
|
707
|
-
exports
|
|
873
|
+
Object.defineProperty(exports, 'Card', {
|
|
874
|
+
enumerable: true,
|
|
875
|
+
get: function () { return IntegrationCard__default["default"]; }
|
|
876
|
+
});
|
|
877
|
+
Object.defineProperty(exports, 'DisconnectAlert', {
|
|
878
|
+
enumerable: true,
|
|
879
|
+
get: function () { return IntegrationDisconnectAlert__default["default"]; }
|
|
880
|
+
});
|
|
881
|
+
Object.defineProperty(exports, 'WalkthroughModal', {
|
|
882
|
+
enumerable: true,
|
|
883
|
+
get: function () { return IntegrationWalkthroughModal__default["default"]; }
|
|
884
|
+
});
|
|
708
885
|
exports.Connect = Connect;
|
|
709
886
|
exports.Demo = Demo;
|
|
710
|
-
exports.DisconnectAlert = DisconnectAlert;
|
|
711
887
|
exports.Finish = Finish;
|
|
712
888
|
exports.Modal = Modal;
|
|
713
|
-
exports.
|
|
889
|
+
exports.Twilio = Twilio;
|
|
714
890
|
//# sourceMappingURL=index.cjs.js.map
|