Add warn for proportions mutation for product (#40)
This commit is contained in:
@@ -15,9 +15,10 @@ import {
|
||||
ProductBlacklistMarketInput,
|
||||
ProductMaterials,
|
||||
ProductSizeTypes,
|
||||
ProductProportionsInput,
|
||||
} from '../types/product-types';
|
||||
import { Maybe } from '../types/types';
|
||||
import { nullOrNumber } from './utils';
|
||||
import { booleanStringField, nullOrNumber } from './utils';
|
||||
|
||||
const MINUTE = 60;
|
||||
|
||||
@@ -107,7 +108,9 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
fields['wallpaperResolution'] = nullOrNumber(
|
||||
fields['wallpaperResolution'] ?? null,
|
||||
);
|
||||
fields['proportionsWarning?'] = fields['proportionsWarning?'] ?? '';
|
||||
fields['proportionsWarning'] = booleanStringField(
|
||||
fields['proportionsWarning'] ?? null,
|
||||
);
|
||||
fields['imageResolution'] = nullOrNumber(fields['imageResolution'] ?? null);
|
||||
return <ProductFields>fields;
|
||||
}
|
||||
@@ -432,4 +435,40 @@ export class ProductAPI extends BaseSQLDataSource {
|
||||
return Promise.all(insertMaterials);
|
||||
}
|
||||
}
|
||||
|
||||
async setProportionsWarning(
|
||||
productId: number,
|
||||
proportions: ProductProportionsInput,
|
||||
): Promise<Promise<void>[]> {
|
||||
const promises = [];
|
||||
promises.push(
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'proportions_warning',
|
||||
proportions.proportionsWarning ? '1' : '0',
|
||||
),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'margin_width_max',
|
||||
proportions.marginWidthMax.toString(),
|
||||
),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'margin_width_min',
|
||||
proportions.marginWidthMin.toString(),
|
||||
),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'margin_height_max',
|
||||
proportions.marginHeightMax.toString(),
|
||||
),
|
||||
this.updateProductField(
|
||||
productId,
|
||||
'margin_height_min',
|
||||
proportions.marginHeightMin.toString(),
|
||||
),
|
||||
);
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user