itizawa пре 6 година
родитељ
комит
b760c8b953

+ 4 - 2
src/client/js/components/Admin/Notification/GlobalNotificationList.jsx

@@ -28,13 +28,15 @@ class GlobalNotificationList extends React.Component {
     this.onClickSubmit = this.onClickSubmit.bind(this);
     this.onClickSubmit = this.onClickSubmit.bind(this);
   }
   }
 
 
-  async toggleIsEnabled(notification, isEnabled) {
+  async toggleIsEnabled(notification) {
     const { t } = this.props;
     const { t } = this.props;
+    const isEnabled = !notification.isEnabled;
     try {
     try {
       await this.props.appContainer.apiv3.put(`/notification-setting/global-notification/${notification._id}/enabled`, {
       await this.props.appContainer.apiv3.put(`/notification-setting/global-notification/${notification._id}/enabled`, {
         isEnabled,
         isEnabled,
       });
       });
       toastSuccess(t('notification_setting.toggle_notification', { path: notification.triggerPath }));
       toastSuccess(t('notification_setting.toggle_notification', { path: notification.triggerPath }));
+      await this.props.adminNotificationContainer.retrieveNotificationData();
     }
     }
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);
@@ -78,7 +80,7 @@ class GlobalNotificationList extends React.Component {
                   id="isNotificationEnabled"
                   id="isNotificationEnabled"
                   type="checkbox"
                   type="checkbox"
                   defaultChecked={notification.isEnabled}
                   defaultChecked={notification.isEnabled}
-                  onClick={e => this.toggleIsEnabled(notification, e.target.value)}
+                  onClick={e => this.toggleIsEnabled(notification)}
                 />
                 />
               </td>
               </td>
               <td>
               <td>

+ 1 - 2
src/server/routes/apiv3/notification-setting.js

@@ -193,8 +193,7 @@ module.exports = (crowi) => {
   // TODO swagger
   // TODO swagger
   router.put('/global-notification/:id/enabled', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
   router.put('/global-notification/:id/enabled', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
     const { id } = req.params;
     const { id } = req.params;
-    const isEnabled = req.query;
-    console.log(isEnabled);
+    const { isEnabled } = req.body;
 
 
     try {
     try {
       if (isEnabled) {
       if (isEnabled) {