diff --git a/apps/amakrushi/src/components/PhoneView/ChatWindow/ChatUiWindow.tsx b/apps/amakrushi/src/components/PhoneView/ChatWindow/ChatUiWindow.tsx index c8ef749e..48c0f7e7 100644 --- a/apps/amakrushi/src/components/PhoneView/ChatWindow/ChatUiWindow.tsx +++ b/apps/amakrushi/src/components/PhoneView/ChatWindow/ChatUiWindow.tsx @@ -27,6 +27,7 @@ const ChatUiWindow: React.FC = () => { try { await context?.fetchIsDown(); if(!context?.isDown){ + const chatHistory = await axios.get( `${ process.env.NEXT_PUBLIC_BASE_URL @@ -37,6 +38,7 @@ const ChatUiWindow: React.FC = () => { }, } ); + console.log("ghji:",chatHistory) console.log('history:', chatHistory.data); const normalizedChats = normalizedChat(chatHistory.data); if (normalizedChats.length > 0) { @@ -51,8 +53,12 @@ const ChatUiWindow: React.FC = () => { } }; !context?.loading && fetchData(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [context?.setMessages, context?.fetchIsDown]); + + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [context?.setMessages, context?.fetchIsDown,context?.loading,context?.isDown]); + + const normalizedChat = (chats: any): any => { console.log('in normalized'); diff --git a/apps/amakrushi/src/components/chat-message-item/index.tsx b/apps/amakrushi/src/components/chat-message-item/index.tsx index 991f6640..5fb9e725 100644 --- a/apps/amakrushi/src/components/chat-message-item/index.tsx +++ b/apps/amakrushi/src/components/chat-message-item/index.tsx @@ -18,13 +18,14 @@ import React, { useEffect, useState, } from 'react'; -import { Button } from 'react-bootstrap'; + import { toast } from 'react-hot-toast'; import styles from './index.module.css'; import { analytics } from '../../utils/firebase'; import { logEvent } from 'firebase/analytics'; import RightIcon from '../../assets/icons/right.jsx'; +import CopyText from '../../assets/icons/copy-text.svg'; import MsgThumbsUp from '../../assets/icons/msg-thumbs-up.jsx'; import MsgThumbsDown from '../../assets/icons/msg-thumbs-down.jsx'; import { AppContext } from '../../context'; @@ -33,6 +34,9 @@ import { getFormatedTime } from '../../utils/getUtcTime'; import { useLocalization } from '../../hooks/useLocalization'; import { getReactionUrl } from '../../utils/getUrls'; import { useFlags } from 'flagsmith/react'; +import Image from 'next/image'; +import { Button } from '@chakra-ui/react'; +import flagsmith from 'flagsmith/isomorphic'; const getToastMessage = (t: any, reaction: number): string => { if (reaction === 1) return t('toast.reaction_like'); @@ -43,7 +47,8 @@ const ChatMessageItem: FC = ({ message, onSend, }) => { - const flags = useFlags(['dialer_number']); + const flags = useFlags(['show_msg_id']); + const t = useLocalization(); const context = useContext(AppContext); const [reaction, setReaction] = useState(message?.content?.data?.reaction); @@ -81,6 +86,15 @@ const ChatMessageItem: FC = ({ [t] ); + + async function copyTextToClipboard(text: string) { + console.log("here") + if ('clipboard' in navigator) { + return await navigator.clipboard.writeText(text); + } else { + return document.execCommand('copy', true, text); + } + } const feedbackHandler = useCallback( ({ like, msgId }: { like: 0 | 1 | -1; msgId: string }) => { console.log('vbnm:', { reaction, like }); @@ -173,12 +187,28 @@ const ChatMessageItem: FC = ({ content?.data?.position === 'right' ? 'white' : 'var(--font)', }}> {content.text} +
+ + {content?.data?.position === "left" && flags?.show_msg_id?.enabled &&( + + + + ) + } + = ({ }}> {getFormatedTime( content?.data?.sentTimestamp || - content?.data?.repliedTimestamp + content?.data?.repliedTimestamp )} +
{content?.data?.position === 'left' && ( @@ -255,7 +286,7 @@ const ChatMessageItem: FC = ({ {getFormatedTime( content?.data?.sentTimestamp || - content?.data?.repliedTimestamp + content?.data?.repliedTimestamp )} @@ -289,7 +320,7 @@ const ChatMessageItem: FC = ({ {getFormatedTime( content?.data?.sentTimestamp || - content?.data?.repliedTimestamp + content?.data?.repliedTimestamp )} @@ -327,7 +358,7 @@ const ChatMessageItem: FC = ({ {getFormatedTime( content?.data?.sentTimestamp || - content?.data?.repliedTimestamp + content?.data?.repliedTimestamp )} @@ -369,4 +400,6 @@ const ChatMessageItem: FC = ({ } }; -export default ChatMessageItem; \ No newline at end of file +export default ChatMessageItem; + + \ No newline at end of file