ModelNotification.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { FC } 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. type Props = {
  8. notification: IInAppNotification & HasObjectId
  9. actionMsg: string
  10. actionIcon: string
  11. actionUsers: string
  12. hideActionUsers?: boolean
  13. subMsg?: JSX.Element
  14. };
  15. export const ModelNotification: FC<Props> = ({
  16. notification,
  17. actionMsg,
  18. actionIcon,
  19. actionUsers,
  20. hideActionUsers = false,
  21. subMsg,
  22. }: Props) => {
  23. return (
  24. <div className="p-2 overflow-hidden">
  25. <div className="text-truncate">
  26. {hideActionUsers ? <></> : <b>{actionUsers}</b>}
  27. {` ${actionMsg}`}
  28. <PagePathLabel path={notification.parsedSnapshot?.path ?? ''} />
  29. </div>
  30. { subMsg }
  31. <span className="material-symbols-outlined me-2">{actionIcon}</span>
  32. <FormattedDistanceDate
  33. id={notification._id}
  34. date={notification.createdAt}
  35. isShowTooltip={false}
  36. differenceForAvoidingFormat={Number.POSITIVE_INFINITY}
  37. />
  38. </div>
  39. );
  40. };