import React from 'react'; import { type IRevisionHasId, pagePathUtils } from '@growi/core'; import dynamic from 'next/dynamic'; import type { PageCommentProps } from '~/components/PageComment'; import { useSWRxPageComment } from '~/stores/comment'; import { useIsTrashPage } from '~/stores/page'; import { useCurrentUser } from '../stores/context'; import type { CommentEditorProps } from './PageComment/CommentEditor'; const { isTopPage } = pagePathUtils; const PageComment = dynamic(() => import('~/components/PageComment').then(mod => mod.PageComment), { ssr: false }); const CommentEditor = dynamic(() => import('./PageComment/CommentEditor').then(mod => mod.CommentEditor), { ssr: false }); export type CommentsProps = { pageId: string, pagePath: string, revision: IRevisionHasId, } export const Comments = (props: CommentsProps): JSX.Element => { const { pageId, pagePath, revision } = props; const { mutate } = useSWRxPageComment(pageId); const { data: isDeleted } = useIsTrashPage(); const { data: currentUser } = useCurrentUser(); const isTopPagePath = isTopPage(pagePath); if (pageId == null || isTopPagePath) { return <>; } return (
{ !isDeleted && (
)}
); };