diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-15 17:45:41 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-15 19:06:42 +0200 |
| commit | c95cce04393080a52a54191cff7be8fec68af4b0 (patch) | |
| tree | 1022bc574c8fc8e657be922b26c1cf16cbfd9071 /src/components/organisms/forms/comment-form.tsx | |
| parent | 235fe67d770f83131c9ec10b99012319440db690 (diff) | |
chore: add Article pages
Diffstat (limited to 'src/components/organisms/forms/comment-form.tsx')
| -rw-r--r-- | src/components/organisms/forms/comment-form.tsx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/components/organisms/forms/comment-form.tsx b/src/components/organisms/forms/comment-form.tsx index d7cb0f5..9e0abdf 100644 --- a/src/components/organisms/forms/comment-form.tsx +++ b/src/components/organisms/forms/comment-form.tsx @@ -7,6 +7,14 @@ import { FC, ReactNode, useState } from 'react'; import { useIntl } from 'react-intl'; import styles from './comment-form.module.scss'; +export type CommentFormData = { + comment: string; + email: string; + name: string; + parentId?: number; + website?: string; +}; + export type CommentFormProps = { /** * Set additional classnames to the form wrapper. @@ -17,10 +25,14 @@ export type CommentFormProps = { */ Notice?: ReactNode; /** + * The comment parent id. + */ + parentId?: number; + /** * A callback function to save comment. It takes a function as parameter to * reset the form. */ - saveComment: (reset: () => void) => void; + saveComment: (data: CommentFormData, reset: () => void) => Promise<void>; /** * The form title. */ @@ -34,6 +46,7 @@ export type CommentFormProps = { const CommentForm: FC<CommentFormProps> = ({ className = '', Notice, + parentId, saveComment, title, titleLevel = 2, @@ -95,7 +108,9 @@ const CommentForm: FC<CommentFormProps> = ({ */ const submitHandler = () => { setIsSubmitting(true); - saveComment(resetForm); + saveComment({ comment, email, name, parentId, website }, resetForm).then( + () => setIsSubmitting(false) + ); }; return ( |
