From 72974521a7999bb2ebd00be4d9d6221bee6c156c Mon Sep 17 00:00:00 2001 From: haraldphotowall <95219064+haraldphotowall@users.noreply.github.com> Date: Fri, 3 Dec 2021 13:00:45 +0100 Subject: [PATCH] fix batch bug addproduct mutation (#95) --- src/datasources/product-api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datasources/product-api.ts b/src/datasources/product-api.ts index d8626f6..f4d881c 100644 --- a/src/datasources/product-api.ts +++ b/src/datasources/product-api.ts @@ -380,7 +380,8 @@ export class ProductAPI extends BaseSQLDataSource { * set a unique path, artNo is the productId with e infront. */ async addProduct(name: string, batch: string): Promise { - const path = batch ? batch + ' ' + name : name; + const fixedBatch = !!batch ? batch : ''; + const path = batch ? fixedBatch + ' ' + name : name; const productPath = slug(path); const safePath = await this.getUniqueProductPath(productPath, null); @@ -395,7 +396,7 @@ export class ProductAPI extends BaseSQLDataSource { const id = idres[0]; this.updateProductField(id, 'artNo', `e${id}`); await this.updateProductField(id, 'name', name); - await this.updateProductField(id, 'batch', batch); + await this.updateProductField(id, 'batch', fixedBatch); return id; }