1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-03 06:12:53 +02:00

Handle chat submission

This commit is contained in:
Kamran Ahmed
2025-06-10 04:46:50 +01:00
parent f23df04255
commit df6ed871f7

View File

@@ -157,26 +157,20 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) {
setIsOpen(false); setIsOpen(false);
}); });
function textToJSON(text: string): JSONContent {
return {
type: 'doc',
content: [{ type: 'paragraph', content: [{ type: 'text', text }] }],
};
}
const submitInput = () => { const submitInput = () => {
const trimmed = inputValue.trim(); const trimmed = inputValue.trim();
if (!trimmed) { if (!trimmed) {
return; return;
} }
const json: JSONContent = { const json: JSONContent = textToJSON(trimmed);
type: 'doc',
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: trimmed,
},
],
},
],
};
setInputValue(''); setInputValue('');
handleChatSubmit(json, isRoadmapDetailLoading); handleChatSubmit(json, isRoadmapDetailLoading);
@@ -266,8 +260,10 @@ export function RoadmapFloatingChat(props: RoadmapChatProps) {
key={`default-question-${index}`} key={`default-question-${index}`}
className="flex h-full self-start rounded-md bg-yellow-500/10 px-3 py-2 text-left text-sm text-black hover:bg-yellow-500/20" className="flex h-full self-start rounded-md bg-yellow-500/10 px-3 py-2 text-left text-sm text-black hover:bg-yellow-500/20"
onClick={() => { onClick={() => {
setInputValue(question); handleChatSubmit(
inputRef.current?.focus(); textToJSON(question),
isRoadmapDetailLoading,
);
}} }}
> >
{question} {question}