InAppNotificationList.tsx 1.2 KB

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