kaori 4 lat temu
rodzic
commit
bccb051b10

+ 37 - 3
packages/app/src/components/InAppNotification/AllInAppNotifications.tsx

@@ -1,15 +1,49 @@
-import React, { FC } from 'react';
+import React, { FC, useState, useEffect } from 'react';
+
+import AppContainer from '../../client/services/AppContainer';
+
+import InAppNotificationContents from './InAppNotificationContents';
+import { withUnstatedContainers } from '../UnstatedUtils';
 
 type Props = {
+  appContainer: AppContainer,
 
 };
 
 const AllInAppNotifications: FC<Props> = (props: Props) => {
+  const { appContainer } = props;
+  const [notifications, setNotifications] = useState([]);
+  // const [isLoaded, setIsLoaded] = useState(false);
+
+  // useEffect(() => {
+  //   fetchNotificationStatus();
+  // }, []);
+
+
+  /**
+    * TODO: Fetch notification list by GW-7473
+    */
+  const fetchNotificationList = async() => {
+    const limit = 6;
+    try {
+      const paginationResult = await appContainer.apiv3Get('/in-app-notification/list', { limit });
+
+      setNotifications(paginationResult.data.docs);
+      // setIsLoaded(true);
+    }
+    catch (err) {
+      // logger.error(err);
+    }
+  };
 
   return (
-    <>All In App Notifications</>
+    <InAppNotificationContents notifications={notifications} />
   );
 };
 
+/**
+ * Wrapper component for using unstated
+ */
+const AllInAppNotificationsWrapper = withUnstatedContainers(AllInAppNotifications, [AppContainer]);
 
-export default AllInAppNotifications;
+export default AllInAppNotificationsWrapper;

+ 1 - 1
packages/app/src/components/InAppNotification/InAppNotificationDropdown.tsx

@@ -103,7 +103,7 @@ const InAppNotificationDropdown: FC<Props> = (props: Props) => {
         </button>
       </DropdownToggle>
       <DropdownMenu className="px-2" right>
-        <InAppNotificationContents notifications={notifications} isLoaded={isLoaded} />
+        <InAppNotificationContents notifications={notifications} />
         <DropdownItem divider />
         {/* TODO: Able to show all notifications by #79317 */}
         <a className="dropdown-item d-flex justify-content-center" href="/me/all-in-app-notifications">See All</a>