Преглед изворни кода

fetch GoogleSecuritySettingsData

kaori пре 3 година
родитељ
комит
a3574ab2d0
1 измењених фајлова са 16 додато и 19 уклоњено
  1. 16 19
      packages/app/src/components/Admin/Security/GoogleSecuritySetting.jsx

+ 16 - 19
packages/app/src/components/Admin/Security/GoogleSecuritySetting.jsx

@@ -1,5 +1,4 @@
-/* eslint-disable react/no-danger */
-import React from 'react';
+import React, { useEffect } from 'react';
 
 import PropTypes from 'prop-types';
 
@@ -14,23 +13,21 @@ import GoogleSecurityManagementContents from './GoogleSecuritySettingContents';
 let retrieveErrors = null;
 function GoogleSecurityManagement(props) {
   const { adminGoogleSecurityContainer } = props;
-  // if (adminGoogleSecurityContainer.state.googleClientId === adminGoogleSecurityContainer.dummyGoogleClientId) {
-  //   throw (async() => {
-  //     try {
-  //       await adminGoogleSecurityContainer.retrieveSecurityData();
-  //     }
-  //     catch (err) {
-  //       const errs = toArrayIfNot(err);
-  //       toastError(errs);
-  //       retrieveErrors = errs;
-  //       adminGoogleSecurityContainer.setState({ googleClientId: adminGoogleSecurityContainer.dummyGoogleClientIdForError });
-  //     }
-  //   })();
-  // }
-
-  // if (adminGoogleSecurityContainer.state.googleClientId === adminGoogleSecurityContainer.dummyGoogleClientIdForError) {
-  //   throw new Error(`${retrieveErrors.length} errors occured`);
-  // }
+
+  useEffect(() => {
+    const fetchGoogleSecuritySettingsData = async() => {
+      await adminGoogleSecurityContainer.retrieveSecurityData();
+    };
+
+    try {
+      fetchGoogleSecuritySettingsData();
+    }
+    catch (err) {
+      const errs = toArrayIfNot(err);
+      toastError(errs);
+      logger.error(errs);
+    }
+  }, [adminGoogleSecurityContainer]);
 
   return <GoogleSecurityManagementContents />;
 }