'use server'; import prisma from "@/lib/prisma"; import { SortableItem } from "@/types/SortableItem"; export async function sortItems(items: SortableItem[], type: string) { switch(type) { case "categories": await Promise.all( items.map(item => prisma.portfolioCategory.update({ where: { id: item.id }, data: { sortIndex: item.sortIndex }, }) ) ); break; case "tags": await Promise.all( items.map(item => prisma.portfolioTag.update({ where: { id: item.id }, data: { sortIndex: item.sortIndex }, }) ) ); break; case "types": await Promise.all( items.map(item => prisma.portfolioType.update({ where: { id: item.id }, data: { sortIndex: item.sortIndex }, }) ) ); break; } }