/** * MessageReactions Component * Displays and manages emoji reactions on messages */ import React, { useState } from 'react'; import ReactionPicker from './ReactionPicker'; import './MessageReactions.css'; export default function MessageReactions({ reactions = [], onAddReaction, onRemoveReaction, currentUserId, messageId, }) { const [showPicker, setShowPicker] = useState(false); const handleReactionClick = (emoji) => { // Check if user already reacted with this emoji const existingReaction = reactions.find((r) => r.emoji === emoji); if (existingReaction?.users?.includes(currentUserId)) { // Remove reaction onRemoveReaction?.(messageId, emoji, currentUserId); } else { // Add reaction onAddReaction?.(messageId, emoji, currentUserId); } }; const handleAddReaction = (emoji) => { onAddReaction?.(messageId, emoji, currentUserId); }; return (