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
+1
View File
@@ -7,5 +7,6 @@ EXPOSE 4000
WORKDIR /app WORKDIR /app
# Set node env # Set node env
ENV NODE_ENV=development ENV NODE_ENV=development
ENV NEW_RELIC_NO_CONFIG_FILE=true
# Command container will actually run when called # Command container will actually run when called
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"] CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"]
+7 -1
View File
@@ -305,6 +305,7 @@ export class ProductAPI extends BaseSQLDataSource {
return ids.map(async (id) => this.getProduct(id)); return ids.map(async (id) => this.getProduct(id));
} }
//
// mutations below // mutations below
async updateProductField( async updateProductField(
productId: number, productId: number,
@@ -383,7 +384,11 @@ export class ProductAPI extends BaseSQLDataSource {
* @description Adds a new product to system, will use batchname and name to * @description Adds a new product to system, will use batchname and name to
* set a unique path, artNo is the productId with e infront. * 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 fixedBatch = !!batch ? batch : '';
const path = batch ? fixedBatch + ' ' + name : name; const path = batch ? fixedBatch + ' ' + name : name;
const productPath = slug(path); const productPath = slug(path);
@@ -395,6 +400,7 @@ export class ProductAPI extends BaseSQLDataSource {
path: slug(safePath), path: slug(safePath),
browsable: 0, browsable: 0,
visible: 0, visible: 0,
designerid: designerId,
}) })
.returning('productid'); .returning('productid');
const id = idres[0].productid; const id = idres[0].productid;
+2 -1
View File
@@ -140,11 +140,12 @@ export const productMutationTypeDefs = {
* @function addProduct * @function addProduct
* @description Will add a product * @description Will add a product
*/ */
async addProduct(_, { name, batch }, { dataSources, auth }) { async addProduct(_, { name, batch, designerId }, { dataSources, auth }) {
checkAccess(['products.write'], auth); checkAccess(['products.write'], auth);
const id = await (<ProductAPI>dataSources.productApi).addProduct( const id = await (<ProductAPI>dataSources.productApi).addProduct(
name, name,
batch, batch,
designerId,
); );
return (<ProductAPI>dataSources.productApi).getProduct(id); return (<ProductAPI>dataSources.productApi).getProduct(id);
}, },
+1 -1
View File
@@ -440,7 +440,7 @@ type Mutation {
""" """
Product Product
""" """
addProduct(name: String!, batch: String): Product addProduct(name: String!, batch: String, designerId: Int): Product
productInfo(productId: Int!, info: ProductInfoInput!): Product productInfo(productId: Int!, info: ProductInfoInput!): Product
productWallpaperType( productWallpaperType(
productId: Int! productId: Int!