@bigbinary/neeto-integrations-frontend 4.0.37 → 4.0.39

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.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/app/javascript/src/translations/ar.json +22 -1
  3. package/app/javascript/src/translations/bg.json +22 -1
  4. package/app/javascript/src/translations/ca.json +22 -1
  5. package/app/javascript/src/translations/cs.json +22 -1
  6. package/app/javascript/src/translations/da.json +22 -1
  7. package/app/javascript/src/translations/de.json +22 -1
  8. package/app/javascript/src/translations/en.json +22 -1
  9. package/app/javascript/src/translations/es-MX.json +22 -1
  10. package/app/javascript/src/translations/es.json +22 -1
  11. package/app/javascript/src/translations/et.json +22 -1
  12. package/app/javascript/src/translations/fi.json +22 -1
  13. package/app/javascript/src/translations/fil.json +22 -1
  14. package/app/javascript/src/translations/fr.json +22 -1
  15. package/app/javascript/src/translations/he.json +22 -1
  16. package/app/javascript/src/translations/hi.json +22 -1
  17. package/app/javascript/src/translations/hr.json +22 -1
  18. package/app/javascript/src/translations/hu.json +22 -1
  19. package/app/javascript/src/translations/id.json +22 -1
  20. package/app/javascript/src/translations/it.json +22 -1
  21. package/app/javascript/src/translations/ja.json +22 -1
  22. package/app/javascript/src/translations/ko.json +22 -1
  23. package/app/javascript/src/translations/nl.json +22 -1
  24. package/app/javascript/src/translations/pl.json +22 -1
  25. package/app/javascript/src/translations/pt-BR.json +22 -1
  26. package/app/javascript/src/translations/pt.json +22 -1
  27. package/app/javascript/src/translations/ro.json +22 -1
  28. package/app/javascript/src/translations/ru.json +22 -1
  29. package/app/javascript/src/translations/sk.json +22 -1
  30. package/app/javascript/src/translations/sl.json +22 -1
  31. package/app/javascript/src/translations/sv.json +22 -1
  32. package/app/javascript/src/translations/th.json +22 -1
  33. package/app/javascript/src/translations/tr.json +22 -1
  34. package/app/javascript/src/translations/uk.json +22 -1
  35. package/app/javascript/src/translations/vi.json +22 -1
  36. package/app/javascript/src/translations/zh-CN.json +22 -1
  37. package/app/javascript/src/translations/zh-TW.json +22 -1
  38. package/dist/.ready +1 -1
  39. package/dist/DailyForm.js +2 -2
  40. package/dist/DailyForm.js.map +1 -1
  41. package/dist/Telnyx.js +321 -101
  42. package/dist/Telnyx.js.map +1 -1
  43. package/dist/Twilio.js +50 -19
  44. package/dist/Twilio.js.map +1 -1
  45. package/dist/ZapierForm.js +2 -2
  46. package/dist/ZapierForm.js.map +1 -1
  47. package/dist/cjs/DailyForm.js +2 -2
  48. package/dist/cjs/DailyForm.js.map +1 -1
  49. package/dist/cjs/Telnyx.js +319 -99
  50. package/dist/cjs/Telnyx.js.map +1 -1
  51. package/dist/cjs/Twilio.js +49 -18
  52. package/dist/cjs/Twilio.js.map +1 -1
  53. package/dist/cjs/ZapierForm.js +2 -2
  54. package/dist/cjs/ZapierForm.js.map +1 -1
  55. package/dist/cjs/index.js +3 -3
  56. package/dist/cjs/v2/Telnyx.js +314 -93
  57. package/dist/cjs/v2/Telnyx.js.map +1 -1
  58. package/dist/cjs/v2/Twilio.js +45 -16
  59. package/dist/cjs/v2/Twilio.js.map +1 -1
  60. package/dist/cjs/v2/index.js +3 -3
  61. package/dist/index.js +3 -3
  62. package/dist/useTelnyxApi-B3EKAxdZ.js +136 -0
  63. package/dist/useTelnyxApi-B3EKAxdZ.js.map +1 -0
  64. package/dist/useTelnyxApi-RuLwKpN1.js +131 -0
  65. package/dist/useTelnyxApi-RuLwKpN1.js.map +1 -0
  66. package/dist/{useTwilioApi-C57UuOda.js → useTwilioApi-C067pCq3.js} +35 -7
  67. package/dist/useTwilioApi-C067pCq3.js.map +1 -0
  68. package/dist/{useTwilioApi-CUL0-Xgf.js → useTwilioApi-YSNLrDpP.js} +35 -6
  69. package/dist/useTwilioApi-YSNLrDpP.js.map +1 -0
  70. package/dist/v2/Telnyx.js +318 -97
  71. package/dist/v2/Telnyx.js.map +1 -1
  72. package/dist/v2/Twilio.js +47 -18
  73. package/dist/v2/Twilio.js.map +1 -1
  74. package/dist/v2/index.js +3 -3
  75. package/package.json +7 -7
  76. package/dist/useTelnyxApi-Cv5cIiuo.js +0 -58
  77. package/dist/useTelnyxApi-Cv5cIiuo.js.map +0 -1
  78. package/dist/useTelnyxApi-DS3IVijP.js +0 -62
  79. package/dist/useTelnyxApi-DS3IVijP.js.map +0 -1
  80. package/dist/useTwilioApi-C57UuOda.js.map +0 -1
  81. package/dist/useTwilioApi-CUL0-Xgf.js.map +0 -1
@@ -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,cAAG,CAACC,MAAM,EAAE,CAACC,KAAK,CAAC;AAC3DJ,EAAAA,MAAM,EAAEE,cAAG,CACRG,MAAM,EAAE,CACRC,IAAI,EAAE,CACNC,QAAQ,CACPC,SAAC,CAAC,mCAAmC,EAAE;IACrCC,MAAM,EAAED,SAAC,CAAC,gCAAgC;AAC5C,GAAC,CACH;AACJ,CAAC,CAAC;;ACMF,IAAME,MAAI,GAAG,SAAPA,IAAIA,CAAAC,IAAA,EAAyD;AAAA,EAAA,IAAnDC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS;IAAEC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;AAC1D,EAAA,IAAAC,eAAA,GAAcC,2BAAc,EAAE;IAAtBT,CAAC,GAAAQ,eAAA,CAADR,CAAC;AACT,EAAA,IAAMU,OAAO,GAAGC,yBAAU,EAAE;AAE5B,EAAA,IAAAC,SAAA,GAA8CC,cAAQ,CAAC,KAAK,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAtDI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ATA,OAAOA,GAAA;UAAA,OAAQlD,kBAAkB,CAAC,KAAK,CAAC;AAAA,QAAA;AAAC,OAC1C,CAAC;AAAA,KACC,CAAC;AAAA,GACG,CAAC;AAEhB,CAAC;AACD,WAAemD,oBAAS,CACtBlE,MAAI,EACJmE,OAAO,CAACrE,CAAC,CAAC,sDAAsD,CAClE,CAAC;;;;"}
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,cAAG,CAACC,MAAM,EAAE,CAACC,KAAK,CAAC;AAC3DJ,EAAAA,MAAM,EAAEE,cAAG,CACRG,MAAM,EAAE,CACRC,IAAI,EAAE,CACNC,QAAQ,CACPC,SAAC,CAAC,mCAAmC,EAAE;IACrCC,MAAM,EAAED,SAAC,CAAC,gCAAgC;AAC5C,GAAC,CACH;AACJ,CAAC,CAAC;;ACMF,IAAME,MAAI,GAAG,SAAPA,IAAIA,CAAAC,IAAA,EAAyD;AAAA,EAAA,IAAnDC,UAAU,GAAAD,IAAA,CAAVC,UAAU;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS;IAAEC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;AAC1D,EAAA,IAAAC,eAAA,GAAcC,2BAAc,EAAE;IAAtBT,CAAC,GAAAQ,eAAA,CAADR,CAAC;AACT,EAAA,IAAMU,OAAO,GAAGC,yBAAU,EAAE;AAE5B,EAAA,IAAAC,SAAA,GAA8CC,cAAQ,CAAC,KAAK,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAtDI,IAAAA,eAAe,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,kBAAkB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AA;AAAC,OAC1C,CAAC;AAAA,KACC,CAAC;AAAA,GACG,CAAC;AAEhB,CAAC;AACD,WAAemD,oBAAS,CACtBlE,MAAI,EACJmE,OAAO,CAACrE,CAAC,CAAC,sDAAsD,CAClE,CAAC;;;;"}
@@ -1,22 +1,26 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
5
+ var FormikFormWrapper = require('@bigbinary/neetoui/formik/Form');
4
6
  var neetoCist = require('@bigbinary/neeto-cist');
7
+ var ramda = require('ramda');
8
+ var reactI18next = require('react-i18next');
5
9
  var CardLayout = require('@bigbinary/neeto-molecules/CardLayout');
6
- var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
7
- var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
8
- var Form = require('@bigbinary/neetoui/formik/Form');
9
10
  var Input = require('@bigbinary/neetoui/formik/Input');
10
11
  var Select = require('@bigbinary/neetoui/formik/Select');
11
- var reactI18next = require('react-i18next');
12
+ var Tag = require('@bigbinary/neetoui/Tag');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+ var Callout = require('@bigbinary/neetoui/Callout');
15
+ var Spinner = require('@bigbinary/neetoui/Spinner');
16
+ var useTelnyxApi = require('../useTelnyxApi-B3EKAxdZ.js');
17
+ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
12
18
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
13
- var ramda = require('ramda');
14
- var useTelnyxApi = require('../useTelnyxApi-DS3IVijP.js');
19
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
15
20
  var i18next = require('i18next');
16
21
  var yup = require('yup');
17
- var jsxRuntime = require('react/jsx-runtime');
22
+ require('@babel/runtime/helpers/defineProperty');
18
23
  require('@tanstack/react-query');
19
- require('@bigbinary/neeto-commons-frontend/react-utils');
20
24
  require('axios');
21
25
  require('../query-BF3HFRA7.js');
22
26
 
@@ -39,85 +43,310 @@ function _interopNamespaceDefault(e) {
39
43
 
40
44
  var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
41
45
 
42
- var buildPhoneNumberOptions = function buildPhoneNumberOptions(phoneNumbers) {
43
- return phoneNumbers ? phoneNumbers.map(function (_ref) {
44
- var id = _ref.id,
45
- phoneNumber = _ref.phoneNumber;
46
+ var ConnectionTypeCard = function ConnectionTypeCard(_ref) {
47
+ var value = _ref.value,
48
+ selected = _ref.selected,
49
+ title = _ref.title,
50
+ description = _ref.description,
51
+ _ref$recommended = _ref.recommended,
52
+ recommended = _ref$recommended === void 0 ? false : _ref$recommended,
53
+ onSelect = _ref.onSelect,
54
+ children = _ref.children;
55
+ var _useTranslation = reactI18next.useTranslation(),
56
+ t = _useTranslation.t;
57
+ var isSelected = selected === value;
58
+ 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");
59
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
60
+ className: cardClass,
61
+ onClick: function onClick() {
62
+ return onSelect(value);
63
+ },
64
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
65
+ className: "flex items-center gap-x-2",
66
+ children: [/*#__PURE__*/jsxRuntime.jsx("input", {
67
+ value: value,
68
+ checked: isSelected,
69
+ name: "connectionType",
70
+ type: "radio",
71
+ onChange: function onChange() {
72
+ return onSelect(value);
73
+ },
74
+ onClick: function onClick(e) {
75
+ return e.stopPropagation();
76
+ }
77
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
78
+ className: "font-semibold",
79
+ children: title
80
+ }), recommended && /*#__PURE__*/jsxRuntime.jsx(Tag, {
81
+ style: "success",
82
+ label: t("neetoIntegrations.telnyx.connectionType.messagingProfile.recommendedBadge")
83
+ })]
84
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
85
+ className: "text-sm neeto-ui-text-gray-600",
86
+ children: description
87
+ }), isSelected && children]
88
+ });
89
+ };
90
+
91
+ var CONNECTION_TYPES = Object.freeze({
92
+ PHONE_NUMBER: "phone_number",
93
+ MESSAGING_PROFILE: "messaging_profile"
94
+ });
95
+
96
+ var ZeroSendersWarning = function ZeroSendersWarning(_ref) {
97
+ var apiKey = _ref.apiKey,
98
+ messagingProfileId = _ref.messagingProfileId;
99
+ var _useTranslation = reactI18next.useTranslation(),
100
+ t = _useTranslation.t;
101
+ var _useFetchTelnyxMessag = useTelnyxApi.useFetchTelnyxMessagingProfileSenders({
102
+ apiKey: apiKey,
103
+ messagingProfileId: messagingProfileId,
104
+ enabled: !!apiKey && !!messagingProfileId
105
+ }),
106
+ data = _useFetchTelnyxMessag.data,
107
+ isFetching = _useFetchTelnyxMessag.isFetching;
108
+ if (!messagingProfileId) return null;
109
+ if (isFetching) return /*#__PURE__*/jsxRuntime.jsx(Spinner, {
110
+ size: "sm"
111
+ });
112
+ if (!data || data.senderCount > 0) return null;
113
+ return /*#__PURE__*/jsxRuntime.jsx(Callout, {
114
+ style: "warning",
115
+ children: t("neetoIntegrations.telnyx.zeroSendersWarning")
116
+ });
117
+ };
118
+
119
+ var Form = function Form(_ref) {
120
+ var _errors$phoneNumber, _errors$messagingProf, _values$messagingProf;
121
+ var phoneNumberOptions = _ref.phoneNumberOptions,
122
+ messagingProfileOptions = _ref.messagingProfileOptions,
123
+ senderOptionsAvailable = _ref.senderOptionsAvailable,
124
+ formikProps = _ref.formikProps,
125
+ _ref$initialFocusRef = _ref.initialFocusRef,
126
+ initialFocusRef = _ref$initialFocusRef === void 0 ? null : _ref$initialFocusRef;
127
+ var _useTranslation = reactI18next.useTranslation(),
128
+ t = _useTranslation.t;
129
+ var setFieldValue = formikProps.setFieldValue,
130
+ values = formikProps.values,
131
+ errors = formikProps.errors;
132
+ var handleConnectionTypeChange = function handleConnectionTypeChange(nextType) {
133
+ setFieldValue("connectionType", nextType);
134
+ if (nextType === CONNECTION_TYPES.PHONE_NUMBER) {
135
+ setFieldValue("messagingProfile", null);
136
+ } else {
137
+ setFieldValue("phoneNumber", null);
138
+ }
139
+ };
140
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
141
+ className: "flex w-full flex-col gap-y-6",
142
+ children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
143
+ autoFocus: true,
144
+ required: true,
145
+ "data-testid": "integrations-telnyx-api-key",
146
+ disabled: senderOptionsAvailable,
147
+ label: t("neetoIntegrations.telnyx.apiKey"),
148
+ name: "apiKey",
149
+ ref: initialFocusRef
150
+ }), senderOptionsAvailable && /*#__PURE__*/jsxRuntime.jsxs("div", {
151
+ className: "flex w-full flex-col gap-y-4",
152
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
153
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
154
+ className: "font-semibold",
155
+ children: t("neetoIntegrations.telnyx.smsSendingMethod.title")
156
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
157
+ className: "text-sm neeto-ui-text-gray-600",
158
+ children: t("neetoIntegrations.telnyx.smsSendingMethod.subtitle")
159
+ })]
160
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
161
+ className: "flex w-full flex-col gap-y-3",
162
+ children: [/*#__PURE__*/jsxRuntime.jsx(ConnectionTypeCard, {
163
+ selected: values.connectionType,
164
+ value: CONNECTION_TYPES.PHONE_NUMBER,
165
+ description: t("neetoIntegrations.telnyx.connectionType.phoneNumber.description"),
166
+ title: t("neetoIntegrations.telnyx.connectionType.phoneNumber.label"),
167
+ onSelect: handleConnectionTypeChange,
168
+ children: /*#__PURE__*/jsxRuntime.jsx(Select, {
169
+ error: (_errors$phoneNumber = errors.phoneNumber) === null || _errors$phoneNumber === void 0 ? void 0 : _errors$phoneNumber.value,
170
+ label: t("neetoIntegrations.common.phNo"),
171
+ name: "phoneNumber",
172
+ options: phoneNumberOptions,
173
+ size: "large",
174
+ onChange: function onChange(selected) {
175
+ return setFieldValue("phoneNumber", selected);
176
+ }
177
+ })
178
+ }), /*#__PURE__*/jsxRuntime.jsxs(ConnectionTypeCard, {
179
+ recommended: true,
180
+ selected: values.connectionType,
181
+ value: CONNECTION_TYPES.MESSAGING_PROFILE,
182
+ description: t("neetoIntegrations.telnyx.connectionType.messagingProfile.description"),
183
+ title: t("neetoIntegrations.telnyx.connectionType.messagingProfile.label"),
184
+ onSelect: handleConnectionTypeChange,
185
+ children: [/*#__PURE__*/jsxRuntime.jsx(Select, {
186
+ error: (_errors$messagingProf = errors.messagingProfile) === null || _errors$messagingProf === void 0 ? void 0 : _errors$messagingProf.value,
187
+ label: t("neetoIntegrations.telnyx.messagingProfile.label"),
188
+ name: "messagingProfile",
189
+ options: messagingProfileOptions,
190
+ size: "large",
191
+ placeholder: t("neetoIntegrations.telnyx.messagingProfile.placeholder"),
192
+ onChange: function onChange(selected) {
193
+ return setFieldValue("messagingProfile", selected);
194
+ }
195
+ }), /*#__PURE__*/jsxRuntime.jsx(ZeroSendersWarning, {
196
+ apiKey: values.apiKey,
197
+ messagingProfileId: (_values$messagingProf = values.messagingProfile) === null || _values$messagingProf === void 0 ? void 0 : _values$messagingProf.value
198
+ })]
199
+ })]
200
+ })]
201
+ })]
202
+ });
203
+ };
204
+
205
+ var buildPhoneNumberOptions = function buildPhoneNumberOptions() {
206
+ var phoneNumbers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
207
+ return phoneNumbers.map(function (pn) {
208
+ return {
209
+ label: pn.phoneNumber,
210
+ value: pn.id
211
+ };
212
+ });
213
+ };
214
+ var buildMessagingProfileOptions = function buildMessagingProfileOptions() {
215
+ var profiles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
216
+ return profiles.map(function (p) {
46
217
  return {
47
- value: id,
48
- label: phoneNumber
218
+ label: p.name,
219
+ value: p.id
49
220
  };
50
- }) : [];
221
+ });
51
222
  };
52
- var buildTelnyxConfigurationValidationSchema = function buildTelnyxConfigurationValidationSchema(isPhoneNumberRequired) {
223
+ var buildTelnyxConfigurationValidationSchema = function buildTelnyxConfigurationValidationSchema() {
224
+ var hasSenderOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
53
225
  return yup__namespace.object().shape({
54
- apiKey: yup__namespace.string().required(i18next.t("neetoIntegrations.telnyx.validations.apiKeyRequired")),
55
- messagingProfileId: yup__namespace.string().required(i18next.t("neetoIntegrations.telnyx.validations.messagingProfileIdRequired")),
56
- phoneNumber: isPhoneNumberRequired ? yup__namespace.object().shape({
57
- label: yup__namespace.string(),
58
- value: yup__namespace.string()
59
- }).nullable().required(i18next.t("neetoIntegrations.telnyx.validations.phoneNumberRequired")) : yup__namespace.mixed().nullable()
226
+ apiKey: yup__namespace.string().required(i18next.t("validations.required")),
227
+ connectionType: yup__namespace.string().oneOf(Object.values(CONNECTION_TYPES)).required(i18next.t("validations.required")),
228
+ phoneNumber: hasSenderOptions ? yup__namespace.mixed().when("connectionType", {
229
+ is: CONNECTION_TYPES.PHONE_NUMBER,
230
+ then: function then() {
231
+ return yup__namespace.object().required(i18next.t("validations.required"));
232
+ },
233
+ otherwise: function otherwise() {
234
+ return yup__namespace.mixed().nullable();
235
+ }
236
+ }) : yup__namespace.mixed().nullable(),
237
+ messagingProfile: hasSenderOptions ? yup__namespace.mixed().when("connectionType", {
238
+ is: CONNECTION_TYPES.MESSAGING_PROFILE,
239
+ then: function then() {
240
+ return yup__namespace.object().required(i18next.t("validations.required"));
241
+ },
242
+ otherwise: function otherwise() {
243
+ return yup__namespace.mixed().nullable();
244
+ }
245
+ }) : yup__namespace.mixed().nullable()
60
246
  });
61
247
  };
62
248
 
249
+ 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 }; })(); }
250
+ 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); }
63
251
  var useTelnyxForm = function useTelnyxForm(_ref) {
64
252
  var integrable = _ref.integrable,
65
- onConnect = _ref.onConnect;
66
- var _useState = React.useState([]),
67
- _useState2 = _slicedToArray(_useState, 2),
68
- phoneNumbers = _useState2[0],
69
- setPhoneNumbers = _useState2[1];
70
- var _useFetchTelnyxSmsCon = useTelnyxApi.useFetchTelnyxSmsConfiguration({
253
+ _ref$onConnect = _ref.onConnect,
254
+ onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect;
255
+ var _useFetchTelnyxConfig = useTelnyxApi.useFetchTelnyxConfiguration({
71
256
  integrable: integrable
72
257
  }),
73
- configuration = _useFetchTelnyxSmsCon.data,
74
- isLoading = _useFetchTelnyxSmsCon.isLoading;
75
- var _useFetchTelnyxPhoneN = useTelnyxApi.useFetchTelnyxPhoneNumbers(),
76
- fetchTelnyxPhoneNumbers = _useFetchTelnyxPhoneN.mutate,
77
- isFetchPhoneNumbersLoading = _useFetchTelnyxPhoneN.isPending;
78
- var _useCreateTelnyxSmsCo = useTelnyxApi.useCreateTelnyxSmsConfiguration({
258
+ data = _useFetchTelnyxConfig.data,
259
+ isConfigLoading = _useFetchTelnyxConfig.isFetching;
260
+ var configuration = React.useMemo(function () {
261
+ return data !== null && data !== void 0 ? data : {};
262
+ }, [data]);
263
+ var _useStateWithDependen = reactUtils.useStateWithDependency(configuration),
264
+ _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
265
+ credentials = _useStateWithDependen2[0],
266
+ setCredentials = _useStateWithDependen2[1];
267
+ var _useFetchTelnyxSender = useTelnyxApi.useFetchTelnyxSenderOptions({
268
+ credentials: credentials
269
+ }),
270
+ senderOptions = _useFetchTelnyxSender.data,
271
+ isSenderOptionsLoading = _useFetchTelnyxSender.isFetching;
272
+ var _useUpsertTelnyxConfi = useTelnyxApi.useUpsertTelnyxConfiguration({
273
+ onSuccess: onConnect,
79
274
  integrable: integrable
80
275
  }),
81
- createTelnyxSmsConfiguration = _useCreateTelnyxSmsCo.mutate,
82
- isCreateSmsConfigurationLoading = _useCreateTelnyxSmsCo.isPending;
83
- var handleSubmit = function handleSubmit(values) {
84
- if (ramda.isEmpty(phoneNumbers)) {
85
- var params = {
86
- apiKey: values.apiKey,
87
- messagingProfileId: values.messagingProfileId
88
- };
89
- fetchTelnyxPhoneNumbers(params, {
90
- onSuccess: function onSuccess(_ref2) {
91
- var phoneNumbers = _ref2.phoneNumbers;
92
- return setPhoneNumbers(phoneNumbers);
276
+ upsert = _useUpsertTelnyxConfi.mutateAsync,
277
+ isSubmitting = _useUpsertTelnyxConfi.isPending;
278
+ var phoneNumberOptions = React.useMemo(function () {
279
+ var _senderOptions$phoneN;
280
+ return buildPhoneNumberOptions((_senderOptions$phoneN = senderOptions === null || senderOptions === void 0 ? void 0 : senderOptions.phoneNumbers) !== null && _senderOptions$phoneN !== void 0 ? _senderOptions$phoneN : []);
281
+ }, [senderOptions]);
282
+ var messagingProfileOptions = React.useMemo(function () {
283
+ var _senderOptions$messag;
284
+ return buildMessagingProfileOptions((_senderOptions$messag = senderOptions === null || senderOptions === void 0 ? void 0 : senderOptions.messagingProfiles) !== null && _senderOptions$messag !== void 0 ? _senderOptions$messag : []);
285
+ }, [senderOptions]);
286
+ var initialValues = React.useMemo(function () {
287
+ var _configuration$apiKey, _configuration$connec;
288
+ var selectedPhone = neetoCist._findBy({
289
+ label: configuration === null || configuration === void 0 ? void 0 : configuration.phoneNumber
290
+ }, phoneNumberOptions);
291
+ var selectedProfile = neetoCist._findBy({
292
+ value: configuration === null || configuration === void 0 ? void 0 : configuration.messagingProfileId
293
+ }, messagingProfileOptions);
294
+ return {
295
+ apiKey: (_configuration$apiKey = configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) !== null && _configuration$apiKey !== void 0 ? _configuration$apiKey : "",
296
+ connectionType: (_configuration$connec = configuration === null || configuration === void 0 ? void 0 : configuration.connectionType) !== null && _configuration$connec !== void 0 ? _configuration$connec : CONNECTION_TYPES.PHONE_NUMBER,
297
+ phoneNumber: selectedPhone !== null && selectedPhone !== void 0 ? selectedPhone : null,
298
+ messagingProfile: selectedProfile !== null && selectedProfile !== void 0 ? selectedProfile : null
299
+ };
300
+ }, [configuration, phoneNumberOptions, messagingProfileOptions]);
301
+ var hasCredentials = !!(credentials !== null && credentials !== void 0 && credentials.api_key) || !!(credentials !== null && credentials !== void 0 && credentials.apiKey);
302
+ var senderOptionsAvailable = hasCredentials && !!senderOptions;
303
+ var handleSubmit = /*#__PURE__*/function () {
304
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(values) {
305
+ var payload, _values$phoneNumber, _values$phoneNumber2, _values$messagingProf, _values$messagingProf2;
306
+ return _regenerator().w(function (_context) {
307
+ while (1) switch (_context.n) {
308
+ case 0:
309
+ if (!(!senderOptionsAvailable && !(configuration !== null && configuration !== void 0 && configuration.connectionType))) {
310
+ _context.n = 1;
311
+ break;
312
+ }
313
+ setCredentials({
314
+ api_key: values.apiKey
315
+ });
316
+ return _context.a(2);
317
+ case 1:
318
+ // Second click ("Save changes"): real save
319
+ payload = {
320
+ api_key: values.apiKey,
321
+ connection_type: values.connectionType
322
+ };
323
+ if (values.connectionType === CONNECTION_TYPES.PHONE_NUMBER) {
324
+ payload.phone_number_id = (_values$phoneNumber = values.phoneNumber) === null || _values$phoneNumber === void 0 ? void 0 : _values$phoneNumber.value;
325
+ payload.phone_number = (_values$phoneNumber2 = values.phoneNumber) === null || _values$phoneNumber2 === void 0 ? void 0 : _values$phoneNumber2.label;
326
+ } else {
327
+ payload.messaging_profile_id = (_values$messagingProf = values.messagingProfile) === null || _values$messagingProf === void 0 ? void 0 : _values$messagingProf.value;
328
+ payload.messaging_profile_name = (_values$messagingProf2 = values.messagingProfile) === null || _values$messagingProf2 === void 0 ? void 0 : _values$messagingProf2.label;
329
+ }
330
+ _context.n = 2;
331
+ return upsert(payload);
332
+ case 2:
333
+ return _context.a(2);
93
334
  }
94
- });
95
- return;
96
- }
97
- var payload = {
98
- apiKey: values.apiKey,
99
- messagingProfileId: values.messagingProfileId,
100
- phoneNumberId: values.phoneNumber.value
335
+ }, _callee);
336
+ }));
337
+ return function handleSubmit(_x) {
338
+ return _ref2.apply(this, arguments);
101
339
  };
102
- createTelnyxSmsConfiguration(payload, {
103
- onSuccess: onConnect
104
- });
105
- };
106
- var isSubmitting = isFetchPhoneNumbersLoading || isCreateSmsConfigurationLoading;
107
- var phoneNumberOptions = buildPhoneNumberOptions(phoneNumbers);
108
- var initialValues = {
109
- apiKey: (configuration === null || configuration === void 0 ? void 0 : configuration.apiKey) || "",
110
- messagingProfileId: (configuration === null || configuration === void 0 ? void 0 : configuration.messagingProfileId) || "",
111
- phoneNumber: neetoCist.findBy({
112
- label: configuration === null || configuration === void 0 ? void 0 : configuration.phoneNumber
113
- }, phoneNumberOptions) || null
114
- };
340
+ }();
115
341
  return {
116
342
  initialValues: initialValues,
343
+ handleSubmit: handleSubmit,
117
344
  phoneNumberOptions: phoneNumberOptions,
345
+ messagingProfileOptions: messagingProfileOptions,
346
+ senderOptionsAvailable: senderOptionsAvailable,
347
+ isLoading: isConfigLoading || isSenderOptionsLoading,
118
348
  isSubmitting: isSubmitting,
119
- isLoading: isLoading,
120
- handleSubmit: handleSubmit
349
+ configuration: configuration
121
350
  };
122
351
  };
123
352
 
@@ -128,32 +357,33 @@ var Telnyx = function Telnyx(_ref) {
128
357
  onClose = _ref$onClose === void 0 ? neetoCist.noop : _ref$onClose,
129
358
  _ref$onConnect = _ref.onConnect,
130
359
  onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect;
131
- var formRef = React.useRef(null);
132
360
  var _useTranslation = reactI18next.useTranslation(),
133
361
  t = _useTranslation.t;
362
+ var initialFocusRef = React.useRef();
363
+ var formRef = React.useRef();
134
364
  var _useTelnyxForm = useTelnyxForm({
135
365
  integrable: integrable,
136
- onConnect: onConnect
137
- }),
366
+ onConnect: onConnect}),
138
367
  initialValues = _useTelnyxForm.initialValues,
139
368
  handleSubmit = _useTelnyxForm.handleSubmit,
140
369
  phoneNumberOptions = _useTelnyxForm.phoneNumberOptions,
141
- isSubmitting = _useTelnyxForm.isSubmitting,
142
- isLoading = _useTelnyxForm.isLoading;
143
- var hasPhoneNumbers = neetoCist.isNotEmpty(phoneNumberOptions);
144
- var submitButtonLabel = hasPhoneNumbers ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify");
145
- if (isLoading) return /*#__PURE__*/jsxRuntime.jsx(PageLoader, {});
146
- return /*#__PURE__*/jsxRuntime.jsx(Form, {
370
+ messagingProfileOptions = _useTelnyxForm.messagingProfileOptions,
371
+ senderOptionsAvailable = _useTelnyxForm.senderOptionsAvailable,
372
+ isLoading = _useTelnyxForm.isLoading,
373
+ isSubmitting = _useTelnyxForm.isSubmitting;
374
+ var isSubmitDisabled = function isSubmitDisabled(values) {
375
+ return ramda.equals(initialValues, values) || isLoading;
376
+ };
377
+ return /*#__PURE__*/jsxRuntime.jsx(FormikFormWrapper, {
147
378
  className: "w-full",
148
379
  formikProps: {
149
380
  enableReinitialize: true,
381
+ validationSchema: buildTelnyxConfigurationValidationSchema(senderOptionsAvailable),
150
382
  initialValues: initialValues,
151
- validationSchema: buildTelnyxConfigurationValidationSchema(hasPhoneNumbers),
152
383
  innerRef: formRef,
153
384
  onSubmit: handleSubmit
154
385
  },
155
- children: function children(_ref2) {
156
- var dirty = _ref2.dirty;
386
+ children: function children(formikProps) {
157
387
  return /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
158
388
  actionBlock: /*#__PURE__*/jsxRuntime.jsx(ActionBlock, {
159
389
  isSubmitting: isSubmitting,
@@ -161,27 +391,17 @@ var Telnyx = function Telnyx(_ref) {
161
391
  onClick: onClose
162
392
  },
163
393
  submitButtonProps: {
164
- label: submitButtonLabel,
165
- // The button is disabled if phoneNumberOptions is empty and there is no apiKey in initialValues while the form is not dirty.
166
- // If phoneNumberOptions is not empty, the button is disabled when the form is unchanged.
167
- disabled: !hasPhoneNumbers ? !initialValues.apiKey && !dirty : !dirty
394
+ label: senderOptionsAvailable ? t("neetoIntegrations.common.saveChanges") : t("neetoIntegrations.common.verify"),
395
+ disabled: isSubmitDisabled(formikProps.values) || isSubmitting,
396
+ loading: isSubmitting || isLoading
168
397
  }
169
398
  }),
170
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
171
- className: "space-y-4",
172
- children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
173
- disabled: hasPhoneNumbers,
174
- label: t("neetoIntegrations.telnyx.apiKey"),
175
- name: "apiKey"
176
- }), /*#__PURE__*/jsxRuntime.jsx(Input, {
177
- disabled: hasPhoneNumbers,
178
- label: t("neetoIntegrations.telnyx.messagingProfileId"),
179
- name: "messagingProfileId"
180
- }), hasPhoneNumbers && /*#__PURE__*/jsxRuntime.jsx(Select, {
181
- label: t("neetoIntegrations.telnyx.phoneNumber"),
182
- name: "phoneNumber",
183
- options: phoneNumberOptions
184
- })]
399
+ children: /*#__PURE__*/jsxRuntime.jsx(Form, {
400
+ formikProps: formikProps,
401
+ initialFocusRef: initialFocusRef,
402
+ messagingProfileOptions: messagingProfileOptions,
403
+ phoneNumberOptions: phoneNumberOptions,
404
+ senderOptionsAvailable: senderOptionsAvailable
185
405
  })
186
406
  });
187
407
  }