import React, { forwardRef, ForwardRefRenderFunction, useImperativeHandle, } from 'react'; import { PagePathLabel } from '@growi/ui'; import { IInAppNotificationOpenable } from '~/client/interfaces/in-app-notification-openable'; import { HasObjectId } from '~/interfaces/has-object-id'; import { IInAppNotification } from '~/interfaces/in-app-notification'; import { parseSnapshot } from '../../../models/serializers/in-app-notification-snapshot/page'; import FormattedDistanceDate from '../../FormattedDistanceDate'; interface Props { notification: IInAppNotification & HasObjectId actionMsg: string actionIcon: string actionUsers: string } const PageModelNotification: ForwardRefRenderFunction = (props: Props, ref) => { const { notification, actionMsg, actionIcon, actionUsers, } = props; const snapshot = parseSnapshot(notification.snapshot); // publish open() useImperativeHandle(ref, () => ({ open() { if (notification.target != null) { // jump to target page const targetPagePath = notification.target.path; if (targetPagePath != null) { window.location.href = targetPagePath; } } }, })); return (
{actionUsers} {actionMsg}
); }; export default forwardRef(PageModelNotification);