import React, { useState, useMemo } from "react"; import { clsx } from "clsx"; interface FaqItem { id: string; question: string; answer: string; category: string; tags: string[]; helpful?: number; notHelpful?: number; lastUpdated?: string; featured?: boolean; } interface PlusFaqProps { title?: string; description?: string; faqItems?: FaqItem[]; categories?: string[]; showSearch?: boolean; showCategories?: boolean; showVoting?: boolean; showLastUpdated?: boolean; showFeatured?: boolean; maxItemsPerCategory?: number; className?: string; theme?: { primaryColor?: string; secondaryColor?: string; accentColor?: string; fontFamily?: string; }; } const defaultFaqItems: FaqItem[] = [ { id: "1", question: "AgentC란 무엇인가요?", answer: "AgentC는 비즈니스 자동화와 고객 관리를 위한 종합적인 SaaS 플랫폼입니다. AI 기반 챗봇, 워크플로우 자동화, CRM, 분석 도구 등을 제공하여 비즈니스 효율성을 극대화합니다.", category: "기본 정보", tags: ["소개", "플랫폼", "기능"], helpful: 45, notHelpful: 3, lastUpdated: "2024-01-15", featured: true, }, { id: "2", question: "무료 체험 기간은 얼마나 되나요?", answer: "모든 요금제에서 14-30일의 무료 체험을 제공합니다. 체험 기간 동안 모든 기능을 제한 없이 사용하실 수 있으며, 신용카드 등록 없이도 시작할 수 있습니다.", category: "요금제", tags: ["무료체험", "결제", "기간"], helpful: 38, notHelpful: 2, lastUpdated: "2024-01-10", featured: true, }, { id: "3", question: "데이터는 안전하게 보호되나요?", answer: "네, 저희는 엔터프라이즈급 보안을 제공합니다. 모든 데이터는 AES-256으로 암호화되며, ISO 27001, SOC 2 Type II 인증을 획득했습니다. 또한 GDPR 및 국내 개인정보보호법을 완전히 준수합니다.", category: "보안", tags: ["보안", "암호화", "개인정보보호"], helpful: 52, notHelpful: 1, lastUpdated: "2024-01-08", }, { id: "4", question: "API 연동이 가능한가요?", answer: "네, RESTful API와 GraphQL API를 모두 제공합니다. 개발자 친화적인 문서와 SDK를 제공하며, 웹훅을 통한 실시간 데이터 동기화도 지원합니다.", category: "기술", tags: ["API", "개발", "연동"], helpful: 29, notHelpful: 4, lastUpdated: "2024-01-12", }, { id: "5", question: "팀원을 초대할 수 있나요?", answer: "Professional 이상 요금제에서 팀 협업 기능을 제공합니다. 역할 기반 권한 관리, 팀 대시보드, 실시간 협업 도구 등을 사용하실 수 있습니다.", category: "팀 관리", tags: ["팀", "협업", "권한"], helpful: 33, notHelpful: 2, lastUpdated: "2024-01-14", }, { id: "6", question: "고객 지원은 어떻게 받을 수 있나요?", answer: "이메일, 라이브 채팅, 전화 지원을 제공합니다. Enterprise 고객에게는 전담 계정 매니저와 24/7 우선 지원을 제공합니다. 또한 상세한 문서와 튜토리얼을 온라인으로 제공합니다.", category: "고객 지원", tags: ["지원", "문의", "서비스"], helpful: 41, notHelpful: 1, lastUpdated: "2024-01-11", }, { id: "7", question: "요금제 변경은 언제든 가능한가요?", answer: "네, 언제든지 요금제를 업그레이드하거나 다운그레이드할 수 있습니다. 업그레이드 시 즉시 적용되며, 다운그레이드는 다음 결제 주기부터 적용됩니다.", category: "요금제", tags: ["변경", "업그레이드", "다운그레이드"], helpful: 25, notHelpful: 3, lastUpdated: "2024-01-09", }, ]; const defaultCategories = [ "전체", "기본 정보", "요금제", "보안", "기술", "팀 관리", "고객 지원", ]; export function PlusFaq({ title = "자주 묻는 질문", description = "궁금한 점들에 대한 답변을 확인해보세요.", faqItems = defaultFaqItems, categories = defaultCategories, showSearch = true, showCategories = true, showVoting = true, showLastUpdated = true, showFeatured = true, maxItemsPerCategory = 10, className, theme = {}, }: PlusFaqProps) { const [searchQuery, setSearchQuery] = useState(""); const [selectedCategory, setSelectedCategory] = useState("전체"); const [openItems, setOpenItems] = useState>(new Set()); const [votes, setVotes] = useState< Record >({}); // Filter and search FAQ items const filteredItems = useMemo(() => { let items = faqItems; // Filter by category if (selectedCategory !== "전체") { items = items.filter((item) => item.category === selectedCategory); } // Filter by search query if (searchQuery) { const query = searchQuery.toLowerCase(); items = items.filter( (item) => item.question.toLowerCase().includes(query) || item.answer.toLowerCase().includes(query) || item.tags.some((tag) => tag.toLowerCase().includes(query)) ); } // Sort by featured first, then by helpful votes return items.sort((a, b) => { if (a.featured && !b.featured) return -1; if (!a.featured && b.featured) return 1; const aHelpful = (a.helpful || 0) + (votes[a.id]?.helpful || 0); const bHelpful = (b.helpful || 0) + (votes[b.id]?.helpful || 0); return bHelpful - aHelpful; }); }, [faqItems, selectedCategory, searchQuery, votes]); const toggleItem = (itemId: string) => { const newOpenItems = new Set(openItems); if (newOpenItems.has(itemId)) { newOpenItems.delete(itemId); } else { newOpenItems.add(itemId); } setOpenItems(newOpenItems); }; const handleVote = (itemId: string, type: "helpful" | "notHelpful") => { setVotes((prev) => ({ ...prev, [itemId]: { helpful: type === "helpful" ? (prev[itemId]?.helpful || 0) + 1 : prev[itemId]?.helpful || 0, notHelpful: type === "notHelpful" ? (prev[itemId]?.notHelpful || 0) + 1 : prev[itemId]?.notHelpful || 0, }, })); }; const FaqItem = ({ item }: { item: FaqItem }) => { const isOpen = openItems.has(item.id); const currentVotes = votes[item.id] || { helpful: 0, notHelpful: 0 }; const totalHelpful = (item.helpful || 0) + currentVotes.helpful; const totalNotHelpful = (item.notHelpful || 0) + currentVotes.notHelpful; return (
{isOpen && (
{item.answer}
{/* Tags */} {item.tags.length > 0 && (
{item.tags.map((tag) => ( #{tag} ))}
)} {/* Voting */} {showVoting && (
이 답변이 도움이 되었나요?
)}
)}
); }; return (
{/* Header */}

{title}

{description}

{/* Search */} {showSearch && (
setSearchQuery(e.target.value)} className="w-full px-4 py-3 pl-12 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" style={{ borderColor: theme.primaryColor ? `${theme.primaryColor}20` : undefined, }} />
)} {/* Categories */} {showCategories && (
{categories.map((category) => ( ))}
)} {/* Results count */}
{filteredItems.length}개의 결과{" "} {searchQuery && `"${searchQuery}"에 대한 검색 결과`}
{/* FAQ Items */}
{filteredItems.length > 0 ? ( filteredItems .slice(0, maxItemsPerCategory) .map((item) => ) ) : (

검색 결과가 없습니다

다른 키워드로 검색해보시거나 카테고리를 변경해보세요.

)}
{/* Contact CTA */}

찾으시는 답변이 없나요?

저희 고객 지원팀이 직접 도움을 드리겠습니다.

); }