diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-09 17:18:46 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:15:27 +0100 |
| commit | f699802b837d7d9fcf150ff2bf00cd3c5475c87a (patch) | |
| tree | 6c96a140193e7386b454b6d444058a99a0e07454 /src/components/templates/page/page-layout.tsx | |
| parent | bd9c9ae7e2ae973969569dd434836de9f38b07d4 (diff) | |
refactor(components): rewrite CommentsList component
* use ApprovedCommentProps to make CommentData type
* add the author name of the parent on reply form heading
* add tests
Diffstat (limited to 'src/components/templates/page/page-layout.tsx')
| -rw-r--r-- | src/components/templates/page/page-layout.tsx | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/components/templates/page/page-layout.tsx b/src/components/templates/page/page-layout.tsx index 434b8ff..28c850b 100644 --- a/src/components/templates/page/page-layout.tsx +++ b/src/components/templates/page/page-layout.tsx @@ -9,7 +9,7 @@ import { import { useIntl } from 'react-intl'; import type { BreadcrumbList } from 'schema-dts'; import { sendComment } from '../../../services/graphql'; -import type { SendCommentInput, SingleComment } from '../../../types'; +import type { SendCommentInput } from '../../../types'; import { useIsMounted } from '../../../utils/hooks'; import { Heading, Sidebar } from '../../atoms'; import { @@ -29,16 +29,6 @@ import { } from '../../organisms'; import styles from './page-layout.module.scss'; -/** - * Check if there is at least one comment. - * - * @param {SingleComment[] | undefined} comments - The comments. - */ -const hasComments = ( - comments: SingleComment[] | undefined -): comments is SingleComment[] => - Array.isArray(comments) && comments.length > 0; - export type PageLayoutProps = { /** * True if the page accepts new comments. Default: false. @@ -262,7 +252,7 @@ export const PageLayout: FC<PageLayoutProps> = ({ <Heading className={styles.comments__title} level={2}> {commentsTitle} </Heading> - {hasComments(comments) ? ( + {comments?.length ? ( <CommentsList comments={comments} depth={2} |
