From 2771de88f40a5f4ed7480bd8614532dda72deeda Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Sat, 4 Nov 2023 19:26:16 +0100
Subject: 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
---
 src/components/organisms/layout/comments-list.tsx | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

(limited to 'src/components/organisms/layout/comments-list.tsx')

diff --git a/src/components/organisms/layout/comments-list.tsx b/src/components/organisms/layout/comments-list.tsx
index af0152a..2d43583 100644
--- a/src/components/organisms/layout/comments-list.tsx
+++ b/src/components/organisms/layout/comments-list.tsx
@@ -6,10 +6,7 @@ import { UserComment, type UserCommentProps } from './comment';
 // eslint-disable-next-line @typescript-eslint/no-magic-numbers
 export type CommentsListDepth = 0 | 1 | 2 | 3 | 4;
 
-export type CommentsListProps = Pick<
-  UserCommentProps,
-  'Notice' | 'saveComment'
-> & {
+export type CommentsListProps = Pick<UserCommentProps, 'onSubmit'> & {
   /**
    * An array of comments.
    */
@@ -28,8 +25,7 @@ export type CommentsListProps = Pick<
 export const CommentsList: FC<CommentsListProps> = ({
   comments,
   depth,
-  Notice,
-  saveComment,
+  onSubmit,
 }) => {
   /**
    * Get each comment wrapped in a list item.
@@ -45,12 +41,7 @@ export const CommentsList: FC<CommentsListProps> = ({
 
     return commentsList.map(({ replies, ...comment }) => (
       <ListItem key={comment.id}>
-        <UserComment
-          canReply={!isLastLevel}
-          Notice={Notice}
-          saveComment={saveComment}
-          {...comment}
-        />
+        <UserComment canReply={!isLastLevel} onSubmit={onSubmit} {...comment} />
         {replies.length && !isLastLevel ? (
           <List hideMarker isOrdered spacing="sm">
             {getItems(replies, startLevel + 1)}
-- 
cgit v1.2.3

