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

hit api to change statuses open

kaori 4 лет назад
Родитель
Сommit
cf76eee40b

+ 6 - 2
packages/app/src/components/InAppNotification/InAppNotificationPage.tsx

@@ -9,6 +9,7 @@ import { useSWRxInAppNotifications } from '../../stores/in-app-notification';
 import PaginationWrapper from '../PaginationWrapper';
 import PaginationWrapper from '../PaginationWrapper';
 import CustomNavAndContents from '../CustomNavigation/CustomNavAndContents';
 import CustomNavAndContents from '../CustomNavigation/CustomNavAndContents';
 import { InAppNotificationStatuses } from '~/interfaces/in-app-notification';
 import { InAppNotificationStatuses } from '~/interfaces/in-app-notification';
+import { apiv3Put } from '~/client/util/apiv3-client';
 
 
 
 
 type Props = {
 type Props = {
@@ -63,6 +64,10 @@ const InAppNotificationPageBody: FC<Props> = (props) => {
     );
     );
   };
   };
 
 
+  const updateUnopendNotificationStatusesToOpened = async() => {
+    await apiv3Put('/in-app-notification/all-statuses-open');
+  };
+
   // commonize notification lists by 81953
   // commonize notification lists by 81953
   const UnopenedInAppNotificationList = () => {
   const UnopenedInAppNotificationList = () => {
     const { data: unopendNotificationData } = useSWRxInAppNotifications(limit, offsetOfUnopenedNotificationCat, InAppNotificationStatuses.STATUS_UNOPENED);
     const { data: unopendNotificationData } = useSWRxInAppNotifications(limit, offsetOfUnopenedNotificationCat, InAppNotificationStatuses.STATUS_UNOPENED);
@@ -83,8 +88,7 @@ const InAppNotificationPageBody: FC<Props> = (props) => {
           <button
           <button
             type="button"
             type="button"
             className="btn btn-outline-primary"
             className="btn btn-outline-primary"
-            // TODO: set "UNOPENED" notification status "OPEND" by 81951
-            // onClick={}
+            onClick={updateUnopendNotificationStatusesToOpened}
           >
           >
             {t('in_app_notification.mark_all_as_read')}
             {t('in_app_notification.mark_all_as_read')}
           </button>
           </button>

+ 16 - 0
packages/app/src/server/routes/apiv3/in-app-notification.ts

@@ -103,5 +103,21 @@ module.exports = (crowi) => {
     }
     }
   });
   });
 
 
+  router.put('/open-all', accessTokenParser, loginRequiredStrictly, csrf, async(req, res) => {
+    // const user = req.user;
+    // const id = req.body.id;
+    console.log('api叩かれた');
+
+    // try {
+    //   // findする
+    //   const notifications = await inAppNotificationService.markAllNotificationsAsOpened(user);
+    //   const result = { notifications };
+    //   return res.apiv3(result);
+    // }
+    // catch (err) {
+    //   return res.apiv3Err(err);
+    // }
+  });
+
   return router;
   return router;
 };
 };