'use client'; // File: app/(admin)/admin/ai/intent-classification/page.tsx // Change Log // - 2026-05-19: สร้างหน้า Intent Definitions List (Admin, ADR-024). import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { useIntentDefinitions, useCreateIntentDefinition, } from '@/hooks/ai/use-intent-classification'; import { IntentForm } from '@/components/ai/intent-classification/intent-form'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import { Plus, Brain, TestTube } from 'lucide-react'; import type { IntentCategory } from '@/lib/services/ai-intent.service'; /** สีของ category badge */ const CATEGORY_COLORS: Record = { read: 'bg-blue-100 text-blue-800', suggest: 'bg-purple-100 text-purple-800', utility: 'bg-gray-100 text-gray-800', }; export default function IntentClassificationPage() { const router = useRouter(); const [showForm, setShowForm] = useState(false); const { data: definitions, isLoading } = useIntentDefinitions(); const createMutation = useCreateIntentDefinition(); const handleCreate = async (data: { intentCode: string; descriptionTh: string; descriptionEn: string; category: IntentCategory; }) => { await createMutation.mutateAsync(data); setShowForm(false); }; return (
{/* Header */}

Intent Classification

จัดการ Intent Definitions และ Patterns สำหรับ AI Chat

{/* Table */} Intent Definitions ({definitions?.length || 0}) {isLoading ? (

กำลังโหลด...

) : ( Intent Code คำอธิบาย Category สถานะ Patterns {definitions?.map((def) => ( router.push( `/admin/ai/intent-classification/${def.intentCode}` ) } > {def.intentCode}
{def.descriptionTh}
{def.descriptionEn}
{def.category} {def.isActive ? 'Active' : 'Inactive'} {def.patterns?.length || 0}
))}
)}
{/* Create Form Dialog */} setShowForm(false)} onSubmit={handleCreate} isLoading={createMutation.isPending} />
); }