@bigbinary/neeto-integrations-frontend 4.0.13 → 4.0.14

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telnyx.js","sources":["../../app/javascript/src/apis/telnyx.js","../../app/javascript/src/hooks/reactQuery/useTelnyxApi.js","../../app/javascript/src/components/Integrations/Telnyx/utils.js","../../app/javascript/src/components/Integrations/Telnyx/hooks/useTelnyxForm.js","../../app/javascript/src/components/Integrations/Telnyx/index.jsx"],"sourcesContent":["import axios from \"axios\";\n\nimport {\n TELNYX_PHONE_NUMBERS_URL,\n TELNYX_SMS_CONFIGURATION_URL,\n} from \"src/constants/urls\";\n\nconst fetchTelnyxSmsConfiguration = integrable =>\n axios.get(TELNYX_SMS_CONFIGURATION_URL, { params: integrable });\n\nconst fetchTelnyxPhoneNumbers = ({ apiKey, messagingProfileId }) =>\n axios.get(TELNYX_PHONE_NUMBERS_URL, {\n params: { telnyx: { apiKey, messagingProfileId } },\n });\n\nconst createTelnyxSmsConfiguration = payload =>\n axios.post(TELNYX_SMS_CONFIGURATION_URL, { telnyx: payload });\n\nconst telnyxApi = {\n fetchTelnyxPhoneNumbers,\n fetchTelnyxSmsConfiguration,\n createTelnyxSmsConfiguration,\n};\n\nexport default telnyxApi;\n","import { useQuery, useMutation } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\nimport { prop } from \"ramda\";\n\nimport telnyxApi from \"apis/telnyx\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nconst useFetchTelnyxSmsConfiguration = ({ integrable }) =>\n useQuery({\n queryKey: [\n QUERY_KEYS.TELNYX_SMS_CONFIGURATION,\n integrable?.integrableType,\n integrable?.integrableId,\n ],\n queryFn: () => telnyxApi.fetchTelnyxSmsConfiguration(integrable),\n select: prop(\"smsConfiguration\"),\n });\n\nconst useFetchTelnyxPhoneNumbers = () =>\n useMutation({ mutationFn: telnyxApi.fetchTelnyxPhoneNumbers });\n\nconst useCreateTelnyxSmsConfiguration = ({ integrable }) =>\n useMutationWithInvalidation(telnyxApi.createTelnyxSmsConfiguration, {\n keysToInvalidate: [\n [\n QUERY_KEYS.TELNYX_SMS_CONFIGURATION,\n integrable?.integrableType,\n integrable?.integrableId,\n ],\n ],\n });\n\nexport {\n useFetchTelnyxPhoneNumbers,\n useFetchTelnyxSmsConfiguration,\n useCreateTelnyxSmsConfiguration,\n};\n","import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const buildPhoneNumberOptions = phoneNumbers =>\n phoneNumbers\n ? phoneNumbers.map(({ id, phoneNumber }) => ({\n value: id,\n label: phoneNumber,\n }))\n : [];\n\nexport const buildTelnyxConfigurationValidationSchema = isPhoneNumberRequired =>\n yup.object().shape({\n apiKey: yup\n .string()\n .required(t(\"neetoIntegrations.telnyx.validations.apiKeyRequired\")),\n messagingProfileId: yup\n .string()\n .required(\n t(\"neetoIntegrations.telnyx.validations.messagingProfileIdRequired\")\n ),\n phoneNumber: isPhoneNumberRequired\n ? yup\n .object()\n .shape({ label: yup.string(), value: yup.string() })\n .nullable()\n .required(\n t(\"neetoIntegrations.telnyx.validations.phoneNumberRequired\")\n )\n : yup.mixed().nullable(),\n });\n","import { useState } from \"react\";\n\nimport { findBy } from \"neetocist\";\nimport { isEmpty } from \"ramda\";\n\nimport {\n useCreateTelnyxSmsConfiguration,\n useFetchTelnyxPhoneNumbers,\n useFetchTelnyxSmsConfiguration,\n} from \"hooks/reactQuery/useTelnyxApi\";\n\nimport { buildPhoneNumberOptions } from \"../utils\";\n\nconst useTelnyxForm = ({ integrable, onConnect }) => {\n const [phoneNumbers, setPhoneNumbers] = useState([]);\n\n const { data: configuration, isLoading } = useFetchTelnyxSmsConfiguration({\n integrable,\n });\n\n const {\n mutate: fetchTelnyxPhoneNumbers,\n isPending: isFetchPhoneNumbersLoading,\n } = useFetchTelnyxPhoneNumbers();\n\n const {\n mutate: createTelnyxSmsConfiguration,\n isPending: isCreateSmsConfigurationLoading,\n } = useCreateTelnyxSmsConfiguration({ integrable });\n\n const handleSubmit = values => {\n if (isEmpty(phoneNumbers)) {\n const params = {\n apiKey: values.apiKey,\n messagingProfileId: values.messagingProfileId,\n };\n\n fetchTelnyxPhoneNumbers(params, {\n onSuccess: ({ phoneNumbers }) => setPhoneNumbers(phoneNumbers),\n });\n\n return;\n }\n\n const payload = {\n apiKey: values.apiKey,\n messagingProfileId: values.messagingProfileId,\n phoneNumberId: values.phoneNumber.value,\n };\n\n createTelnyxSmsConfiguration(payload, { onSuccess: onConnect });\n };\n\n const isSubmitting =\n isFetchPhoneNumbersLoading || isCreateSmsConfigurationLoading;\n\n const phoneNumberOptions = buildPhoneNumberOptions(phoneNumbers);\n\n const initialValues = {\n apiKey: configuration?.apiKey || \"\",\n messagingProfileId: configuration?.messagingProfileId || \"\",\n phoneNumber:\n findBy({ label: configuration?.phoneNumber }, phoneNumberOptions) || null,\n };\n\n return {\n initialValues,\n phoneNumberOptions,\n isSubmitting,\n isLoading,\n handleSubmit,\n };\n};\n\nexport default useTelnyxForm;\n","import { useRef } from \"react\";\n\nimport { isNotEmpty, noop } from \"neetocist\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport PageLoader from \"neetomolecules/PageLoader\";\nimport { ActionBlock, Form, Input, Select } from \"neetoui/formik\";\nimport { isEmpty } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport useTelnyxForm from \"./hooks/useTelnyxForm\";\nimport { buildTelnyxConfigurationValidationSchema } from \"./utils\";\n\nconst Telnyx = ({ integrable = null, onClose = noop, onConnect = noop }) => {\n const formRef = useRef(null);\n\n const { t } = useTranslation();\n\n const {\n initialValues,\n handleSubmit,\n phoneNumberOptions,\n isSubmitting,\n isLoading,\n } = useTelnyxForm({ integrable, onConnect });\n\n const isPhoneNumberRequired = isNotEmpty(phoneNumberOptions);\n\n const submitButtonLabel = isNotEmpty(phoneNumberOptions)\n ? t(\"neetoIntegrations.common.saveChanges\")\n : t(\"neetoIntegrations.common.verify\");\n\n if (isLoading) return <PageLoader />;\n\n return (\n <Form\n className=\"w-full\"\n formikProps={{\n enableReinitialize: true,\n initialValues,\n validationSchema: buildTelnyxConfigurationValidationSchema(\n isPhoneNumberRequired\n ),\n innerRef: formRef,\n onSubmit: handleSubmit,\n }}\n >\n {({ dirty }) => (\n <CardLayout\n actionBlock={\n <ActionBlock\n {...{ isSubmitting }}\n cancelButtonProps={{ onClick: onClose }}\n submitButtonProps={{\n label: submitButtonLabel,\n // The button is disabled if phoneNumberOptions is empty and there is no apiKey in initialValues while the form is not dirty.\n // If phoneNumberOptions is not empty, the button is disabled when the form is unchanged.\n disabled: isEmpty(phoneNumberOptions)\n ? !initialValues.apiKey && !dirty\n : !dirty,\n }}\n />\n }\n >\n <div className=\"space-y-4\">\n <Input label={t(\"neetoIntegrations.telnyx.apiKey\")} name=\"apiKey\" />\n <Input\n label={t(\"neetoIntegrations.telnyx.messagingProfileId\")}\n name=\"messagingProfileId\"\n />\n {isNotEmpty(phoneNumberOptions) && (\n <Select\n label={t(\"neetoIntegrations.telnyx.phoneNumber\")}\n name=\"phoneNumber\"\n options={phoneNumberOptions}\n />\n )}\n </div>\n </CardLayout>\n )}\n </Form>\n );\n};\n\nexport default Telnyx;\n"],"names":["fetchTelnyxSmsConfiguration","integrable","axios","get","TELNYX_SMS_CONFIGURATION_URL","params","fetchTelnyxPhoneNumbers","_ref","apiKey","messagingProfileId","TELNYX_PHONE_NUMBERS_URL","telnyx","createTelnyxSmsConfiguration","payload","post","telnyxApi","useFetchTelnyxSmsConfiguration","useQuery","queryKey","QUERY_KEYS","TELNYX_SMS_CONFIGURATION","integrableType","integrableId","queryFn","select","prop","useFetchTelnyxPhoneNumbers","useMutation","mutationFn","useCreateTelnyxSmsConfiguration","_ref2","useMutationWithInvalidation","keysToInvalidate","buildPhoneNumberOptions","phoneNumbers","map","id","phoneNumber","value","label","buildTelnyxConfigurationValidationSchema","isPhoneNumberRequired","yup","object","shape","string","required","t","nullable","mixed","useTelnyxForm","onConnect","_useState","useState","_useState2","_slicedToArray","setPhoneNumbers","_useFetchTelnyxSmsCon","configuration","data","isLoading","_useFetchTelnyxPhoneN","mutate","isFetchPhoneNumbersLoading","isPending","_useCreateTelnyxSmsCo","isCreateSmsConfigurationLoading","handleSubmit","values","isEmpty","onSuccess","phoneNumberId","isSubmitting","phoneNumberOptions","initialValues","findBy","Telnyx","_ref$integrable","_ref$onClose","onClose","noop","_ref$onConnect","formRef","useRef","_useTranslation","useTranslation","_useTelnyxForm","isNotEmpty","submitButtonLabel","_jsx","PageLoader","Form","className","formikProps","enableReinitialize","validationSchema","innerRef","onSubmit","children","dirty","CardLayout","actionBlock","ActionBlock","cancelButtonProps","onClick","submitButtonProps","disabled","_jsxs","Input","name","Select","options"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAGC,UAAU,EAAA;AAAA,EAAA,OAC5CC,KAAK,CAACC,GAAG,CAACC,kCAA4B,EAAE;AAAEC,IAAAA,MAAM,EAAEJ;AAAW,GAAC,CAAC;AAAA,CAAA;AAEjE,IAAMK,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAAC,IAAA,EAAA;AAAA,EAAA,IAAMC,MAAM,GAAAD,IAAA,CAANC,MAAM;IAAEC,kBAAkB,GAAAF,IAAA,CAAlBE,kBAAkB;AAAA,EAAA,OAC3DP,KAAK,CAACC,GAAG,CAACO,8BAAwB,EAAE;AAClCL,IAAAA,MAAM,EAAE;AAAEM,MAAAA,MAAM,EAAE;AAAEH,QAAAA,MAAM,EAANA,MAAM;AAAEC,QAAAA,kBAAkB,EAAlBA;AAAmB;AAAE;AACnD,GAAC,CAAC;AAAA,CAAA;AAEJ,IAAMG,4BAA4B,GAAG,SAA/BA,4BAA4BA,CAAGC,OAAO,EAAA;AAAA,EAAA,OAC1CX,KAAK,CAACY,IAAI,C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AEtC;AAAmB,WAC7B,CACF;SACE;AAAC,OACI,CAAC;AAAA;AACd,GACG,CAAC;AAEX;;;;"}
package/dist/cjs/index.js CHANGED
@@ -5,24 +5,7 @@ var DisconnectAlert = require('./DisconnectAlert.js');
5
5
  var Daily = require('./Daily.js');
6
6
  var DailyForm = require('../Form-DlSv5McM.js');
7
7
  var GoogleCalendar = require('./GoogleCalendar.js');
8
- var React = require('react');
9
- var neetoCist = require('@bigbinary/neeto-cist');
10
- var CardLayout = require('@bigbinary/neeto-molecules/CardLayout');
11
- var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
12
- var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
13
- var Form = require('@bigbinary/neetoui/formik/Form');
14
- var Input = require('@bigbinary/neetoui/formik/Input');
15
- var Select = require('@bigbinary/neetoui/formik/Select');
16
- var ramda = require('ramda');
17
- var reactI18next = require('react-i18next');
18
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
19
- var reactQuery = require('@tanstack/react-query');
20
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
21
- var axios = require('axios');
22
- var query = require('../query-tu4TNsM9.js');
23
- var i18next = require('i18next');
24
- var yup = require('yup');
25
- var jsxRuntime = require('react/jsx-runtime');
8
+ var Telnyx = require('./Telnyx.js');
26
9
  var Twilio = require('./Twilio.js');
27
10
  var Zoom = require('./Zoom.js');
28
11
  var Modal = require('./Modal.js');
@@ -31,251 +14,56 @@ var Demo = require('./Demo.js');
31
14
  var Finish = require('./Finish.js');
32
15
  var WalkthroughModal = require('./WalkthroughModal.js');
33
16
  require('@babel/runtime/helpers/defineProperty');
17
+ require('@bigbinary/neeto-cist');
18
+ require('@bigbinary/neeto-commons-frontend/react-utils');
34
19
  require('@bigbinary/neeto-icons/Check');
35
20
  require('@bigbinary/neetoui/Button');
36
21
  require('@bigbinary/neetoui/Tooltip');
37
22
  require('@bigbinary/neetoui/Typography');
23
+ require('react-i18next');
24
+ require('react/jsx-runtime');
38
25
  require('@babel/runtime/helpers/objectWithoutProperties');
39
26
  require('@bigbinary/neeto-commons-frontend/react-utils/withT');
40
27
  require('@bigbinary/neetoui/Alert');
28
+ require('i18next');
29
+ require('@babel/runtime/helpers/slicedToArray');
30
+ require('react');
41
31
  require('@bigbinary/neeto-commons-frontend/utils');
42
32
  require('@bigbinary/neeto-icons/misc/Daily');
43
33
  require('@bigbinary/neeto-molecules/CopyToClipboardButton');
44
34
  require('@bigbinary/neetoui/Spinner');
35
+ require('@bigbinary/neeto-molecules/CardLayout');
45
36
  require('@bigbinary/neeto-molecules/Container');
46
37
  require('@bigbinary/neeto-molecules/Header');
38
+ require('@bigbinary/neetoui/formik/Input');
39
+ require('@bigbinary/neetoui/formik/Form');
40
+ require('@bigbinary/neetoui/formik/ActionBlock');
47
41
  require('react-router-dom');
42
+ require('@tanstack/react-query');
48
43
  require('@bigbinary/neeto-commons-frontend/constants');
44
+ require('axios');
45
+ require('../query-tu4TNsM9.js');
46
+ require('yup');
49
47
  require('@babel/runtime/helpers/toConsumableArray');
50
48
  require('@bigbinary/neeto-icons/misc/GoogleCalendar');
51
49
  require('@bigbinary/neeto-icons/misc/Google');
52
50
  require('@bigbinary/neetoui/Callout');
51
+ require('@bigbinary/neeto-molecules/PageLoader');
52
+ require('@bigbinary/neetoui/formik/Select');
53
+ require('ramda');
53
54
  require('@bigbinary/neeto-icons/misc/Zoom');
54
55
  require('@bigbinary/neetoui/Modal');
55
56
  require('classnames');
56
57
  require('../index-dxk7jTL7.js');
57
58
 
58
- function _interopNamespaceDefault(e) {
59
- var n = Object.create(null);
60
- if (e) {
61
- Object.keys(e).forEach(function (k) {
62
- if (k !== 'default') {
63
- var d = Object.getOwnPropertyDescriptor(e, k);
64
- Object.defineProperty(n, k, d.get ? d : {
65
- enumerable: true,
66
- get: function () { return e[k]; }
67
- });
68
- }
69
- });
70
- }
71
- n.default = e;
72
- return Object.freeze(n);
73
- }
74
59
 
75
- var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
76
-
77
- var fetchTelnyxSmsConfiguration = function fetchTelnyxSmsConfiguration(integrable) {
78
- return axios.get(query.TELNYX_SMS_CONFIGURATION_URL, {
79
- params: integrable
80
- });
81
- };
82
- var fetchTelnyxPhoneNumbers = function fetchTelnyxPhoneNumbers(_ref) {
83
- var apiKey = _ref.apiKey,
84
- messagingProfileId = _ref.messagingProfileId;
85
- return axios.get(query.TELNYX_PHONE_NUMBERS_URL, {
86
- params: {
87
- telnyx: {
88
- apiKey: apiKey,
89
- messagingProfileId: messagingProfileId
90
- }
91
- }
92
- });
93
- };
94
- var createTelnyxSmsConfiguration = function createTelnyxSmsConfiguration(payload) {
95
- return axios.post(query.TELNYX_SMS_CONFIGURATION_URL, {
96
- telnyx: payload
97
- });
98
- };
99
- var telnyxApi = {
100
- fetchTelnyxPhoneNumbers: fetchTelnyxPhoneNumbers,
101
- fetchTelnyxSmsConfiguration: fetchTelnyxSmsConfiguration,
102
- createTelnyxSmsConfiguration: createTelnyxSmsConfiguration
103
- };
104
-
105
- var useFetchTelnyxSmsConfiguration = function useFetchTelnyxSmsConfiguration(_ref) {
106
- var integrable = _ref.integrable;
107
- return reactQuery.useQuery({
108
- queryKey: [query.QUERY_KEYS.TELNYX_SMS_CONFIGURATION, integrable === null || integrable === void 0 ? void 0 : integrable.integrableType, integrable === null || integrable === void 0 ? void 0 : integrable.integrableId],
109
- queryFn: function queryFn() {
110
- return telnyxApi.fetchTelnyxSmsConfiguration(integrable);
111
- },
112
- select: ramda.prop("smsConfiguration")
113
- });
114
- };
115
- var useFetchTelnyxPhoneNumbers = function useFetchTelnyxPhoneNumbers() {
116
- return reactQuery.useMutation({
117
- mutationFn: telnyxApi.fetchTelnyxPhoneNumbers
118
- });
119
- };
120
- var useCreateTelnyxSmsConfiguration = function useCreateTelnyxSmsConfiguration(_ref2) {
121
- var integrable = _ref2.integrable;
122
- return reactUtils.useMutationWithInvalidation(telnyxApi.createTelnyxSmsConfiguration, {
123
- keysToInvalidate: [[query.QUERY_KEYS.TELNYX_SMS_CONFIGURATION, integrable === null || integrable === void 0 ? void 0 : integrable.integrableType, integrable === null || integrable === void 0 ? void 0 : integrable.integrableId]]
124
- });
125
- };
126
-
127
- var buildPhoneNumberOptions = function buildPhoneNumberOptions(phoneNumbers) {
128
- return phoneNumbers ? phoneNumbers.map(function (_ref) {
129
- var id = _ref.id,
130
- phoneNumber = _ref.phoneNumber;
131
- return {
132
- value: id,
133
- label: phoneNumber
134
- };
135
- }) : [];
136
- };
137
- var buildTelnyxConfigurationValidationSchema = function buildTelnyxConfigurationValidationSchema(isPhoneNumberRequired) {
138
- return yup__namespace.object().shape({
139
- apiKey: yup__namespace.string().required(i18next.t("neetoIntegrations.telnyx.validations.apiKeyRequired")),
140
- messagingProfileId: yup__namespace.string().required(i18next.t("neetoIntegrations.telnyx.validations.messagingProfileIdRequired")),
141
- phoneNumber: isPhoneNumberRequired ? yup__namespace.object().shape({
142
- label: yup__namespace.string(),
143
- value: yup__namespace.string()
144
- }).nullable().required(i18next.t("neetoIntegrations.telnyx.validations.phoneNumberRequired")) : yup__namespace.mixed().nullable()
145
- });
146
- };
147
-
148
- var useTelnyxForm = function useTelnyxForm(_ref) {
149
- var integrable = _ref.integrable,
150
- onConnect = _ref.onConnect;
151
- var _useState = React.useState([]),
152
- _useState2 = _slicedToArray(_useState, 2),
153
- phoneNumbers = _useState2[0],
154
- setPhoneNumbers = _useState2[1];
155
- var _useFetchTelnyxSmsCon = useFetchTelnyxSmsConfiguration({
156
- integrable: integrable
157
- }),
158
- configuration = _useFetchTelnyxSmsCon.data,
159
- isLoading = _useFetchTelnyxSmsCon.isLoading;
160
- var _useFetchTelnyxPhoneN = useFetchTelnyxPhoneNumbers(),
161
- fetchTelnyxPhoneNumbers = _useFetchTelnyxPhoneN.mutate,
162
- isFetchPhoneNumbersLoading = _useFetchTelnyxPhoneN.isPending;
163
- var _useCreateTelnyxSmsCo = useCreateTelnyxSmsConfiguration({
164
- integrable: integrable
165
- }),
166
- createTelnyxSmsConfiguration = _useCreateTelnyxSmsCo.mutate,
167
- isCreateSmsConfigurationLoading = _useCreateTelnyxSmsCo.isPending;
168
- var handleSubmit = function handleSubmit(values) {
169
- if (ramda.isEmpty(phoneNumbers)) {
170
- var params = {
171
- apiKey: values.apiKey,
172
- messagingProfileId: values.messagingProfileId
173
- };
174
- fetchTelnyxPhoneNumbers(params, {
175
- onSuccess: function onSuccess(_ref2) {
176
- var phoneNumbers = _ref2.phoneNumbers;
177
- return setPhoneNumbers(phoneNumbers);
178
- }
179
- });
180
- return;
181
- }
182
- var payload = {
183
- apiKey: values.apiKey,
184
- messagingProfileId: values.messagingProfileId,
185
- phoneNumberId: values.phoneNumber.value
186
- };
187
- createTelnyxSmsConfiguration(payload, {
188
- onSuccess: onConnect
189
- });
190
- };
191
- var isSubmitting = isFetchPhoneNumbersLoading || isCreateSmsConfigurationLoading;
192
- var phoneNumberOptions = buildPhoneNumberOptions(phoneNumbers);
193
- var initialValues = {
194
- apiKey: (configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) || "",
195
- messagingProfileId: (configuration === null || configuration === void 0 ? void 0 : configuration.messagingProfileId) || "",
196
- phoneNumber: neetoCist.findBy({
197
- label: configuration === null || configuration === void 0 ? void 0 : configuration.phoneNumber
198
- }, phoneNumberOptions) || null
199
- };
200
- return {
201
- initialValues: initialValues,
202
- phoneNumberOptions: phoneNumberOptions,
203
- isSubmitting: isSubmitting,
204
- isLoading: isLoading,
205
- handleSubmit: handleSubmit
206
- };
207
- };
208
-
209
- var Telnyx = function Telnyx(_ref) {
210
- var _ref$integrable = _ref.integrable,
211
- integrable = _ref$integrable === void 0 ? null : _ref$integrable,
212
- _ref$onClose = _ref.onClose,
213
- onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose,
214
- _ref$onConnect = _ref.onConnect,
215
- onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect;
216
- var formRef = React.useRef(null);
217
- var _useTranslation = reactI18next.useTranslation(),
218
- t = _useTranslation.t;
219
- var _useTelnyxForm = useTelnyxForm({
220
- integrable: integrable,
221
- onConnect: onConnect
222
- }),
223
- initialValues = _useTelnyxForm.initialValues,
224
- handleSubmit = _useTelnyxForm.handleSubmit,
225
- phoneNumberOptions = _useTelnyxForm.phoneNumberOptions,
226
- isSubmitting = _useTelnyxForm.isSubmitting,
227
- isLoading = _useTelnyxForm.isLoading;
228
- var isPhoneNumberRequired = neetoCist.isNotEmpty(phoneNumberOptions);
229
- var submitButtonLabel = neetoCist.isNotEmpty(phoneNumberOptions) ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify");
230
- if (isLoading) return /*#__PURE__*/jsxRuntime.jsx(PageLoader, {});
231
- return /*#__PURE__*/jsxRuntime.jsx(Form, {
232
- className: "w-full",
233
- formikProps: {
234
- enableReinitialize: true,
235
- initialValues: initialValues,
236
- validationSchema: buildTelnyxConfigurationValidationSchema(isPhoneNumberRequired),
237
- innerRef: formRef,
238
- onSubmit: handleSubmit
239
- },
240
- children: function children(_ref2) {
241
- var dirty = _ref2.dirty;
242
- return /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
243
- actionBlock: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
244
- isSubmitting: isSubmitting,
245
- cancelButtonProps: {
246
- onClick: onClose
247
- },
248
- submitButtonProps: {
249
- label: submitButtonLabel,
250
- // The button is disabled if phoneNumberOptions is empty and there is no apiKey in initialValues while the form is not dirty.
251
- // If phoneNumberOptions is not empty, the button is disabled when the form is unchanged.
252
- disabled: ramda.isEmpty(phoneNumberOptions) ? !initialValues.apiKey && !dirty : !dirty
253
- }
254
- }),
255
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
256
- className: "space-y-4",
257
- children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
258
- label: t("neetoIntegrations.telnyx.apiKey"),
259
- name: "apiKey"
260
- }), /*#__PURE__*/jsxRuntime.jsx(Input, {
261
- label: t("neetoIntegrations.telnyx.messagingProfileId"),
262
- name: "messagingProfileId"
263
- }), neetoCist.isNotEmpty(phoneNumberOptions) && /*#__PURE__*/jsxRuntime.jsx(Select, {
264
- label: t("neetoIntegrations.telnyx.phoneNumber"),
265
- name: "phoneNumber",
266
- options: phoneNumberOptions
267
- })]
268
- })
269
- });
270
- }
271
- });
272
- };
273
60
 
274
61
  exports.Manage = Manage;
275
62
  exports.DisconnectAlert = DisconnectAlert;
276
63
  exports.Daily = Daily;
277
64
  exports.DailyForm = DailyForm.Form;
278
65
  exports.GoogleCalendar = GoogleCalendar;
66
+ exports.Telnyx = Telnyx;
279
67
  exports.Twilio = Twilio;
280
68
  exports.Zoom = Zoom;
281
69
  exports.Modal = Modal;
@@ -283,5 +71,4 @@ exports.Connect = Connect;
283
71
  exports.Demo = Demo;
284
72
  exports.Finish = Finish;
285
73
  exports.WalkthroughModal = WalkthroughModal;
286
- exports.Telnyx = Telnyx;
287
74
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../app/javascript/src/apis/telnyx.js","../../app/javascript/src/hooks/reactQuery/useTelnyxApi.js","../../app/javascript/src/components/Integrations/Telnyx/utils.js","../../app/javascript/src/components/Integrations/Telnyx/hooks/useTelnyxForm.js","../../app/javascript/src/components/Integrations/Telnyx/index.jsx"],"sourcesContent":["import axios from \"axios\";\n\nimport {\n TELNYX_PHONE_NUMBERS_URL,\n TELNYX_SMS_CONFIGURATION_URL,\n} from \"src/constants/urls\";\n\nconst fetchTelnyxSmsConfiguration = integrable =>\n axios.get(TELNYX_SMS_CONFIGURATION_URL, { params: integrable });\n\nconst fetchTelnyxPhoneNumbers = ({ apiKey, messagingProfileId }) =>\n axios.get(TELNYX_PHONE_NUMBERS_URL, {\n params: { telnyx: { apiKey, messagingProfileId } },\n });\n\nconst createTelnyxSmsConfiguration = payload =>\n axios.post(TELNYX_SMS_CONFIGURATION_URL, { telnyx: payload });\n\nconst telnyxApi = {\n fetchTelnyxPhoneNumbers,\n fetchTelnyxSmsConfiguration,\n createTelnyxSmsConfiguration,\n};\n\nexport default telnyxApi;\n","import { useQuery, useMutation } from \"@tanstack/react-query\";\nimport { useMutationWithInvalidation } from \"neetocommons/react-utils\";\nimport { prop } from \"ramda\";\n\nimport telnyxApi from \"apis/telnyx\";\nimport { QUERY_KEYS } from \"src/constants/query\";\n\nconst useFetchTelnyxSmsConfiguration = ({ integrable }) =>\n useQuery({\n queryKey: [\n QUERY_KEYS.TELNYX_SMS_CONFIGURATION,\n integrable?.integrableType,\n integrable?.integrableId,\n ],\n queryFn: () => telnyxApi.fetchTelnyxSmsConfiguration(integrable),\n select: prop(\"smsConfiguration\"),\n });\n\nconst useFetchTelnyxPhoneNumbers = () =>\n useMutation({ mutationFn: telnyxApi.fetchTelnyxPhoneNumbers });\n\nconst useCreateTelnyxSmsConfiguration = ({ integrable }) =>\n useMutationWithInvalidation(telnyxApi.createTelnyxSmsConfiguration, {\n keysToInvalidate: [\n [\n QUERY_KEYS.TELNYX_SMS_CONFIGURATION,\n integrable?.integrableType,\n integrable?.integrableId,\n ],\n ],\n });\n\nexport {\n useFetchTelnyxPhoneNumbers,\n useFetchTelnyxSmsConfiguration,\n useCreateTelnyxSmsConfiguration,\n};\n","import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const buildPhoneNumberOptions = phoneNumbers =>\n phoneNumbers\n ? phoneNumbers.map(({ id, phoneNumber }) => ({\n value: id,\n label: phoneNumber,\n }))\n : [];\n\nexport const buildTelnyxConfigurationValidationSchema = isPhoneNumberRequired =>\n yup.object().shape({\n apiKey: yup\n .string()\n .required(t(\"neetoIntegrations.telnyx.validations.apiKeyRequired\")),\n messagingProfileId: yup\n .string()\n .required(\n t(\"neetoIntegrations.telnyx.validations.messagingProfileIdRequired\")\n ),\n phoneNumber: isPhoneNumberRequired\n ? yup\n .object()\n .shape({ label: yup.string(), value: yup.string() })\n .nullable()\n .required(\n t(\"neetoIntegrations.telnyx.validations.phoneNumberRequired\")\n )\n : yup.mixed().nullable(),\n });\n","import { useState } from \"react\";\n\nimport { findBy } from \"neetocist\";\nimport { isEmpty } from \"ramda\";\n\nimport {\n useCreateTelnyxSmsConfiguration,\n useFetchTelnyxPhoneNumbers,\n useFetchTelnyxSmsConfiguration,\n} from \"hooks/reactQuery/useTelnyxApi\";\n\nimport { buildPhoneNumberOptions } from \"../utils\";\n\nconst useTelnyxForm = ({ integrable, onConnect }) => {\n const [phoneNumbers, setPhoneNumbers] = useState([]);\n\n const { data: configuration, isLoading } = useFetchTelnyxSmsConfiguration({\n integrable,\n });\n\n const {\n mutate: fetchTelnyxPhoneNumbers,\n isPending: isFetchPhoneNumbersLoading,\n } = useFetchTelnyxPhoneNumbers();\n\n const {\n mutate: createTelnyxSmsConfiguration,\n isPending: isCreateSmsConfigurationLoading,\n } = useCreateTelnyxSmsConfiguration({ integrable });\n\n const handleSubmit = values => {\n if (isEmpty(phoneNumbers)) {\n const params = {\n apiKey: values.apiKey,\n messagingProfileId: values.messagingProfileId,\n };\n\n fetchTelnyxPhoneNumbers(params, {\n onSuccess: ({ phoneNumbers }) => setPhoneNumbers(phoneNumbers),\n });\n\n return;\n }\n\n const payload = {\n apiKey: values.apiKey,\n messagingProfileId: values.messagingProfileId,\n phoneNumberId: values.phoneNumber.value,\n };\n\n createTelnyxSmsConfiguration(payload, { onSuccess: onConnect });\n };\n\n const isSubmitting =\n isFetchPhoneNumbersLoading || isCreateSmsConfigurationLoading;\n\n const phoneNumberOptions = buildPhoneNumberOptions(phoneNumbers);\n\n const initialValues = {\n apiKey: configuration?.apiKey || \"\",\n messagingProfileId: configuration?.messagingProfileId || \"\",\n phoneNumber:\n findBy({ label: configuration?.phoneNumber }, phoneNumberOptions) || null,\n };\n\n return {\n initialValues,\n phoneNumberOptions,\n isSubmitting,\n isLoading,\n handleSubmit,\n };\n};\n\nexport default useTelnyxForm;\n","import { useRef } from \"react\";\n\nimport { isNotEmpty, noop } from \"neetocist\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport PageLoader from \"neetomolecules/PageLoader\";\nimport { ActionBlock, Form, Input, Select } from \"neetoui/formik\";\nimport { isEmpty } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport useTelnyxForm from \"./hooks/useTelnyxForm\";\nimport { buildTelnyxConfigurationValidationSchema } from \"./utils\";\n\nconst Telnyx = ({ integrable = null, onClose = noop, onConnect = noop }) => {\n const formRef = useRef(null);\n\n const { t } = useTranslation();\n\n const {\n initialValues,\n handleSubmit,\n phoneNumberOptions,\n isSubmitting,\n isLoading,\n } = useTelnyxForm({ integrable, onConnect });\n\n const isPhoneNumberRequired = isNotEmpty(phoneNumberOptions);\n\n const submitButtonLabel = isNotEmpty(phoneNumberOptions)\n ? t(\"neetoIntegrations.common.saveChanges\")\n : t(\"neetoIntegrations.common.verify\");\n\n if (isLoading) return <PageLoader />;\n\n return (\n <Form\n className=\"w-full\"\n formikProps={{\n enableReinitialize: true,\n initialValues,\n validationSchema: buildTelnyxConfigurationValidationSchema(\n isPhoneNumberRequired\n ),\n innerRef: formRef,\n onSubmit: handleSubmit,\n }}\n >\n {({ dirty }) => (\n <CardLayout\n actionBlock={\n <ActionBlock\n {...{ isSubmitting }}\n cancelButtonProps={{ onClick: onClose }}\n submitButtonProps={{\n label: submitButtonLabel,\n // The button is disabled if phoneNumberOptions is empty and there is no apiKey in initialValues while the form is not dirty.\n // If phoneNumberOptions is not empty, the button is disabled when the form is unchanged.\n disabled: isEmpty(phoneNumberOptions)\n ? !initialValues.apiKey && !dirty\n : !dirty,\n }}\n />\n }\n >\n <div className=\"space-y-4\">\n <Input label={t(\"neetoIntegrations.telnyx.apiKey\")} name=\"apiKey\" />\n <Input\n label={t(\"neetoIntegrations.telnyx.messagingProfileId\")}\n name=\"messagingProfileId\"\n />\n {isNotEmpty(phoneNumberOptions) && (\n <Select\n label={t(\"neetoIntegrations.telnyx.phoneNumber\")}\n name=\"phoneNumber\"\n options={phoneNumberOptions}\n />\n )}\n </div>\n </CardLayout>\n )}\n </Form>\n );\n};\n\nexport default Telnyx;\n"],"names":["fetchTelnyxSmsConfiguration","integrable","axios","get","TELNYX_SMS_CONFIGURATION_URL","params","fetchTelnyxPhoneNumbers","_ref","apiKey","messagingProfileId","TELNYX_PHONE_NUMBERS_URL","telnyx","createTelnyxSmsConfiguration","payload","post","telnyxApi","useFetchTelnyxSmsConfiguration","useQuery","queryKey","QUERY_KEYS","TELNYX_SMS_CONFIGURATION","integrableType","integrableId","queryFn","select","prop","useFetchTelnyxPhoneNumbers","useMutation","mutationFn","useCreateTelnyxSmsConfiguration","_ref2","useMutationWithInvalidation","keysToInvalidate","buildPhoneNumberOptions","phoneNumbers","map","id","phoneNumber","value","label","buildTelnyxConfigurationValidationSchema","isPhoneNumberRequired","yup","object","shape","string","required","t","nullable","mixed","useTelnyxForm","onConnect","_useState","useState","_useState2","_slicedToArray","setPhoneNumbers","_useFetchTelnyxSmsCon","configuration","data","isLoading","_useFetchTelnyxPhoneN","mutate","isFetchPhoneNumbersLoading","isPending","_useCreateTelnyxSmsCo","isCreateSmsConfigurationLoading","handleSubmit","values","isEmpty","onSuccess","phoneNumberId","isSubmitting","phoneNumberOptions","initialValues","findBy","Telnyx","_ref$integrable","_ref$onClose","onClose","noop","_ref$onConnect","formRef","useRef","_useTranslation","useTranslation","_useTelnyxForm","isNotEmpty","submitButtonLabel","_jsx","PageLoader","Form","className","formikProps","enableReinitialize","validationSchema","innerRef","onSubmit","children","dirty","CardLayout","actionBlock","ActionBlock","cancelButtonProps","onClick","submitButtonProps","disabled","_jsxs","Input","name","Select","options"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAGC,UAAU,EAAA;AAAA,EAAA,OAC5CC,KAAK,CAACC,GAAG,CAACC,kCAA4B,EAAE;AAAEC,IAAAA,MAAM,EAAEJ;AAAW,GAAC,CAA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AAA;AAAKf,UAAAA,SAAS,EAAC,WAAW;UAAAM,QAAA,EAAA,cACxBT,cAAA,CAACmB,KAAK,EAAA;AAACrE,YAAAA,KAAK,EAAEQ,CAAC,CAAC,iCAAiC,CAAE;AAAC8D,YAAAA,IAAI,EAAC;AAAQ,WAAE,CAAC,eACpEpB,cAAA,CAACmB,KAAK,EAAA;AACJrE,YAAAA,KAAK,EAAEQ,CAAC,CAAC,6CAA6C,CAAE;AACxD8D,YAAAA,IAAI,EAAC;WACN,CAAC,EACDtB,oBAAU,CAACd,kBAAkB,CAAC,iBAC7BgB,cAAA,CAACqB,MAAM,EAAA;AACLvE,YAAAA,KAAK,EAAEQ,CAAC,CAAC,sCAAsC,CAAE;AACjD8D,YAAAA,IAAI,EAAC,aAAa;AAClBE,YAAAA,OAAO,EAAEtC;AAAmB,WAC7B,CACF;SACE;AAAC,OACI,CAAC;AAAA;AACd,GACG,CAAC;AAEX;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,26 +1,9 @@
1
1
  export { default as Manage } from './Manage.js';
2
2
  export { default as DisconnectAlert } from './DisconnectAlert.js';
3
3
  export { default as Daily } from './Daily.js';
4
- export { F as DailyForm } from './Form-DGYvhKlX.js';
4
+ export { F as DailyForm } from './Form-DKAK6ylB.js';
5
5
  export { default as GoogleCalendar } from './GoogleCalendar.js';
6
- import { useState, useRef } from 'react';
7
- import { findBy, isNotEmpty, noop } from '@bigbinary/neeto-cist';
8
- import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
9
- import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
10
- import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
11
- import Form from '@bigbinary/neetoui/formik/Form';
12
- import Input from '@bigbinary/neetoui/formik/Input';
13
- import Select from '@bigbinary/neetoui/formik/Select';
14
- import { prop, isEmpty } from 'ramda';
15
- import { useTranslation } from 'react-i18next';
16
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
17
- import { useQuery, useMutation } from '@tanstack/react-query';
18
- import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
19
- import axios from 'axios';
20
- import { T as TELNYX_SMS_CONFIGURATION_URL, a as TELNYX_PHONE_NUMBERS_URL, Q as QUERY_KEYS } from './query-CSH3yyWi.js';
21
- import { t } from 'i18next';
22
- import * as yup from 'yup';
23
- import { jsx, jsxs } from 'react/jsx-runtime';
6
+ export { default as Telnyx } from './Telnyx.js';
24
7
  export { default as Twilio } from './Twilio.js';
25
8
  export { default as Zoom } from './Zoom.js';
26
9
  export { default as Modal } from './Modal.js';
@@ -29,226 +12,45 @@ export { default as Demo } from './Demo.js';
29
12
  export { default as Finish } from './Finish.js';
30
13
  export { default as WalkthroughModal } from './WalkthroughModal.js';
31
14
  import '@babel/runtime/helpers/defineProperty';
15
+ import '@bigbinary/neeto-cist';
16
+ import '@bigbinary/neeto-commons-frontend/react-utils';
32
17
  import '@bigbinary/neeto-icons/Check';
33
18
  import '@bigbinary/neetoui/Button';
34
19
  import '@bigbinary/neetoui/Tooltip';
35
20
  import '@bigbinary/neetoui/Typography';
21
+ import 'react-i18next';
22
+ import 'react/jsx-runtime';
36
23
  import '@babel/runtime/helpers/objectWithoutProperties';
37
24
  import '@bigbinary/neeto-commons-frontend/react-utils/withT';
38
25
  import '@bigbinary/neetoui/Alert';
26
+ import 'i18next';
27
+ import '@babel/runtime/helpers/slicedToArray';
28
+ import 'react';
39
29
  import '@bigbinary/neeto-commons-frontend/utils';
40
30
  import '@bigbinary/neeto-icons/misc/Daily';
41
31
  import '@bigbinary/neeto-molecules/CopyToClipboardButton';
42
32
  import '@bigbinary/neetoui/Spinner';
33
+ import '@bigbinary/neeto-molecules/CardLayout';
43
34
  import '@bigbinary/neeto-molecules/Container';
44
35
  import '@bigbinary/neeto-molecules/Header';
36
+ import '@bigbinary/neetoui/formik/Input';
37
+ import '@bigbinary/neetoui/formik/Form';
38
+ import '@bigbinary/neetoui/formik/ActionBlock';
45
39
  import 'react-router-dom';
40
+ import '@tanstack/react-query';
46
41
  import '@bigbinary/neeto-commons-frontend/constants';
42
+ import 'axios';
43
+ import './query-DWavsm0z.js';
44
+ import 'yup';
47
45
  import '@babel/runtime/helpers/toConsumableArray';
48
46
  import '@bigbinary/neeto-icons/misc/GoogleCalendar';
49
47
  import '@bigbinary/neeto-icons/misc/Google';
50
48
  import '@bigbinary/neetoui/Callout';
49
+ import '@bigbinary/neeto-molecules/PageLoader';
50
+ import '@bigbinary/neetoui/formik/Select';
51
+ import 'ramda';
51
52
  import '@bigbinary/neeto-icons/misc/Zoom';
52
53
  import '@bigbinary/neetoui/Modal';
53
54
  import 'classnames';
54
55
  import './index-MS1ts-9f.js';
55
-
56
- var fetchTelnyxSmsConfiguration = function fetchTelnyxSmsConfiguration(integrable) {
57
- return axios.get(TELNYX_SMS_CONFIGURATION_URL, {
58
- params: integrable
59
- });
60
- };
61
- var fetchTelnyxPhoneNumbers = function fetchTelnyxPhoneNumbers(_ref) {
62
- var apiKey = _ref.apiKey,
63
- messagingProfileId = _ref.messagingProfileId;
64
- return axios.get(TELNYX_PHONE_NUMBERS_URL, {
65
- params: {
66
- telnyx: {
67
- apiKey: apiKey,
68
- messagingProfileId: messagingProfileId
69
- }
70
- }
71
- });
72
- };
73
- var createTelnyxSmsConfiguration = function createTelnyxSmsConfiguration(payload) {
74
- return axios.post(TELNYX_SMS_CONFIGURATION_URL, {
75
- telnyx: payload
76
- });
77
- };
78
- var telnyxApi = {
79
- fetchTelnyxPhoneNumbers: fetchTelnyxPhoneNumbers,
80
- fetchTelnyxSmsConfiguration: fetchTelnyxSmsConfiguration,
81
- createTelnyxSmsConfiguration: createTelnyxSmsConfiguration
82
- };
83
-
84
- var useFetchTelnyxSmsConfiguration = function useFetchTelnyxSmsConfiguration(_ref) {
85
- var integrable = _ref.integrable;
86
- return useQuery({
87
- queryKey: [QUERY_KEYS.TELNYX_SMS_CONFIGURATION, integrable === null || integrable === void 0 ? void 0 : integrable.integrableType, integrable === null || integrable === void 0 ? void 0 : integrable.integrableId],
88
- queryFn: function queryFn() {
89
- return telnyxApi.fetchTelnyxSmsConfiguration(integrable);
90
- },
91
- select: prop("smsConfiguration")
92
- });
93
- };
94
- var useFetchTelnyxPhoneNumbers = function useFetchTelnyxPhoneNumbers() {
95
- return useMutation({
96
- mutationFn: telnyxApi.fetchTelnyxPhoneNumbers
97
- });
98
- };
99
- var useCreateTelnyxSmsConfiguration = function useCreateTelnyxSmsConfiguration(_ref2) {
100
- var integrable = _ref2.integrable;
101
- return useMutationWithInvalidation(telnyxApi.createTelnyxSmsConfiguration, {
102
- keysToInvalidate: [[QUERY_KEYS.TELNYX_SMS_CONFIGURATION, integrable === null || integrable === void 0 ? void 0 : integrable.integrableType, integrable === null || integrable === void 0 ? void 0 : integrable.integrableId]]
103
- });
104
- };
105
-
106
- var buildPhoneNumberOptions = function buildPhoneNumberOptions(phoneNumbers) {
107
- return phoneNumbers ? phoneNumbers.map(function (_ref) {
108
- var id = _ref.id,
109
- phoneNumber = _ref.phoneNumber;
110
- return {
111
- value: id,
112
- label: phoneNumber
113
- };
114
- }) : [];
115
- };
116
- var buildTelnyxConfigurationValidationSchema = function buildTelnyxConfigurationValidationSchema(isPhoneNumberRequired) {
117
- return yup.object().shape({
118
- apiKey: yup.string().required(t("neetoIntegrations.telnyx.validations.apiKeyRequired")),
119
- messagingProfileId: yup.string().required(t("neetoIntegrations.telnyx.validations.messagingProfileIdRequired")),
120
- phoneNumber: isPhoneNumberRequired ? yup.object().shape({
121
- label: yup.string(),
122
- value: yup.string()
123
- }).nullable().required(t("neetoIntegrations.telnyx.validations.phoneNumberRequired")) : yup.mixed().nullable()
124
- });
125
- };
126
-
127
- var useTelnyxForm = function useTelnyxForm(_ref) {
128
- var integrable = _ref.integrable,
129
- onConnect = _ref.onConnect;
130
- var _useState = useState([]),
131
- _useState2 = _slicedToArray(_useState, 2),
132
- phoneNumbers = _useState2[0],
133
- setPhoneNumbers = _useState2[1];
134
- var _useFetchTelnyxSmsCon = useFetchTelnyxSmsConfiguration({
135
- integrable: integrable
136
- }),
137
- configuration = _useFetchTelnyxSmsCon.data,
138
- isLoading = _useFetchTelnyxSmsCon.isLoading;
139
- var _useFetchTelnyxPhoneN = useFetchTelnyxPhoneNumbers(),
140
- fetchTelnyxPhoneNumbers = _useFetchTelnyxPhoneN.mutate,
141
- isFetchPhoneNumbersLoading = _useFetchTelnyxPhoneN.isPending;
142
- var _useCreateTelnyxSmsCo = useCreateTelnyxSmsConfiguration({
143
- integrable: integrable
144
- }),
145
- createTelnyxSmsConfiguration = _useCreateTelnyxSmsCo.mutate,
146
- isCreateSmsConfigurationLoading = _useCreateTelnyxSmsCo.isPending;
147
- var handleSubmit = function handleSubmit(values) {
148
- if (isEmpty(phoneNumbers)) {
149
- var params = {
150
- apiKey: values.apiKey,
151
- messagingProfileId: values.messagingProfileId
152
- };
153
- fetchTelnyxPhoneNumbers(params, {
154
- onSuccess: function onSuccess(_ref2) {
155
- var phoneNumbers = _ref2.phoneNumbers;
156
- return setPhoneNumbers(phoneNumbers);
157
- }
158
- });
159
- return;
160
- }
161
- var payload = {
162
- apiKey: values.apiKey,
163
- messagingProfileId: values.messagingProfileId,
164
- phoneNumberId: values.phoneNumber.value
165
- };
166
- createTelnyxSmsConfiguration(payload, {
167
- onSuccess: onConnect
168
- });
169
- };
170
- var isSubmitting = isFetchPhoneNumbersLoading || isCreateSmsConfigurationLoading;
171
- var phoneNumberOptions = buildPhoneNumberOptions(phoneNumbers);
172
- var initialValues = {
173
- apiKey: (configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) || "",
174
- messagingProfileId: (configuration === null || configuration === void 0 ? void 0 : configuration.messagingProfileId) || "",
175
- phoneNumber: findBy({
176
- label: configuration === null || configuration === void 0 ? void 0 : configuration.phoneNumber
177
- }, phoneNumberOptions) || null
178
- };
179
- return {
180
- initialValues: initialValues,
181
- phoneNumberOptions: phoneNumberOptions,
182
- isSubmitting: isSubmitting,
183
- isLoading: isLoading,
184
- handleSubmit: handleSubmit
185
- };
186
- };
187
-
188
- var Telnyx = function Telnyx(_ref) {
189
- var _ref$integrable = _ref.integrable,
190
- integrable = _ref$integrable === void 0 ? null : _ref$integrable,
191
- _ref$onClose = _ref.onClose,
192
- onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
193
- _ref$onConnect = _ref.onConnect,
194
- onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect;
195
- var formRef = useRef(null);
196
- var _useTranslation = useTranslation(),
197
- t = _useTranslation.t;
198
- var _useTelnyxForm = useTelnyxForm({
199
- integrable: integrable,
200
- onConnect: onConnect
201
- }),
202
- initialValues = _useTelnyxForm.initialValues,
203
- handleSubmit = _useTelnyxForm.handleSubmit,
204
- phoneNumberOptions = _useTelnyxForm.phoneNumberOptions,
205
- isSubmitting = _useTelnyxForm.isSubmitting,
206
- isLoading = _useTelnyxForm.isLoading;
207
- var isPhoneNumberRequired = isNotEmpty(phoneNumberOptions);
208
- var submitButtonLabel = isNotEmpty(phoneNumberOptions) ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify");
209
- if (isLoading) return /*#__PURE__*/jsx(PageLoader, {});
210
- return /*#__PURE__*/jsx(Form, {
211
- className: "w-full",
212
- formikProps: {
213
- enableReinitialize: true,
214
- initialValues: initialValues,
215
- validationSchema: buildTelnyxConfigurationValidationSchema(isPhoneNumberRequired),
216
- innerRef: formRef,
217
- onSubmit: handleSubmit
218
- },
219
- children: function children(_ref2) {
220
- var dirty = _ref2.dirty;
221
- return /*#__PURE__*/jsx(CardLayout, {
222
- actionBlock: /*#__PURE__*/jsx(ActionBlock, {
223
- isSubmitting: isSubmitting,
224
- cancelButtonProps: {
225
- onClick: onClose
226
- },
227
- submitButtonProps: {
228
- label: submitButtonLabel,
229
- // The button is disabled if phoneNumberOptions is empty and there is no apiKey in initialValues while the form is not dirty.
230
- // If phoneNumberOptions is not empty, the button is disabled when the form is unchanged.
231
- disabled: isEmpty(phoneNumberOptions) ? !initialValues.apiKey && !dirty : !dirty
232
- }
233
- }),
234
- children: /*#__PURE__*/jsxs("div", {
235
- className: "space-y-4",
236
- children: [/*#__PURE__*/jsx(Input, {
237
- label: t("neetoIntegrations.telnyx.apiKey"),
238
- name: "apiKey"
239
- }), /*#__PURE__*/jsx(Input, {
240
- label: t("neetoIntegrations.telnyx.messagingProfileId"),
241
- name: "messagingProfileId"
242
- }), isNotEmpty(phoneNumberOptions) && /*#__PURE__*/jsx(Select, {
243
- label: t("neetoIntegrations.telnyx.phoneNumber"),
244
- name: "phoneNumber",
245
- options: phoneNumberOptions
246
- })]
247
- })
248
- });
249
- }
250
- });
251
- };
252
-
253
- export { Telnyx };
254
56
  //# sourceMappingURL=index.js.map