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