From 48a05b1d7f758c27841283db5ea703bb84a38d7d Mon Sep 17 00:00:00 2001 From: sangrae Date: Thu, 26 Nov 2026 22:55:05 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=EC=B1=97=EB=B4=87=20FAQ=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/entities/chat/chatKeys.ts | 5 +++++ src/shared/entities/chat/chatQueries.ts | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/shared/entities/chat/chatKeys.ts create mode 100644 src/shared/entities/chat/chatQueries.ts diff --git a/src/shared/entities/chat/chatKeys.ts b/src/shared/entities/chat/chatKeys.ts new file mode 100644 index 00000000..9e06e506 --- /dev/null +++ b/src/shared/entities/chat/chatKeys.ts @@ -0,0 +1,5 @@ +// 챗봇 조회 캐시 key. 답변은 스트리밍이라 캐시하지 않고, 추천 질문(FAQ) 목록만 받아 둔다. +export const chatKeys = { + root: () => ["chat"] as const, + faqs: () => [...chatKeys.root(), "faqs"] as const, +}; diff --git a/src/shared/entities/chat/chatQueries.ts b/src/shared/entities/chat/chatQueries.ts new file mode 100644 index 00000000..590e0ece --- /dev/null +++ b/src/shared/entities/chat/chatQueries.ts @@ -0,0 +1,24 @@ +import { queryOptions } from "@tanstack/react-query"; +import { z } from "zod"; + +import { api } from "@/shared/api"; +import { chatKeys } from "@/shared/entities/chat/chatKeys"; + +// 운영진이 등록한 추천 질문 — 등록 순서대로 최대 5개, 없으면 빈 배열이다. +// 질문은 100자 이하라 그대로 챗봇 질문(1~500자)으로 보낼 수 있다. +export const chatFaqsResponseSchema = z.array( + z.looseObject({ faqId: z.number(), question: z.string() }), +); + +// 화면은 이 queryOptions로만 데이터를 받는다 +export const chatQueries = { + // 챗봇 진입 화면 추천 질문(GET /v1/app/chat/faqs) + faqs: () => + queryOptions({ + queryKey: chatKeys.faqs(), + queryFn: async ({ signal }) => + chatFaqsResponseSchema.parse( + await api.get("/v1/app/chat/faqs", { signal }), + ), + }), +}; From 2fcfa017fc05e873d64204a5ee1de2d61864156e Mon Sep 17 00:00:00 2001 From: sangrae Date: Thu, 26 Nov 2026 22:55:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EC=B1=97=EB=B4=87=20=EC=B6=94?= =?UTF-8?q?=EC=B2=9C=20=EC=A7=88=EB=AC=B8=EC=9D=84=20FAQ=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=9C=BC=EB=A1=9C=20=EB=B3=B4=EC=97=AC=20=EC=A3=BC?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/chat/ChatEntryScreen.tsx | 25 +++++++++++-------- .../chat/constants/chatSuggestedQuestions.ts | 10 -------- 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 src/features/chat/constants/chatSuggestedQuestions.ts diff --git a/src/features/chat/ChatEntryScreen.tsx b/src/features/chat/ChatEntryScreen.tsx index e044df09..5051da89 100644 --- a/src/features/chat/ChatEntryScreen.tsx +++ b/src/features/chat/ChatEntryScreen.tsx @@ -1,3 +1,4 @@ +import { useQuery } from "@tanstack/react-query"; import { TopNavigationButton, Typography } from "@wanteddev/wds"; import { IconChevronLeft } from "@wanteddev/wds-icon"; import { useCallback, useEffect, useRef, useState } from "react"; @@ -14,7 +15,6 @@ import ChatLoadingDots from "@/features/chat/components/ChatLoadingDots"; import ChatMessageBubble from "@/features/chat/components/ChatMessageBubble"; import SuggestedQuestion from "@/features/chat/components/SuggestedQuestion"; import { CHAT_SEND_FAILURE_MESSAGE } from "@/features/chat/constants/chat"; -import { CHAT_SUGGESTED_QUESTIONS } from "@/features/chat/constants/chatSuggestedQuestions"; import { useChatStream } from "@/features/chat/hooks/useChatStream"; import { clearChatSnapshot, @@ -22,6 +22,7 @@ import { saveChatSnapshot, } from "@/features/chat/utils/chatSnapshot"; import { useBackNavigation } from "@/hooks/useBackNavigation"; +import { chatQueries } from "@/shared/entities/chat/chatQueries"; // Figma: 챗봇 진입 화면(nodeId 1887:91534)과 챗봇 대화창(1770:63314) — 메시지를 하나라도 // 보내면 진입 화면의 웰컴 문구·그라데이션·추천 질문이 페이드아웃되고 대화창(말풍선 + 응답 @@ -32,6 +33,8 @@ function ChatEntryScreen() { const location = useLocation(); // 출처 링크로 공지·행사에 갔다가 뒤로 돌아왔으면 떠날 때의 대화를 이어 간다(utils/chatSnapshot) const [restored] = useState(() => readChatSnapshot(location.key)); + // 추천 질문은 보조 기능이라 받는 중·실패·0개면 영역을 그리지 않는다 — 입력창은 기다리지 않는다 + const { data: faqs = [] } = useQuery(chatQueries.faqs()); const [inputValue, setInputValue] = useState(""); const [isLeaveOpen, setIsLeaveOpen] = useState(false); const [isFailureToastOpen, setIsFailureToastOpen] = useState(false); @@ -163,15 +166,17 @@ function ChatEntryScreen() { -
- {CHAT_SUGGESTED_QUESTIONS.map((question) => ( - sendMessage(question.text)} - question={question.text} - /> - ))} -
+ {faqs.length > 0 && ( +
+ {faqs.map((faq) => ( + sendMessage(faq.question)} + question={faq.question} + /> + ))} +
+ )}