-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/f 146 integrate chatbot reports chatting #117
Feature/f 146 integrate chatbot reports chatting #117
Conversation
✅ Deploy Preview for wfp-hungermap ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…-hunger-map into feature/f-146-integrate-chatbot-reports-chatting
…-hunger-map into feature/f-146-integrate-chatbot-reports-chatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall valuable improvements, thanks for thinking about the context and local storage! Also one more thing I noticed, on mobile the chatbot icon in the Topbar is displayed over the theme toggle, I think it would be nice to actually put the theme toggle in the mobile bar for smaller screens. Could you do that as well?
src/components/Chatbot/Chatbot.tsx
Outdated
)} | ||
style={{ | ||
wordWrap: 'break-word', | ||
overflowWrap: 'break-word', | ||
whiteSpace: 'normal', | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use className from tailwind, we do not use the style prop
@@ -33,6 +34,7 @@ export default function CountryReports({ countryCodesData }: CountryReportsProps | |||
data={DownloadPortalOperations.formatTableData( | |||
filteredData, | |||
setSelectedCountry, | |||
useChatbot().chatWithReport, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract this into const
const chatBot = useChatbot()
const { chatWithReport } = chatbot
setCurrentChatIndex: React.Dispatch<React.SetStateAction<number>>; | ||
openChat: (chatIndex: number) => void; | ||
startNewChat: (newChat?: IChat) => void; | ||
chatWithReport: (countryName: string, report: string) => Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chatWithReport is a little bit weird naming. Can it be more precise? At least I don't understand what it is about
src/operations/chatbot/Chatbot.ts
Outdated
return [ | ||
{ | ||
id: 1, | ||
title: 'Chat 1', | ||
messages: [], | ||
isTyping: false, | ||
timestamp: Date.now(), | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code duplication with the thing above
return [ | ||
{ | ||
id: 1, | ||
title: 'Chat 1', | ||
messages: [], | ||
isTyping: false, | ||
timestamp: Date.now(), | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code duplication with the thing above
src/operations/chatbot/Chatbot.ts
Outdated
if (typeof window !== 'undefined') { | ||
const chatsWithTimestamp = chats.map((chat) => ({ | ||
...chat, | ||
timestamp: chat.timestamp || Date.now(), | ||
})); | ||
|
||
localStorage.setItem('chatbotChatsWithTimestamp', JSON.stringify(chatsWithTimestamp)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add error handling if window is undefined with the Snackbar
} catch (error) { | ||
throw new Error(`Error extracting text from PDF: ${error}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better Error Handling with the Snackbar is required
Implement Report Chat Functionality and According Chatbot Accessibility
Changes Introduced:
Chat with Reports in DownloadPortal
Global Chatbot Access
I also explored alternative methods for extracting additional PDF information, including OCR and OpenAI Assistant, text extraction approach seems to be effective and sufficient for our case
Edit: Chatbot was removed from the Topbar component itself and was placed into the layout files of the pages. The visual positioning still is the same. This allows easier usage of the Topbar without the Chatbot for example in the error page later on.