Procházet zdrojové kódy

fix resetAllSettings

zahmis před 4 roky
rodič
revize
07ca21c41d

+ 10 - 6
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -29,6 +29,8 @@ const SlackIntegration = (props) => {
   const fetchSlackIntegrationData = useCallback(async() => {
     try {
       const { data } = await appContainer.apiv3.get('/slack-integration-settings');
+      console.log(data);
+
       const {
         slackSigningSecret, slackBotToken, slackSigningSecretEnvVars, slackBotTokenEnvVars,
       } = data.settings;
@@ -38,36 +40,38 @@ const SlackIntegration = (props) => {
         setSlackWSNameInWithoutProxy(workspaceName);
       }
 
-      setCurrentBotType(currentBotType);
+      setCurrentBotType(data.currentBotType);
       setSlackSigningSecret(slackSigningSecret);
       setSlackBotToken(slackBotToken);
       setSlackSigningSecretEnv(slackSigningSecretEnvVars);
       setSlackBotTokenEnv(slackBotTokenEnvVars);
+      console.log(data.currentBotType);
     }
     catch (err) {
       toastError(err);
     }
-  }, [appContainer.apiv3, currentBotType]);
+  }, [appContainer.apiv3]);
 
-  const resetAllSettings = useCallback(async() => {
+  const resetAllSettings = async() => {
     try {
       await appContainer.apiv3.put('/slack-integration-settings/custom-bot-without-proxy', {
         slackSigningSecret: '',
         slackBotToken: '',
         currentBotType: '',
       });
+      console.log('hoge');
+      fetchSlackIntegrationData();
       toastSuccess('success');
     }
     catch (err) {
       toastError(err);
     }
-  }, [appContainer.apiv3]);
+  };
 
 
   useEffect(() => {
     fetchSlackIntegrationData();
-    resetAllSettings();
-  }, [fetchSlackIntegrationData, resetAllSettings]);
+  }, [fetchSlackIntegrationData]);
 
 
   const handleBotTypeSelect = (clickedBotType) => {