Skip to content

Commit

Permalink
(#72) ๐Ÿš€ feat: ์ฑ—๋ด‡ ๊ฐ€์ด๋“œ API ๋ฐ์ดํ„ฐ link, linkName ์ถ”๊ฐ€ ๋ฐ ์—ฐ๋™
Browse files Browse the repository at this point in the history
  • Loading branch information
inaemon committed Nov 27, 2024
1 parent 592a5bd commit f9d1ad7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/api/ChatbotApiHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const handleGetGuideAnswer = async ({stadiumName, categoryName, orderNumb
const data = response.payload;
const parsedData = {
answer: data.answer,
imageUrl: data.imgUrl ?? "", // imgUrl์ด null์ผ ๊ฒฝ์šฐ ๋นˆ ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜
imageUrl: data.imgUrl ?? "", // imgUrl์ด null์ผ ๊ฒฝ์šฐ ๋นˆ ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜
linkName: data.linkName ?? "", // linkName์ด null์ผ ๊ฒฝ์šฐ ๋นˆ ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜
link: data.link ?? "", // link๊ฐ€ null์ผ ๊ฒฝ์šฐ ๋นˆ ๋ฌธ์ž์—ด ๋ฐ˜ํ™˜
};

//console.log(parsedData);
Expand Down
4 changes: 3 additions & 1 deletion src/api/ChatbotApiType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ export interface GuideGetParamsType {
// GET ์‘๋‹ต
export interface GuideGetResponseType {
answer: string;
imgUrl: string | null;
imgUrl: string | null; // ์ด๋ฏธ์ง€
linkName: string | null; // ์ด๋™ ๊ฒฝ๋กœ๋ช…
link: string | null; // ์ด๋™ ๊ฒฝ๋กœ
}
15 changes: 13 additions & 2 deletions src/pages/Chatbot/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ const Chatbot = () => {
const [responseGuideDataList, setResponseGuideDataList] = useState<GuideResponseData[]>([]); // ์„ธ๋ถ€ ์นดํ…Œ๊ณ ๋ฆฌ index์™€ ๋งคํ•‘ํ•˜์—ฌ API ์‘๋‹ต ์ €์žฅ

// API ์‘๋‹ต์„ category index์— ๋งคํ•‘ํ•˜์—ฌ ์ €์žฅ
const handleGuideResponseUpdate = (answer: string, imgUrl: string, categoryKey: number, categoryName: string, subCategoryKey: number, subCategoryName: string) => {
const handleGuideResponseUpdate = (answer: string, imgUrl: string, link: string, categoryKey: number, categoryName: string, subCategoryKey: number, subCategoryName: string) => {
setResponseGuideDataList((prev) => [
...prev,

{
answer: answer,
imgUrl: imgUrl,
link; link,
categoryNumber: categoryKey,
categoryName: categoryName,
subcategoryNumber: subCategoryKey,
Expand All @@ -75,13 +76,18 @@ const Chatbot = () => {
const renderGuideAnswerData = (response: GuideGetResponseType) => {
const answerImageUrl = response.imgUrl;
const answerString = response.answer;
const answerLinkName = response.linkName;
const answerLink = response.link;

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

return (
Expand All @@ -91,6 +97,11 @@ const Chatbot = () => {
<RookieChat
contentList={answerListWithImg}
/>
: answerLink ?
// ์ด๋ฏธ์ง€, ๋‹ต๋ณ€, ๋งํฌ๋กœ ์ด๋™ํ•˜๋Š” ๋ฒ„ํŠผ ์ถœ๋ ฅ
<RookieChat
contentList={answerListWithBtn}
/>
:
// ๋‹ต๋ณ€ ์ถœ๋ ฅ
<RookieChat
Expand Down

0 comments on commit f9d1ad7

Please sign in to comment.