InAppNotificationList.tsx 1.2 KB

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