fix batch bug addproduct mutation (#95)

This commit is contained in:
haraldphotowall
2021-12-03 13:00:45 +01:00
committed by GitHub
parent 8cea3b5db6
commit 72974521a7
+3 -2
View File
@@ -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<number> {
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;
}