added comments in code (#81)
This commit is contained in:
@@ -117,6 +117,10 @@ export const productQueryTypeDefs = {
|
||||
///////////////////
|
||||
// Mutations below
|
||||
export const productMutationTypeDefs = {
|
||||
/**
|
||||
* @function addProduct
|
||||
* @description Will add a product
|
||||
*/
|
||||
async addProduct(_, { name, batch }, { dataSources, auth }) {
|
||||
checkAccess(['products.write'], auth);
|
||||
const id = await (<ProductAPI>dataSources.productApi).addProduct(
|
||||
@@ -125,6 +129,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(id);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productInfo
|
||||
* @description Mutate base information about a product
|
||||
*/
|
||||
async productInfo(_, { productId, info }, { dataSources, auth }) {
|
||||
checkAccess(['products.write'], auth);
|
||||
await (<ProductAPI>dataSources.productApi).updateProductInfo(
|
||||
@@ -133,6 +142,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productFocusPoint
|
||||
* @description Mutate the focuspoint for a product
|
||||
*/
|
||||
async productFocusPoint(
|
||||
_,
|
||||
{ productId, focusXpoint2, focusYpoint2 },
|
||||
@@ -154,6 +168,11 @@ export const productMutationTypeDefs = {
|
||||
)).generateNewInteriors(product);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productBlacklisting
|
||||
* @description Mutate the product blacklist
|
||||
*/
|
||||
async productBlacklisting(_, { productId, markets }, { dataSources, auth }) {
|
||||
checkAccess(['products.write'], auth);
|
||||
await (<ProductAPI>dataSources.productApi).updateBlacklisting(
|
||||
@@ -162,6 +181,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productGroup
|
||||
* @description Mutate the product groups, when changing group interiors lambda is triggered.
|
||||
*/
|
||||
async productGroup(_, { productId, groupIds }, { dataSources, auth }) {
|
||||
checkAccess(['products.write'], auth);
|
||||
await (<ProductAPI>dataSources.productApi).updateGroups(
|
||||
@@ -176,6 +200,11 @@ export const productMutationTypeDefs = {
|
||||
)).generateNewInteriors(product);
|
||||
return product;
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productGroupInteriors
|
||||
* @description Mutate the list of interiors on a product and its groups.
|
||||
*/
|
||||
async productGroupInteriors(
|
||||
_,
|
||||
{ productId, groupId, uris },
|
||||
@@ -189,6 +218,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productKeywords
|
||||
* @description Mutate the keywords for a product
|
||||
*/
|
||||
async productKeywords(_, { productId, keywordIds }, { dataSources, auth }) {
|
||||
checkAccess(['products.write'], auth);
|
||||
await (<KeywordAPI>dataSources.keywordApi).setProductKeywords(
|
||||
@@ -197,6 +231,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productProportionsWarning
|
||||
* @description Mutate the values for proportion warnings on a product
|
||||
*/
|
||||
async productProportionsWarning(
|
||||
_,
|
||||
{ productId, proportions },
|
||||
@@ -209,6 +248,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function addOwnInteriorToPrintProduct
|
||||
* @description Add a uploaded interior image to a product and its groups.
|
||||
*/
|
||||
async addOwnInteriorToPrintProduct(
|
||||
_,
|
||||
{ printId, uploadedS3Key },
|
||||
@@ -220,6 +264,11 @@ export const productMutationTypeDefs = {
|
||||
uploadedS3Key,
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productWallpaperType
|
||||
* @description Set the wallpapertype for a wallpaper product
|
||||
*/
|
||||
async productWallpaperType(
|
||||
_,
|
||||
{ productId, wallpaperTypes },
|
||||
@@ -232,6 +281,13 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function updateProductImage
|
||||
* @description Set a new image for the product, image is first uploaded to inquiries
|
||||
* bucket then moved to photowall-images. When new image is uploaded interiors are
|
||||
* generated.
|
||||
*/
|
||||
async updateProductImage(
|
||||
_,
|
||||
{ productId, uploadedS3Key, width, height },
|
||||
@@ -263,6 +319,12 @@ export const productMutationTypeDefs = {
|
||||
)).generateNewInteriors(product);
|
||||
return 'success';
|
||||
},
|
||||
|
||||
/**
|
||||
* @function addRelatedProducts
|
||||
* @description Adds a related product to a product, when doing this the related product
|
||||
* gets the same relationship back. So products are always related to eachother.
|
||||
*/
|
||||
async addRelatedProducts(
|
||||
_,
|
||||
{ productId, articleNumbers },
|
||||
@@ -275,6 +337,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function removeRelatedProducts
|
||||
* @description remove relation between products
|
||||
*/
|
||||
async removeRelatedProducts(
|
||||
_,
|
||||
{ productId, relatedProductIds },
|
||||
@@ -288,6 +355,10 @@ export const productMutationTypeDefs = {
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function addCategoriesToProduct
|
||||
* @description Add categories to a product
|
||||
*/
|
||||
async addCategoriesToProduct(
|
||||
_,
|
||||
{ productId, categoryIds },
|
||||
@@ -301,6 +372,10 @@ export const productMutationTypeDefs = {
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function removeCategoriesFromProduct
|
||||
* @description Remove categories from a product
|
||||
*/
|
||||
async removeCategoriesFromProduct(
|
||||
_,
|
||||
{ productId, categoryIds },
|
||||
@@ -313,6 +388,11 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function updateProductComments
|
||||
* @description Mutate product comments
|
||||
*/
|
||||
async updateProductComments(
|
||||
_,
|
||||
{ productId, comments },
|
||||
|
||||
Reference in New Issue
Block a user