Add moveToTop on portfolio update so items pin to absolute list top.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-23 15:23:17 +03:30
co-authored by Cursor
parent af0573c089
commit 37bce1e9fa
2 changed files with 15 additions and 2 deletions
+7 -1
View File
@@ -280,6 +280,10 @@ export class PortfoliosService {
}
}
const pinnedSortOrder = dto.moveToTop
? await this.nextSortOrder(businessId)
: undefined;
const updated = await this.prisma.$transaction(async (tx) => {
const data: Prisma.portfoliosUncheckedUpdateInput = {
slug,
@@ -302,7 +306,9 @@ export class PortfoliosService {
if (featuredMediaId !== undefined) {
data.featured_media_id = featuredMediaId;
}
if (dto.sortOrder !== undefined) {
if (pinnedSortOrder !== undefined) {
data.sort_order = pinnedSortOrder;
} else if (dto.sortOrder !== undefined) {
data.sort_order = dto.sortOrder;
}
if (publishedAt !== undefined) {