feat(support-chat): infer intent with model and remove scope tabs

This commit is contained in:
devops committed 2026-10-14 19:20:41 +00:00
1 parent e0581f22aa
commit 33afd7f45a
10 files changed
+110 -68

No files matched your search

@@ -13,7 +13,6 @@ const token = () => {
export default function SupportChat() {
const [open, setOpen] = useState(false);
const [message, setMessage] = useState('');
const [scope, setScope] = useState<'public' | 'orders' | 'wallet'>('public');
const [busy, setBusy] = useState(false);
const [rows, setRows] = useState<{ question: string; answer: string }[]>([]);
const identity = useRef('');
@@ -28,7 +27,6 @@ export default function SupportChat() {
pending.current?.abort();
setRows([]);
setMessage('');
setScope('public');
setBusy(false);
}
};
@@ -72,7 +70,7 @@ export default function SupportChat() {
...(current ? { Authorization: `Bearer ${current}` } : {})
},
credentials: 'include',
body: JSON.stringify({ message: question, scope }),
body: JSON.stringify({ message: question }),
signal: AbortSignal.any([controller.signal, AbortSignal.timeout(50000)])
});
if (response.status === 401) {
@@ -151,43 +149,6 @@ export default function SupportChat() {
</button>
</div>
{/* Scope Selector Bar */}
<div className="bg-medical-gray-100 p-2 border-b border-medical-gray-200 flex items-center gap-1">
<button
type="button"
onClick={() => setScope('public')}
className={`flex-1 py-1.5 text-xs font-medium rounded-lg transition-all ${
scope === 'public'
? 'bg-white text-canina-blue shadow-sm font-bold border border-medical-gray-300'
: 'text-medical-gray-600 hover:text-medical-gray-900 hover:bg-white/50'
}`}
>
محصولات و عمومی
</button>
<button
type="button"
onClick={() => setScope('orders')}
className={`flex-1 py-1.5 text-xs font-medium rounded-lg transition-all ${
scope === 'orders'
? 'bg-white text-canina-blue shadow-sm font-bold border border-medical-gray-300'
: 'text-medical-gray-600 hover:text-medical-gray-900 hover:bg-white/50'
}`}
>
سفارش‌های من
</button>
<button
type="button"
onClick={() => setScope('wallet')}
className={`flex-1 py-1.5 text-xs font-medium rounded-lg transition-all ${
scope === 'wallet'
? 'bg-white text-canina-blue shadow-sm font-bold border border-medical-gray-300'
: 'text-medical-gray-600 hover:text-medical-gray-900 hover:bg-white/50'
}`}
>
کیف پول
</button>
</div>
{/* Message Area */}
<div
ref={chatScrollRef}