import { useState } from "react"; import type { CommentRecord } from "@/features/comments/model/types"; import { formatSeoulDateTime } from "@/shared/lib/formatters"; export function CommentItem({ canDelete = true, canEdit, comment, isSaving, onDelete, onEdit, onShowReplies, replyActionLabel }: { readonly canDelete?: boolean; readonly canEdit: boolean; readonly comment: CommentRecord; readonly isSaving: boolean; readonly onDelete: () => void; readonly onEdit: (comment: string) => void; readonly onShowReplies?: () => void; readonly replyActionLabel?: "답글 보기" | "답글 작성" }) { const [draft, setDraft] = useState(comment.comment); const [isEditing, setIsEditing] = useState(false); const label = `${comment.comment}`; function saveEdit() { const nextComment = draft.trim(); if (nextComment.length === 0) { return; } onEdit(nextComment); setIsEditing(false); } return (

{comment.nickname}

{formatSeoulDateTime(comment.date)}{comment.isSecret ? " · 비밀" : ""}

{replyActionLabel !== undefined && onShowReplies !== undefined ? : null} {canEdit ? : null} {canDelete ? : null}
{isEditing ? (