InAppNotificationList.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import React, { FC } from 'react';
  2. import type { IUser, IPage, 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<IUser | IPage>>,
  7. elemClassName?: string,
  8. type?: 'button' | 'dropdown-item',
  9. };
  10. const InAppNotificationList: FC<Props> = (props: Props) => {
  11. const { inAppNotificationData } = props;
  12. if (inAppNotificationData == null) {
  13. return (
  14. <div className="wiki">
  15. <div className="text-muted text-center">
  16. <i className="fa fa-2x fa-spinner fa-pulse me-1"></i>
  17. </div>
  18. </div>
  19. );
  20. }
  21. const notifications = inAppNotificationData.docs;
  22. return (
  23. <>
  24. { notifications.map((notification: IInAppNotification<IUser | IPage> & HasObjectId) => {
  25. return (
  26. <InAppNotificationElm key={notification._id} notification={notification} type={props.type} elemClassName={props.elemClassName} />
  27. );
  28. }) }
  29. </>
  30. );
  31. };
  32. export default InAppNotificationList;