From e0e122ed57088990c3a40f6c4a14428eaec3e620 Mon Sep 17 00:00:00 2001 From: Alireza Hassani Date: Sat, 22 Aug 2026 20:38:58 +0330 Subject: [PATCH] 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 --- src/store/dto/store-items.dto.ts | 4 ++++ src/store/store-items.service.ts | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/store/dto/store-items.dto.ts b/src/store/dto/store-items.dto.ts index bc9cb2e..59eb0a2 100644 --- a/src/store/dto/store-items.dto.ts +++ b/src/store/dto/store-items.dto.ts @@ -75,6 +75,10 @@ export class ListStoreItemsDto { @IsInt() @Min(1) pageSize?: number; + + @IsOptional() + @IsString() + name?: string; } export class ListPublicStoreItemsDto { diff --git a/src/store/store-items.service.ts b/src/store/store-items.service.ts index 5a80e8e..19b9cb6 100644 --- a/src/store/store-items.service.ts +++ b/src/store/store-items.service.ts @@ -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({