'use client'; import { useEffect, useState } from 'react'; import { Bookmark, Trash2, ChevronRight, Scale, BookOpen } from 'lucide-react'; import { useBookmarks } from '@/lib/navigation'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; interface BookmarkItem { type: 'section' | 'judgment' | 'law'; id: number; label: string; url: string; savedAt: string; } export function BookmarksView() { const { navigate, getBookmarks, removeBookmark } = useBookmarks() as any; const [items, setItems] = useState([]); const refresh = () => setItems(getBookmarks()); useEffect(() => { refresh(); window.addEventListener('bookmarks-changed', refresh); return () => window.removeEventListener('bookmarks-changed', refresh); }, [getBookmarks]); const handleRemove = (type: string, id: number) => { removeBookmark(type, id); refresh(); }; const handleNavigate = (item: BookmarkItem) => { const params = new URLSearchParams(item.url.split('?')[1] || ''); const view = params.get('view'); const id = params.get('id'); if (view === 'law' && id) navigate({ name: 'law', lawId: Number.parseInt(id, 10) }); else if (view === 'section' && id) navigate({ name: 'section', sectionId: Number.parseInt(id, 10) }); else if (view === 'judgment' && id) navigate({ name: 'judgment', judgmentId: Number.parseInt(id, 10) }); }; return (

รายการบันทึก

มาตรา/ฎีกา/กฎหมายที่คุณบันทึกไว้ (เก็บในเบราว์เซอร์ของคุณ)

{items.length === 0 ? (

ยังไม่มีรายการบันทึก

คลิกปุ่ม "บันทึก" ที่มาตราหรือฎีกาเพื่อเพิ่มลงรายการนี้

) : (
{items.map(item => (
{item.type === 'judgment' ? ( ) : ( )}
))}
)}
); } /** Resolves the Thai label for a bookmark type — extracted to satisfy S3358 (no nested ternary). */ function getBookmarkTypeLabel(type: 'section' | 'judgment' | 'law'): string { if (type === 'judgment') return 'ฎีกา'; if (type === 'law') return 'กฎหมาย'; return 'มาตรา'; }