فهرست منبع

simplufy actioMsg

kaori 4 سال پیش
والد
کامیت
8fc1743f7d
1فایلهای تغییر یافته به همراه14 افزوده شده و 13 حذف شده
  1. 14 13
      packages/app/src/components/InAppNotification/InAppNotificationElm.tsx

+ 14 - 13
packages/app/src/components/InAppNotification/InAppNotificationElm.tsx

@@ -79,18 +79,19 @@ const InAppNotificationElm = (props: Props): JSX.Element => {
   const actionUsers = getActionUsers();
   const pagePath = { path: props.notification.target.path };
 
-  const renderInAppNotificationContent = (): string => {
-    const action: string = notification.action;
-
-    switch (action) {
-      case 'PAGE_UPDATE':
-        return 'updated on';
-      case 'COMMENT_CREATE':
-        return 'commented on';
-      default:
-        return '';
-    }
-  };
+  const action: string = notification.action;
+  let actionMsg: string;
+
+  switch (action) {
+    case 'PAGE_UPDATE':
+      actionMsg = 'updated on';
+      break;
+    case 'COMMENT_CREATE':
+      actionMsg = 'commented on';
+      break;
+    default:
+      actionMsg = '';
+  }
 
 
   return (
@@ -102,7 +103,7 @@ const InAppNotificationElm = (props: Props): JSX.Element => {
         <div className="p-2">
           <div onClick={() => notificationClickHandler(notification)}>
             <div>
-              <b>{actionUsers}</b> {renderInAppNotificationContent()} <PagePathLabel page={pagePath} />
+              <b>{actionUsers}</b> {actionMsg} <PagePathLabel page={pagePath} />
             </div>
             <i className="fa fa-file-o mr-2" />
             <FormattedDistanceDate id={notification._id} date={notification.createdAt} isShowTooltip={false} />