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:
co-authored by
Cursor
parent
24ce75c2e6
commit
e0e122ed57
@@ -75,6 +75,10 @@ export class ListStoreItemsDto {
|
|||||||
@IsInt()
|
@IsInt()
|
||||||
@Min(1)
|
@Min(1)
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ListPublicStoreItemsDto {
|
export class ListPublicStoreItemsDto {
|
||||||
|
|||||||
@@ -68,7 +68,27 @@ export class StoreItemsService {
|
|||||||
const page = query.page ?? 1;
|
const page = query.page ?? 1;
|
||||||
const pageSize = query.pageSize ?? 20;
|
const pageSize = query.pageSize ?? 20;
|
||||||
const skip = (page - 1) * pageSize;
|
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([
|
const [items, total] = await Promise.all([
|
||||||
this.prisma.storeItemVariant.findMany({
|
this.prisma.storeItemVariant.findMany({
|
||||||
|
|||||||
Reference in New Issue
Block a user