import { useState } from 'react' import { useQuery, useQueryClient } from '@tanstack/react-query' import { Headset, Sparkles, Send } from 'lucide-react' import { Link, useNavigate } from 'react-router-dom' import { getMyCs, createCs, aiCardMessage } from '../api/client' import { useShop } from '../store/shop' import StatusBadge from '../components/StatusBadge' const CATS = ['DELIVERY', 'PRODUCT', 'PAYMENT', 'REFUND', 'OTHER'] export default function Cs() { const qc = useQueryClient() const nav = useNavigate() const { custToken } = useShop() const [category, setCategory] = useState('DELIVERY') const [orderNo, setOrderNo] = useState('') const [subject, setSubject] = useState('') const [content, setContent] = useState('') const [msg, setMsg] = useState('') // AI 카드메시지 도우미 const [occasion, setOccasion] = useState('Birthday') const [tone, setTone] = useState('Warm') const [recipient, setRecipient] = useState('') const [cardSuggestions, setCardSuggestions] = useState([]) const { data: tickets } = useQuery({ queryKey: ['cs'], queryFn: getMyCs, enabled: !!custToken }) const submit = async (e: React.FormEvent) => { e.preventDefault(); setMsg('') if (!custToken) { nav('/account'); return } try { const r = await createCs({ orderNo, category, subject, content }) setMsg(r?.aiReply ? `AI auto-reply: ${r.aiReply}` : 'Your request has been submitted.') setSubject(''); setContent(''); qc.invalidateQueries({ queryKey: ['cs'] }) } catch { setMsg('Failed to submit your request.') } } const genCard = async () => { const r = await aiCardMessage(occasion, tone, recipient).catch(() => null) setCardSuggestions(r?.messages || []) } return (

Customer Support (1:1)

{/* AI 카드 메시지 작성 도우미 */}
AI Card Message Helper
setOccasion(e.target.value)} placeholder="Occasion (e.g. Birthday)" className="px-3 py-2 rounded-lg border border-blush-100 text-sm bg-white outline-none" /> setTone(e.target.value)} placeholder="Tone" className="px-3 py-2 rounded-lg border border-blush-100 text-sm bg-white outline-none" /> setRecipient(e.target.value)} placeholder="Recipient" className="px-3 py-2 rounded-lg border border-blush-100 text-sm bg-white outline-none" />
{!!cardSuggestions.length && (
    {cardSuggestions.map((m, i) =>
  • {m}
  • )}
)}
{/* 문의 작성 */}
setOrderNo(e.target.value)} placeholder="Order number (optional)" className="px-3 py-2 rounded-xl border border-blush-100 text-sm outline-none focus:border-bloom" />
setSubject(e.target.value)} required placeholder="Subject" className="w-full px-3 py-2.5 rounded-xl border border-blush-100 text-sm outline-none focus:border-bloom" />