Refactor portfolio

This commit is contained in:
2025-07-21 23:45:39 +02:00
parent 312b2c2f94
commit a8d5dbaa09
31 changed files with 1111 additions and 30 deletions

View File

@ -0,0 +1,40 @@
'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;
}
}