feat(store): add store sortOrder and swipeable package gallery
Enable HQ-controlled store list ordering and horizontal multi-image browsing on package detail. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -154,7 +154,7 @@ export class StoreService {
|
||||
category: true,
|
||||
coverResource: true,
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
orderBy: [{ sortOrder: 'asc' }, { createdAt: 'desc' }],
|
||||
});
|
||||
|
||||
const whitelistPhones = stores.some((s) => s.visibilityWhitelistEnabled)
|
||||
@@ -172,6 +172,7 @@ export class StoreService {
|
||||
distanceMeters: number | null;
|
||||
latitude?: unknown;
|
||||
longitude?: unknown;
|
||||
sortOrder?: number;
|
||||
};
|
||||
|
||||
const items: StoreListItem[] = [];
|
||||
@@ -190,13 +191,16 @@ export class StoreService {
|
||||
items.push({ ...mapped, distanceMeters });
|
||||
}
|
||||
|
||||
if (hasUser) {
|
||||
items.sort((a, b) => {
|
||||
items.sort((a, b) => {
|
||||
const so = (a.sortOrder ?? 0) - (b.sortOrder ?? 0);
|
||||
if (so !== 0) return so;
|
||||
if (hasUser) {
|
||||
const da = a.distanceMeters ?? Number.POSITIVE_INFINITY;
|
||||
const db = b.distanceMeters ?? Number.POSITIVE_INFINITY;
|
||||
return da - db;
|
||||
});
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return serializeBigInt(items);
|
||||
}
|
||||
@@ -268,7 +272,7 @@ export class StoreService {
|
||||
const stores = await this.prisma.store.findMany({
|
||||
where,
|
||||
include: { category: true, coverResource: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
orderBy: [{ sortOrder: 'asc' }, { createdAt: 'desc' }],
|
||||
});
|
||||
return serializeBigInt(stores.map(mapStoreCompat));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user