Skip to content

Commit

Permalink
(#72) ๐Ÿž fix: ์ฑ—๋ด‡ ๊ฐ€์ด๋“œ ์„ ํƒํ•œ stadium ๊ฐ’์„ ๋ฐฑ์—”๋“œ ํ†ต์‹ ์šฉ ํŒŒ๋ผ๋ฏธํ„ฐ ๋ฐ์ดํ„ฐ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ API ์š”์ฒญ
Browse files Browse the repository at this point in the history
  • Loading branch information
inaemon committed Nov 25, 2024
1 parent 4ffc3e9 commit 050132e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/api/ChatbotApiHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
import { getGuide } from "./ChatbotApiService";
import { GuideGetParamsType } from "./ChatbotApiType";

import { getStadiumChatApiData } from "@/src/constants/ChatbotData";

export const handleGetGuideAnswer = async ({stadiumName, categoryName, orderNumber}: GuideGetParamsType) => {
try {
const stadiumApiData = getStadiumChatApiData(stadiumName);
console.log(stadiumApiData);

// API ์š”์ฒญ
const response = await getGuide(
{
stadiumName: stadiumName,
stadiumName: stadiumApiData,
categoryName: categoryName,
orderNumber: orderNumber,
}
Expand Down
22 changes: 20 additions & 2 deletions src/constants/ChatbotData.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import prohibitedItemsIcon from "@/src/assets/webp/chatbot_prohibition.webp";
import chatbotManualIcon from "@/src/assets/webp/chatbot_manual.webp";

import { stadiumList } from "@/src/constants/ZoneData";
import { StadiumType, stadiumStringList } from "@/src/constants/ZoneData";

export const chatbotName = "๋ฃจํ‚ค";


export const getStadiumChatApiData = (frontendValue: string): string => {
const { frontendValues, backendParameters } = questionCategories.baseballCategories;

// ํ•ด๋‹น frontendValue์˜ ์ธ๋ฑ์Šค ์ฐพ๊ธฐ
const index = frontendValues.indexOf(frontendValue);

// ์œ ํšจํ•˜์ง€ ์•Š์€ frontendValue์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ
//if (index < 0 || index >= stadiumList.length) {
if (index === -1) { // Array.indexOf๋Š” ๋ฐฐ์—ด์˜ ์œ ํšจํ•œ ์ธ๋ฑ์Šค ๋˜๋Š” -1์„ ๋ฐ˜ํ™˜
throw new Error(`Frontend value "${frontendValue}" not found.`);
}

// backendParameters์—์„œ ๋งค์นญ๋˜๋Š” ๊ฐ’ ๋ฐ˜ํ™˜
return backendParameters[index];
};

export const questionCategories = {
// ๊ธฐ๋ณธ ๋ฐ์ดํ„ฐ
chatbotName,
greetings: [`์•ˆ๋…•ํ•˜์„ธ์š”! ์ฑ—๋ด‡ ${chatbotName} ์ž…๋‹ˆ๋‹ค.`, "๊ถ๊ธˆํ•˜์‹  ์ •๋ณด๋ฅผ ์‹ค์‹œ๊ฐ„ ์ฑ„ํŒ…์œผ๋กœ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค."],

// ํ•„์ˆ˜๋กœ ์„ ํƒํ•ด์•ผํ•˜๋Š” ๋ฐ์ดํ„ฐ
baseballCategories: {
frontendValues: stadiumList, // ์ฑ—๋ด‡ ๊ตฌ๋‹จ๋ณ„ ๊ตฌ์žฅ๋ช… (ํ”„๋ก ํŠธ์—์„œ ๋ณด์—ฌ์ฃผ๋Š” ๊ฐ’)
frontendValues: stadiumStringList, // ์ฑ—๋ด‡ ๊ตฌ๋‹จ๋ณ„ ๊ตฌ์žฅ๋ช… (ํ”„๋ก ํŠธ์—์„œ ๋ณด์—ฌ์ฃผ๋Š” ๊ฐ’)
backendParameters: ["lg", "kt", "kiwoom", "kia", "samsung", "hanhwa", "lotte", "ssg", "nc"], // ์ฑ—๋ด‡ ๊ตฌ๋‹จ๋ณ„ ๊ตฌ์žฅ๋ช… (๋ฐฑ์—”๋“œ์— API ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„˜๊ฒจ์ฃผ๋Š” ๊ฐ’)
userMessage: ["์•ผ๊ตฌ์— ๊ด€๋ จ๋œ ๊ถ๊ธˆํ•œ ์ ์ด ์žˆ์œผ์‹ ๊ฐ€์š”?", "1. ๊ถ๊ธˆํ•œ ๋‚ด์šฉ์„ ์–ธ์ œ๋“  ์ž์œ ๋กญ๊ฒŒ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”", "2. ์•„๋ž˜ ์งˆ๋ฌธ ์นดํ…Œ๊ณ ๋ฆฌ ์„ ํƒ์„ ํ•ด์ฃผ์‹œ๋ฉด, โ€˜์ž์ฃผ ๋ฌผ์–ด๋ณด๋Š” ์งˆ๋ฌธโ€™์„ ๋ฌผ์–ด๋ณผ ์ˆ˜ ์žˆ์–ด์š”!"]
},
Expand Down
7 changes: 7 additions & 0 deletions src/constants/ZoneData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum StadiumType {
CHANDWON_NC_PARK = "์ฐฝ์› NC ํŒŒํฌ (์ฐฝ์›)"
}

// Enum type ๋ฐฐ์—ด
export const stadiumList = [
StadiumType.JAMSIL,
StadiumType.SUWON_KT,
Expand All @@ -25,6 +26,12 @@ export const stadiumList = [
StadiumType.CHANDWON_NC_PARK
];

// String type ๋ฐฐ์—ด
function convertEnumArrayToStringArray(stadiumList: StadiumType[]): string[] {
return stadiumList.map(stadium => stadium.toString());
}
export const stadiumStringList = convertEnumArrayToStringArray(stadiumList);

// ์ž ์‹ค Zone ๊ด€๋ฆฌ

// KT Zone ๊ด€๋ฆฌ
Expand Down

0 comments on commit 050132e

Please sign in to comment.