@bigbinary/neeto-integrations-frontend 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -64,6 +64,7 @@ var INTEGRATIONS_ENGINE_BASE_URL = "/neeto_integrations";
64
64
  var TWILIO_CONFIGURATION_BASE_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/twilio/sms_configurations");
65
65
  var INTEGRATIONS_ENGINE_DAILY_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/daily");
66
66
  var INTEGRATIONS_ENGINE_ZOOM_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/zoom");
67
+ var INTEGRATION_DETAILS_URL = "".concat(INTEGRATIONS_ENGINE_BASE_URL, "/status");
67
68
 
68
69
  var create = function create(payload) {
69
70
  return axios.post(INTEGRATIONS_ENGINE_DAILY_URL, {
@@ -89,11 +90,11 @@ var QUERY_KEYS = {
89
90
  ZOOM_DETAILS: "zoom-details"
90
91
  };
91
92
 
92
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
93
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
93
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
94
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
94
95
  var useCreateDaily = function useCreateDaily() {
95
96
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
96
- return useMutationWithInvalidation(dailiesApi.create, _objectSpread$3({
97
+ return useMutationWithInvalidation(dailiesApi.create, _objectSpread$4({
97
98
  keysToInvalidate: [QUERY_KEYS.DAILY_CO_DETAILS]
98
99
  }, options));
99
100
  };
@@ -433,8 +434,8 @@ var TWILIO_INTEGRATION_STEPS = [{
433
434
  isCompleted: false
434
435
  }];
435
436
 
436
- function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
437
- function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
437
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
438
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
438
439
  var ConfigurationForm = function ConfigurationForm(_ref) {
439
440
  var _errors$twilioPhoneNu;
440
441
  var phoneNumberOptions = _ref.phoneNumberOptions,
@@ -483,7 +484,7 @@ var ConfigurationForm = function ConfigurationForm(_ref) {
483
484
  options: phoneNumberOptions,
484
485
  size: "large",
485
486
  onChange: function onChange(selected) {
486
- return setValues(_objectSpread$2(_objectSpread$2({}, values), {}, {
487
+ return setValues(_objectSpread$3(_objectSpread$3({}, values), {}, {
487
488
  twilioPhoneNumber: selected
488
489
  }));
489
490
  }
@@ -506,25 +507,36 @@ function _toConsumableArray(arr) {
506
507
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
507
508
  }
508
509
 
510
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
511
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
512
+ var fetchTwilioSmsConfiguration = function fetchTwilioSmsConfiguration(integrable) {
513
+ return axios.get(TWILIO_CONFIGURATION_BASE_URL, {
514
+ params: integrable
515
+ });
516
+ };
517
+ var removeTwilioConfiguration = function removeTwilioConfiguration() {
518
+ return axios["delete"](TWILIO_CONFIGURATION_BASE_URL);
519
+ };
520
+ var getTwilioPhoneNumbers = function getTwilioPhoneNumbers(data) {
521
+ return axios.get("".concat(TWILIO_CONFIGURATION_BASE_URL, "/new"), {
522
+ params: data
523
+ });
524
+ };
525
+ var createTwilioConfiguration = function createTwilioConfiguration(payload, integrable) {
526
+ return axios.post(TWILIO_CONFIGURATION_BASE_URL, _objectSpread$2(_objectSpread$2({}, payload), integrable));
527
+ };
509
528
  var twilioApi = {
510
- fetchTwilioSmsConfiguration: function fetchTwilioSmsConfiguration() {
511
- return axios.get(TWILIO_CONFIGURATION_BASE_URL);
512
- },
513
- removeTwilioConfiguration: function removeTwilioConfiguration() {
514
- return axios["delete"](TWILIO_CONFIGURATION_BASE_URL);
515
- },
516
- getTwilioPhoneNumbers: function getTwilioPhoneNumbers(data) {
517
- return axios.get("".concat(TWILIO_CONFIGURATION_BASE_URL, "/new"), {
518
- params: data
519
- });
520
- },
521
- createTwilioConfiguration: function createTwilioConfiguration(payload) {
522
- return axios.post(TWILIO_CONFIGURATION_BASE_URL, payload);
523
- }
529
+ fetchTwilioSmsConfiguration: fetchTwilioSmsConfiguration,
530
+ removeTwilioConfiguration: removeTwilioConfiguration,
531
+ getTwilioPhoneNumbers: getTwilioPhoneNumbers,
532
+ createTwilioConfiguration: createTwilioConfiguration
524
533
  };
525
534
 
526
- var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
527
- return useQuery(QUERY_KEYS.TWILIO_SMS_CONFIGURATION, twilioApi.fetchTwilioSmsConfiguration, {
535
+ var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration(_ref) {
536
+ var integrable = _ref.integrable;
537
+ return useQuery([QUERY_KEYS.TWILIO_SMS_CONFIGURATION, integrable === null || integrable === void 0 ? void 0 : integrable.integrableId], function () {
538
+ return twilioApi.fetchTwilioSmsConfiguration(integrable);
539
+ }, {
528
540
  select: function select(response) {
529
541
  var _smsConfiguration$twi, _smsConfiguration$twi2, _smsConfiguration$twi3;
530
542
  var smsConfiguration = response.smsConfiguration;
@@ -536,10 +548,10 @@ var useFetchTwilioSmsConfiguration = function useFetchTwilioSmsConfiguration() {
536
548
  }
537
549
  });
538
550
  };
539
- var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
551
+ var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref2) {
540
552
  var _formRef$current, _formRef$current$valu, _formRef$current2, _formRef$current2$val;
541
- var credentials = _ref.credentials,
542
- formRef = _ref.formRef;
553
+ var credentials = _ref2.credentials,
554
+ formRef = _ref2.formRef;
543
555
  return useQuery([QUERY_KEYS.TWILIO_PHONE_NUMBERS, {
544
556
  credentials: credentials
545
557
  }], function () {
@@ -550,27 +562,31 @@ var useFetchTwilioPhoneNumbers = function useFetchTwilioPhoneNumbers(_ref) {
550
562
  retry: false
551
563
  });
552
564
  };
553
- var useCreateTwilioConfiguration = function useCreateTwilioConfiguration() {
554
- return useMutationWithInvalidation(twilioApi.createTwilioConfiguration, {
555
- keysToInvalidate: [QUERY_KEYS.TWILIO_SMS_CONFIGURATION]
565
+ var useCreateTwilioConfiguration = function useCreateTwilioConfiguration(_ref3) {
566
+ var integrable = _ref3.integrable;
567
+ return useMutationWithInvalidation(function (payload) {
568
+ return twilioApi.createTwilioConfiguration(payload, integrable);
569
+ }, {
570
+ keysToInvalidate: [QUERY_KEYS.TWILIO_SMS_CONFIGURATION, integrable === null || integrable === void 0 ? void 0 : integrable.integrableId]
556
571
  });
557
572
  };
558
573
 
559
574
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
560
575
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
561
576
  var useTwilio = function useTwilio(_ref) {
562
- var _ref$onSave = _ref.onSave,
563
- onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
564
- _ref$setSteps = _ref.setSteps,
577
+ var _ref$setSteps = _ref.setSteps,
565
578
  setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
566
579
  _ref$onConnect = _ref.onConnect,
567
580
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
568
581
  _ref$formRef = _ref.formRef,
569
- formRef = _ref$formRef === void 0 ? null : _ref$formRef;
570
- var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration(),
582
+ formRef = _ref$formRef === void 0 ? null : _ref$formRef,
583
+ _ref$integrable = _ref.integrable,
584
+ integrable = _ref$integrable === void 0 ? null : _ref$integrable;
585
+ var _useFetchTwilioSmsCon = useFetchTwilioSmsConfiguration({
586
+ integrable: integrable
587
+ }),
571
588
  configuration = _useFetchTwilioSmsCon.data,
572
- isConfigurationLoading = _useFetchTwilioSmsCon.isLoading,
573
- refetchTwilioSmsConfiguration = _useFetchTwilioSmsCon.refetch;
589
+ isConfigurationLoading = _useFetchTwilioSmsCon.isLoading;
574
590
  var _useStateWithDependen = useStateWithDependency(configuration),
575
591
  _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
576
592
  credentials = _useStateWithDependen2[0],
@@ -581,7 +597,9 @@ var useTwilio = function useTwilio(_ref) {
581
597
  }),
582
598
  phoneNumbers = _useFetchTwilioPhoneN.data,
583
599
  isPhoneNumbersLoading = _useFetchTwilioPhoneN.isLoading;
584
- var _useCreateTwilioConfi = useCreateTwilioConfiguration(),
600
+ var _useCreateTwilioConfi = useCreateTwilioConfiguration({
601
+ integrable: integrable
602
+ }),
585
603
  saveConfiguration = _useCreateTwilioConfi.mutate,
586
604
  isSubmitting = _useCreateTwilioConfi.isLoading;
587
605
  useEffect(function () {
@@ -606,11 +624,7 @@ var useTwilio = function useTwilio(_ref) {
606
624
  return;
607
625
  }
608
626
  saveConfiguration(payload, {
609
- onSuccess: function onSuccess() {
610
- onSave();
611
- refetchTwilioSmsConfiguration();
612
- onConnect === null || onConnect === void 0 ? void 0 : onConnect();
613
- }
627
+ onSuccess: onConnect
614
628
  });
615
629
  };
616
630
  return {
@@ -639,23 +653,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
639
653
  var TwilioConfiguration = function TwilioConfiguration(_ref) {
640
654
  var _ref$onCancel = _ref.onCancel,
641
655
  onCancel = _ref$onCancel === void 0 ? noop : _ref$onCancel,
642
- _ref$onSave = _ref.onSave,
643
- onSave = _ref$onSave === void 0 ? noop : _ref$onSave,
644
656
  _ref$setSteps = _ref.setSteps,
645
657
  setSteps = _ref$setSteps === void 0 ? noop : _ref$setSteps,
646
658
  _ref$onConnect = _ref.onConnect,
647
659
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect,
648
660
  _ref$isModal = _ref.isModal,
649
- isModal = _ref$isModal === void 0 ? false : _ref$isModal;
661
+ isModal = _ref$isModal === void 0 ? false : _ref$isModal,
662
+ _ref$integrable = _ref.integrable,
663
+ integrable = _ref$integrable === void 0 ? null : _ref$integrable;
650
664
  var _useTranslation = useTranslation(),
651
665
  t = _useTranslation.t;
652
666
  var initialFocusRef = useRef();
653
667
  var formRef = useRef();
654
668
  var _useTwilio = useTwilio({
655
- onSave: onSave,
656
669
  setSteps: setSteps,
657
670
  onConnect: onConnect,
658
- formRef: formRef
671
+ formRef: formRef,
672
+ integrable: integrable
659
673
  }),
660
674
  handleSubmit = _useTwilio.handleSubmit,
661
675
  phoneNumbers = _useTwilio.phoneNumbers,
@@ -726,7 +740,13 @@ var TwilioConfiguration = function TwilioConfiguration(_ref) {
726
740
  };
727
741
 
728
742
  var Twilio = function Twilio(_ref) {
729
- var _ref$onClose = _ref.onClose,
743
+ var _ref$integrable = _ref.integrable,
744
+ integrable = _ref$integrable === void 0 ? null : _ref$integrable,
745
+ _ref$isModal = _ref.isModal,
746
+ isModal = _ref$isModal === void 0 ? true : _ref$isModal,
747
+ _ref$isModalOpen = _ref.isModalOpen,
748
+ isModalOpen = _ref$isModalOpen === void 0 ? true : _ref$isModalOpen,
749
+ _ref$onClose = _ref.onClose,
730
750
  onClose = _ref$onClose === void 0 ? noop : _ref$onClose,
731
751
  _ref$onConnect = _ref.onConnect,
732
752
  onConnect = _ref$onConnect === void 0 ? noop : _ref$onConnect;
@@ -735,11 +755,12 @@ var Twilio = function Twilio(_ref) {
735
755
  steps = _useState2[0],
736
756
  setSteps = _useState2[1];
737
757
  return /*#__PURE__*/React__default.createElement(Modal, {
738
- isOpen: true,
758
+ isOpen: isModalOpen,
739
759
  steps: steps,
740
760
  onClose: onClose
741
761
  }, /*#__PURE__*/React__default.createElement(TwilioConfiguration, {
742
- isModal: true,
762
+ integrable: integrable,
763
+ isModal: isModal,
743
764
  setSteps: setSteps,
744
765
  onCancel: onClose,
745
766
  onConnect: onConnect
@@ -747,7 +768,11 @@ var Twilio = function Twilio(_ref) {
747
768
  };
748
769
 
749
770
  var show = function show() {
750
- return axios.get(INTEGRATIONS_ENGINE_ZOOM_URL);
771
+ return axios.get(INTEGRATION_DETAILS_URL, {
772
+ params: {
773
+ serviceName: "Zoom"
774
+ }
775
+ });
751
776
  };
752
777
  var destroy = function destroy() {
753
778
  return axios["delete"]("".concat(INTEGRATIONS_ENGINE_ZOOM_URL, "/oauth"));