diff --git a/jam-ui/src/components/client/chat/JKChatMessage.js b/jam-ui/src/components/client/chat/JKChatMessage.js index 4f35da668..da7479df2 100644 --- a/jam-ui/src/components/client/chat/JKChatMessage.js +++ b/jam-ui/src/components/client/chat/JKChatMessage.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { formatTimestamp } from '../../../utils/formatTimestamp'; +import { formatFileSize } from '../../../services/attachmentValidation'; /** * Get initials for avatar from sender name @@ -8,67 +9,120 @@ import { formatTimestamp } from '../../../utils/formatTimestamp'; * @param {string} name - Sender name * @returns {string} Initials (e.g., "JD" for "John Doe") */ -const getInitials = (name) => { +const getInitials = name => { if (!name) return '?'; const parts = name.trim().split(' '); if (parts.length === 1) return parts[0][0].toUpperCase(); return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase(); }; +/** + * Check if message is an attachment + * @param {Object} message - Message object + * @returns {boolean} True if message has attachment + */ +const isAttachmentMessage = message => { + return message.attachmentId && message.attachmentName; +}; + /** * JKChatMessage - Individual message display component * * Displays a single chat message with avatar, sender name, message text, and timestamp. + * Supports attachment messages with distinct styling and metadata display. * * Features: * - Avatar with initials (first + last name) * - Sender name in bold * - Relative timestamp (via formatTimestamp utility) * - Message text with word wrapping + * - Attachment display with paperclip icon, filename, and size * - React.memo for performance optimization */ const JKChatMessage = ({ message }) => { - const { senderName, message: text, createdAt } = message; + const { senderName, message: text, createdAt, attachmentName, attachmentSize } = message; - return ( -