u
This commit is contained in:
@@ -253,7 +253,7 @@ export function register(app, basePath = '') {
|
||||
const parsed = parseSku(req.params.sku);
|
||||
if (parsed.error) return res.status(400).json({ error: parsed.error });
|
||||
|
||||
if (req.body?.sku || req.body?.childSku) {
|
||||
if (req.body?.sku) {
|
||||
return res.status(400).json({
|
||||
error: 'sku is not allowed when creating a child article; omit sku to auto-generate or use PUT to attach an existing article',
|
||||
});
|
||||
@@ -282,9 +282,7 @@ export function register(app, basePath = '') {
|
||||
const parsed = parseSku(req.params.sku);
|
||||
if (parsed.error) return res.status(400).json({ error: parsed.error });
|
||||
|
||||
const childSku = typeof req.body?.sku === 'string' && req.body.sku.trim()
|
||||
? req.body.sku.trim()
|
||||
: (typeof req.body?.childSku === 'string' && req.body.childSku.trim() ? req.body.childSku.trim() : '');
|
||||
const childSku = typeof req.body?.sku === 'string' ? req.body.sku.trim() : '';
|
||||
if (!childSku) {
|
||||
return res.status(400).json({ error: 'sku is required' });
|
||||
}
|
||||
@@ -354,7 +352,7 @@ export function register(app, basePath = '') {
|
||||
const parsedChild = parseSku(req.params.childSku);
|
||||
if (parsedChild.error) return res.status(400).json({ error: 'childSku is required' });
|
||||
|
||||
const deleteArticle = req.query.deleteArticle === 'true' || req.body?.deleteArticle === true;
|
||||
const deleteArticle = req.query.deleteArticle === 'true';
|
||||
|
||||
try {
|
||||
const result = await db.removeChild(req.user.id, parsed.sku, parsedChild.sku, {
|
||||
|
||||
Reference in New Issue
Block a user