diff options
| -rw-r--r-- | src/app/api/product/import/route.tsx | 14 |
1 files changed, 7 insertions, 7 deletions
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 } |
