itizawa 6 лет назад
Родитель
Сommit
e85f40c1e2
1 измененных файлов с 10 добавлено и 7 удалено
  1. 10 7
      src/client/js/components/Admin/Users/UserRemoveForm.jsx

+ 10 - 7
src/client/js/components/Admin/Users/UserRemoveForm.jsx

@@ -14,22 +14,25 @@ class UserRemoveForm extends React.Component {
 
 
     };
     };
 
 
-    this.handleSubmit = this.handleSubmit.bind(this);
+    this.onClickDeleteBtn = this.onClickDeleteBtn.bind(this);
   }
   }
 
 
-  // これは将来的にapiにするので。あとボタンにするとデザインがよくなかったので。
-  handleSubmit(event) {
-    $(event.currentTarget).parent().submit();
+  async onClickDeleteBtn() {
+    const { appContainer, user } = this.props;
+
+    await appContainer.apiv3.delete('/users/delete', {
+      userId: user._id,
+    });
   }
   }
 
 
   render() {
   render() {
-    const { t, appContainer, user } = this.props;
+    const { t, appContainer } = this.props;
 
 
     return (
     return (
       <a className="px-4">
       <a className="px-4">
-        <form action={`/admin/user/${user._id}/remove`} method="post">
+        <form onClick={this.onClickDeleteBtn}>
           <input type="hidden" name="_csrf" value={appContainer.csrfToken} />
           <input type="hidden" name="_csrf" value={appContainer.csrfToken} />
-          <span onClick={this.handleSubmit}>
+          <span>
             <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
             <i className="icon-fw icon-fire text-danger"></i> { t('Delete') }
           </span>
           </span>
         </form>
         </form>