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