'use client'; import { useEffect, useRef } from 'react'; export type ChatFeedItem = { id: string; at: number; nickname: string; message: string; kind: 'chat' | 'donation'; payAmount?: number; }; export default function ChatFeedPanel({ items, visible, compact = false, }: { items: ChatFeedItem[]; visible: boolean; compact?: boolean; }) { const listRef = useRef(null); useEffect(() => { const el = listRef.current; if (!el) return; el.scrollTop = el.scrollHeight; }, [items.length, items[items.length - 1]?.id]); if (!visible) return null; return (
채팅
{items.length === 0 ? (

채팅 대기 중…

) : ( items.map((item) => (

{item.nickname} : {item.message || (item.kind === 'donation' ? '치즈 후원' : '')} {item.kind === 'donation' && item.payAmount != null ? ( ({item.payAmount}치즈) ) : null}

)) )}
); }