From 570b867dec4832c201e70ae8a756db70d6af4ac4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 21 Nov 2023 10:16:21 +0700 Subject: Fix stock opname and product search where --- src/app/api/stock-opname/route.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/app/api/stock-opname') diff --git a/src/app/api/stock-opname/route.tsx b/src/app/api/stock-opname/route.tsx index 3aa9d06..ef4e1d5 100644 --- a/src/app/api/stock-opname/route.tsx +++ b/src/app/api/stock-opname/route.tsx @@ -1,5 +1,5 @@ import { StockOpnameLocationRes, StockOpnameRequest } from "@/common/types/stockOpname"; -import { Team } from "@prisma/client"; +import { Prisma, Team } from "@prisma/client"; import { NextRequest, NextResponse } from "next/server"; import { prisma } from "prisma/client"; import _ from "lodash" @@ -23,15 +23,16 @@ export async function GET(request: NextRequest) { return NextResponse.json({ error: 'Bad Request. Missing companyId' }, { status: 400 }) } - const where = { + const where: Prisma.ProductWhereInput = { AND: { stockOpnames: { some: {} }, companyId: parseInt(companyId), isDifferent: show ? (show == 'diff' ? true : false) : undefined, OR: [ - { name: { contains: search ?? '' } }, - { itemCode: { contains: search ?? '' } }, - { barcode: { contains: search ?? '' } }, + { name: { mode: 'insensitive', contains: search ?? '' } }, + { itemCode: { mode: 'insensitive', contains: search ?? '' } }, + { barcode: { mode: 'insensitive', contains: search ?? '' } }, + { stockOpnames: { some: { location: { name: { mode: 'insensitive', contains: search ?? '' } } } } }, ] } } -- cgit v1.2.3