InAppNotificationList.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, { FC } from 'react';
  2. import type { HasObjectId } from '@growi/core';
  3. import type { IInAppNotification, PaginateResult } from '~/interfaces/in-app-notification';
  4. import InAppNotificationElm from './InAppNotificationElm';
  5. type Props = {
  6. inAppNotificationData?: PaginateResult<IInAppNotification>,
  7. onUnopenedNotificationOpend?: () => void,
  8. };
  9. const InAppNotificationList: FC<Props> = (props: Props) => {
  10. const { inAppNotificationData, onUnopenedNotificationOpend } = props;
  11. if (inAppNotificationData == null) {
  12. return (
  13. <div className="wiki">
  14. <div className="text-muted text-center">
  15. <i className="fa fa-2x fa-spinner fa-pulse me-1"></i>
  16. </div>
  17. </div>
  18. );
  19. }
  20. const notifications = inAppNotificationData.docs;
  21. return (
  22. <div className="list-group">
  23. { notifications.map((notification: IInAppNotification & HasObjectId) => {
  24. return (
  25. <InAppNotificationElm
  26. key={notification._id}
  27. notification={notification}
  28. onUnopenedNotificationOpend={onUnopenedNotificationOpend}
  29. />
  30. );
  31. }) }
  32. </div>
  33. );
  34. };
  35. export default InAppNotificationList;