89-poster-defaults (#96)
* print defaults in printproducts * Add default to printproduct mutation * added insertDefaults when changing productgroup * fixed bug for square in square * cleanup, and tests for calculations * small fixes, added return values for update
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
import {
|
||||
PrintProduct,
|
||||
Product,
|
||||
ProductListResult,
|
||||
ProductsFilterInput,
|
||||
@@ -17,6 +18,8 @@ import { IdNumberResult } from '../types/types';
|
||||
import { moveS3File } from '../aws/s3';
|
||||
import { DesignerAPI } from '../datasources/designer-api';
|
||||
import { checkAccess } from '../cognito/access-control';
|
||||
import { PrintProductDefaultsAPI } from '../datasources/printproduct-defaults-api';
|
||||
import { PrintProductDefaults } from '../types/printproduct-defaults-types';
|
||||
|
||||
const ProductBlacklist = {
|
||||
async market(parent, _args, { dataSources }) {
|
||||
@@ -50,6 +53,11 @@ const PrintProduct = {
|
||||
async interiors({ id }, _args, { dataSources }) {
|
||||
return (<InteriorAPI>dataSources.interiorApi).getPrintProductInteriors(id);
|
||||
},
|
||||
async defaults({ id }, _args, { dataSources }) {
|
||||
return (<PrintProductDefaultsAPI>(
|
||||
dataSources.printProductDefaultsApi
|
||||
)).getDefaults(id);
|
||||
},
|
||||
};
|
||||
|
||||
async function getProductsResult(
|
||||
@@ -276,6 +284,21 @@ export const productMutationTypeDefs = {
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function printProductDefaults
|
||||
* @description Add default values to a printproduct, this is used through admin gui.
|
||||
*/
|
||||
async printProductDefaults(
|
||||
_,
|
||||
{ printId, widthMm, heightMm, cropX, cropY, border },
|
||||
{ dataSources, auth },
|
||||
): Promise<PrintProductDefaults> {
|
||||
checkAccess(['products.write'], auth);
|
||||
return (<PrintProductDefaultsAPI>(
|
||||
dataSources.printProductDefaultsApi
|
||||
)).updateDefaults(printId, widthMm, heightMm, cropX, cropY, border);
|
||||
},
|
||||
|
||||
/**
|
||||
* @function productWallpaperType
|
||||
* @description Set the wallpapertype for a wallpaper product
|
||||
|
||||
Reference in New Issue
Block a user