Add prod from CMS (#111)
This commit is contained in:
@@ -7,5 +7,6 @@ EXPOSE 4000
|
||||
WORKDIR /app
|
||||
# Set node env
|
||||
ENV NODE_ENV=development
|
||||
ENV NEW_RELIC_NO_CONFIG_FILE=true
|
||||
# Command container will actually run when called
|
||||
CMD ["npx", "nodemon", "-w", "src", "--ext", "ts", "--exec", "ts-node", "src/index.ts"]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -140,11 +140,12 @@ export const productMutationTypeDefs = {
|
||||
* @function addProduct
|
||||
* @description Will add a product
|
||||
*/
|
||||
async addProduct(_, { name, batch }, { dataSources, auth }) {
|
||||
async addProduct(_, { name, batch, designerId }, { dataSources, auth }) {
|
||||
checkAccess(['products.write'], auth);
|
||||
const id = await (<ProductAPI>dataSources.productApi).addProduct(
|
||||
name,
|
||||
batch,
|
||||
designerId,
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(id);
|
||||
},
|
||||
|
||||
+1
-1
@@ -440,7 +440,7 @@ type Mutation {
|
||||
"""
|
||||
Product
|
||||
"""
|
||||
addProduct(name: String!, batch: String): Product
|
||||
addProduct(name: String!, batch: String, designerId: Int): Product
|
||||
productInfo(productId: Int!, info: ProductInfoInput!): Product
|
||||
productWallpaperType(
|
||||
productId: Int!
|
||||
|
||||
Reference in New Issue
Block a user