@bigbinary/neeto-integrations-frontend 4.0.37 → 4.0.38
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/app/javascript/src/translations/en.json +22 -1
- package/dist/.ready +1 -1
- package/dist/DailyForm.js +2 -2
- package/dist/DailyForm.js.map +1 -1
- package/dist/Telnyx.js +321 -101
- package/dist/Telnyx.js.map +1 -1
- package/dist/Twilio.js +50 -19
- package/dist/Twilio.js.map +1 -1
- package/dist/ZapierForm.js +2 -2
- package/dist/ZapierForm.js.map +1 -1
- package/dist/cjs/DailyForm.js +2 -2
- package/dist/cjs/DailyForm.js.map +1 -1
- package/dist/cjs/Telnyx.js +319 -99
- package/dist/cjs/Telnyx.js.map +1 -1
- package/dist/cjs/Twilio.js +49 -18
- package/dist/cjs/Twilio.js.map +1 -1
- package/dist/cjs/ZapierForm.js +2 -2
- package/dist/cjs/ZapierForm.js.map +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/v2/Telnyx.js +314 -93
- package/dist/cjs/v2/Telnyx.js.map +1 -1
- package/dist/cjs/v2/Twilio.js +45 -16
- package/dist/cjs/v2/Twilio.js.map +1 -1
- package/dist/cjs/v2/index.js +3 -3
- package/dist/index.js +3 -3
- package/dist/useTelnyxApi-B3EKAxdZ.js +136 -0
- package/dist/useTelnyxApi-B3EKAxdZ.js.map +1 -0
- package/dist/useTelnyxApi-RuLwKpN1.js +131 -0
- package/dist/useTelnyxApi-RuLwKpN1.js.map +1 -0
- package/dist/{useTwilioApi-C57UuOda.js → useTwilioApi-C067pCq3.js} +35 -7
- package/dist/useTwilioApi-C067pCq3.js.map +1 -0
- package/dist/{useTwilioApi-CUL0-Xgf.js → useTwilioApi-YSNLrDpP.js} +35 -6
- package/dist/useTwilioApi-YSNLrDpP.js.map +1 -0
- package/dist/v2/Telnyx.js +318 -97
- package/dist/v2/Telnyx.js.map +1 -1
- package/dist/v2/Twilio.js +47 -18
- package/dist/v2/Twilio.js.map +1 -1
- package/dist/v2/index.js +3 -3
- package/package.json +7 -7
- package/dist/useTelnyxApi-Cv5cIiuo.js +0 -58
- package/dist/useTelnyxApi-Cv5cIiuo.js.map +0 -1
- package/dist/useTelnyxApi-DS3IVijP.js +0 -62
- package/dist/useTelnyxApi-DS3IVijP.js.map +0 -1
- package/dist/useTwilioApi-C57UuOda.js.map +0 -1
- package/dist/useTwilioApi-CUL0-Xgf.js.map +0 -1
|
@@ -94,12 +94,33 @@
|
|
|
94
94
|
"invalidCredentials": "Twilio credentials are invalid",
|
|
95
95
|
"invalidPhoneNumberConfig": "Twilio phone number is invalid",
|
|
96
96
|
"invalidMessagingServiceConfig": "Twilio messaging service is invalid"
|
|
97
|
-
}
|
|
97
|
+
},
|
|
98
|
+
"zeroSendersWarning": "This messaging service has no senders attached. Without those senders, you won't be able to send SMS messages. Add a phone number, short code, or alpha sender in Twilio before SMS will deliver."
|
|
98
99
|
},
|
|
99
100
|
"telnyx": {
|
|
100
101
|
"apiKey": "API key",
|
|
101
102
|
"messagingProfileId": "Messaging Profile ID",
|
|
102
103
|
"phoneNumber": "Phone number",
|
|
104
|
+
"zeroSendersWarning": "This messaging profile has no senders attached. Without those senders, you won't be able to send SMS messages. Add a phone number or sender ID in Telnyx before SMS will deliver.",
|
|
105
|
+
"smsSendingMethod": {
|
|
106
|
+
"title": "SMS sending method",
|
|
107
|
+
"subtitle": "Choose how messages are sent. We recommend a messaging profile for better routing."
|
|
108
|
+
},
|
|
109
|
+
"connectionType": {
|
|
110
|
+
"phoneNumber": {
|
|
111
|
+
"label": "Phone number",
|
|
112
|
+
"description": "Send from a specific Telnyx phone number."
|
|
113
|
+
},
|
|
114
|
+
"messagingProfile": {
|
|
115
|
+
"label": "Messaging profile",
|
|
116
|
+
"description": "Let Telnyx route messages through the profile's attached senders.",
|
|
117
|
+
"recommendedBadge": "Recommended"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"messagingProfile": {
|
|
121
|
+
"label": "Messaging profile",
|
|
122
|
+
"placeholder": "Select a messaging profile"
|
|
123
|
+
},
|
|
103
124
|
"validations": {
|
|
104
125
|
"apiKeyRequired": "API key is required.",
|
|
105
126
|
"messagingProfileIdRequired": "Messaging Profile ID is required.",
|
package/dist/.ready
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Built at 2026-05-
|
|
1
|
+
Built at 2026-05-28T12:50:10.115Z
|
package/dist/DailyForm.js
CHANGED
|
@@ -9,7 +9,7 @@ import Button from '@bigbinary/neetoui/Button';
|
|
|
9
9
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
10
10
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
11
11
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
12
|
-
import
|
|
12
|
+
import FormikFormWrapper from '@bigbinary/neetoui/formik/Form';
|
|
13
13
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
14
14
|
import { useTranslation, Trans } from 'react-i18next';
|
|
15
15
|
import { useHistory } from 'react-router-dom';
|
|
@@ -92,7 +92,7 @@ var Form = function Form(_ref) {
|
|
|
92
92
|
}
|
|
93
93
|
}), /*#__PURE__*/jsxs("div", {
|
|
94
94
|
className: "w-full",
|
|
95
|
-
children: [/*#__PURE__*/jsx(
|
|
95
|
+
children: [/*#__PURE__*/jsx(FormikFormWrapper, {
|
|
96
96
|
formikProps: {
|
|
97
97
|
initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,
|
|
98
98
|
validationSchema: DAILY_CO_VALIDATION_SCHEMA,
|
package/dist/DailyForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DailyForm.js","sources":["../app/javascript/src/components/Integrations/Daily/constants.js","../app/javascript/src/components/Integrations/Daily/Form.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const MANAGE_DAILY_CO_FORM_INITIAL_VALUES = { apiKey: \"\" };\n\nexport const DAILY_CO_VALIDATION_SCHEMA = yup.object().shape({\n apiKey: yup\n .string()\n .trim()\n .required(\n t(\"neetoIntegrations.errors.required\", {\n entity: t(\"neetoIntegrations.daily.apiKey\"),\n })\n ),\n});\n","import { useState } from \"react\";\n\nimport i18next from \"i18next\";\nimport { withTitle } from \"neetocommons/react-utils\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport Container from \"neetomolecules/Container\";\nimport Header from \"neetomolecules/Header\";\nimport { Button, Spinner, Typography } from \"neetoui\";\nimport { Input, Form as FormikForm, ActionBlock } from \"neetoui/formik\";\nimport { Trans, useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport WalkthroughModal from \"components/WalkthroughModal\";\nimport { useCreateDaily } from \"hooks/reactQuery/useDailiesApi\";\n\nimport {\n MANAGE_DAILY_CO_FORM_INITIAL_VALUES,\n DAILY_CO_VALIDATION_SCHEMA,\n} from \"./constants\";\n\nconst Form = ({ helpDocUrl, videoUrl, onConnect, breadcrumbs }) => {\n const { t } = useTranslation();\n const history = useHistory();\n\n const [isDemoModalOpen, setIsDemoModalOpen] = useState(false);\n\n const { mutate: createDaily, isPending: isConnecting } = useCreateDaily({\n onSuccess: () => onConnect?.(),\n });\n\n const handleSubmit = payload => createDaily(payload);\n\n if (isConnecting) {\n return (\n <div className=\"flex h-full w-full items-center justify-center\">\n <Spinner />\n </div>\n );\n }\n\n return (\n <Container isHeaderFixed>\n <Header\n {...{ breadcrumbs }}\n title={t(\"neetoIntegrations.daily.connect.title\")}\n titleHelpPopoverProps={{\n title: t(\"neetoIntegrations.daily.connect.title\"),\n description: (\n <Typography lineHeight=\"normal\" style=\"body2\">\n <Trans\n i18nKey=\"neetoIntegrations.daily.helpDoc\"\n components={{\n videoLink: (\n <Button\n style=\"link\"\n onClick={() => setIsDemoModalOpen(true)}\n />\n ),\n }}\n />\n </Typography>\n ),\n helpLinkProps: {\n href: helpDocUrl,\n \"data-testid\": \"api-key-help-doc-link\",\n },\n }}\n />\n <div className=\"w-full\">\n <FormikForm\n formikProps={{\n initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,\n validationSchema: DAILY_CO_VALIDATION_SCHEMA,\n onSubmit: handleSubmit,\n }}\n >\n <CardLayout\n actionBlock={\n <ActionBlock\n cancelButtonProps={{ onClick: () => history.goBack() }}\n isSubmitting={isConnecting}\n submitButtonProps={{\n label: t(\"neetoIntegrations.common.connect\"),\n }}\n />\n }\n >\n <Input\n autoFocus\n required\n label={t(\"neetoIntegrations.daily.apiKey\")}\n name=\"apiKey\"\n />\n </CardLayout>\n </FormikForm>\n <WalkthroughModal\n {...{ videoUrl }}\n isOpen={isDemoModalOpen}\n onClose={() => setIsDemoModalOpen(false)}\n />\n </div>\n </Container>\n );\n};\nexport default withTitle(\n Form,\n i18next.t(\"neetoIntegrations.browserTitles.integrations.dailyco\")\n);\n"],"names":["MANAGE_DAILY_CO_FORM_INITIAL_VALUES","apiKey","DAILY_CO_VALIDATION_SCHEMA","yup","object","shape","string","trim","required","t","entity","Form","_ref","helpDocUrl","videoUrl","onConnect","breadcrumbs","_useTranslation","useTranslation","history","useHistory","_useState","useState","_useState2","_slicedToArray","isDemoModalOpen","setIsDemoModalOpen","_useCreateDaily","useCreateDaily","onSuccess","createDaily","mutate","isConnecting","isPending","handleSubmit","payload","_jsx","className","children","Spinner","_jsxs","Container","isHeaderFixed","Header","title","titleHelpPopoverProps","description","Typography","lineHeight","style","Trans","i18nKey","components","videoLink","Button","onClick","helpLinkProps","href","FormikForm","formikProps","initialValues","validationSchema","onSubmit","CardLayout","actionBlock","ActionBlock","cancelButtonProps","goBack","isSubmitting","submitButtonProps","label","Input","autoFocus","name","WalkthroughModal","isOpen","onClose","withTitle","i18next"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,mCAAmC,GAAG;AAAEC,EAAAA,MAAM,EAAE;AAAG,CAAC;AAE1D,IAAMC,0BAA0B,GAAGC,GAAG,CAACC,MAAM,EAAE,CAACC,KAAK,CAAC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BACEI,GAAA,CAAA,KAAA,EAAA;AAAKC,MAAAA,SAAS,EAAC,gDAAgD;AAAAC,MAAAA,QAAA,eAC7DF,GAAA,CAACG,OAAO,EAAA,EAAE;AAAC,KACR,CAAC;AAEV,EAAA;EAEA,oBACEC,IAAA,CAACC,SAAS,EAAA;IAACC,aAAa,EAAA,IAAA;IAAAJ,QAAA,EAAA,cACtBF,GAAA,CAACO,MAAM,EAAA;AACC3B,MAAAA,WAAW,EAAXA,WAAW;AACjB4B,MAAAA,KAAK,EAAEnC,CAAC,CAAC,uCAAuC,CAAE;AAClDoC,MAAAA,qBAAqB,EAAE;AACrBD,QAAAA,KAAK,EAAEnC,CAAC,CAAC,uCAAuC,CAAC;QACjDqC,WAAW,eACTV,GAAA,CAACW,UAAU,EAAA;AAACC,UAAAA,UAAU,EAAC,QAAQ;AAACC,UAAAA,KAAK,EAAC,OAAO;UAAAX,QAAA,eAC3CF,GAAA,CAACc,KAAK,EAAA;AACJC,YAAAA,OAAO,EAAC,iCAAiC;AACzCC,YAAAA,UAAU,EAAE;cACVC,SAAS,eACPjB,GAAA,CAACkB,MAAM,EAAA;AACLL,gBAAAA,KAAK,EAAC,MAAM;gBACZM,OAAO,EAAE,SAATA,OAAOA,GAAA;kBAAA,OAAQ7B,kBAAkB,CAAC,IAAI,CAAC;AAAA,gBAAA;eACxC;AAEL;WACD;AAAC,SACQ,CACb;AACD8B,QAAAA,aAAa,EAAE;AACbC,UAAAA,IAAI,EAAE5C,UAAU;AAChB,UAAA,aAAa,EAAE;AACjB;AACF;KACD,CAAC,eACF2B,IAAA,CAAA,KAAA,EAAA;AAAKH,MAAAA,SAAS,EAAC,QAAQ;MAAAC,QAAA,EAAA,cACrBF,GAAA,CAACsB,
|
|
1
|
+
{"version":3,"file":"DailyForm.js","sources":["../app/javascript/src/components/Integrations/Daily/constants.js","../app/javascript/src/components/Integrations/Daily/Form.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const MANAGE_DAILY_CO_FORM_INITIAL_VALUES = { apiKey: \"\" };\n\nexport const DAILY_CO_VALIDATION_SCHEMA = yup.object().shape({\n apiKey: yup\n .string()\n .trim()\n .required(\n t(\"neetoIntegrations.errors.required\", {\n entity: t(\"neetoIntegrations.daily.apiKey\"),\n })\n ),\n});\n","import { useState } from \"react\";\n\nimport i18next from \"i18next\";\nimport { withTitle } from \"neetocommons/react-utils\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport Container from \"neetomolecules/Container\";\nimport Header from \"neetomolecules/Header\";\nimport { Button, Spinner, Typography } from \"neetoui\";\nimport { Input, Form as FormikForm, ActionBlock } from \"neetoui/formik\";\nimport { Trans, useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport WalkthroughModal from \"components/WalkthroughModal\";\nimport { useCreateDaily } from \"hooks/reactQuery/useDailiesApi\";\n\nimport {\n MANAGE_DAILY_CO_FORM_INITIAL_VALUES,\n DAILY_CO_VALIDATION_SCHEMA,\n} from \"./constants\";\n\nconst Form = ({ helpDocUrl, videoUrl, onConnect, breadcrumbs }) => {\n const { t } = useTranslation();\n const history = useHistory();\n\n const [isDemoModalOpen, setIsDemoModalOpen] = useState(false);\n\n const { mutate: createDaily, isPending: isConnecting } = useCreateDaily({\n onSuccess: () => onConnect?.(),\n });\n\n const handleSubmit = payload => createDaily(payload);\n\n if (isConnecting) {\n return (\n <div className=\"flex h-full w-full items-center justify-center\">\n <Spinner />\n </div>\n );\n }\n\n return (\n <Container isHeaderFixed>\n <Header\n {...{ breadcrumbs }}\n title={t(\"neetoIntegrations.daily.connect.title\")}\n titleHelpPopoverProps={{\n title: t(\"neetoIntegrations.daily.connect.title\"),\n description: (\n <Typography lineHeight=\"normal\" style=\"body2\">\n <Trans\n i18nKey=\"neetoIntegrations.daily.helpDoc\"\n components={{\n videoLink: (\n <Button\n style=\"link\"\n onClick={() => setIsDemoModalOpen(true)}\n />\n ),\n }}\n />\n </Typography>\n ),\n helpLinkProps: {\n href: helpDocUrl,\n \"data-testid\": \"api-key-help-doc-link\",\n },\n }}\n />\n <div className=\"w-full\">\n <FormikForm\n formikProps={{\n initialValues: MANAGE_DAILY_CO_FORM_INITIAL_VALUES,\n validationSchema: DAILY_CO_VALIDATION_SCHEMA,\n onSubmit: handleSubmit,\n }}\n >\n <CardLayout\n actionBlock={\n <ActionBlock\n cancelButtonProps={{ onClick: () => history.goBack() }}\n isSubmitting={isConnecting}\n submitButtonProps={{\n label: t(\"neetoIntegrations.common.connect\"),\n }}\n />\n }\n >\n <Input\n autoFocus\n required\n label={t(\"neetoIntegrations.daily.apiKey\")}\n name=\"apiKey\"\n />\n </CardLayout>\n </FormikForm>\n <WalkthroughModal\n {...{ videoUrl }}\n isOpen={isDemoModalOpen}\n onClose={() => setIsDemoModalOpen(false)}\n />\n </div>\n </Container>\n );\n};\nexport default withTitle(\n Form,\n i18next.t(\"neetoIntegrations.browserTitles.integrations.dailyco\")\n);\n"],"names":["MANAGE_DAILY_CO_FORM_INITIAL_VALUES","apiKey","DAILY_CO_VALIDATION_SCHEMA","yup","object","shape","string","trim","required","t","entity","Form","_ref","helpDocUrl","videoUrl","onConnect","breadcrumbs","_useTranslation","useTranslation","history","useHistory","_useState","useState","_useState2","_slicedToArray","isDemoModalOpen","setIsDemoModalOpen","_useCreateDaily","useCreateDaily","onSuccess","createDaily","mutate","isConnecting","isPending","handleSubmit","payload","_jsx","className","children","Spinner","_jsxs","Container","isHeaderFixed","Header","title","titleHelpPopoverProps","description","Typography","lineHeight","style","Trans","i18nKey","components","videoLink","Button","onClick","helpLinkProps","href","FormikForm","formikProps","initialValues","validationSchema","onSubmit","CardLayout","actionBlock","ActionBlock","cancelButtonProps","goBack","isSubmitting","submitButtonProps","label","Input","autoFocus","name","WalkthroughModal","isOpen","onClose","withTitle","i18next"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,mCAAmC,GAAG;AAAEC,EAAAA,MAAM,EAAE;AAAG,CAAC;A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gBAAgB,EAAE3D,0BAA0B;AAC5C4D,UAAAA,QAAQ,EAAE5B;SACV;QAAAI,QAAA,eAEFF,GAAA,CAAC2B,UAAU,EAAA;UACTC,WAAW,eACT5B,GAAA,CAAC6B,WAAW,EAAA;AACVC,YAAAA,iBAAiB,EAAE;cAAEX,OAAO,EAAE,SAATA,OAAOA,GAAA;AAAA,gBAAA,OAAQpC,OAAO,CAACgD,MAAM,EAAE;AAAA,cAAA;aAAG;AACvDC,YAAAA,YAAY,EAAEpC,YAAa;AAC3BqC,YAAAA,iBAAiB,EAAE;cACjBC,KAAK,EAAE7D,CAAC,CAAC,kCAAkC;AAC7C;AAAE,WACH,CACF;UAAA6B,QAAA,eAEDF,GAAA,CAACmC,KAAK,EAAA;YACJC,SAAS,EAAA,IAAA;YACThE,QAAQ,EAAA,IAAA;AACR8D,YAAAA,KAAK,EAAE7D,CAAC,CAAC,gCAAgC,CAAE;AAC3CgE,YAAAA,IAAI,EAAC;WACN;SACS;AAAC,OACH,CAAC,eACbrC,GAAA,CAACsC,gBAAgB,EAAA;AACT5D,QAAAA,QAAQ,EAARA,QAAQ;AACd6D,QAAAA,MAAM,EAAElD,eAAgB;QACxBmD,OAAO,EAAE,SAATA,OAAOA,GAAA;UAAA,OAAQlD,kBAAkB,CAAC,KAAK,CAAC;AAAA,QAAA;AAAC,OAC1C,CAAC;AAAA,KACC,CAAC;AAAA,GACG,CAAC;AAEhB,CAAC;AACD,aAAemD,SAAS,CACtBlE,IAAI,EACJmE,OAAO,CAACrE,CAAC,CAAC,sDAAsD,CAClE,CAAC;;;;"}
|
package/dist/Telnyx.js
CHANGED
|
@@ -1,102 +1,331 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { findBy, isNotEmpty, noop } from '@bigbinary/neeto-cist';
|
|
3
|
-
import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
|
|
4
|
-
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
1
|
+
import { useMemo, useRef } from 'react';
|
|
5
2
|
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
6
|
-
import
|
|
3
|
+
import FormikFormWrapper from '@bigbinary/neetoui/formik/Form';
|
|
4
|
+
import { _findBy, noop } from '@bigbinary/neeto-cist';
|
|
5
|
+
import { equals } from 'ramda';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
|
|
7
8
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
8
9
|
import Select from '@bigbinary/neetoui/formik/Select';
|
|
9
|
-
import
|
|
10
|
+
import Tag from '@bigbinary/neetoui/Tag';
|
|
11
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
|
+
import Callout from '@bigbinary/neetoui/Callout';
|
|
13
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
14
|
+
import { u as useFetchTelnyxMessagingProfileSenders, a as useFetchTelnyxConfiguration, b as useFetchTelnyxSenderOptions, c as useUpsertTelnyxConfiguration } from './useTelnyxApi-RuLwKpN1.js';
|
|
15
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
10
16
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
11
|
-
import {
|
|
12
|
-
import { u as useFetchTelnyxSmsConfiguration, a as useFetchTelnyxPhoneNumbers, b as useCreateTelnyxSmsConfiguration } from './useTelnyxApi-Cv5cIiuo.js';
|
|
17
|
+
import { useStateWithDependency } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
13
18
|
import { t } from 'i18next';
|
|
14
19
|
import * as yup from 'yup';
|
|
15
|
-
import
|
|
20
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
16
21
|
import '@tanstack/react-query';
|
|
17
|
-
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
18
22
|
import 'axios';
|
|
19
23
|
import './query-gurbhBqu.js';
|
|
20
24
|
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
var ConnectionTypeCard = function ConnectionTypeCard(_ref) {
|
|
26
|
+
var value = _ref.value,
|
|
27
|
+
selected = _ref.selected,
|
|
28
|
+
title = _ref.title,
|
|
29
|
+
description = _ref.description,
|
|
30
|
+
_ref$recommended = _ref.recommended,
|
|
31
|
+
recommended = _ref$recommended === void 0 ? false : _ref$recommended,
|
|
32
|
+
onSelect = _ref.onSelect,
|
|
33
|
+
children = _ref.children;
|
|
34
|
+
var _useTranslation = useTranslation(),
|
|
35
|
+
t = _useTranslation.t;
|
|
36
|
+
var isSelected = selected === value;
|
|
37
|
+
var cardClass = "flex w-full cursor-pointer flex-col gap-y-2 neeto-ui-rounded border p-4 ".concat(isSelected ? "neeto-ui-border-success-500 neeto-ui-bg-success-100" : "neeto-ui-border-gray-200");
|
|
38
|
+
return /*#__PURE__*/jsxs("div", {
|
|
39
|
+
className: cardClass,
|
|
40
|
+
onClick: function onClick() {
|
|
41
|
+
return onSelect(value);
|
|
42
|
+
},
|
|
43
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
44
|
+
className: "flex items-center gap-x-2",
|
|
45
|
+
children: [/*#__PURE__*/jsx("input", {
|
|
46
|
+
value: value,
|
|
47
|
+
checked: isSelected,
|
|
48
|
+
name: "connectionType",
|
|
49
|
+
type: "radio",
|
|
50
|
+
onChange: function onChange() {
|
|
51
|
+
return onSelect(value);
|
|
52
|
+
},
|
|
53
|
+
onClick: function onClick(e) {
|
|
54
|
+
return e.stopPropagation();
|
|
55
|
+
}
|
|
56
|
+
}), /*#__PURE__*/jsx("div", {
|
|
57
|
+
className: "font-semibold",
|
|
58
|
+
children: title
|
|
59
|
+
}), recommended && /*#__PURE__*/jsx(Tag, {
|
|
60
|
+
style: "success",
|
|
61
|
+
label: t("neetoIntegrations.telnyx.connectionType.messagingProfile.recommendedBadge")
|
|
62
|
+
})]
|
|
63
|
+
}), /*#__PURE__*/jsx("div", {
|
|
64
|
+
className: "text-sm neeto-ui-text-gray-600",
|
|
65
|
+
children: description
|
|
66
|
+
}), isSelected && children]
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var CONNECTION_TYPES = Object.freeze({
|
|
71
|
+
PHONE_NUMBER: "phone_number",
|
|
72
|
+
MESSAGING_PROFILE: "messaging_profile"
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
var ZeroSendersWarning = function ZeroSendersWarning(_ref) {
|
|
76
|
+
var apiKey = _ref.apiKey,
|
|
77
|
+
messagingProfileId = _ref.messagingProfileId;
|
|
78
|
+
var _useTranslation = useTranslation(),
|
|
79
|
+
t = _useTranslation.t;
|
|
80
|
+
var _useFetchTelnyxMessag = useFetchTelnyxMessagingProfileSenders({
|
|
81
|
+
apiKey: apiKey,
|
|
82
|
+
messagingProfileId: messagingProfileId,
|
|
83
|
+
enabled: !!apiKey && !!messagingProfileId
|
|
84
|
+
}),
|
|
85
|
+
data = _useFetchTelnyxMessag.data,
|
|
86
|
+
isFetching = _useFetchTelnyxMessag.isFetching;
|
|
87
|
+
if (!messagingProfileId) return null;
|
|
88
|
+
if (isFetching) return /*#__PURE__*/jsx(Spinner, {
|
|
89
|
+
size: "sm"
|
|
90
|
+
});
|
|
91
|
+
if (!data || data.senderCount > 0) return null;
|
|
92
|
+
return /*#__PURE__*/jsx(Callout, {
|
|
93
|
+
style: "warning",
|
|
94
|
+
children: t("neetoIntegrations.telnyx.zeroSendersWarning")
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var Form = function Form(_ref) {
|
|
99
|
+
var _errors$phoneNumber, _errors$messagingProf, _values$messagingProf;
|
|
100
|
+
var phoneNumberOptions = _ref.phoneNumberOptions,
|
|
101
|
+
messagingProfileOptions = _ref.messagingProfileOptions,
|
|
102
|
+
senderOptionsAvailable = _ref.senderOptionsAvailable,
|
|
103
|
+
formikProps = _ref.formikProps,
|
|
104
|
+
_ref$initialFocusRef = _ref.initialFocusRef,
|
|
105
|
+
initialFocusRef = _ref$initialFocusRef === void 0 ? null : _ref$initialFocusRef;
|
|
106
|
+
var _useTranslation = useTranslation(),
|
|
107
|
+
t = _useTranslation.t;
|
|
108
|
+
var setFieldValue = formikProps.setFieldValue,
|
|
109
|
+
values = formikProps.values,
|
|
110
|
+
errors = formikProps.errors;
|
|
111
|
+
var handleConnectionTypeChange = function handleConnectionTypeChange(nextType) {
|
|
112
|
+
setFieldValue("connectionType", nextType);
|
|
113
|
+
if (nextType === CONNECTION_TYPES.PHONE_NUMBER) {
|
|
114
|
+
setFieldValue("messagingProfile", null);
|
|
115
|
+
} else {
|
|
116
|
+
setFieldValue("phoneNumber", null);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return /*#__PURE__*/jsxs("div", {
|
|
120
|
+
className: "flex w-full flex-col gap-y-6",
|
|
121
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
122
|
+
autoFocus: true,
|
|
123
|
+
required: true,
|
|
124
|
+
"data-testid": "integrations-telnyx-api-key",
|
|
125
|
+
disabled: senderOptionsAvailable,
|
|
126
|
+
label: t("neetoIntegrations.telnyx.apiKey"),
|
|
127
|
+
name: "apiKey",
|
|
128
|
+
ref: initialFocusRef
|
|
129
|
+
}), senderOptionsAvailable && /*#__PURE__*/jsxs("div", {
|
|
130
|
+
className: "flex w-full flex-col gap-y-4",
|
|
131
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
132
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
133
|
+
className: "font-semibold",
|
|
134
|
+
children: t("neetoIntegrations.telnyx.smsSendingMethod.title")
|
|
135
|
+
}), /*#__PURE__*/jsx("div", {
|
|
136
|
+
className: "text-sm neeto-ui-text-gray-600",
|
|
137
|
+
children: t("neetoIntegrations.telnyx.smsSendingMethod.subtitle")
|
|
138
|
+
})]
|
|
139
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
140
|
+
className: "flex w-full flex-col gap-y-3",
|
|
141
|
+
children: [/*#__PURE__*/jsx(ConnectionTypeCard, {
|
|
142
|
+
selected: values.connectionType,
|
|
143
|
+
value: CONNECTION_TYPES.PHONE_NUMBER,
|
|
144
|
+
description: t("neetoIntegrations.telnyx.connectionType.phoneNumber.description"),
|
|
145
|
+
title: t("neetoIntegrations.telnyx.connectionType.phoneNumber.label"),
|
|
146
|
+
onSelect: handleConnectionTypeChange,
|
|
147
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
148
|
+
error: (_errors$phoneNumber = errors.phoneNumber) === null || _errors$phoneNumber === void 0 ? void 0 : _errors$phoneNumber.value,
|
|
149
|
+
label: t("neetoIntegrations.common.phNo"),
|
|
150
|
+
name: "phoneNumber",
|
|
151
|
+
options: phoneNumberOptions,
|
|
152
|
+
size: "large",
|
|
153
|
+
onChange: function onChange(selected) {
|
|
154
|
+
return setFieldValue("phoneNumber", selected);
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}), /*#__PURE__*/jsxs(ConnectionTypeCard, {
|
|
158
|
+
recommended: true,
|
|
159
|
+
selected: values.connectionType,
|
|
160
|
+
value: CONNECTION_TYPES.MESSAGING_PROFILE,
|
|
161
|
+
description: t("neetoIntegrations.telnyx.connectionType.messagingProfile.description"),
|
|
162
|
+
title: t("neetoIntegrations.telnyx.connectionType.messagingProfile.label"),
|
|
163
|
+
onSelect: handleConnectionTypeChange,
|
|
164
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
165
|
+
error: (_errors$messagingProf = errors.messagingProfile) === null || _errors$messagingProf === void 0 ? void 0 : _errors$messagingProf.value,
|
|
166
|
+
label: t("neetoIntegrations.telnyx.messagingProfile.label"),
|
|
167
|
+
name: "messagingProfile",
|
|
168
|
+
options: messagingProfileOptions,
|
|
169
|
+
size: "large",
|
|
170
|
+
placeholder: t("neetoIntegrations.telnyx.messagingProfile.placeholder"),
|
|
171
|
+
onChange: function onChange(selected) {
|
|
172
|
+
return setFieldValue("messagingProfile", selected);
|
|
173
|
+
}
|
|
174
|
+
}), /*#__PURE__*/jsx(ZeroSendersWarning, {
|
|
175
|
+
apiKey: values.apiKey,
|
|
176
|
+
messagingProfileId: (_values$messagingProf = values.messagingProfile) === null || _values$messagingProf === void 0 ? void 0 : _values$messagingProf.value
|
|
177
|
+
})]
|
|
178
|
+
})]
|
|
179
|
+
})]
|
|
180
|
+
})]
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
var buildPhoneNumberOptions = function buildPhoneNumberOptions() {
|
|
185
|
+
var phoneNumbers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
186
|
+
return phoneNumbers.map(function (pn) {
|
|
187
|
+
return {
|
|
188
|
+
label: pn.phoneNumber,
|
|
189
|
+
value: pn.id
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
var buildMessagingProfileOptions = function buildMessagingProfileOptions() {
|
|
194
|
+
var profiles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
195
|
+
return profiles.map(function (p) {
|
|
25
196
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
197
|
+
label: p.name,
|
|
198
|
+
value: p.id
|
|
28
199
|
};
|
|
29
|
-
})
|
|
200
|
+
});
|
|
30
201
|
};
|
|
31
|
-
var buildTelnyxConfigurationValidationSchema = function buildTelnyxConfigurationValidationSchema(
|
|
202
|
+
var buildTelnyxConfigurationValidationSchema = function buildTelnyxConfigurationValidationSchema() {
|
|
203
|
+
var hasSenderOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
32
204
|
return yup.object().shape({
|
|
33
|
-
apiKey: yup.string().required(t("
|
|
34
|
-
|
|
35
|
-
phoneNumber:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
205
|
+
apiKey: yup.string().required(t("validations.required")),
|
|
206
|
+
connectionType: yup.string().oneOf(Object.values(CONNECTION_TYPES)).required(t("validations.required")),
|
|
207
|
+
phoneNumber: hasSenderOptions ? yup.mixed().when("connectionType", {
|
|
208
|
+
is: CONNECTION_TYPES.PHONE_NUMBER,
|
|
209
|
+
then: function then() {
|
|
210
|
+
return yup.object().required(t("validations.required"));
|
|
211
|
+
},
|
|
212
|
+
otherwise: function otherwise() {
|
|
213
|
+
return yup.mixed().nullable();
|
|
214
|
+
}
|
|
215
|
+
}) : yup.mixed().nullable(),
|
|
216
|
+
messagingProfile: hasSenderOptions ? yup.mixed().when("connectionType", {
|
|
217
|
+
is: CONNECTION_TYPES.MESSAGING_PROFILE,
|
|
218
|
+
then: function then() {
|
|
219
|
+
return yup.object().required(t("validations.required"));
|
|
220
|
+
},
|
|
221
|
+
otherwise: function otherwise() {
|
|
222
|
+
return yup.mixed().nullable();
|
|
223
|
+
}
|
|
224
|
+
}) : yup.mixed().nullable()
|
|
39
225
|
});
|
|
40
226
|
};
|
|
41
227
|
|
|
228
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = true, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), true), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
229
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
42
230
|
var useTelnyxForm = function useTelnyxForm(_ref) {
|
|
43
231
|
var integrable = _ref.integrable,
|
|
44
|
-
onConnect = _ref.onConnect
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
phoneNumbers = _useState2[0],
|
|
48
|
-
setPhoneNumbers = _useState2[1];
|
|
49
|
-
var _useFetchTelnyxSmsCon = useFetchTelnyxSmsConfiguration({
|
|
232
|
+
_ref$onConnect = _ref.onConnect,
|
|
233
|
+
onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect;
|
|
234
|
+
var _useFetchTelnyxConfig = useFetchTelnyxConfiguration({
|
|
50
235
|
integrable: integrable
|
|
51
236
|
}),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var
|
|
237
|
+
data = _useFetchTelnyxConfig.data,
|
|
238
|
+
isConfigLoading = _useFetchTelnyxConfig.isFetching;
|
|
239
|
+
var configuration = useMemo(function () {
|
|
240
|
+
return data !== null && data !== void 0 ? data : {};
|
|
241
|
+
}, [data]);
|
|
242
|
+
var _useStateWithDependen = useStateWithDependency(configuration),
|
|
243
|
+
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
244
|
+
credentials = _useStateWithDependen2[0],
|
|
245
|
+
setCredentials = _useStateWithDependen2[1];
|
|
246
|
+
var _useFetchTelnyxSender = useFetchTelnyxSenderOptions({
|
|
247
|
+
credentials: credentials
|
|
248
|
+
}),
|
|
249
|
+
senderOptions = _useFetchTelnyxSender.data,
|
|
250
|
+
isSenderOptionsLoading = _useFetchTelnyxSender.isFetching;
|
|
251
|
+
var _useUpsertTelnyxConfi = useUpsertTelnyxConfiguration({
|
|
252
|
+
onSuccess: onConnect,
|
|
58
253
|
integrable: integrable
|
|
59
254
|
}),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
255
|
+
upsert = _useUpsertTelnyxConfi.mutateAsync,
|
|
256
|
+
isSubmitting = _useUpsertTelnyxConfi.isPending;
|
|
257
|
+
var phoneNumberOptions = useMemo(function () {
|
|
258
|
+
var _senderOptions$phoneN;
|
|
259
|
+
return buildPhoneNumberOptions((_senderOptions$phoneN = senderOptions === null || senderOptions === void 0 ? void 0 : senderOptions.phoneNumbers) !== null && _senderOptions$phoneN !== void 0 ? _senderOptions$phoneN : []);
|
|
260
|
+
}, [senderOptions]);
|
|
261
|
+
var messagingProfileOptions = useMemo(function () {
|
|
262
|
+
var _senderOptions$messag;
|
|
263
|
+
return buildMessagingProfileOptions((_senderOptions$messag = senderOptions === null || senderOptions === void 0 ? void 0 : senderOptions.messagingProfiles) !== null && _senderOptions$messag !== void 0 ? _senderOptions$messag : []);
|
|
264
|
+
}, [senderOptions]);
|
|
265
|
+
var initialValues = useMemo(function () {
|
|
266
|
+
var _configuration$apiKey, _configuration$connec;
|
|
267
|
+
var selectedPhone = _findBy({
|
|
268
|
+
label: configuration === null || configuration === void 0 ? void 0 : configuration.phoneNumber
|
|
269
|
+
}, phoneNumberOptions);
|
|
270
|
+
var selectedProfile = _findBy({
|
|
271
|
+
value: configuration === null || configuration === void 0 ? void 0 : configuration.messagingProfileId
|
|
272
|
+
}, messagingProfileOptions);
|
|
273
|
+
return {
|
|
274
|
+
apiKey: (_configuration$apiKey = configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) !== null && _configuration$apiKey !== void 0 ? _configuration$apiKey : "",
|
|
275
|
+
connectionType: (_configuration$connec = configuration === null || configuration === void 0 ? void 0 : configuration.connectionType) !== null && _configuration$connec !== void 0 ? _configuration$connec : CONNECTION_TYPES.PHONE_NUMBER,
|
|
276
|
+
phoneNumber: selectedPhone !== null && selectedPhone !== void 0 ? selectedPhone : null,
|
|
277
|
+
messagingProfile: selectedProfile !== null && selectedProfile !== void 0 ? selectedProfile : null
|
|
278
|
+
};
|
|
279
|
+
}, [configuration, phoneNumberOptions, messagingProfileOptions]);
|
|
280
|
+
var hasCredentials = !!(credentials !== null && credentials !== void 0 && credentials.api_key) || !!(credentials !== null && credentials !== void 0 && credentials.apiKey);
|
|
281
|
+
var senderOptionsAvailable = hasCredentials && !!senderOptions;
|
|
282
|
+
var handleSubmit = /*#__PURE__*/function () {
|
|
283
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(values) {
|
|
284
|
+
var payload, _values$phoneNumber, _values$phoneNumber2, _values$messagingProf, _values$messagingProf2;
|
|
285
|
+
return _regenerator().w(function (_context) {
|
|
286
|
+
while (1) switch (_context.n) {
|
|
287
|
+
case 0:
|
|
288
|
+
if (!(!senderOptionsAvailable && !(configuration !== null && configuration !== void 0 && configuration.connectionType))) {
|
|
289
|
+
_context.n = 1;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
setCredentials({
|
|
293
|
+
api_key: values.apiKey
|
|
294
|
+
});
|
|
295
|
+
return _context.a(2);
|
|
296
|
+
case 1:
|
|
297
|
+
// Second click ("Save changes"): real save
|
|
298
|
+
payload = {
|
|
299
|
+
api_key: values.apiKey,
|
|
300
|
+
connection_type: values.connectionType
|
|
301
|
+
};
|
|
302
|
+
if (values.connectionType === CONNECTION_TYPES.PHONE_NUMBER) {
|
|
303
|
+
payload.phone_number_id = (_values$phoneNumber = values.phoneNumber) === null || _values$phoneNumber === void 0 ? void 0 : _values$phoneNumber.value;
|
|
304
|
+
payload.phone_number = (_values$phoneNumber2 = values.phoneNumber) === null || _values$phoneNumber2 === void 0 ? void 0 : _values$phoneNumber2.label;
|
|
305
|
+
} else {
|
|
306
|
+
payload.messaging_profile_id = (_values$messagingProf = values.messagingProfile) === null || _values$messagingProf === void 0 ? void 0 : _values$messagingProf.value;
|
|
307
|
+
payload.messaging_profile_name = (_values$messagingProf2 = values.messagingProfile) === null || _values$messagingProf2 === void 0 ? void 0 : _values$messagingProf2.label;
|
|
308
|
+
}
|
|
309
|
+
_context.n = 2;
|
|
310
|
+
return upsert(payload);
|
|
311
|
+
case 2:
|
|
312
|
+
return _context.a(2);
|
|
72
313
|
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
apiKey: values.apiKey,
|
|
78
|
-
messagingProfileId: values.messagingProfileId,
|
|
79
|
-
phoneNumberId: values.phoneNumber.value
|
|
314
|
+
}, _callee);
|
|
315
|
+
}));
|
|
316
|
+
return function handleSubmit(_x) {
|
|
317
|
+
return _ref2.apply(this, arguments);
|
|
80
318
|
};
|
|
81
|
-
|
|
82
|
-
onSuccess: onConnect
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
var isSubmitting = isFetchPhoneNumbersLoading || isCreateSmsConfigurationLoading;
|
|
86
|
-
var phoneNumberOptions = buildPhoneNumberOptions(phoneNumbers);
|
|
87
|
-
var initialValues = {
|
|
88
|
-
apiKey: (configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) || "",
|
|
89
|
-
messagingProfileId: (configuration === null || configuration === void 0 ? void 0 : configuration.messagingProfileId) || "",
|
|
90
|
-
phoneNumber: findBy({
|
|
91
|
-
label: configuration === null || configuration === void 0 ? void 0 : configuration.phoneNumber
|
|
92
|
-
}, phoneNumberOptions) || null
|
|
93
|
-
};
|
|
319
|
+
}();
|
|
94
320
|
return {
|
|
95
321
|
initialValues: initialValues,
|
|
322
|
+
handleSubmit: handleSubmit,
|
|
96
323
|
phoneNumberOptions: phoneNumberOptions,
|
|
324
|
+
messagingProfileOptions: messagingProfileOptions,
|
|
325
|
+
senderOptionsAvailable: senderOptionsAvailable,
|
|
326
|
+
isLoading: isConfigLoading || isSenderOptionsLoading,
|
|
97
327
|
isSubmitting: isSubmitting,
|
|
98
|
-
|
|
99
|
-
handleSubmit: handleSubmit
|
|
328
|
+
configuration: configuration
|
|
100
329
|
};
|
|
101
330
|
};
|
|
102
331
|
|
|
@@ -107,32 +336,33 @@ var Telnyx = function Telnyx(_ref) {
|
|
|
107
336
|
onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
|
|
108
337
|
_ref$onConnect = _ref.onConnect,
|
|
109
338
|
onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect;
|
|
110
|
-
var formRef = useRef(null);
|
|
111
339
|
var _useTranslation = useTranslation(),
|
|
112
340
|
t = _useTranslation.t;
|
|
341
|
+
var initialFocusRef = useRef();
|
|
342
|
+
var formRef = useRef();
|
|
113
343
|
var _useTelnyxForm = useTelnyxForm({
|
|
114
344
|
integrable: integrable,
|
|
115
|
-
onConnect: onConnect
|
|
116
|
-
}),
|
|
345
|
+
onConnect: onConnect}),
|
|
117
346
|
initialValues = _useTelnyxForm.initialValues,
|
|
118
347
|
handleSubmit = _useTelnyxForm.handleSubmit,
|
|
119
348
|
phoneNumberOptions = _useTelnyxForm.phoneNumberOptions,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
349
|
+
messagingProfileOptions = _useTelnyxForm.messagingProfileOptions,
|
|
350
|
+
senderOptionsAvailable = _useTelnyxForm.senderOptionsAvailable,
|
|
351
|
+
isLoading = _useTelnyxForm.isLoading,
|
|
352
|
+
isSubmitting = _useTelnyxForm.isSubmitting;
|
|
353
|
+
var isSubmitDisabled = function isSubmitDisabled(values) {
|
|
354
|
+
return equals(initialValues, values) || isLoading;
|
|
355
|
+
};
|
|
356
|
+
return /*#__PURE__*/jsx(FormikFormWrapper, {
|
|
126
357
|
className: "w-full",
|
|
127
358
|
formikProps: {
|
|
128
359
|
enableReinitialize: true,
|
|
360
|
+
validationSchema: buildTelnyxConfigurationValidationSchema(senderOptionsAvailable),
|
|
129
361
|
initialValues: initialValues,
|
|
130
|
-
validationSchema: buildTelnyxConfigurationValidationSchema(hasPhoneNumbers),
|
|
131
362
|
innerRef: formRef,
|
|
132
363
|
onSubmit: handleSubmit
|
|
133
364
|
},
|
|
134
|
-
children: function children(
|
|
135
|
-
var dirty = _ref2.dirty;
|
|
365
|
+
children: function children(formikProps) {
|
|
136
366
|
return /*#__PURE__*/jsx(CardLayout, {
|
|
137
367
|
actionBlock: /*#__PURE__*/jsx(ActionBlock, {
|
|
138
368
|
isSubmitting: isSubmitting,
|
|
@@ -140,27 +370,17 @@ var Telnyx = function Telnyx(_ref) {
|
|
|
140
370
|
onClick: onClose
|
|
141
371
|
},
|
|
142
372
|
submitButtonProps: {
|
|
143
|
-
label:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
disabled: !hasPhoneNumbers ? !initialValues.apiKey && !dirty : !dirty
|
|
373
|
+
label: senderOptionsAvailable ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
|
|
374
|
+
disabled: isSubmitDisabled(formikProps.values) || isSubmitting,
|
|
375
|
+
loading: isSubmitting || isLoading
|
|
147
376
|
}
|
|
148
377
|
}),
|
|
149
|
-
children: /*#__PURE__*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}), /*#__PURE__*/jsx(Input, {
|
|
156
|
-
disabled: hasPhoneNumbers,
|
|
157
|
-
label: t("neetoIntegrations.telnyx.messagingProfileId"),
|
|
158
|
-
name: "messagingProfileId"
|
|
159
|
-
}), hasPhoneNumbers && /*#__PURE__*/jsx(Select, {
|
|
160
|
-
label: t("neetoIntegrations.telnyx.phoneNumber"),
|
|
161
|
-
name: "phoneNumber",
|
|
162
|
-
options: phoneNumberOptions
|
|
163
|
-
})]
|
|
378
|
+
children: /*#__PURE__*/jsx(Form, {
|
|
379
|
+
formikProps: formikProps,
|
|
380
|
+
initialFocusRef: initialFocusRef,
|
|
381
|
+
messagingProfileOptions: messagingProfileOptions,
|
|
382
|
+
phoneNumberOptions: phoneNumberOptions,
|
|
383
|
+
senderOptionsAvailable: senderOptionsAvailable
|
|
164
384
|
})
|
|
165
385
|
});
|
|
166
386
|
}
|