diff --git a/app/categories/table.tsx b/app/categories/table.tsx index 58118d7..ea8a883 100644 --- a/app/categories/table.tsx +++ b/app/categories/table.tsx @@ -8,14 +8,18 @@ import { TableRow, TableCell, Tooltip, + Select, + SelectItem, + Selection, } from '@nextui-org/react' import { DeleteIcon, EditIcon } from '@/components/icons' -import { BookmarkCategoryWithBookmarks } from '@/types' +import { BookmarkCategory, BookmarkCategoryWithBookmarks } from '@/types' import { useRouter } from 'next/navigation' const columns = [ { name: 'NAME', uid: 'name' }, + { name: 'POSITION', uid: 'position' }, { name: 'BOOKMARK COUNT', uid: 'bookmarkcount' }, { name: 'ACTIONS', uid: 'actions' }, ] @@ -41,6 +45,26 @@ export default function TableComponent({ return } + const updateCategory = async ( + bookmark_category: BookmarkCategory, + position: Selection + ) => { + if (position === 'all') return + + const body = { + ...bookmark_category, + position: parseInt(position.values().next().value), + } + + await fetch('/api/bookmark_category', { + method: 'PATCH', + body: JSON.stringify(body), + }) + + router.refresh() + return + } + return ( <>