u
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
||||
parseFullHash,
|
||||
articleErrorStatus,
|
||||
interpolateString,
|
||||
interpolateObjects,
|
||||
} from './shared.js';
|
||||
|
||||
/**
|
||||
@@ -403,7 +402,7 @@ export function register(app, basePath = '') {
|
||||
if (!template || template.company_id !== companyId) {
|
||||
return res.status(404).json({ error: 'Label template not found' });
|
||||
}
|
||||
|
||||
|
||||
let article;
|
||||
try {
|
||||
const result = await db.getBySku(req.user.id, sku);
|
||||
@@ -434,7 +433,16 @@ export function register(app, basePath = '') {
|
||||
? content
|
||||
: [];
|
||||
|
||||
const interpolatedObjects = interpolateObjects(objects, article);
|
||||
const interpolatedObjects = objects.map(obj => {
|
||||
const cloned = { ...obj };
|
||||
if (typeof cloned.text === 'string') {
|
||||
cloned.text = interpolateString(cloned.text, article);
|
||||
}
|
||||
if (typeof cloned.code === 'string') {
|
||||
cloned.code = interpolateString(cloned.code, article);
|
||||
}
|
||||
return cloned;
|
||||
});
|
||||
|
||||
const printPayload = await renderLabel({
|
||||
width: template.width,
|
||||
@@ -460,7 +468,7 @@ export function register(app, basePath = '') {
|
||||
console.error('Print article label failed:', error);
|
||||
res.status(500).json({ error: error.message });
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,10 +96,12 @@ export function register(app, basePath = '') {
|
||||
|
||||
try {
|
||||
const templates = await db.list(req.user.id);
|
||||
res.status(200).json({ labeltemplates: templates.map((t) => {
|
||||
const { content, ...rest } = serializeTemplate(t);
|
||||
return rest;
|
||||
}) });
|
||||
res.status(200).json({
|
||||
labeltemplates: templates.map((t) => {
|
||||
const { content, ...rest } = serializeTemplate(t);
|
||||
return rest;
|
||||
})
|
||||
});
|
||||
} catch (error) {
|
||||
const status = labeltemplateErrorStatus(error);
|
||||
if (status === 500) console.error('List label templates failed:', error);
|
||||
|
||||
Reference in New Issue
Block a user