From 38db9dbede5ee9d99068fb9a98941fd15c2730bf Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 10 Aug 2024 09:29:29 +0700
Subject: <iman> update import product

---
 src/app/api/product/import/route.tsx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'src/app/api/product/import/route.tsx')

diff --git a/src/app/api/product/import/route.tsx b/src/app/api/product/import/route.tsx
index e4e38c6..3f11def 100644
--- a/src/app/api/product/import/route.tsx
+++ b/src/app/api/product/import/route.tsx
@@ -19,13 +19,13 @@ export async function POST(request: NextRequest) {
   const newProducts = fileData.map(row => ({
     id: undefined,
     isDifferent: false,
-    name: row[0].toString(),
-    barcode: row[1].toString(),
-    itemCode: row[2].toString(),
-    onhandQty: row[3],
-    differenceQty: row[4],
-    companyId: row[5],
-    externalId: row[6] ?? null
+    name: row[0]?.toString() || '', // Handle undefined values
+    barcode: row[1]?.toString() || '', // Handle undefined values
+    itemCode: row[2]?.toString() || '', // Handle undefined values
+    onhandQty: row[3] || 0, // Handle undefined values
+    differenceQty: row[4] || 0, // Handle undefined values
+    companyId: intCompanyId, // Use the parsed company ID
+    externalId: row[6] ? row[6].toString() : null // Handle undefined values
   }));
 
   const whereCompany = { companyId: intCompanyId }
-- 
cgit v1.2.3

