Add prod from CMS (#111)

This commit is contained in:
Niklas Fondberg
2022-04-19 13:02:48 +02:00
committed by GitHub
parent 1afebfdfdb
commit 60d4d312f1
4 changed files with 11 additions and 3 deletions
+7 -1
View File
@@ -305,6 +305,7 @@ export class ProductAPI extends BaseSQLDataSource {
return ids.map(async (id) => this.getProduct(id));
}
//
// mutations below
async updateProductField(
productId: number,
@@ -383,7 +384,11 @@ export class ProductAPI extends BaseSQLDataSource {
* @description Adds a new product to system, will use batchname and name to
* set a unique path, artNo is the productId with e infront.
*/
async addProduct(name: string, batch: string): Promise<number> {
async addProduct(
name: string,
batch: string,
designerId: number,
): Promise<number> {
const fixedBatch = !!batch ? batch : '';
const path = batch ? fixedBatch + ' ' + name : name;
const productPath = slug(path);
@@ -395,6 +400,7 @@ export class ProductAPI extends BaseSQLDataSource {
path: slug(safePath),
browsable: 0,
visible: 0,
designerid: designerId,
})
.returning('productid');
const id = idres[0].productid;