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

+ 8 - 6
packages/app/src/components/InAppNotification/NotificationContent.tsx

@@ -2,6 +2,7 @@ import React from 'react';
 import { PagePathLabel } from '@growi/ui';
 import { IInAppNotification } from '../../interfaces/in-app-notification';
 import loggerFactory from '~/utils/logger';
+import { apiv3Post } from '../../client/util/apiv3-client';
 
 import FormattedDistanceDate from '../FormattedDistanceDate';
 
@@ -12,13 +13,14 @@ interface Props {
   notification: IInAppNotification
 }
 
-const notificationClickHandler = async(pagePath: string) => {
+const notificationClickHandler = async(notification: IInAppNotification) => {
 
   try {
-    // TODO: change notification status read by #80904
-    // await this.props.crowi.apiPost('/notification.open', { id: notification._id });
+    window.location.href = notification.target.path;
+    // set notification status "STATUS_OPEND"
+    await apiv3Post('/in-app-notification/open', { id: notification._id });
     // jump to target page
-    window.location.href = pagePath;
+    console.log('path', notification.target.path);
   }
   catch (err) {
     logger.error(err);
@@ -30,7 +32,7 @@ export const PageCommentNotification = (props: Props): JSX.Element => {
   const pagePath = { path: props.notification.target.path };
 
   return (
-    <div onClick={() => notificationClickHandler(pagePath.path)}>
+    <div onClick={() => notificationClickHandler(props.notification)}>
       <div>
         <b>{props.actionUsers}</b> commented on  <PagePathLabel page={pagePath} />
       </div>
@@ -45,7 +47,7 @@ export const PageUpdateNotification = (props: Props): JSX.Element => {
   const pagePath = { path: props.notification.target.path };
 
   return (
-    <div onClick={() => notificationClickHandler(pagePath.path)}>
+    <div onClick={() => notificationClickHandler(props.notification)}>
       <div>
         <b>{props.actionUsers}</b> page updated on <PagePathLabel page={pagePath} />
       </div>