Skip to content

Commit

Permalink
(#79) ๐Ÿš€ feat: ์—”ํ„ฐํ‚ค ์ž…๋ ฅ์‹œ ์ฑ—๋ด‡ ํด๋กœ๋ฐ” ์ „์†ก ๋ฒ„ํŠผ ๋ˆŒ๋ฆฌ๋Š” ์ด๋ฒคํŠธ ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
inaemon committed Nov 28, 2024
1 parent 7dcf1d8 commit f6d4751
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/pages/Chatbot/components/input/ChatbotInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,34 @@ const ChatbotInputField = ({isStadiumSelected, onSelect, onClovaResponseUpdate}:
return; // response๊ฐ€ ์—†์œผ๋ฉด ์ข…๋ฃŒ
}

// ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์— ์—…๋ฐ์ดํŠธ
// ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์— ํด๋กœ๋ฐ” ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ
onClovaResponseUpdate(
inputQuestion?? "",
response.answer ?? "",
inputQuestion?? "", // ์งˆ๋ฌธ
response.answer ?? "", // ๋‹ต๋ณ€
);

} catch (error) {
// ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์— ์—…๋ฐ์ดํŠธ
// ๋ถ€๋ชจ ์ปดํฌ๋„ŒํŠธ์— ํด๋กœ๋ฐ” ๋ฐ์ดํ„ฐ ์—…๋ฐ์ดํŠธ
onClovaResponseUpdate(
inputQuestion ?? "",
"ํด๋กœ๋ฐ” ๋‹ต๋ณ€์„ ๋ฐ›๋Š” ๊ฒƒ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค (์—๋Ÿฌ๋ช…: "+error+")",
);

} finally {
setIsLoading(false); // ๋กœ๋”ฉ ์ข…๋ฃŒ
setIsLoading(false); // ๋กœ๋”ฉ ์ƒํƒœ ์ข…๋ฃŒ
}

}, [inputClovaMessage, onClovaResponseUpdate]);


// Enter ํ‚ค ์ž…๋ ฅ์‹œ ๋ฒ„ํŠผ ํด๋ฆญ ์ฒ˜๋ฆฌ
const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter") {
handleSendButton(); // Enter ํ‚ค๊ฐ€ ๋ˆŒ๋ฆฌ๋ฉด handleSendButton ํ˜ธ์ถœ
}
};


return (
<>
{/* ํ”Œ๋Ÿฌ์Šค ๋ฒ„ํŠผ ๋ฆฌ์ŠคํŠธ */}
Expand All @@ -110,6 +118,7 @@ const ChatbotInputField = ({isStadiumSelected, onSelect, onClovaResponseUpdate}:
className="border-none w-full bg-transparent text-grayscale-60 text-xs font-medium outline-none px-2"
value={inputClovaMessage} // input ๊ฐ’ ์ดˆ๊ธฐํ™”
onChange={(e) => setInputClovaMessage(e.target.value)} // input ๊ฐ’์ด ๋ณ€๊ฒฝ๋  ๋•Œ ์ƒํƒœ ์—…๋ฐ์ดํŠธ
onKeyDown={handleKeyDown} // Enter ํ‚ค ๋ˆŒ๋ €์„ ๋•Œ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ
/>
</div>
<button
Expand Down

0 comments on commit f6d4751

Please sign in to comment.