Add name filter to business store-items list.

Lets the dashboard specials picker search store items without loading the full catalog.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-22 20:38:58 +03:30
co-authored by Cursor
parent 24ce75c2e6
commit e0e122ed57
2 changed files with 25 additions and 1 deletions
+4
View File
@@ -75,6 +75,10 @@ export class ListStoreItemsDto {
@IsInt()
@Min(1)
pageSize?: number;
@IsOptional()
@IsString()
name?: string;
}
export class ListPublicStoreItemsDto {
+21 -1
View File
@@ -68,7 +68,27 @@ export class StoreItemsService {
const page = query.page ?? 1;
const pageSize = query.pageSize ?? 20;
const skip = (page - 1) * pageSize;
const where = { businessId };
const name = query.name?.trim();
const where: Prisma.StoreItemVariantWhereInput = {
businessId,
...(name
? {
storeItem: {
product: {
OR: [
{ title: { contains: name, mode: 'insensitive' } },
{
content: {
path: ['nameFa'],
string_contains: name,
},
},
],
},
},
}
: {}),
};
const [items, total] = await Promise.all([
this.prisma.storeItemVariant.findMany({