'use client'; import { useEffect, useState } from 'react'; import { Scale, Loader2, AlertTriangle, ChevronRight } from 'lucide-react'; import { useNavigation } from '@/lib/navigation'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; interface JudgmentListItem { judgmentId: number; caseNumber: string | null; caseYear: string | null; category: string | null; caseTypeGroup: string | null; title: string | null; topic: string | null; topicsList?: string[]; lawsCitedList?: string[]; fact: string | null; decision: string | null; sourceUrl: string | null; sourceName: string | null; licenseNote: string | null; } interface ApiResponse { data: JudgmentListItem[]; page: number; pageSize: number; total: number; totalPages: number; } export function JudgmentsView() { const { navigate } = useNavigation(); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [category, setCategory] = useState<'labor' | 'criminal' | 'all'>('labor'); const [page, setPage] = useState(1); useEffect(() => { setLoading(true); const params = new URLSearchParams({ page: String(page), pageSize: '30', }); if (category !== 'all') params.set('category', category); fetch(`/api/judgments?${params}`) .then(r => r.json()) .then(setData) .catch(console.error) .finally(() => setLoading(false)); }, [category, page]); return (

คำพิพากษาศาลฎีกา

รวบรวมคำพิพากษาฎีกาจาก deka.in.th, ops.mol.go.th และ TSCC Dataset — {data?.total || 0} คดี

{/* Latest judgments highlight (page 1 only) */} {page === 1 && data && data.data.length > 0 && (
{data.data.slice(0, 3).map((j, i) => { const isLatest = i === 0; return ( ); })}
)} {/* Category filter */}
{([ { v: 'labor', label: 'คดีแรงงาน' }, { v: 'criminal', label: 'คดีอาญา (TSCC)' }, { v: 'all', label: 'ทั้งหมด' }, ] as const).map(opt => ( ))}
{/* List */} {loading && (
)} {!loading && data && ( <> {category === 'criminal' && (
คำพิพากษาคดีอาญามาจาก TSCC Dataset{' '} ซึ่งกำหนดให้ใช้เพื่อการวิจัยเท่านั้น (academic use only) ห้ามนำไปใช้เชิงพาณิชย์
)}
พบทั้งหมด {(data?.total || 0).toLocaleString('th-TH')} เรื่อง · หน้า {data.page}/{data.totalPages}
{data.data.map(j => { const topics = j.topicsList || []; const lawsCited = j.lawsCitedList || []; return ( ); })}
{/* Pagination */} {data.totalPages > 1 && (
{page} / {data.totalPages}
)} )}
); }