ModelNotification.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. hidePath?: boolean;
  15. subMsg?: JSX.Element;
  16. };
  17. export const ModelNotification: FC<Props> = ({
  18. notification,
  19. actionMsg,
  20. actionIcon,
  21. actionUsers,
  22. hideActionUsers = false,
  23. hidePath = false,
  24. subMsg,
  25. }: Props) => {
  26. return (
  27. <div className={`${styles['modal-notification']} p-2 overflow-hidden`}>
  28. <div className="text-truncate page-title">
  29. {hideActionUsers ? <></> : <b>{actionUsers}</b>}
  30. {` ${actionMsg}`}
  31. {!hidePath && (
  32. <PagePathLabel path={notification.parsedSnapshot?.path ?? ''} />
  33. )}
  34. </div>
  35. {subMsg}
  36. <span className="material-symbols-outlined me-2">{actionIcon}</span>
  37. <FormattedDistanceDate
  38. id={notification._id}
  39. date={notification.createdAt}
  40. isShowTooltip={false}
  41. differenceForAvoidingFormat={Number.POSITIVE_INFINITY}
  42. />
  43. </div>
  44. );
  45. };