import { createPortal } from 'react-dom' import { ArrowUp, ImagePlus, Reply, Smile, X } from 'lucide-react' import type { User } from '../../types' import { useCollabChat } from './useCollabChat' import { ChatMessages } from './CollabChatMessages' import { EmojiPicker } from './CollabChatEmojiPicker' import { ReactionMenu } from './CollabChatReactionMenu' /* ── Main Component ── */ interface CollabChatProps { tripId: number currentUser: User } export default function CollabChat({ tripId, currentUser }: CollabChatProps) { const S = useCollabChat(tripId, currentUser) const { t, canEdit, loading, text, replyTo, setReplyTo, sending, showEmoji, setShowEmoji, reactMenu, setReactMenu, containerRef, textareaRef, emojiBtnRef, imageInputRef, imageFiles, imagePreviews, uploadProgress, addImageFiles, removeImage, handlePaste, handleDrop, handleTextChange, handleSend, handleKeyDown, handleReact, handleEmojiSelect } = S if (loading) { return (
) } return (
{/* Composer */}
e.preventDefault()} onDrop={handleDrop} style={{ flexShrink: 0, paddingTop: 8, paddingLeft: 12, paddingRight: 12, borderTop: '1px solid var(--border-faint)' }} className="pb-3 bg-surface-card"> {/* Reply preview */} {replyTo && (
{replyTo.username}: {(replyTo.text || '').slice(0, 60)}
)} {imagePreviews.length > 0 &&
{imagePreviews.map((url, i) =>
)}
} {uploadProgress > 0 && uploadProgress < 100 &&
{t('collab.chat.uploading', { percent: uploadProgress })}
}
{/* Emoji button */} {canEdit && ( )} {canEdit && <> { if (e.target.files) addImageFiles(e.target.files); e.currentTarget.value = '' }} />}