ModelNotification.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { FC, JSX } from 'react';
  2. import React from 'react';
  3. import type { HasObjectId } from '@growi/core';
  4. import { PagePathLabel } from '@growi/ui/dist/components';
  5. import type { IInAppNotification } from '~/interfaces/in-app-notification';
  6. import FormattedDistanceDate from '../../FormattedDistanceDate';
  7. import styles from './ModelNotification.module.scss';
  8. type Props = {
  9. notification: IInAppNotification & HasObjectId;
  10. actionMsg: string;
  11. actionIcon: string;
  12. actionUsers: string;
  13. hideActionUsers?: boolean;
  14. subMsg?: JSX.Element;
  15. };
  16. export const ModelNotification: FC<Props> = ({
  17. notification,
  18. actionMsg,
  19. actionIcon,
  20. actionUsers,
  21. hideActionUsers = false,
  22. subMsg,
  23. }: Props) => {
  24. return (
  25. <div className={`${styles['modal-notification']} p-2 overflow-hidden`}>
  26. <div className="text-truncate page-title">
  27. {hideActionUsers ? <></> : <b>{actionUsers}</b>}
  28. {` ${actionMsg}`}
  29. <PagePathLabel path={notification.parsedSnapshot?.path ?? ''} />
  30. </div>
  31. {subMsg}
  32. <span className="material-symbols-outlined me-2">{actionIcon}</span>
  33. <FormattedDistanceDate
  34. id={notification._id}
  35. date={notification.createdAt}
  36. isShowTooltip={false}
  37. differenceForAvoidingFormat={Number.POSITIVE_INFINITY}
  38. />
  39. </div>
  40. );
  41. };