import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import AppContainer from '../../../services/AppContainer'; import AdminAppContainer from '../../../services/AdminAppContainer'; import { withUnstatedContainers } from '../../UnstatedUtils'; import CustomBotWithoutProxySettingsAccordion, { botInstallationStep } from './CustomBotWithoutProxySettingsAccordion'; import CustomBotWithoutProxyConnectionStatus from './CustomBotWithoutProxyConnectionStatus'; const CustomBotWithoutProxySettings = (props) => { const { appContainer, connectionStatuses } = props; const { t } = useTranslation(); const [siteName, setSiteName] = useState(''); const [isIntegrationSuccess, setIsIntegrationSuccess] = useState(false); const [connectionMessage, setConnectionMessage] = useState(null); const [testChannel, setTestChannel] = useState(''); const testConnection = async() => { try { await appContainer.apiv3.post('/slack-integration-settings/without-proxy/test', { channel: testChannel }); setConnectionMessage(''); setIsIntegrationSuccess(true); } catch (err) { setConnectionMessage(err[0]); setIsIntegrationSuccess(false); } }; const inputTestChannelHandler = (channel) => { setTestChannel(channel); }; useEffect(() => { const siteName = appContainer.config.crowi.title; setSiteName(siteName); }, [appContainer]); const workspaceName = connectionStatuses[props.slackBotToken]?.workspaceName; return ( <>