Просмотр исходного кода

124062 change button from send to done

soumaeda 2 лет назад
Родитель
Сommit
33a4aede74
1 измененных файлов с 12 добавлено и 4 удалено
  1. 12 4
      apps/app/src/components/Admin/Users/PasswordResetModal.jsx

+ 12 - 4
apps/app/src/components/Admin/Users/PasswordResetModal.jsx

@@ -19,7 +19,7 @@ class PasswordResetModal extends React.Component {
     this.state = {
       temporaryPassword: [],
       isPasswordResetDone: false,
-      sendEmail: false,
+      isEmailSent: false,
     };
 
     this.resetPassword = this.resetPassword.bind(this);
@@ -40,12 +40,19 @@ class PasswordResetModal extends React.Component {
 
   renderButtons() {
     const { t, isMailerSetup } = this.props;
+    const { isEmailSent } = this.state;
 
     return (
       <>
-        <button type="submit" className="btn btn-primary" onClick={this.onClickSendNewPasswordButton} disabled={!isMailerSetup}>
-          {t('Send')}
-        </button>
+        {isEmailSent ? (
+          <button type="submit" className="btn btn-secondary" disabled>
+            {t('Done')}
+          </button>
+        ) : (
+          <button type="submit" className="btn btn-primary" onClick={this.onClickSendNewPasswordButton} disabled={!isMailerSetup}>
+            {t('Send')}
+          </button>
+        )}
         <button type="submit" className="btn btn-danger" onClick={this.props.onClose}>
           {t('Close')}
         </button>
@@ -150,6 +157,7 @@ class PasswordResetModal extends React.Component {
 
     try {
       await apiv3Put('/users/reset-password-email', { id: userForPasswordResetModal._id, newPassword: this.state.temporaryPassword });
+      this.setState({ isEmailSent: true });
     }
     catch (err) {
       toastError(err);