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