'use client'; import '../style.scss'; import React from 'react'; import BoardResponse from '@/dtos/response/forum/board/boardResponse'; import PostResponse from '@/dtos/response/forum/post/postResponse'; import CommentListResponse from '@/dtos/response/forum/comment/commentListResponse'; import WriteForm from './WriteForm'; import Item from './Item'; import Loading from '@/app/component/Loading'; type Props = { board: BoardResponse, post: PostResponse, data: CommentListResponse; loading: boolean; replyTargetID: number|null; onReply: (commentID: number) => void; onDelete: () => void; onSuccess: () => void; } export default function List({ board, post, data, loading, replyTargetID, onReply, onSuccess, onDelete } : Props) { return ( <> {loading && } {data && data.total > 0 && (
    {data.list.map((row) => { return ( onReply(row.id)} onDelete={onDelete} onSuccess={onSuccess} /> {/* row에 대한 답글 폼(토글) */} {replyTargetID === row.id && (
    onReply(row.id)} />
    )} {Array.isArray(row.children) && row.children.length > 0 && (
      {row.children.map((ch) => ( onReply(row.id)} onDelete={onDelete} onSuccess={onSuccess} /> {replyTargetID != null && replyTargetID === ch.id && (
      onReply(ch.id)} />
      )}
      ))}
    )}
    ) })}
)} ); }