Przeglądaj źródła

imprv onAssociate props

kaori 3 lat temu
rodzic
commit
5b8dda9670
1 zmienionych plików z 11 dodań i 15 usunięć
  1. 11 15
      packages/app/src/components/Me/AssociateModal.jsx

+ 11 - 15
packages/app/src/components/Me/AssociateModal.jsx

@@ -49,21 +49,12 @@ class AssociateModal extends React.Component {
 
   async onClickAddBtn() {
     const {
-      t, onAssociated, associateLdapAccount,
+      onAssociate, onClose,
     } = this.props;
     const { username, password } = this.state;
 
-    try {
-      await associateLdapAccount({ username, password });
-      this.props.onClose();
-      toastSuccess(t('security_setting.updated_general_security_setting'));
-    }
-    catch (err) {
-      toastError(err);
-    }
-    if (onAssociated != null) {
-      onAssociated();
-    }
+    onAssociate({ username, password });
+    onClose();
   }
 
   render() {
@@ -135,15 +126,20 @@ AssociateModal.propTypes = {
 
   isOpen: PropTypes.bool.isRequired,
   onClose: PropTypes.func.isRequired,
-  onAssociated: PropTypes.func,
-  associateLdapAccount: PropTypes.func,
+  onAssociate: PropTypes.func.isRequired,
 };
 
 const AssociateModalWrapperFC = (props) => {
   const { t } = useTranslation();
   const { mutate: mutatePersonalExternalAccounts } = useSWRxPersonalExternalAccounts();
   const { associateLdapAccount } = usePersonalSettings();
-  return <AssociateModal t={t} onAssociated={mutatePersonalExternalAccounts} associateLdapAccount={associateLdapAccount} {...props} />;
+
+  const associateLdapAccountHandler = (account) => {
+    associateLdapAccount(account);
+    mutatePersonalExternalAccounts();
+  };
+
+  return <AssociateModal t={t} onAssociate={associateLdapAccountHandler} {...props} />;
 };
 
 /**