Skip to content

Commit

Permalink
Merging main to production (#129)
Browse files Browse the repository at this point in the history
* Style: fixed odia title (#104)

* style: ui scroll bug on faq page

* style: fixed odia title

* Feat chat history (#106)

fix: token authentication

* Delete .env.production

* UI changes (#112)

* style: minor ui changes

* fix: delete history page fix and flagsmith self hoasted added

---------

Co-authored-by: Prateek Jakhar <[email protected]>

* fix: conversation id (#115)

* fix: conversation id

* Added down time page (#117)

* Update ContextProvider.tsx (#118)

* Feat dialer popup (#120)

* added down time page

* Update chat.tsx

* Added Auth header (#122)



* added down time page

* added dialer popup

* added auth in headers

* Update chat.tsx

* chore: msgId display for testing (#127)

* chore: msgId display for testing

* Feat dsply msg (#128)

* fix: history not loading on refresh

---------

Co-authored-by: Prateek Jakhar <[email protected]>
  • Loading branch information
geeky-abhishek and prtkjakhar authored May 17, 2023
1 parent 45a0ffa commit 0d9fa98
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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');
Expand Down
49 changes: 41 additions & 8 deletions apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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');
Expand All @@ -43,7 +47,8 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
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);
Expand Down Expand Up @@ -81,6 +86,15 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
[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 });
Expand Down Expand Up @@ -173,12 +187,28 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
content?.data?.position === 'right' ? 'white' : 'var(--font)',
}}>
{content.text}

</span>
<div
style={{
display: 'flex',
justifyContent: 'flex-end',
justifyContent: content?.data?.position === 'left' ? 'space-between' : 'flex-end',
}}>

{content?.data?.position === "left" && flags?.show_msg_id?.enabled &&(
<span>
<Button colorScheme='teal' variant='outline' size='xs' onClick={() => copyTextToClipboard(content?.data?.messageId).then(() => {
toast.success("coppied");
})
.catch((err) => {
console.log(err);
})}>
{content?.data?.messageId}
</Button>

</span>)
}

<span
style={{
color:
Expand All @@ -189,9 +219,10 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
}}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>

</div>
</Bubble>
{content?.data?.position === 'left' && (
Expand Down Expand Up @@ -255,7 +286,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
<span style={{ color: 'var(--font)', fontSize: '10px' }}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand Down Expand Up @@ -289,7 +320,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
<span style={{ color: 'var(--font)', fontSize: '10px' }}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand Down Expand Up @@ -327,7 +358,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
<span style={{ color: 'var(--font)', fontSize: '10px' }}>
{getFormatedTime(
content?.data?.sentTimestamp ||
content?.data?.repliedTimestamp
content?.data?.repliedTimestamp
)}
</span>
</div>
Expand Down Expand Up @@ -369,4 +400,6 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({
}
};

export default ChatMessageItem;
export default ChatMessageItem;


1 comment on commit 0d9fa98

@vercel
Copy link

@vercel vercel bot commented on 0d9fa98 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.