From 07819844d5ef7e323fd956eacfedecb2f4f4bb80 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 17 Nov 2023 15:16:23 +0700
Subject: Update result feature

---
 src/app/api/stock-opname/location/route.tsx | 41 ++++++++++++++---------------
 1 file changed, 20 insertions(+), 21 deletions(-)

(limited to 'src/app/api/stock-opname/location/route.tsx')

diff --git a/src/app/api/stock-opname/location/route.tsx b/src/app/api/stock-opname/location/route.tsx
index 1009486..e6c20ec 100644
--- a/src/app/api/stock-opname/location/route.tsx
+++ b/src/app/api/stock-opname/location/route.tsx
@@ -1,28 +1,8 @@
 import { DetailTeam, StockOpnameLocationRes } from "@/common/types/stockOpname";
-import { Location, Team } from "@prisma/client";
+import { Team } from "@prisma/client";
 import { NextRequest, NextResponse } from "next/server";
 import { prisma } from "prisma/client";
 
-
-
-const getOpnameQuantity = async (where: { locationId: number, productId: number }) => {
-  const detailTeam: DetailTeam = {
-    COUNT1: { quantity: undefined, user: undefined },
-    COUNT2: { quantity: undefined, user: undefined },
-    VERIFICATION: { quantity: undefined, user: undefined },
-  }
-  for (const team of Object.keys(Team)) {
-    const opname = await prisma.stockOpname.findFirst({
-      where: { ...where, team: team as Team },
-      select: { quantity: true, user: true },
-    })
-    if (!opname) continue
-    detailTeam[team as Team]['quantity'] = opname?.quantity
-    detailTeam[team as Team]['user'] = opname?.user
-  }
-  return detailTeam
-}
-
 export async function GET(request: NextRequest) {
   const searchParams = request.nextUrl.searchParams;
   const productId = searchParams.get('productId') ?? '';
@@ -54,4 +34,23 @@ export async function GET(request: NextRequest) {
   }
 
   return NextResponse.json(result)
+}
+
+const getOpnameQuantity = async (where: { locationId: number, productId: number }) => {
+  const detailTeam: DetailTeam = {
+    COUNT1: { quantity: undefined, user: undefined },
+    COUNT2: { quantity: undefined, user: undefined },
+    COUNT3: { quantity: undefined, user: undefined },
+    VERIFICATION: { quantity: undefined, user: undefined },
+  }
+  for (const team of Object.keys(Team)) {
+    const opname = await prisma.stockOpname.findFirst({
+      where: { ...where, team: team as Team },
+      select: { quantity: true, user: true },
+    })
+    if (!opname) continue
+    detailTeam[team as Team]['quantity'] = opname?.quantity
+    detailTeam[team as Team]['user'] = opname?.user
+  }
+  return detailTeam
 }
\ No newline at end of file
-- 
cgit v1.2.3

