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:
Arwid Thornström
2021-12-08 11:00:15 +01:00
committed by GitHub
parent b556bb8df2
commit 6741e82479
9 changed files with 3669 additions and 20 deletions
+23
View File
@@ -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