diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-04 19:26:16 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:15:27 +0100 |
| commit | 2771de88f40a5f4ed7480bd8614532dda72deeda (patch) | |
| tree | ed4d1b9ee3f6322817efa2d1b1113c247367a12a /src/components/organisms/layout/comment.tsx | |
| parent | c4a561c333f6f82678efcffef5ce3ed0f8e322f4 (diff) | |
refactor(components): rewrite CommentForm component
* remove `Notice` prop to handle it directly in the form
* replace `saveComment` prop with `onSubmit`
* use `useForm` hook to handle the form
Diffstat (limited to 'src/components/organisms/layout/comment.tsx')
| -rw-r--r-- | src/components/organisms/layout/comment.tsx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/components/organisms/layout/comment.tsx b/src/components/organisms/layout/comment.tsx index adbb2cc..b55bb3d 100644 --- a/src/components/organisms/layout/comment.tsx +++ b/src/components/organisms/layout/comment.tsx @@ -1,4 +1,3 @@ -/* eslint-disable max-statements */ import NextImage from 'next/image'; import Script from 'next/script'; import type { FC } from 'react'; @@ -6,7 +5,7 @@ import { useIntl } from 'react-intl'; import type { Comment as CommentSchema, WithContext } from 'schema-dts'; import type { SingleComment } from '../../../types'; import { useSettings, useToggle } from '../../../utils/hooks'; -import { Button, Link, Time } from '../../atoms'; +import { Button, Heading, Link, Time } from '../../atoms'; import { Card, CardActions, @@ -24,7 +23,7 @@ export type UserCommentProps = Pick< SingleComment, 'approved' | 'content' | 'id' | 'meta' | 'parentId' > & - Pick<CommentFormProps, 'Notice' | 'saveComment'> & { + Pick<CommentFormProps, 'onSubmit'> & { /** * Enable or disable the reply button. Default: true. */ @@ -42,9 +41,8 @@ export const UserComment: FC<UserCommentProps> = ({ content, id, meta, - Notice, + onSubmit, parentId, - saveComment, ...props }) => { const intl = useIntl(); @@ -173,13 +171,15 @@ export const UserComment: FC<UserCommentProps> = ({ ) : null} </Card> {isReplying ? ( - <Card className={styles.form} variant={2}> + <Card className={styles.form__wrapper} variant={2}> <CardBody> + <Heading className={styles.form__heading} level={2}> + {formTitle} + </Heading> <CommentForm - Notice={Notice} + className={styles.form} + onSubmit={onSubmit} parentId={id} - saveComment={saveComment} - title={formTitle} /> </CardBody> </Card> |
