Skip to content

Commit

Permalink
(#79) ๐Ÿž fix: ๋ฐฐํฌ ์˜ค๋ฅ˜ (๋ฌธ๋ฒ• ์˜ค๋ฅ˜) ํ•ด๊ฒฐ
Browse files Browse the repository at this point in the history
  • Loading branch information
inaemon committed Nov 28, 2024
1 parent 04a2ced commit 9792c45
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
33 changes: 16 additions & 17 deletions src/pages/Chatbot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import DateBanner from "./components/DateBanner";
import { questionCategories } from "@/src/constants/ChatbotData";
import { GuideGetResponseType, ClovaPostResponseType } from "@/src/api/ChatbotApiType";

import RookieChat from "./components/chat/RookieChat";
import RookieChat, { RookieChatContentType } from "./components/chat/RookieChat";
import UserChat from "./components/chat/UserChat";
import CategoryChat from "./components/chat/CategoryChat";

Expand Down Expand Up @@ -88,7 +88,7 @@ const Chatbot = () => {
return (
<>
{/* ๋ฃจํ‚ค ์‚ฌ์šฉ ์„ค๋ช…์„œ */}
<RookieImageMessage imgIcon={chatbotManualIcon} />
<RookieImageMessage imgIcon={chatbotManualIcon.src} />

{/* ์Šคํƒ€๋””์›€ ์„ ํƒ์ฐฝ */}
<StadiumSelection stadiums={stadiumList} onSelect={handleStadiumSelect} />
Expand All @@ -115,7 +115,7 @@ const Chatbot = () => {
contentList={[
{
type: "component",
content: <CategoryChat stadiumName={selectedStadium} categoryKey={0} categoryFrontName={selectedCategoryFrontName} onGuideResponseUpdate={renderSubCategoryChat} />
content: <CategoryChat stadiumName={selectedStadium} categoryFrontName={selectedCategoryFrontName} onGuideResponseUpdate={renderSubCategoryChat} />
}
]}
/>
Expand Down Expand Up @@ -146,51 +146,50 @@ const Chatbot = () => {
);
}


// ๊ฐ€์ด๋“œ ๋‹ต๋ณ€ ๋ Œ๋”๋ง
const renderGuideAnswerData = (response: GuideGetResponseType) => {
const answerImageUrl = response.imgUrl;
const answerString = response.answer;
const answerLinkName = response.linkName;
const answerLink = response.link;
const answerImageUrl = response.imgUrl ?? "";
const answerString = response.answer ?? "";
const answerLinkName = response.linkName ?? "";
const answerLink = response.link ?? "";

const answerListWithImg = [
const answerListWithImg: RookieChatContentType[] = [
{ type: "imgUrl", content: answerImageUrl },
{ type: "preformattedText", content: answerString }
];
const answerList = [
const answerList: RookieChatContentType[] = [
{ type: "preformattedTextWithTail", content: answerString },
];
const answerListWithBtn = [
const answerListWithBtn: RookieChatContentType[] = [
{ type: "preformattedTextButtonWithTail", content: answerString, buttonContent: answerLinkName, url: answerLink },
];

return (
<>
{answerImageUrl ?
{answerImageUrl ? (
// ์ด๋ฏธ์ง€, ๋‹ต๋ณ€ ์ถœ๋ ฅ
<RookieChat
contentList={answerListWithImg}
/>
: answerLink ?
): answerLink ? (
// ์ด๋ฏธ์ง€, ๋‹ต๋ณ€, ๋งํฌ๋กœ ์ด๋™ํ•˜๋Š” ๋ฒ„ํŠผ ์ถœ๋ ฅ
<RookieChat
contentList={answerListWithBtn}
/>
:
): (
// ๋‹ต๋ณ€ ์ถœ๋ ฅ
<RookieChat
contentList={answerList}
/>
}
)}
</>
);
}


// ์ฟจ๋กœ๋ฐ” ๋‹ต๋ณ€ ๋žœ๋”๋ง
const renderClovaAnswerData = (question: string, answer: ClovaPostResponseType) => {
const answerList = [
const renderClovaAnswerData = (question: string, answer: string) => {
const answerList: RookieChatContentType[] = [
{ type: "preformattedTextWithTail", content: answer },
];

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Chatbot/components/chat/CategoryChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CategoryChat = ({stadiumName, categoryFrontName, onGuideResponseUpdate}: P
{"image" in categoryData && categoryData.image && (
<div className="mb-2">
{/* ์ด๋ฏธ์ง€ ๋‚ด์šฉ ์ถœ๋ ฅ*/}
<RookieImageMessage imgIcon={categoryData.image} />
<RookieImageMessage imgIcon={categoryData.image.src} />
</div>
)}

Expand Down
25 changes: 14 additions & 11 deletions src/pages/Chatbot/components/chat/RookieChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import RookiePreformattedMessageWithTail from "@/src/pages/Chatbot/components/me
import RookiePreformattedMessage from "@/src/pages/Chatbot/components/message/custom/RookiePreformattedMessage";
import RookieImageMessage from "@/src/pages/Chatbot/components/message/custom/RookieImageMessage";
import RookieImgUrlMessage from "@/src/pages/Chatbot/components/message/custom/RookieImgUrlMessage";
import RookiePreformattedButtonMessage from "@/src/pages/Chatbot/components/message/custom/RookiePreformattedButtonMessage";
import RookiePreformattedButtonMessageWithTail from "@/src/pages/Chatbot/components/message/custom/RookiePreformattedButtonMessageWithTail";

import { questionCategories } from "@/src/constants/ChatbotData";
Expand Down Expand Up @@ -37,20 +38,22 @@ import { questionCategories } from "@/src/constants/ChatbotData";
// -> \n ์„ ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ์ธ์‹ํ•˜๋Š” ๋ฒ„ํŠผ์ด ๋‹ฌ๋ฆฐ ๊ผฌ๋ž‘์ง€ ๋งํ’์„ ์— ์ถœ๋ ฅ
// 9. ๋ฒ„ํŠผ + ๋ฌธ์ž์—ด
// -> \n ์„ ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ์ธ์‹ํ•˜๋Š” ๋ฒ„ํŠผ์ด ๋‹ฌ๋ฆฐ ์ผ๋ฐ˜ ๋งํ’์„ ์— ์ถœ๋ ฅ
export type RookieChatContentType = |
{ type: "image"; content: string } |
{ type: "imgUrl"; content: string } |
{ type: "component"; content: React.ReactNode} |
{ type: "textListWithTail"; content: string[] } |
{ type: "textList"; content: string[] } |
{ type: "preformattedTextWithTail"; content: string } |
{ type: "preformattedText"; content: string } |
{ type: "preformattedTextButtonWithTail"; content: string; buttonContent:string; url: string; } |
{ type: "preformattedTextButton"; content: string; buttonContent:string; url: string; };

interface RookieChatProps { /*
initialMessage?: string[];
initialPreformattedMessage?: string; */
contentList?: Array<
{ type: "image"; content: string } |
{ type: "imgUrl"; content: string } |
{ type: "component"; content: React.ReactNode} |
{ type: "textListWithTail"; content: string[] } |
{ type: "textList"; content: string[] } |
{ type: "preformattedTextWithTail"; content: string } |
{ type: "preformattedText"; content: string } |
{ type: "preformattedTextButtonWithTail"; content: string; buttonContent:string; url: string; } |
{ type: "preformattedTextButton"; content: string; buttonContent:string; url: string; }
>;
contentList?: Array<RookieChatContentType>;
}

// ๋ฃจํ‚ค ์ฑ„ํŒ… ํ•œ ์„ธํŠธ๋ฅผ ๊ทธ๋ฃนํ™”ํ•œ ์ปดํฌ๋„ŒํŠธ
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Chatbot/components/input/ChatbotInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { handleGetClovaAnswer } from "@/src/api/ChatbotApiHandler";
interface Props {
isStadiumSelected: boolean; // boolean ๊ฐ’์„ props๋กœ ๋ฐ›์Œ
onSelect: (category: string) => void;
onClovaResponseUpdate: (answer: string) => void;
onClovaResponseUpdate: (question: string, answer: string) => void;
}

const ChatbotInputField = ({isStadiumSelected, onSelect, onClovaResponseUpdate}: Props) => {
Expand Down

0 comments on commit 9792c45

Please sign in to comment.