From 0c8dd99d19dcb4d18039d110cc4e09767cc9446d Mon Sep 17 00:00:00 2001 From: PopDaph Date: Tue, 3 Oct 2023 14:59:56 +0200 Subject: [PATCH] Edit emoji button --- .../conversation/ConversationMessage.tsx | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/front/components/assistant/conversation/ConversationMessage.tsx b/front/components/assistant/conversation/ConversationMessage.tsx index fdef617e9c8d5..8fd27e0a0954f 100644 --- a/front/components/assistant/conversation/ConversationMessage.tsx +++ b/front/components/assistant/conversation/ConversationMessage.tsx @@ -1,4 +1,10 @@ -import { Avatar, Button, DropdownMenu } from "@dust-tt/sparkle"; +import { + Avatar, + Button, + DropdownMenu, + IconButton, + PlusIcon, +} from "@dust-tt/sparkle"; import { Emoji, EmojiMartData } from "@emoji-mart/data"; import Picker from "@emoji-mart/react"; import { ComponentType, MouseEventHandler, useEffect, useState } from "react"; @@ -80,6 +86,18 @@ export function ConversationMessage({ } }; + const handleEmojiClick = async (emojiCode: string) => { + const reaction = reactions.find((r) => r.emoji === emojiCode); + const hasReacted = + (reaction && + reaction.users.find((u) => u.userId === user.id) !== undefined) || + false; + await handleEmoji({ + emoji: emojiCode, + isToRemove: hasReacted, + }); + }; + let hasMoreReactions = null; if (reactions.length > MAX_REACTIONS_TO_SHOW) { hasMoreReactions = reactions.length - MAX_REACTIONS_TO_SHOW; @@ -153,15 +171,29 @@ export function ConversationMessage({ ))} -
+ +
+ await handleEmojiClick("+1")} + > + 👍 + + await handleEmojiClick("-1")} + > + 👎 + + await handleEmojiClick("heart")} + > + ❤️ + -