'use client'; import { useEffect, useState } from 'react'; import { BookOpen, ChevronRight } from 'lucide-react'; import { useNavigation } from '@/lib/navigation'; import { Badge } from '@/components/ui/badge'; import type { LawSummary } from '@/lib/types'; const CATEGORY_LABEL: Record = { labor: 'กฎหมายแรงงาน', civil: 'แพ่งและพาณิชย์', criminal: 'อาญา', civil_procedure: 'วิธีพิจารณาแพ่ง', criminal_procedure: 'วิธีพิจารณาอาญา', land: 'ที่ดิน', rent: 'เช่าเคหะ', narcotics: 'ยาเสพติด', traffic: 'จราจร', other: 'อื่นๆ', }; export function LawsView() { const { navigate } = useNavigation(); const [laws, setLaws] = useState([]); const [loading, setLoading] = useState(true); const [filter, setFilter] = useState('all'); useEffect(() => { fetch('/api/laws') .then(r => r.json()) .then(setLaws) .catch(console.error) .finally(() => setLoading(false)); }, []); const grouped: Record = {}; for (const l of laws) { const cat = l.category || 'other'; if (!grouped[cat]) grouped[cat] = []; grouped[cat].push(l); } const categories = Object.keys(grouped); const visible = filter === 'all' ? laws : (grouped[filter] || []); return (

กฎหมายทั้งหมด

รวบรวมกฎหมายไทยทุกหมวด · คลิกที่กฎหมายเพื่อดูมาตราทั้งหมด

{categories.map(c => ( ))}
{loading ? (
กำลังโหลด…
) : (
{visible.map(law => ( ))}
)}
); }