|
|
@@ -1,15 +1,34 @@
|
|
|
import React, { useState } from 'react';
|
|
|
-
|
|
|
+import PropTypes from 'prop-types';
|
|
|
+import AppContainer from '../../../services/AppContainer';
|
|
|
+import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
+import { toastError } from '../../../util/apiNotification';
|
|
|
import AccessTokenSettings from './AccessTokenSettings';
|
|
|
import OfficialBotSettings from './OfficialBotSettings';
|
|
|
import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
|
|
|
import CustomBotWithProxySettings from './CustomBotWithProxySettings';
|
|
|
import ConfirmBotChangeModal from './ConfirmBotChangeModal';
|
|
|
|
|
|
-const SlackIntegration = () => {
|
|
|
+const SlackIntegration = (props) => {
|
|
|
+ const { appContainer } = props;
|
|
|
+
|
|
|
const [currentBotType, setCurrentBotType] = useState(null);
|
|
|
const [selectedBotType, setSelectedBotType] = useState(null);
|
|
|
|
|
|
+ const resetBotType = async() => {
|
|
|
+ try {
|
|
|
+ const res = await appContainer.apiv3.put('slack-integration/custom-bot-without-proxy', {
|
|
|
+ slackSigningSecret: '',
|
|
|
+ slackBotToken: '',
|
|
|
+ botType: '',
|
|
|
+ });
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ toastError(err);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
const handleBotTypeSelect = (clickedBotType) => {
|
|
|
if (clickedBotType === currentBotType) {
|
|
|
return;
|
|
|
@@ -26,6 +45,7 @@ const SlackIntegration = () => {
|
|
|
};
|
|
|
|
|
|
const changeCurrentBotSettings = () => {
|
|
|
+ resetBotType();
|
|
|
setCurrentBotType(selectedBotType);
|
|
|
setSelectedBotType(null);
|
|
|
};
|
|
|
@@ -106,4 +126,10 @@ const SlackIntegration = () => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-export default SlackIntegration;
|
|
|
+const SlackIntegrationWrapper = withUnstatedContainers(SlackIntegration, [AppContainer]);
|
|
|
+
|
|
|
+SlackIntegration.propTypes = {
|
|
|
+ appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
+};
|
|
|
+
|
|
|
+export default SlackIntegrationWrapper;
|