Skip to content

Commit

Permalink
Fix/new btn response (#227)
Browse files Browse the repository at this point in the history
* Allow selecting multiple crops

* Added throttle for selecting options

* Upgrade location capture module

* added mode in context

* Button changes for new response format

* reduced settimeout to 4 seconds
  • Loading branch information
amit-s19 committed Feb 27, 2024
1 parent 75f27e1 commit 0f7ca39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions apps/amakrushi/src/components/chat-message-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
);
const getLists = useCallback(
({ choices, isWeather = false }: { choices: any, isWeather: Boolean }) => {
console.log('qwer12:', { choices, optionDisabled });
return (
<List className={`${styles.list}`}>
{choices?.map((choice: any, index: string) => (
Expand All @@ -160,12 +159,15 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
console.log('clearing chat');
context?.setMessages([]);
}
context?.sendMessage(choice);
if (isWeather)
context?.sendMessage(choice?.textInEnglish, false, true, choice);
else
context?.sendMessage(choice);
setOptionDisabled(true);
if (isWeather)
setTimeout(() => {
setOptionDisabled(false);
}, 7000)
}, 4000)
}
}}>
<div
Expand All @@ -180,7 +182,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
? 'var(--font)'
: 'var(--secondarygreen)',
}}>
<div>{choice}</div>
<div>{isWeather ? choice?.textInEnglish : choice}</div>
<div style={{ marginLeft: 'auto' }}>
<RightIcon
width="30px"
Expand Down Expand Up @@ -709,7 +711,7 @@ const ChatMessageItem: FC<ChatMessageItemPropType> = ({ message, onSend }) => {
`\n\n` +
t('message.options')}
{getLists({
choices: JSON.parse(content?.text)?.crops,
choices: JSON.parse(content?.text)?.buttons,
isWeather: true
})}
</span>
Expand Down
3 changes: 2 additions & 1 deletion apps/amakrushi/src/context/ContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ const ContextProvider: FC<{

//@ts-ignore
const sendMessage = useCallback(
(text: string, media: any, isVisibile = true): void => {
(text: string, media: any, isVisibile = true, selectedButton: any): void => {
if (!sessionStorage.getItem('conversationId')) {
const cId = uuidv4();
console.log('convId', cId);
Expand Down Expand Up @@ -411,6 +411,7 @@ const ContextProvider: FC<{
asrId: sessionStorage.getItem('asrId'),
userId: localStorage.getItem('userID'),
conversationId: sessionStorage.getItem('conversationId'),
selectedButton: selectedButton || null
}
});
setStartTime(Date.now());
Expand Down

0 comments on commit 0f7ca39

Please sign in to comment.